babylon.max.js 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/action.ts":
  314. /*!***************************!*\
  315. !*** ./Actions/action.ts ***!
  316. \***************************/
  317. /*! exports provided: Action */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  322. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  324. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  325. /**
  326. * The action to be carried out following a trigger
  327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  328. */
  329. var Action = /** @class */ (function () {
  330. /**
  331. * Creates a new Action
  332. * @param triggerOptions the trigger, with or without parameters, for the action
  333. * @param condition an optional determinant of action
  334. */
  335. function Action(
  336. /** the trigger, with or without parameters, for the action */
  337. triggerOptions, condition) {
  338. this.triggerOptions = triggerOptions;
  339. /**
  340. * An event triggered prior to action being executed.
  341. */
  342. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  343. if (triggerOptions.parameter) {
  344. this.trigger = triggerOptions.trigger;
  345. this._triggerParameter = triggerOptions.parameter;
  346. }
  347. else if (triggerOptions.trigger) {
  348. this.trigger = triggerOptions.trigger;
  349. }
  350. else {
  351. this.trigger = triggerOptions;
  352. }
  353. this._nextActiveAction = this;
  354. this._condition = condition;
  355. }
  356. /**
  357. * Internal only
  358. * @hidden
  359. */
  360. Action.prototype._prepare = function () {
  361. };
  362. /**
  363. * Gets the trigger parameters
  364. * @returns the trigger parameters
  365. */
  366. Action.prototype.getTriggerParameter = function () {
  367. return this._triggerParameter;
  368. };
  369. /**
  370. * Internal only - executes current action event
  371. * @hidden
  372. */
  373. Action.prototype._executeCurrent = function (evt) {
  374. if (this._nextActiveAction._condition) {
  375. var condition = this._nextActiveAction._condition;
  376. var currentRenderId = this._actionManager.getScene().getRenderId();
  377. // We cache the current evaluation for the current frame
  378. if (condition._evaluationId === currentRenderId) {
  379. if (!condition._currentResult) {
  380. return;
  381. }
  382. }
  383. else {
  384. condition._evaluationId = currentRenderId;
  385. if (!condition.isValid()) {
  386. condition._currentResult = false;
  387. return;
  388. }
  389. condition._currentResult = true;
  390. }
  391. }
  392. this.onBeforeExecuteObservable.notifyObservers(this);
  393. this._nextActiveAction.execute(evt);
  394. this.skipToNextActiveAction();
  395. };
  396. /**
  397. * Execute placeholder for child classes
  398. * @param evt optional action event
  399. */
  400. Action.prototype.execute = function (evt) {
  401. };
  402. /**
  403. * Skips to next active action
  404. */
  405. Action.prototype.skipToNextActiveAction = function () {
  406. if (this._nextActiveAction._child) {
  407. if (!this._nextActiveAction._child._actionManager) {
  408. this._nextActiveAction._child._actionManager = this._actionManager;
  409. }
  410. this._nextActiveAction = this._nextActiveAction._child;
  411. }
  412. else {
  413. this._nextActiveAction = this;
  414. }
  415. };
  416. /**
  417. * Adds action to chain of actions, may be a DoNothingAction
  418. * @param action defines the next action to execute
  419. * @returns The action passed in
  420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  421. */
  422. Action.prototype.then = function (action) {
  423. this._child = action;
  424. action._actionManager = this._actionManager;
  425. action._prepare();
  426. return action;
  427. };
  428. /**
  429. * Internal only
  430. * @hidden
  431. */
  432. Action.prototype._getProperty = function (propertyPath) {
  433. return this._actionManager._getProperty(propertyPath);
  434. };
  435. /**
  436. * Internal only
  437. * @hidden
  438. */
  439. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  440. return this._actionManager._getEffectiveTarget(target, propertyPath);
  441. };
  442. /**
  443. * Serialize placeholder for child classes
  444. * @param parent of child
  445. * @returns the serialized object
  446. */
  447. Action.prototype.serialize = function (parent) {
  448. };
  449. /**
  450. * Internal only called by serialize
  451. * @hidden
  452. */
  453. Action.prototype._serialize = function (serializedAction, parent) {
  454. var serializationObject = {
  455. type: 1,
  456. children: [],
  457. name: serializedAction.name,
  458. properties: serializedAction.properties || []
  459. };
  460. // Serialize child
  461. if (this._child) {
  462. this._child.serialize(serializationObject);
  463. }
  464. // Check if "this" has a condition
  465. if (this._condition) {
  466. var serializedCondition = this._condition.serialize();
  467. serializedCondition.children.push(serializationObject);
  468. if (parent) {
  469. parent.children.push(serializedCondition);
  470. }
  471. return serializedCondition;
  472. }
  473. if (parent) {
  474. parent.children.push(serializationObject);
  475. }
  476. return serializationObject;
  477. };
  478. /**
  479. * Internal only
  480. * @hidden
  481. */
  482. Action._SerializeValueAsString = function (value) {
  483. if (typeof value === "number") {
  484. return value.toString();
  485. }
  486. if (typeof value === "boolean") {
  487. return value ? "true" : "false";
  488. }
  489. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  490. return value.x + ", " + value.y;
  491. }
  492. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  493. return value.x + ", " + value.y + ", " + value.z;
  494. }
  495. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  496. return value.r + ", " + value.g + ", " + value.b;
  497. }
  498. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  499. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  500. }
  501. return value; // string
  502. };
  503. /**
  504. * Internal only
  505. * @hidden
  506. */
  507. Action._GetTargetProperty = function (target) {
  508. return {
  509. name: "target",
  510. targetType: target._isMesh ? "MeshProperties"
  511. : target._isLight ? "LightProperties"
  512. : target._isCamera ? "CameraProperties"
  513. : "SceneProperties",
  514. value: target._isScene ? "Scene" : target.name
  515. };
  516. };
  517. return Action;
  518. }());
  519. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  520. /***/ }),
  521. /***/ "./Actions/actionEvent.ts":
  522. /*!********************************!*\
  523. !*** ./Actions/actionEvent.ts ***!
  524. \********************************/
  525. /*! exports provided: ActionEvent */
  526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  527. "use strict";
  528. __webpack_require__.r(__webpack_exports__);
  529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  530. /**
  531. * ActionEvent is the event being sent when an action is triggered.
  532. */
  533. var ActionEvent = /** @class */ (function () {
  534. /**
  535. * Creates a new ActionEvent
  536. * @param source The mesh or sprite that triggered the action
  537. * @param pointerX The X mouse cursor position at the time of the event
  538. * @param pointerY The Y mouse cursor position at the time of the event
  539. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  540. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  541. * @param additionalData additional data for the event
  542. */
  543. function ActionEvent(
  544. /** The mesh or sprite that triggered the action */
  545. source,
  546. /** The X mouse cursor position at the time of the event */
  547. pointerX,
  548. /** The Y mouse cursor position at the time of the event */
  549. pointerY,
  550. /** The mesh that is currently pointed at (can be null) */
  551. meshUnderPointer,
  552. /** the original (browser) event that triggered the ActionEvent */
  553. sourceEvent,
  554. /** additional data for the event */
  555. additionalData) {
  556. this.source = source;
  557. this.pointerX = pointerX;
  558. this.pointerY = pointerY;
  559. this.meshUnderPointer = meshUnderPointer;
  560. this.sourceEvent = sourceEvent;
  561. this.additionalData = additionalData;
  562. }
  563. /**
  564. * Helper function to auto-create an ActionEvent from a source mesh.
  565. * @param source The source mesh that triggered the event
  566. * @param evt The original (browser) event
  567. * @param additionalData additional data for the event
  568. * @returns the new ActionEvent
  569. */
  570. ActionEvent.CreateNew = function (source, evt, additionalData) {
  571. var scene = source.getScene();
  572. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  573. };
  574. /**
  575. * Helper function to auto-create an ActionEvent from a source sprite
  576. * @param source The source sprite that triggered the event
  577. * @param scene Scene associated with the sprite
  578. * @param evt The original (browser) event
  579. * @param additionalData additional data for the event
  580. * @returns the new ActionEvent
  581. */
  582. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  583. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  584. };
  585. /**
  586. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  587. * @param scene the scene where the event occurred
  588. * @param evt The original (browser) event
  589. * @returns the new ActionEvent
  590. */
  591. ActionEvent.CreateNewFromScene = function (scene, evt) {
  592. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  593. };
  594. /**
  595. * Helper function to auto-create an ActionEvent from a primitive
  596. * @param prim defines the target primitive
  597. * @param pointerPos defines the pointer position
  598. * @param evt The original (browser) event
  599. * @param additionalData additional data for the event
  600. * @returns the new ActionEvent
  601. */
  602. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  603. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  604. };
  605. return ActionEvent;
  606. }());
  607. /***/ }),
  608. /***/ "./Actions/actionManager.ts":
  609. /*!**********************************!*\
  610. !*** ./Actions/actionManager.ts ***!
  611. \**********************************/
  612. /*! exports provided: ActionManager */
  613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  614. "use strict";
  615. __webpack_require__.r(__webpack_exports__);
  616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  618. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  619. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  620. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  621. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  622. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  624. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  625. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  626. /**
  627. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  628. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  630. */
  631. var ActionManager = /** @class */ (function () {
  632. /**
  633. * Creates a new action manager
  634. * @param scene defines the hosting scene
  635. */
  636. function ActionManager(scene) {
  637. // Members
  638. /** Gets the list of actions */
  639. this.actions = new Array();
  640. /** Gets the cursor to use when hovering items */
  641. this.hoverCursor = '';
  642. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  643. scene.actionManagers.push(this);
  644. }
  645. // Methods
  646. /**
  647. * Releases all associated resources
  648. */
  649. ActionManager.prototype.dispose = function () {
  650. var index = this._scene.actionManagers.indexOf(this);
  651. for (var i = 0; i < this.actions.length; i++) {
  652. var action = this.actions[i];
  653. ActionManager.Triggers[action.trigger]--;
  654. if (ActionManager.Triggers[action.trigger] === 0) {
  655. delete ActionManager.Triggers[action.trigger];
  656. }
  657. }
  658. if (index > -1) {
  659. this._scene.actionManagers.splice(index, 1);
  660. }
  661. };
  662. /**
  663. * Gets hosting scene
  664. * @returns the hosting scene
  665. */
  666. ActionManager.prototype.getScene = function () {
  667. return this._scene;
  668. };
  669. /**
  670. * Does this action manager handles actions of any of the given triggers
  671. * @param triggers defines the triggers to be tested
  672. * @return a boolean indicating whether one (or more) of the triggers is handled
  673. */
  674. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  675. for (var index = 0; index < this.actions.length; index++) {
  676. var action = this.actions[index];
  677. if (triggers.indexOf(action.trigger) > -1) {
  678. return true;
  679. }
  680. }
  681. return false;
  682. };
  683. /**
  684. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  685. * speed.
  686. * @param triggerA defines the trigger to be tested
  687. * @param triggerB defines the trigger to be tested
  688. * @return a boolean indicating whether one (or more) of the triggers is handled
  689. */
  690. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  691. for (var index = 0; index < this.actions.length; index++) {
  692. var action = this.actions[index];
  693. if (triggerA == action.trigger || triggerB == action.trigger) {
  694. return true;
  695. }
  696. }
  697. return false;
  698. };
  699. /**
  700. * Does this action manager handles actions of a given trigger
  701. * @param trigger defines the trigger to be tested
  702. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  703. * @return whether the trigger is handled
  704. */
  705. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  706. for (var index = 0; index < this.actions.length; index++) {
  707. var action = this.actions[index];
  708. if (action.trigger === trigger) {
  709. if (parameterPredicate) {
  710. if (parameterPredicate(action.getTriggerParameter())) {
  711. return true;
  712. }
  713. }
  714. else {
  715. return true;
  716. }
  717. }
  718. }
  719. return false;
  720. };
  721. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  722. /**
  723. * Does this action manager has pointer triggers
  724. */
  725. get: function () {
  726. for (var index = 0; index < this.actions.length; index++) {
  727. var action = this.actions[index];
  728. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  729. return true;
  730. }
  731. }
  732. return false;
  733. },
  734. enumerable: true,
  735. configurable: true
  736. });
  737. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  738. /**
  739. * Does this action manager has pick triggers
  740. */
  741. get: function () {
  742. for (var index = 0; index < this.actions.length; index++) {
  743. var action = this.actions[index];
  744. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  745. return true;
  746. }
  747. }
  748. return false;
  749. },
  750. enumerable: true,
  751. configurable: true
  752. });
  753. Object.defineProperty(ActionManager, "HasTriggers", {
  754. /**
  755. * Does exist one action manager with at least one trigger
  756. **/
  757. get: function () {
  758. for (var t in ActionManager.Triggers) {
  759. if (ActionManager.Triggers.hasOwnProperty(t)) {
  760. return true;
  761. }
  762. }
  763. return false;
  764. },
  765. enumerable: true,
  766. configurable: true
  767. });
  768. Object.defineProperty(ActionManager, "HasPickTriggers", {
  769. /**
  770. * Does exist one action manager with at least one pick trigger
  771. **/
  772. get: function () {
  773. for (var t in ActionManager.Triggers) {
  774. if (ActionManager.Triggers.hasOwnProperty(t)) {
  775. var t_int = parseInt(t);
  776. if (t_int >= ActionManager.OnPickTrigger && t_int <= ActionManager.OnPickUpTrigger) {
  777. return true;
  778. }
  779. }
  780. }
  781. return false;
  782. },
  783. enumerable: true,
  784. configurable: true
  785. });
  786. /**
  787. * Does exist one action manager that handles actions of a given trigger
  788. * @param trigger defines the trigger to be tested
  789. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  790. **/
  791. ActionManager.HasSpecificTrigger = function (trigger) {
  792. for (var t in ActionManager.Triggers) {
  793. if (ActionManager.Triggers.hasOwnProperty(t)) {
  794. var t_int = parseInt(t);
  795. if (t_int === trigger) {
  796. return true;
  797. }
  798. }
  799. }
  800. return false;
  801. };
  802. /**
  803. * Registers an action to this action manager
  804. * @param action defines the action to be registered
  805. * @return the action amended (prepared) after registration
  806. */
  807. ActionManager.prototype.registerAction = function (action) {
  808. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  809. if (this.getScene().actionManager !== this) {
  810. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  811. return null;
  812. }
  813. }
  814. this.actions.push(action);
  815. if (ActionManager.Triggers[action.trigger]) {
  816. ActionManager.Triggers[action.trigger]++;
  817. }
  818. else {
  819. ActionManager.Triggers[action.trigger] = 1;
  820. }
  821. action._actionManager = this;
  822. action._prepare();
  823. return action;
  824. };
  825. /**
  826. * Unregisters an action to this action manager
  827. * @param action defines the action to be unregistered
  828. * @return a boolean indicating whether the action has been unregistered
  829. */
  830. ActionManager.prototype.unregisterAction = function (action) {
  831. var index = this.actions.indexOf(action);
  832. if (index !== -1) {
  833. this.actions.splice(index, 1);
  834. ActionManager.Triggers[action.trigger] -= 1;
  835. if (ActionManager.Triggers[action.trigger] === 0) {
  836. delete ActionManager.Triggers[action.trigger];
  837. }
  838. delete action._actionManager;
  839. return true;
  840. }
  841. return false;
  842. };
  843. /**
  844. * Process a specific trigger
  845. * @param trigger defines the trigger to process
  846. * @param evt defines the event details to be processed
  847. */
  848. ActionManager.prototype.processTrigger = function (trigger, evt) {
  849. for (var index = 0; index < this.actions.length; index++) {
  850. var action = this.actions[index];
  851. if (action.trigger === trigger) {
  852. if (evt) {
  853. if (trigger === ActionManager.OnKeyUpTrigger
  854. || trigger === ActionManager.OnKeyDownTrigger) {
  855. var parameter = action.getTriggerParameter();
  856. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  857. if (!parameter.toLowerCase) {
  858. continue;
  859. }
  860. var lowerCase = parameter.toLowerCase();
  861. if (lowerCase !== evt.sourceEvent.key) {
  862. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  863. var actualkey = String.fromCharCode(unicode).toLowerCase();
  864. if (actualkey !== lowerCase) {
  865. continue;
  866. }
  867. }
  868. }
  869. }
  870. }
  871. action._executeCurrent(evt);
  872. }
  873. }
  874. };
  875. /** @hidden */
  876. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  877. var properties = propertyPath.split(".");
  878. for (var index = 0; index < properties.length - 1; index++) {
  879. target = target[properties[index]];
  880. }
  881. return target;
  882. };
  883. /** @hidden */
  884. ActionManager.prototype._getProperty = function (propertyPath) {
  885. var properties = propertyPath.split(".");
  886. return properties[properties.length - 1];
  887. };
  888. /**
  889. * Serialize this manager to a JSON object
  890. * @param name defines the property name to store this manager
  891. * @returns a JSON representation of this manager
  892. */
  893. ActionManager.prototype.serialize = function (name) {
  894. var root = {
  895. children: new Array(),
  896. name: name,
  897. type: 3,
  898. properties: new Array() // Empty for root but required
  899. };
  900. for (var i = 0; i < this.actions.length; i++) {
  901. var triggerObject = {
  902. type: 0,
  903. children: new Array(),
  904. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  905. properties: new Array()
  906. };
  907. var triggerOptions = this.actions[i].triggerOptions;
  908. if (triggerOptions && typeof triggerOptions !== "number") {
  909. if (triggerOptions.parameter instanceof Node) {
  910. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_2__["Action"]._GetTargetProperty(triggerOptions.parameter));
  911. }
  912. else {
  913. var parameter = {};
  914. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  915. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  916. parameter._meshId = triggerOptions.parameter.mesh.id;
  917. }
  918. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  919. }
  920. }
  921. // Serialize child action, recursively
  922. this.actions[i].serialize(triggerObject);
  923. // Add serialized trigger
  924. root.children.push(triggerObject);
  925. }
  926. return root;
  927. };
  928. /**
  929. * Creates a new ActionManager from a JSON data
  930. * @param parsedActions defines the JSON data to read from
  931. * @param object defines the hosting mesh
  932. * @param scene defines the hosting scene
  933. */
  934. ActionManager.Parse = function (parsedActions, object, scene) {
  935. var actionManager = new ActionManager(scene);
  936. if (object === null) {
  937. scene.actionManager = actionManager;
  938. }
  939. else {
  940. object.actionManager = actionManager;
  941. }
  942. // instanciate a new object
  943. var instanciate = function (name, params) {
  944. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  945. if (internalClassType) {
  946. var newInstance = Object.create(internalClassType.prototype);
  947. newInstance.constructor.apply(newInstance, params);
  948. return newInstance;
  949. }
  950. };
  951. var parseParameter = function (name, value, target, propertyPath) {
  952. if (propertyPath === null) {
  953. // String, boolean or float
  954. var floatValue = parseFloat(value);
  955. if (value === "true" || value === "false") {
  956. return value === "true";
  957. }
  958. else {
  959. return isNaN(floatValue) ? value : floatValue;
  960. }
  961. }
  962. var effectiveTarget = propertyPath.split(".");
  963. var values = value.split(",");
  964. // Get effective Target
  965. for (var i = 0; i < effectiveTarget.length; i++) {
  966. target = target[effectiveTarget[i]];
  967. }
  968. // Return appropriate value with its type
  969. if (typeof (target) === "boolean") {
  970. return values[0] === "true";
  971. }
  972. if (typeof (target) === "string") {
  973. return values[0];
  974. }
  975. // Parameters with multiple values such as Vector3 etc.
  976. var split = new Array();
  977. for (var i = 0; i < values.length; i++) {
  978. split.push(parseFloat(values[i]));
  979. }
  980. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  981. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(split);
  982. }
  983. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"]) {
  984. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArray(split);
  985. }
  986. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  987. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(split);
  988. }
  989. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"]) {
  990. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].FromArray(split);
  991. }
  992. return parseFloat(values[0]);
  993. };
  994. // traverse graph per trigger
  995. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  996. if (combineArray === void 0) { combineArray = null; }
  997. if (parsedAction.detached) {
  998. return;
  999. }
  1000. var parameters = new Array();
  1001. var target = null;
  1002. var propertyPath = null;
  1003. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1004. // Parameters
  1005. if (parsedAction.type === 2) {
  1006. parameters.push(actionManager);
  1007. }
  1008. else {
  1009. parameters.push(trigger);
  1010. }
  1011. if (combine) {
  1012. var actions = new Array();
  1013. for (var j = 0; j < parsedAction.combine.length; j++) {
  1014. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1015. }
  1016. parameters.push(actions);
  1017. }
  1018. else {
  1019. for (var i = 0; i < parsedAction.properties.length; i++) {
  1020. var value = parsedAction.properties[i].value;
  1021. var name = parsedAction.properties[i].name;
  1022. var targetType = parsedAction.properties[i].targetType;
  1023. if (name === "target") {
  1024. if (targetType !== null && targetType === "SceneProperties") {
  1025. value = target = scene;
  1026. }
  1027. else {
  1028. value = target = scene.getNodeByName(value);
  1029. }
  1030. }
  1031. else if (name === "parent") {
  1032. value = scene.getNodeByName(value);
  1033. }
  1034. else if (name === "sound") {
  1035. // Can not externalize to component, so only checks for the presence off the API.
  1036. if (scene.getSoundByName) {
  1037. value = scene.getSoundByName(value);
  1038. }
  1039. }
  1040. else if (name !== "propertyPath") {
  1041. if (parsedAction.type === 2 && name === "operator") {
  1042. value = _condition__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"][value];
  1043. }
  1044. else {
  1045. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1046. }
  1047. }
  1048. else {
  1049. propertyPath = value;
  1050. }
  1051. parameters.push(value);
  1052. }
  1053. }
  1054. if (combineArray === null) {
  1055. parameters.push(condition);
  1056. }
  1057. else {
  1058. parameters.push(null);
  1059. }
  1060. // If interpolate value action
  1061. if (parsedAction.name === "InterpolateValueAction") {
  1062. var param = parameters[parameters.length - 2];
  1063. parameters[parameters.length - 1] = param;
  1064. parameters[parameters.length - 2] = condition;
  1065. }
  1066. // Action or condition(s) and not CombineAction
  1067. var newAction = instanciate(parsedAction.name, parameters);
  1068. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"] && condition !== null) {
  1069. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_3__["DoNothingAction"](trigger, condition);
  1070. if (action) {
  1071. action.then(nothing);
  1072. }
  1073. else {
  1074. actionManager.registerAction(nothing);
  1075. }
  1076. action = nothing;
  1077. }
  1078. if (combineArray === null) {
  1079. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"]) {
  1080. condition = newAction;
  1081. newAction = action;
  1082. }
  1083. else {
  1084. condition = null;
  1085. if (action) {
  1086. action.then(newAction);
  1087. }
  1088. else {
  1089. actionManager.registerAction(newAction);
  1090. }
  1091. }
  1092. }
  1093. else {
  1094. combineArray.push(newAction);
  1095. }
  1096. for (var i = 0; i < parsedAction.children.length; i++) {
  1097. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1098. }
  1099. };
  1100. // triggers
  1101. for (var i = 0; i < parsedActions.children.length; i++) {
  1102. var triggerParams;
  1103. var trigger = parsedActions.children[i];
  1104. if (trigger.properties.length > 0) {
  1105. var param = trigger.properties[0].value;
  1106. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1107. if (value._meshId) {
  1108. value.mesh = scene.getMeshByID(value._meshId);
  1109. }
  1110. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1111. }
  1112. else {
  1113. triggerParams = ActionManager[trigger.name];
  1114. }
  1115. for (var j = 0; j < trigger.children.length; j++) {
  1116. if (!trigger.detached) {
  1117. traverse(trigger.children[j], triggerParams, null, null);
  1118. }
  1119. }
  1120. }
  1121. };
  1122. /**
  1123. * Get a trigger name by index
  1124. * @param trigger defines the trigger index
  1125. * @returns a trigger name
  1126. */
  1127. ActionManager.GetTriggerName = function (trigger) {
  1128. switch (trigger) {
  1129. case 0: return "NothingTrigger";
  1130. case 1: return "OnPickTrigger";
  1131. case 2: return "OnLeftPickTrigger";
  1132. case 3: return "OnRightPickTrigger";
  1133. case 4: return "OnCenterPickTrigger";
  1134. case 5: return "OnPickDownTrigger";
  1135. case 6: return "OnPickUpTrigger";
  1136. case 7: return "OnLongPressTrigger";
  1137. case 8: return "OnPointerOverTrigger";
  1138. case 9: return "OnPointerOutTrigger";
  1139. case 10: return "OnEveryFrameTrigger";
  1140. case 11: return "OnIntersectionEnterTrigger";
  1141. case 12: return "OnIntersectionExitTrigger";
  1142. case 13: return "OnKeyDownTrigger";
  1143. case 14: return "OnKeyUpTrigger";
  1144. case 15: return "OnPickOutTrigger";
  1145. default: return "";
  1146. }
  1147. };
  1148. /**
  1149. * Nothing
  1150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1151. */
  1152. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger;
  1153. /**
  1154. * On pick
  1155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1156. */
  1157. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickTrigger;
  1158. /**
  1159. * On left pick
  1160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1161. */
  1162. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLeftPickTrigger;
  1163. /**
  1164. * On right pick
  1165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1166. */
  1167. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnRightPickTrigger;
  1168. /**
  1169. * On center pick
  1170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1171. */
  1172. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnCenterPickTrigger;
  1173. /**
  1174. * On pick down
  1175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1176. */
  1177. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickDownTrigger;
  1178. /**
  1179. * On double pick
  1180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1181. */
  1182. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnDoublePickTrigger;
  1183. /**
  1184. * On pick up
  1185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1186. */
  1187. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickUpTrigger;
  1188. /**
  1189. * On pick out.
  1190. * This trigger will only be raised if you also declared a OnPickDown
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickOutTrigger;
  1194. /**
  1195. * On long press
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLongPressTrigger;
  1199. /**
  1200. * On pointer over
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOverTrigger;
  1204. /**
  1205. * On pointer out
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOutTrigger;
  1209. /**
  1210. * On every frame
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnEveryFrameTrigger;
  1214. /**
  1215. * On intersection enter
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1219. /**
  1220. * On intersection exit
  1221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1222. */
  1223. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionExitTrigger;
  1224. /**
  1225. * On key down
  1226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1227. */
  1228. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnKeyDownTrigger;
  1229. /**
  1230. * On key up
  1231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1232. */
  1233. ActionManager.OnKeyUpTrigger = 15;
  1234. /** Gets the list of active triggers */
  1235. ActionManager.Triggers = {};
  1236. return ActionManager;
  1237. }());
  1238. /***/ }),
  1239. /***/ "./Actions/condition.ts":
  1240. /*!******************************!*\
  1241. !*** ./Actions/condition.ts ***!
  1242. \******************************/
  1243. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1245. "use strict";
  1246. __webpack_require__.r(__webpack_exports__);
  1247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1252. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1253. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1254. /**
  1255. * A Condition applied to an Action
  1256. */
  1257. var Condition = /** @class */ (function () {
  1258. /**
  1259. * Creates a new Condition
  1260. * @param actionManager the manager of the action the condition is applied to
  1261. */
  1262. function Condition(actionManager) {
  1263. this._actionManager = actionManager;
  1264. }
  1265. /**
  1266. * Check if the current condition is valid
  1267. * @returns a boolean
  1268. */
  1269. Condition.prototype.isValid = function () {
  1270. return true;
  1271. };
  1272. /**
  1273. * Internal only
  1274. * @hidden
  1275. */
  1276. Condition.prototype._getProperty = function (propertyPath) {
  1277. return this._actionManager._getProperty(propertyPath);
  1278. };
  1279. /**
  1280. * Internal only
  1281. * @hidden
  1282. */
  1283. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1284. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1285. };
  1286. /**
  1287. * Serialize placeholder for child classes
  1288. * @returns the serialized object
  1289. */
  1290. Condition.prototype.serialize = function () {
  1291. };
  1292. /**
  1293. * Internal only
  1294. * @hidden
  1295. */
  1296. Condition.prototype._serialize = function (serializedCondition) {
  1297. return {
  1298. type: 2,
  1299. children: [],
  1300. name: serializedCondition.name,
  1301. properties: serializedCondition.properties
  1302. };
  1303. };
  1304. return Condition;
  1305. }());
  1306. /**
  1307. * Defines specific conditional operators as extensions of Condition
  1308. */
  1309. var ValueCondition = /** @class */ (function (_super) {
  1310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1311. /**
  1312. * Creates a new ValueCondition
  1313. * @param actionManager manager for the action the condition applies to
  1314. * @param target for the action
  1315. * @param propertyPath path to specify the property of the target the conditional operator uses
  1316. * @param value the value compared by the conditional operator against the current value of the property
  1317. * @param operator the conditional operator, default ValueCondition.IsEqual
  1318. */
  1319. function ValueCondition(actionManager, target,
  1320. /** path to specify the property of the target the conditional operator uses */
  1321. propertyPath,
  1322. /** the value compared by the conditional operator against the current value of the property */
  1323. value,
  1324. /** the conditional operator, default ValueCondition.IsEqual */
  1325. operator) {
  1326. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1327. var _this = _super.call(this, actionManager) || this;
  1328. _this.propertyPath = propertyPath;
  1329. _this.value = value;
  1330. _this.operator = operator;
  1331. _this._target = target;
  1332. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1333. _this._property = _this._getProperty(_this.propertyPath);
  1334. return _this;
  1335. }
  1336. Object.defineProperty(ValueCondition, "IsEqual", {
  1337. /**
  1338. * returns the number for IsEqual
  1339. */
  1340. get: function () {
  1341. return ValueCondition._IsEqual;
  1342. },
  1343. enumerable: true,
  1344. configurable: true
  1345. });
  1346. Object.defineProperty(ValueCondition, "IsDifferent", {
  1347. /**
  1348. * Returns the number for IsDifferent
  1349. */
  1350. get: function () {
  1351. return ValueCondition._IsDifferent;
  1352. },
  1353. enumerable: true,
  1354. configurable: true
  1355. });
  1356. Object.defineProperty(ValueCondition, "IsGreater", {
  1357. /**
  1358. * Returns the number for IsGreater
  1359. */
  1360. get: function () {
  1361. return ValueCondition._IsGreater;
  1362. },
  1363. enumerable: true,
  1364. configurable: true
  1365. });
  1366. Object.defineProperty(ValueCondition, "IsLesser", {
  1367. /**
  1368. * Returns the number for IsLesser
  1369. */
  1370. get: function () {
  1371. return ValueCondition._IsLesser;
  1372. },
  1373. enumerable: true,
  1374. configurable: true
  1375. });
  1376. /**
  1377. * Compares the given value with the property value for the specified conditional operator
  1378. * @returns the result of the comparison
  1379. */
  1380. ValueCondition.prototype.isValid = function () {
  1381. switch (this.operator) {
  1382. case ValueCondition.IsGreater:
  1383. return this._effectiveTarget[this._property] > this.value;
  1384. case ValueCondition.IsLesser:
  1385. return this._effectiveTarget[this._property] < this.value;
  1386. case ValueCondition.IsEqual:
  1387. case ValueCondition.IsDifferent:
  1388. var check;
  1389. if (this.value.equals) {
  1390. check = this.value.equals(this._effectiveTarget[this._property]);
  1391. }
  1392. else {
  1393. check = this.value === this._effectiveTarget[this._property];
  1394. }
  1395. return this.operator === ValueCondition.IsEqual ? check : !check;
  1396. }
  1397. return false;
  1398. };
  1399. /**
  1400. * Serialize the ValueCondition into a JSON compatible object
  1401. * @returns serialization object
  1402. */
  1403. ValueCondition.prototype.serialize = function () {
  1404. return this._serialize({
  1405. name: "ValueCondition",
  1406. properties: [
  1407. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1408. { name: "propertyPath", value: this.propertyPath },
  1409. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1410. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1411. ]
  1412. });
  1413. };
  1414. /**
  1415. * Gets the name of the conditional operator for the ValueCondition
  1416. * @param operator the conditional operator
  1417. * @returns the name
  1418. */
  1419. ValueCondition.GetOperatorName = function (operator) {
  1420. switch (operator) {
  1421. case ValueCondition._IsEqual: return "IsEqual";
  1422. case ValueCondition._IsDifferent: return "IsDifferent";
  1423. case ValueCondition._IsGreater: return "IsGreater";
  1424. case ValueCondition._IsLesser: return "IsLesser";
  1425. default: return "";
  1426. }
  1427. };
  1428. /**
  1429. * Internal only
  1430. * @hidden
  1431. */
  1432. ValueCondition._IsEqual = 0;
  1433. /**
  1434. * Internal only
  1435. * @hidden
  1436. */
  1437. ValueCondition._IsDifferent = 1;
  1438. /**
  1439. * Internal only
  1440. * @hidden
  1441. */
  1442. ValueCondition._IsGreater = 2;
  1443. /**
  1444. * Internal only
  1445. * @hidden
  1446. */
  1447. ValueCondition._IsLesser = 3;
  1448. return ValueCondition;
  1449. }(Condition));
  1450. /**
  1451. * Defines a predicate condition as an extension of Condition
  1452. */
  1453. var PredicateCondition = /** @class */ (function (_super) {
  1454. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1455. /**
  1456. * Creates a new PredicateCondition
  1457. * @param actionManager manager for the action the condition applies to
  1458. * @param predicate defines the predicate function used to validate the condition
  1459. */
  1460. function PredicateCondition(actionManager,
  1461. /** defines the predicate function used to validate the condition */
  1462. predicate) {
  1463. var _this = _super.call(this, actionManager) || this;
  1464. _this.predicate = predicate;
  1465. return _this;
  1466. }
  1467. /**
  1468. * @returns the validity of the predicate condition
  1469. */
  1470. PredicateCondition.prototype.isValid = function () {
  1471. return this.predicate();
  1472. };
  1473. return PredicateCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a state condition as an extension of Condition
  1477. */
  1478. var StateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1480. /**
  1481. * Creates a new StateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param target of the condition
  1484. * @param value to compare with target state
  1485. */
  1486. function StateCondition(actionManager, target,
  1487. /** Value to compare with target state */
  1488. value) {
  1489. var _this = _super.call(this, actionManager) || this;
  1490. _this.value = value;
  1491. _this._target = target;
  1492. return _this;
  1493. }
  1494. /**
  1495. * Gets a boolean indicating if the current condition is met
  1496. * @returns the validity of the state
  1497. */
  1498. StateCondition.prototype.isValid = function () {
  1499. return this._target.state === this.value;
  1500. };
  1501. /**
  1502. * Serialize the StateCondition into a JSON compatible object
  1503. * @returns serialization object
  1504. */
  1505. StateCondition.prototype.serialize = function () {
  1506. return this._serialize({
  1507. name: "StateCondition",
  1508. properties: [
  1509. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1510. { name: "value", value: this.value }
  1511. ]
  1512. });
  1513. };
  1514. return StateCondition;
  1515. }(Condition));
  1516. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1517. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1518. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1519. /***/ }),
  1520. /***/ "./Actions/directActions.ts":
  1521. /*!**********************************!*\
  1522. !*** ./Actions/directActions.ts ***!
  1523. \**********************************/
  1524. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1526. "use strict";
  1527. __webpack_require__.r(__webpack_exports__);
  1528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1539. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1540. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1541. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1542. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1543. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1544. /**
  1545. * This defines an action responsible to toggle a boolean once triggered.
  1546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1547. */
  1548. var SwitchBooleanAction = /** @class */ (function (_super) {
  1549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1550. /**
  1551. * Instantiate the action
  1552. * @param triggerOptions defines the trigger options
  1553. * @param target defines the object containing the boolean
  1554. * @param propertyPath defines the path to the boolean property in the target object
  1555. * @param condition defines the trigger related conditions
  1556. */
  1557. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1558. var _this = _super.call(this, triggerOptions, condition) || this;
  1559. _this.propertyPath = propertyPath;
  1560. _this._target = _this._effectiveTarget = target;
  1561. return _this;
  1562. }
  1563. /** @hidden */
  1564. SwitchBooleanAction.prototype._prepare = function () {
  1565. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1566. this._property = this._getProperty(this.propertyPath);
  1567. };
  1568. /**
  1569. * Execute the action toggle the boolean value.
  1570. */
  1571. SwitchBooleanAction.prototype.execute = function () {
  1572. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1573. };
  1574. /**
  1575. * Serializes the actions and its related information.
  1576. * @param parent defines the object to serialize in
  1577. * @returns the serialized object
  1578. */
  1579. SwitchBooleanAction.prototype.serialize = function (parent) {
  1580. return _super.prototype._serialize.call(this, {
  1581. name: "SwitchBooleanAction",
  1582. properties: [
  1583. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1584. { name: "propertyPath", value: this.propertyPath }
  1585. ]
  1586. }, parent);
  1587. };
  1588. return SwitchBooleanAction;
  1589. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1590. /**
  1591. * This defines an action responsible to set a the state field of the target
  1592. * to a desired value once triggered.
  1593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1594. */
  1595. var SetStateAction = /** @class */ (function (_super) {
  1596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1597. /**
  1598. * Instantiate the action
  1599. * @param triggerOptions defines the trigger options
  1600. * @param target defines the object containing the state property
  1601. * @param value defines the value to store in the state field
  1602. * @param condition defines the trigger related conditions
  1603. */
  1604. function SetStateAction(triggerOptions, target, value, condition) {
  1605. var _this = _super.call(this, triggerOptions, condition) || this;
  1606. _this.value = value;
  1607. _this._target = target;
  1608. return _this;
  1609. }
  1610. /**
  1611. * Execute the action and store the value on the target state property.
  1612. */
  1613. SetStateAction.prototype.execute = function () {
  1614. this._target.state = this.value;
  1615. };
  1616. /**
  1617. * Serializes the actions and its related information.
  1618. * @param parent defines the object to serialize in
  1619. * @returns the serialized object
  1620. */
  1621. SetStateAction.prototype.serialize = function (parent) {
  1622. return _super.prototype._serialize.call(this, {
  1623. name: "SetStateAction",
  1624. properties: [
  1625. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1626. { name: "value", value: this.value }
  1627. ]
  1628. }, parent);
  1629. };
  1630. return SetStateAction;
  1631. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1632. /**
  1633. * This defines an action responsible to set a property of the target
  1634. * to a desired value once triggered.
  1635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1636. */
  1637. var SetValueAction = /** @class */ (function (_super) {
  1638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1639. /**
  1640. * Instantiate the action
  1641. * @param triggerOptions defines the trigger options
  1642. * @param target defines the object containing the property
  1643. * @param propertyPath defines the path of the property to set in the target
  1644. * @param value defines the value to set in the property
  1645. * @param condition defines the trigger related conditions
  1646. */
  1647. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1648. var _this = _super.call(this, triggerOptions, condition) || this;
  1649. _this.propertyPath = propertyPath;
  1650. _this.value = value;
  1651. _this._target = _this._effectiveTarget = target;
  1652. return _this;
  1653. }
  1654. /** @hidden */
  1655. SetValueAction.prototype._prepare = function () {
  1656. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1657. this._property = this._getProperty(this.propertyPath);
  1658. };
  1659. /**
  1660. * Execute the action and set the targetted property to the desired value.
  1661. */
  1662. SetValueAction.prototype.execute = function () {
  1663. this._effectiveTarget[this._property] = this.value;
  1664. if (this._target.markAsDirty) {
  1665. this._target.markAsDirty(this._property);
  1666. }
  1667. };
  1668. /**
  1669. * Serializes the actions and its related information.
  1670. * @param parent defines the object to serialize in
  1671. * @returns the serialized object
  1672. */
  1673. SetValueAction.prototype.serialize = function (parent) {
  1674. return _super.prototype._serialize.call(this, {
  1675. name: "SetValueAction",
  1676. properties: [
  1677. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1678. { name: "propertyPath", value: this.propertyPath },
  1679. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1680. ]
  1681. }, parent);
  1682. };
  1683. return SetValueAction;
  1684. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1685. /**
  1686. * This defines an action responsible to increment the target value
  1687. * to a desired value once triggered.
  1688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1689. */
  1690. var IncrementValueAction = /** @class */ (function (_super) {
  1691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1692. /**
  1693. * Instantiate the action
  1694. * @param triggerOptions defines the trigger options
  1695. * @param target defines the object containing the property
  1696. * @param propertyPath defines the path of the property to increment in the target
  1697. * @param value defines the value value we should increment the property by
  1698. * @param condition defines the trigger related conditions
  1699. */
  1700. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1701. var _this = _super.call(this, triggerOptions, condition) || this;
  1702. _this.propertyPath = propertyPath;
  1703. _this.value = value;
  1704. _this._target = _this._effectiveTarget = target;
  1705. return _this;
  1706. }
  1707. /** @hidden */
  1708. IncrementValueAction.prototype._prepare = function () {
  1709. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1710. this._property = this._getProperty(this.propertyPath);
  1711. if (typeof this._effectiveTarget[this._property] !== "number") {
  1712. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1713. }
  1714. };
  1715. /**
  1716. * Execute the action and increment the target of the value amount.
  1717. */
  1718. IncrementValueAction.prototype.execute = function () {
  1719. this._effectiveTarget[this._property] += this.value;
  1720. if (this._target.markAsDirty) {
  1721. this._target.markAsDirty(this._property);
  1722. }
  1723. };
  1724. /**
  1725. * Serializes the actions and its related information.
  1726. * @param parent defines the object to serialize in
  1727. * @returns the serialized object
  1728. */
  1729. IncrementValueAction.prototype.serialize = function (parent) {
  1730. return _super.prototype._serialize.call(this, {
  1731. name: "IncrementValueAction",
  1732. properties: [
  1733. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1734. { name: "propertyPath", value: this.propertyPath },
  1735. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1736. ]
  1737. }, parent);
  1738. };
  1739. return IncrementValueAction;
  1740. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1741. /**
  1742. * This defines an action responsible to start an animation once triggered.
  1743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1744. */
  1745. var PlayAnimationAction = /** @class */ (function (_super) {
  1746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1747. /**
  1748. * Instantiate the action
  1749. * @param triggerOptions defines the trigger options
  1750. * @param target defines the target animation or animation name
  1751. * @param from defines from where the animation should start (animation frame)
  1752. * @param end defines where the animation should stop (animation frame)
  1753. * @param loop defines if the animation should loop or stop after the first play
  1754. * @param condition defines the trigger related conditions
  1755. */
  1756. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1757. var _this = _super.call(this, triggerOptions, condition) || this;
  1758. _this.from = from;
  1759. _this.to = to;
  1760. _this.loop = loop;
  1761. _this._target = target;
  1762. return _this;
  1763. }
  1764. /** @hidden */
  1765. PlayAnimationAction.prototype._prepare = function () {
  1766. };
  1767. /**
  1768. * Execute the action and play the animation.
  1769. */
  1770. PlayAnimationAction.prototype.execute = function () {
  1771. var scene = this._actionManager.getScene();
  1772. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1773. };
  1774. /**
  1775. * Serializes the actions and its related information.
  1776. * @param parent defines the object to serialize in
  1777. * @returns the serialized object
  1778. */
  1779. PlayAnimationAction.prototype.serialize = function (parent) {
  1780. return _super.prototype._serialize.call(this, {
  1781. name: "PlayAnimationAction",
  1782. properties: [
  1783. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1784. { name: "from", value: String(this.from) },
  1785. { name: "to", value: String(this.to) },
  1786. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1787. ]
  1788. }, parent);
  1789. };
  1790. return PlayAnimationAction;
  1791. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1792. /**
  1793. * This defines an action responsible to stop an animation once triggered.
  1794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1795. */
  1796. var StopAnimationAction = /** @class */ (function (_super) {
  1797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1798. /**
  1799. * Instantiate the action
  1800. * @param triggerOptions defines the trigger options
  1801. * @param target defines the target animation or animation name
  1802. * @param condition defines the trigger related conditions
  1803. */
  1804. function StopAnimationAction(triggerOptions, target, condition) {
  1805. var _this = _super.call(this, triggerOptions, condition) || this;
  1806. _this._target = target;
  1807. return _this;
  1808. }
  1809. /** @hidden */
  1810. StopAnimationAction.prototype._prepare = function () {
  1811. };
  1812. /**
  1813. * Execute the action and stop the animation.
  1814. */
  1815. StopAnimationAction.prototype.execute = function () {
  1816. var scene = this._actionManager.getScene();
  1817. scene.stopAnimation(this._target);
  1818. };
  1819. /**
  1820. * Serializes the actions and its related information.
  1821. * @param parent defines the object to serialize in
  1822. * @returns the serialized object
  1823. */
  1824. StopAnimationAction.prototype.serialize = function (parent) {
  1825. return _super.prototype._serialize.call(this, {
  1826. name: "StopAnimationAction",
  1827. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1828. }, parent);
  1829. };
  1830. return StopAnimationAction;
  1831. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1832. /**
  1833. * This defines an action responsible that does nothing once triggered.
  1834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1835. */
  1836. var DoNothingAction = /** @class */ (function (_super) {
  1837. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1838. /**
  1839. * Instantiate the action
  1840. * @param triggerOptions defines the trigger options
  1841. * @param condition defines the trigger related conditions
  1842. */
  1843. function DoNothingAction(triggerOptions, condition) {
  1844. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1845. return _super.call(this, triggerOptions, condition) || this;
  1846. }
  1847. /**
  1848. * Execute the action and do nothing.
  1849. */
  1850. DoNothingAction.prototype.execute = function () {
  1851. };
  1852. /**
  1853. * Serializes the actions and its related information.
  1854. * @param parent defines the object to serialize in
  1855. * @returns the serialized object
  1856. */
  1857. DoNothingAction.prototype.serialize = function (parent) {
  1858. return _super.prototype._serialize.call(this, {
  1859. name: "DoNothingAction",
  1860. properties: []
  1861. }, parent);
  1862. };
  1863. return DoNothingAction;
  1864. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1865. /**
  1866. * This defines an action responsible to trigger several actions once triggered.
  1867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1868. */
  1869. var CombineAction = /** @class */ (function (_super) {
  1870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1871. /**
  1872. * Instantiate the action
  1873. * @param triggerOptions defines the trigger options
  1874. * @param children defines the list of aggregated animations to run
  1875. * @param condition defines the trigger related conditions
  1876. */
  1877. function CombineAction(triggerOptions, children, condition) {
  1878. var _this = _super.call(this, triggerOptions, condition) || this;
  1879. _this.children = children;
  1880. return _this;
  1881. }
  1882. /** @hidden */
  1883. CombineAction.prototype._prepare = function () {
  1884. for (var index = 0; index < this.children.length; index++) {
  1885. this.children[index]._actionManager = this._actionManager;
  1886. this.children[index]._prepare();
  1887. }
  1888. };
  1889. /**
  1890. * Execute the action and executes all the aggregated actions.
  1891. */
  1892. CombineAction.prototype.execute = function (evt) {
  1893. for (var index = 0; index < this.children.length; index++) {
  1894. this.children[index].execute(evt);
  1895. }
  1896. };
  1897. /**
  1898. * Serializes the actions and its related information.
  1899. * @param parent defines the object to serialize in
  1900. * @returns the serialized object
  1901. */
  1902. CombineAction.prototype.serialize = function (parent) {
  1903. var serializationObject = _super.prototype._serialize.call(this, {
  1904. name: "CombineAction",
  1905. properties: [],
  1906. combine: []
  1907. }, parent);
  1908. for (var i = 0; i < this.children.length; i++) {
  1909. serializationObject.combine.push(this.children[i].serialize(null));
  1910. }
  1911. return serializationObject;
  1912. };
  1913. return CombineAction;
  1914. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1915. /**
  1916. * This defines an action responsible to run code (external event) once triggered.
  1917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1918. */
  1919. var ExecuteCodeAction = /** @class */ (function (_super) {
  1920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1921. /**
  1922. * Instantiate the action
  1923. * @param triggerOptions defines the trigger options
  1924. * @param func defines the callback function to run
  1925. * @param condition defines the trigger related conditions
  1926. */
  1927. function ExecuteCodeAction(triggerOptions, func, condition) {
  1928. var _this = _super.call(this, triggerOptions, condition) || this;
  1929. _this.func = func;
  1930. return _this;
  1931. }
  1932. /**
  1933. * Execute the action and run the attached code.
  1934. */
  1935. ExecuteCodeAction.prototype.execute = function (evt) {
  1936. this.func(evt);
  1937. };
  1938. return ExecuteCodeAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to set the parent property of the target once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var SetParentAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param target defines the target containing the parent property
  1950. * @param parent defines from where the animation should start (animation frame)
  1951. * @param condition defines the trigger related conditions
  1952. */
  1953. function SetParentAction(triggerOptions, target, parent, condition) {
  1954. var _this = _super.call(this, triggerOptions, condition) || this;
  1955. _this._target = target;
  1956. _this._parent = parent;
  1957. return _this;
  1958. }
  1959. /** @hidden */
  1960. SetParentAction.prototype._prepare = function () {
  1961. };
  1962. /**
  1963. * Execute the action and set the parent property.
  1964. */
  1965. SetParentAction.prototype.execute = function () {
  1966. if (this._target.parent === this._parent) {
  1967. return;
  1968. }
  1969. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1970. invertParentWorldMatrix.invert();
  1971. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1972. this._target.parent = this._parent;
  1973. };
  1974. /**
  1975. * Serializes the actions and its related information.
  1976. * @param parent defines the object to serialize in
  1977. * @returns the serialized object
  1978. */
  1979. SetParentAction.prototype.serialize = function (parent) {
  1980. return _super.prototype._serialize.call(this, {
  1981. name: "SetParentAction",
  1982. properties: [
  1983. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1984. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  1985. ]
  1986. }, parent);
  1987. };
  1988. return SetParentAction;
  1989. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1990. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1991. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  1992. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  1993. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  1994. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  1995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  1996. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  1997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  1998. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1999. /***/ }),
  2000. /***/ "./Actions/directAudioActions.ts":
  2001. /*!***************************************!*\
  2002. !*** ./Actions/directAudioActions.ts ***!
  2003. \***************************************/
  2004. /*! exports provided: PlaySoundAction, StopSoundAction */
  2005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2006. "use strict";
  2007. __webpack_require__.r(__webpack_exports__);
  2008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2011. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2012. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2013. /**
  2014. * This defines an action helpful to play a defined sound on a triggered action.
  2015. */
  2016. var PlaySoundAction = /** @class */ (function (_super) {
  2017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2018. /**
  2019. * Instantiate the action
  2020. * @param triggerOptions defines the trigger options
  2021. * @param sound defines the sound to play
  2022. * @param condition defines the trigger related conditions
  2023. */
  2024. function PlaySoundAction(triggerOptions, sound, condition) {
  2025. var _this = _super.call(this, triggerOptions, condition) || this;
  2026. _this._sound = sound;
  2027. return _this;
  2028. }
  2029. /** @hidden */
  2030. PlaySoundAction.prototype._prepare = function () {
  2031. };
  2032. /**
  2033. * Execute the action and play the sound.
  2034. */
  2035. PlaySoundAction.prototype.execute = function () {
  2036. if (this._sound !== undefined) {
  2037. this._sound.play();
  2038. }
  2039. };
  2040. /**
  2041. * Serializes the actions and its related information.
  2042. * @param parent defines the object to serialize in
  2043. * @returns the serialized object
  2044. */
  2045. PlaySoundAction.prototype.serialize = function (parent) {
  2046. return _super.prototype._serialize.call(this, {
  2047. name: "PlaySoundAction",
  2048. properties: [{ name: "sound", value: this._sound.name }]
  2049. }, parent);
  2050. };
  2051. return PlaySoundAction;
  2052. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2053. /**
  2054. * This defines an action helpful to stop a defined sound on a triggered action.
  2055. */
  2056. var StopSoundAction = /** @class */ (function (_super) {
  2057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2058. /**
  2059. * Instantiate the action
  2060. * @param triggerOptions defines the trigger options
  2061. * @param sound defines the sound to stop
  2062. * @param condition defines the trigger related conditions
  2063. */
  2064. function StopSoundAction(triggerOptions, sound, condition) {
  2065. var _this = _super.call(this, triggerOptions, condition) || this;
  2066. _this._sound = sound;
  2067. return _this;
  2068. }
  2069. /** @hidden */
  2070. StopSoundAction.prototype._prepare = function () {
  2071. };
  2072. /**
  2073. * Execute the action and stop the sound.
  2074. */
  2075. StopSoundAction.prototype.execute = function () {
  2076. if (this._sound !== undefined) {
  2077. this._sound.stop();
  2078. }
  2079. };
  2080. /**
  2081. * Serializes the actions and its related information.
  2082. * @param parent defines the object to serialize in
  2083. * @returns the serialized object
  2084. */
  2085. StopSoundAction.prototype.serialize = function (parent) {
  2086. return _super.prototype._serialize.call(this, {
  2087. name: "StopSoundAction",
  2088. properties: [{ name: "sound", value: this._sound.name }]
  2089. }, parent);
  2090. };
  2091. return StopSoundAction;
  2092. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2093. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2094. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2095. /***/ }),
  2096. /***/ "./Actions/index.ts":
  2097. /*!**************************!*\
  2098. !*** ./Actions/index.ts ***!
  2099. \**************************/
  2100. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2102. "use strict";
  2103. __webpack_require__.r(__webpack_exports__);
  2104. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2106. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2108. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2110. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2115. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2126. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2129. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2131. /***/ }),
  2132. /***/ "./Actions/interpolateValueAction.ts":
  2133. /*!*******************************************!*\
  2134. !*** ./Actions/interpolateValueAction.ts ***!
  2135. \*******************************************/
  2136. /*! exports provided: InterpolateValueAction */
  2137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2138. "use strict";
  2139. __webpack_require__.r(__webpack_exports__);
  2140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2141. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2142. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2143. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2145. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2146. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2147. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2148. /**
  2149. * This defines an action responsible to change the value of a property
  2150. * by interpolating between its current value and the newly set one once triggered.
  2151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2152. */
  2153. var InterpolateValueAction = /** @class */ (function (_super) {
  2154. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2155. /**
  2156. * Instantiate the action
  2157. * @param triggerOptions defines the trigger options
  2158. * @param target defines the object containing the value to interpolate
  2159. * @param propertyPath defines the path to the property in the target object
  2160. * @param value defines the target value at the end of the interpolation
  2161. * @param duration deines the time it will take for the property to interpolate to the value.
  2162. * @param condition defines the trigger related conditions
  2163. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2164. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2165. */
  2166. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2167. if (duration === void 0) { duration = 1000; }
  2168. var _this = _super.call(this, triggerOptions, condition) || this;
  2169. /**
  2170. * Defines the time it will take for the property to interpolate to the value.
  2171. */
  2172. _this.duration = 1000;
  2173. /**
  2174. * Observable triggered once the interpolation animation has been done.
  2175. */
  2176. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2177. _this.propertyPath = propertyPath;
  2178. _this.value = value;
  2179. _this.duration = duration;
  2180. _this.stopOtherAnimations = stopOtherAnimations;
  2181. _this.onInterpolationDone = onInterpolationDone;
  2182. _this._target = _this._effectiveTarget = target;
  2183. return _this;
  2184. }
  2185. /** @hidden */
  2186. InterpolateValueAction.prototype._prepare = function () {
  2187. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2188. this._property = this._getProperty(this.propertyPath);
  2189. };
  2190. /**
  2191. * Execute the action starts the value interpolation.
  2192. */
  2193. InterpolateValueAction.prototype.execute = function () {
  2194. var _this = this;
  2195. var scene = this._actionManager.getScene();
  2196. var keys = [
  2197. {
  2198. frame: 0,
  2199. value: this._effectiveTarget[this._property]
  2200. }, {
  2201. frame: 100,
  2202. value: this.value
  2203. }
  2204. ];
  2205. var dataType;
  2206. if (typeof this.value === "number") {
  2207. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2208. }
  2209. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2210. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2211. }
  2212. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2213. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2214. }
  2215. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2216. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2217. }
  2218. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2219. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2220. }
  2221. else {
  2222. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2223. return;
  2224. }
  2225. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2226. animation.setKeys(keys);
  2227. if (this.stopOtherAnimations) {
  2228. scene.stopAnimation(this._effectiveTarget);
  2229. }
  2230. var wrapper = function () {
  2231. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2232. if (_this.onInterpolationDone) {
  2233. _this.onInterpolationDone();
  2234. }
  2235. };
  2236. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2237. };
  2238. /**
  2239. * Serializes the actions and its related information.
  2240. * @param parent defines the object to serialize in
  2241. * @returns the serialized object
  2242. */
  2243. InterpolateValueAction.prototype.serialize = function (parent) {
  2244. return _super.prototype._serialize.call(this, {
  2245. name: "InterpolateValueAction",
  2246. properties: [
  2247. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2248. { name: "propertyPath", value: this.propertyPath },
  2249. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2250. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2251. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2252. ]
  2253. }, parent);
  2254. };
  2255. return InterpolateValueAction;
  2256. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2257. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2258. /***/ }),
  2259. /***/ "./Animations/animatable.ts":
  2260. /*!**********************************!*\
  2261. !*** ./Animations/animatable.ts ***!
  2262. \**********************************/
  2263. /*! exports provided: Animatable */
  2264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2265. "use strict";
  2266. __webpack_require__.r(__webpack_exports__);
  2267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2268. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2269. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2270. /**
  2271. * Class used to store an actual running animation
  2272. */
  2273. var Animatable = /** @class */ (function () {
  2274. /**
  2275. * Creates a new Animatable
  2276. * @param scene defines the hosting scene
  2277. * @param target defines the target object
  2278. * @param fromFrame defines the starting frame number (default is 0)
  2279. * @param toFrame defines the ending frame number (default is 100)
  2280. * @param loopAnimation defines if the animation must loop (default is false)
  2281. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2282. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2283. * @param animations defines a group of animation to add to the new Animatable
  2284. * @param onAnimationLoop defines a callback to call when animation loops
  2285. */
  2286. function Animatable(scene,
  2287. /** defines the target object */
  2288. target,
  2289. /** defines the starting frame number (default is 0) */
  2290. fromFrame,
  2291. /** defines the ending frame number (default is 100) */
  2292. toFrame,
  2293. /** defines if the animation must loop (default is false) */
  2294. loopAnimation, speedRatio,
  2295. /** defines a callback to call when animation ends if it is not looping */
  2296. onAnimationEnd, animations,
  2297. /** defines a callback to call when animation loops */
  2298. onAnimationLoop) {
  2299. if (fromFrame === void 0) { fromFrame = 0; }
  2300. if (toFrame === void 0) { toFrame = 100; }
  2301. if (loopAnimation === void 0) { loopAnimation = false; }
  2302. if (speedRatio === void 0) { speedRatio = 1.0; }
  2303. this.target = target;
  2304. this.fromFrame = fromFrame;
  2305. this.toFrame = toFrame;
  2306. this.loopAnimation = loopAnimation;
  2307. this.onAnimationEnd = onAnimationEnd;
  2308. this.onAnimationLoop = onAnimationLoop;
  2309. this._localDelayOffset = null;
  2310. this._pausedDelay = null;
  2311. this._runtimeAnimations = new Array();
  2312. this._paused = false;
  2313. this._speedRatio = 1;
  2314. this._weight = -1.0;
  2315. /**
  2316. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2317. * This will only apply for non looping animation (default is true)
  2318. */
  2319. this.disposeOnEnd = true;
  2320. /**
  2321. * Gets a boolean indicating if the animation has started
  2322. */
  2323. this.animationStarted = false;
  2324. /**
  2325. * Observer raised when the animation ends
  2326. */
  2327. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2328. /**
  2329. * Observer raised when the animation loops
  2330. */
  2331. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2332. this._scene = scene;
  2333. if (animations) {
  2334. this.appendAnimations(target, animations);
  2335. }
  2336. this._speedRatio = speedRatio;
  2337. scene._activeAnimatables.push(this);
  2338. }
  2339. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2340. /**
  2341. * Gets the root Animatable used to synchronize and normalize animations
  2342. */
  2343. get: function () {
  2344. return this._syncRoot;
  2345. },
  2346. enumerable: true,
  2347. configurable: true
  2348. });
  2349. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2350. /**
  2351. * Gets the current frame of the first RuntimeAnimation
  2352. * Used to synchronize Animatables
  2353. */
  2354. get: function () {
  2355. if (this._runtimeAnimations.length === 0) {
  2356. return 0;
  2357. }
  2358. return this._runtimeAnimations[0].currentFrame;
  2359. },
  2360. enumerable: true,
  2361. configurable: true
  2362. });
  2363. Object.defineProperty(Animatable.prototype, "weight", {
  2364. /**
  2365. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2366. */
  2367. get: function () {
  2368. return this._weight;
  2369. },
  2370. set: function (value) {
  2371. if (value === -1) { // -1 is ok and means no weight
  2372. this._weight = -1;
  2373. return;
  2374. }
  2375. // Else weight must be in [0, 1] range
  2376. this._weight = Math.min(Math.max(value, 0), 1.0);
  2377. },
  2378. enumerable: true,
  2379. configurable: true
  2380. });
  2381. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2382. /**
  2383. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2384. */
  2385. get: function () {
  2386. return this._speedRatio;
  2387. },
  2388. set: function (value) {
  2389. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2390. var animation = this._runtimeAnimations[index];
  2391. animation._prepareForSpeedRatioChange(value);
  2392. }
  2393. this._speedRatio = value;
  2394. },
  2395. enumerable: true,
  2396. configurable: true
  2397. });
  2398. // Methods
  2399. /**
  2400. * Synchronize and normalize current Animatable with a source Animatable
  2401. * This is useful when using animation weights and when animations are not of the same length
  2402. * @param root defines the root Animatable to synchronize with
  2403. * @returns the current Animatable
  2404. */
  2405. Animatable.prototype.syncWith = function (root) {
  2406. this._syncRoot = root;
  2407. if (root) {
  2408. // Make sure this animatable will animate after the root
  2409. var index = this._scene._activeAnimatables.indexOf(this);
  2410. if (index > -1) {
  2411. this._scene._activeAnimatables.splice(index, 1);
  2412. this._scene._activeAnimatables.push(this);
  2413. }
  2414. }
  2415. return this;
  2416. };
  2417. /**
  2418. * Gets the list of runtime animations
  2419. * @returns an array of RuntimeAnimation
  2420. */
  2421. Animatable.prototype.getAnimations = function () {
  2422. return this._runtimeAnimations;
  2423. };
  2424. /**
  2425. * Adds more animations to the current animatable
  2426. * @param target defines the target of the animations
  2427. * @param animations defines the new animations to add
  2428. */
  2429. Animatable.prototype.appendAnimations = function (target, animations) {
  2430. for (var index = 0; index < animations.length; index++) {
  2431. var animation = animations[index];
  2432. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"](target, animation, this._scene, this));
  2433. }
  2434. };
  2435. /**
  2436. * Gets the source animation for a specific property
  2437. * @param property defines the propertyu to look for
  2438. * @returns null or the source animation for the given property
  2439. */
  2440. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2441. var runtimeAnimations = this._runtimeAnimations;
  2442. for (var index = 0; index < runtimeAnimations.length; index++) {
  2443. if (runtimeAnimations[index].animation.targetProperty === property) {
  2444. return runtimeAnimations[index].animation;
  2445. }
  2446. }
  2447. return null;
  2448. };
  2449. /**
  2450. * Gets the runtime animation for a specific property
  2451. * @param property defines the propertyu to look for
  2452. * @returns null or the runtime animation for the given property
  2453. */
  2454. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2455. var runtimeAnimations = this._runtimeAnimations;
  2456. for (var index = 0; index < runtimeAnimations.length; index++) {
  2457. if (runtimeAnimations[index].animation.targetProperty === property) {
  2458. return runtimeAnimations[index];
  2459. }
  2460. }
  2461. return null;
  2462. };
  2463. /**
  2464. * Resets the animatable to its original state
  2465. */
  2466. Animatable.prototype.reset = function () {
  2467. var runtimeAnimations = this._runtimeAnimations;
  2468. for (var index = 0; index < runtimeAnimations.length; index++) {
  2469. runtimeAnimations[index].reset(true);
  2470. }
  2471. this._localDelayOffset = null;
  2472. this._pausedDelay = null;
  2473. };
  2474. /**
  2475. * Allows the animatable to blend with current running animations
  2476. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2477. * @param blendingSpeed defines the blending speed to use
  2478. */
  2479. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2480. var runtimeAnimations = this._runtimeAnimations;
  2481. for (var index = 0; index < runtimeAnimations.length; index++) {
  2482. runtimeAnimations[index].animation.enableBlending = true;
  2483. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2484. }
  2485. };
  2486. /**
  2487. * Disable animation blending
  2488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2489. */
  2490. Animatable.prototype.disableBlending = function () {
  2491. var runtimeAnimations = this._runtimeAnimations;
  2492. for (var index = 0; index < runtimeAnimations.length; index++) {
  2493. runtimeAnimations[index].animation.enableBlending = false;
  2494. }
  2495. };
  2496. /**
  2497. * Jump directly to a given frame
  2498. * @param frame defines the frame to jump to
  2499. */
  2500. Animatable.prototype.goToFrame = function (frame) {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. if (runtimeAnimations[0]) {
  2503. var fps = runtimeAnimations[0].animation.framePerSecond;
  2504. var currentFrame = runtimeAnimations[0].currentFrame;
  2505. var adjustTime = frame - currentFrame;
  2506. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2507. if (this._localDelayOffset === null) {
  2508. this._localDelayOffset = 0;
  2509. }
  2510. this._localDelayOffset -= delay;
  2511. }
  2512. for (var index = 0; index < runtimeAnimations.length; index++) {
  2513. runtimeAnimations[index].goToFrame(frame);
  2514. }
  2515. };
  2516. /**
  2517. * Pause the animation
  2518. */
  2519. Animatable.prototype.pause = function () {
  2520. if (this._paused) {
  2521. return;
  2522. }
  2523. this._paused = true;
  2524. };
  2525. /**
  2526. * Restart the animation
  2527. */
  2528. Animatable.prototype.restart = function () {
  2529. this._paused = false;
  2530. };
  2531. Animatable.prototype._raiseOnAnimationEnd = function () {
  2532. if (this.onAnimationEnd) {
  2533. this.onAnimationEnd();
  2534. }
  2535. this.onAnimationEndObservable.notifyObservers(this);
  2536. };
  2537. /**
  2538. * Stop and delete the current animation
  2539. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2540. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2541. */
  2542. Animatable.prototype.stop = function (animationName, targetMask) {
  2543. if (animationName || targetMask) {
  2544. var idx = this._scene._activeAnimatables.indexOf(this);
  2545. if (idx > -1) {
  2546. var runtimeAnimations = this._runtimeAnimations;
  2547. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2548. var runtimeAnimation = runtimeAnimations[index];
  2549. if (animationName && runtimeAnimation.animation.name != animationName) {
  2550. continue;
  2551. }
  2552. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2553. continue;
  2554. }
  2555. runtimeAnimation.dispose();
  2556. runtimeAnimations.splice(index, 1);
  2557. }
  2558. if (runtimeAnimations.length == 0) {
  2559. this._scene._activeAnimatables.splice(idx, 1);
  2560. this._raiseOnAnimationEnd();
  2561. }
  2562. }
  2563. }
  2564. else {
  2565. var index = this._scene._activeAnimatables.indexOf(this);
  2566. if (index > -1) {
  2567. this._scene._activeAnimatables.splice(index, 1);
  2568. var runtimeAnimations = this._runtimeAnimations;
  2569. for (var index = 0; index < runtimeAnimations.length; index++) {
  2570. runtimeAnimations[index].dispose();
  2571. }
  2572. this._raiseOnAnimationEnd();
  2573. }
  2574. }
  2575. };
  2576. /**
  2577. * Wait asynchronously for the animation to end
  2578. * @returns a promise which will be fullfilled when the animation ends
  2579. */
  2580. Animatable.prototype.waitAsync = function () {
  2581. var _this = this;
  2582. return new Promise(function (resolve, reject) {
  2583. _this.onAnimationEndObservable.add(function () {
  2584. resolve(_this);
  2585. }, undefined, undefined, _this, true);
  2586. });
  2587. };
  2588. /** @hidden */
  2589. Animatable.prototype._animate = function (delay) {
  2590. var _this = this;
  2591. if (this._paused) {
  2592. this.animationStarted = false;
  2593. if (this._pausedDelay === null) {
  2594. this._pausedDelay = delay;
  2595. }
  2596. return true;
  2597. }
  2598. if (this._localDelayOffset === null) {
  2599. this._localDelayOffset = delay;
  2600. this._pausedDelay = null;
  2601. }
  2602. else if (this._pausedDelay !== null) {
  2603. this._localDelayOffset += delay - this._pausedDelay;
  2604. this._pausedDelay = null;
  2605. }
  2606. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2607. return true;
  2608. }
  2609. // Animating
  2610. var running = false;
  2611. var runtimeAnimations = this._runtimeAnimations;
  2612. var index;
  2613. for (index = 0; index < runtimeAnimations.length; index++) {
  2614. var animation = runtimeAnimations[index];
  2615. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2616. _this.onAnimationLoopObservable.notifyObservers(_this);
  2617. if (_this.onAnimationLoop) {
  2618. _this.onAnimationLoop();
  2619. }
  2620. });
  2621. running = running || isRunning;
  2622. }
  2623. this.animationStarted = running;
  2624. if (!running) {
  2625. if (this.disposeOnEnd) {
  2626. // Remove from active animatables
  2627. index = this._scene._activeAnimatables.indexOf(this);
  2628. this._scene._activeAnimatables.splice(index, 1);
  2629. // Dispose all runtime animations
  2630. for (index = 0; index < runtimeAnimations.length; index++) {
  2631. runtimeAnimations[index].dispose();
  2632. }
  2633. }
  2634. this._raiseOnAnimationEnd();
  2635. if (this.disposeOnEnd) {
  2636. this.onAnimationEnd = null;
  2637. this.onAnimationLoop = null;
  2638. this.onAnimationLoopObservable.clear();
  2639. this.onAnimationEndObservable.clear();
  2640. }
  2641. }
  2642. return running;
  2643. };
  2644. return Animatable;
  2645. }());
  2646. /***/ }),
  2647. /***/ "./Animations/animation.ts":
  2648. /*!*********************************!*\
  2649. !*** ./Animations/animation.ts ***!
  2650. \*********************************/
  2651. /*! exports provided: AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation */
  2652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2653. "use strict";
  2654. __webpack_require__.r(__webpack_exports__);
  2655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  2656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  2657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return PathCursor; });
  2658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  2659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  2660. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2661. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  2662. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  2663. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  2664. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  2665. /**
  2666. * Represents the range of an animation
  2667. */
  2668. var AnimationRange = /** @class */ (function () {
  2669. /**
  2670. * Initializes the range of an animation
  2671. * @param name The name of the animation range
  2672. * @param from The starting frame of the animation
  2673. * @param to The ending frame of the animation
  2674. */
  2675. function AnimationRange(
  2676. /**The name of the animation range**/
  2677. name,
  2678. /**The starting frame of the animation */
  2679. from,
  2680. /**The ending frame of the animation*/
  2681. to) {
  2682. this.name = name;
  2683. this.from = from;
  2684. this.to = to;
  2685. }
  2686. /**
  2687. * Makes a copy of the animation range
  2688. * @returns A copy of the animation range
  2689. */
  2690. AnimationRange.prototype.clone = function () {
  2691. return new AnimationRange(this.name, this.from, this.to);
  2692. };
  2693. return AnimationRange;
  2694. }());
  2695. /**
  2696. * Composed of a frame, and an action function
  2697. */
  2698. var AnimationEvent = /** @class */ (function () {
  2699. /**
  2700. * Initializes the animation event
  2701. * @param frame The frame for which the event is triggered
  2702. * @param action The event to perform when triggered
  2703. * @param onlyOnce Specifies if the event should be triggered only once
  2704. */
  2705. function AnimationEvent(
  2706. /** The frame for which the event is triggered **/
  2707. frame,
  2708. /** The event to perform when triggered **/
  2709. action,
  2710. /** Specifies if the event should be triggered only once**/
  2711. onlyOnce) {
  2712. this.frame = frame;
  2713. this.action = action;
  2714. this.onlyOnce = onlyOnce;
  2715. /**
  2716. * Specifies if the animation event is done
  2717. */
  2718. this.isDone = false;
  2719. }
  2720. /** @hidden */
  2721. AnimationEvent.prototype._clone = function () {
  2722. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  2723. };
  2724. return AnimationEvent;
  2725. }());
  2726. /**
  2727. * A cursor which tracks a point on a path
  2728. */
  2729. var PathCursor = /** @class */ (function () {
  2730. /**
  2731. * Initializes the path cursor
  2732. * @param path The path to track
  2733. */
  2734. function PathCursor(path) {
  2735. this.path = path;
  2736. /**
  2737. * Stores path cursor callbacks for when an onchange event is triggered
  2738. */
  2739. this._onchange = new Array();
  2740. /**
  2741. * The value of the path cursor
  2742. */
  2743. this.value = 0;
  2744. /**
  2745. * The animation array of the path cursor
  2746. */
  2747. this.animations = new Array();
  2748. }
  2749. /**
  2750. * Gets the cursor point on the path
  2751. * @returns A point on the path cursor at the cursor location
  2752. */
  2753. PathCursor.prototype.getPoint = function () {
  2754. var point = this.path.getPointAtLengthPosition(this.value);
  2755. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](point.x, 0, point.y);
  2756. };
  2757. /**
  2758. * Moves the cursor ahead by the step amount
  2759. * @param step The amount to move the cursor forward
  2760. * @returns This path cursor
  2761. */
  2762. PathCursor.prototype.moveAhead = function (step) {
  2763. if (step === void 0) { step = 0.002; }
  2764. this.move(step);
  2765. return this;
  2766. };
  2767. /**
  2768. * Moves the cursor behind by the step amount
  2769. * @param step The amount to move the cursor back
  2770. * @returns This path cursor
  2771. */
  2772. PathCursor.prototype.moveBack = function (step) {
  2773. if (step === void 0) { step = 0.002; }
  2774. this.move(-step);
  2775. return this;
  2776. };
  2777. /**
  2778. * Moves the cursor by the step amount
  2779. * If the step amount is greater than one, an exception is thrown
  2780. * @param step The amount to move the cursor
  2781. * @returns This path cursor
  2782. */
  2783. PathCursor.prototype.move = function (step) {
  2784. if (Math.abs(step) > 1) {
  2785. throw "step size should be less than 1.";
  2786. }
  2787. this.value += step;
  2788. this.ensureLimits();
  2789. this.raiseOnChange();
  2790. return this;
  2791. };
  2792. /**
  2793. * Ensures that the value is limited between zero and one
  2794. * @returns This path cursor
  2795. */
  2796. PathCursor.prototype.ensureLimits = function () {
  2797. while (this.value > 1) {
  2798. this.value -= 1;
  2799. }
  2800. while (this.value < 0) {
  2801. this.value += 1;
  2802. }
  2803. return this;
  2804. };
  2805. /**
  2806. * Runs onchange callbacks on change (used by the animation engine)
  2807. * @returns This path cursor
  2808. */
  2809. PathCursor.prototype.raiseOnChange = function () {
  2810. var _this = this;
  2811. this._onchange.forEach(function (f) { return f(_this); });
  2812. return this;
  2813. };
  2814. /**
  2815. * Executes a function on change
  2816. * @param f A path cursor onchange callback
  2817. * @returns This path cursor
  2818. */
  2819. PathCursor.prototype.onchange = function (f) {
  2820. this._onchange.push(f);
  2821. return this;
  2822. };
  2823. return PathCursor;
  2824. }());
  2825. /**
  2826. * Enum for the animation key frame interpolation type
  2827. */
  2828. var AnimationKeyInterpolation;
  2829. (function (AnimationKeyInterpolation) {
  2830. /**
  2831. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  2832. */
  2833. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  2834. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  2835. /**
  2836. * Class used to store any kind of animation
  2837. */
  2838. var Animation = /** @class */ (function () {
  2839. /**
  2840. * Initializes the animation
  2841. * @param name Name of the animation
  2842. * @param targetProperty Property to animate
  2843. * @param framePerSecond The frames per second of the animation
  2844. * @param dataType The data type of the animation
  2845. * @param loopMode The loop mode of the animation
  2846. * @param enableBlendings Specifies if blending should be enabled
  2847. */
  2848. function Animation(
  2849. /**Name of the animation */
  2850. name,
  2851. /**Property to animate */
  2852. targetProperty,
  2853. /**The frames per second of the animation */
  2854. framePerSecond,
  2855. /**The data type of the animation */
  2856. dataType,
  2857. /**The loop mode of the animation */
  2858. loopMode,
  2859. /**Specifies if blending should be enabled */
  2860. enableBlending) {
  2861. this.name = name;
  2862. this.targetProperty = targetProperty;
  2863. this.framePerSecond = framePerSecond;
  2864. this.dataType = dataType;
  2865. this.loopMode = loopMode;
  2866. this.enableBlending = enableBlending;
  2867. /**
  2868. * @hidden Internal use only
  2869. */
  2870. this._runtimeAnimations = new Array();
  2871. /**
  2872. * The set of event that will be linked to this animation
  2873. */
  2874. this._events = new Array();
  2875. /**
  2876. * Stores the blending speed of the animation
  2877. */
  2878. this.blendingSpeed = 0.01;
  2879. /**
  2880. * Stores the animation ranges for the animation
  2881. */
  2882. this._ranges = {};
  2883. this.targetPropertyPath = targetProperty.split(".");
  2884. this.dataType = dataType;
  2885. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  2886. }
  2887. /**
  2888. * @hidden Internal use
  2889. */
  2890. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  2891. var dataType = undefined;
  2892. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  2893. dataType = Animation.ANIMATIONTYPE_FLOAT;
  2894. }
  2895. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  2896. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  2897. }
  2898. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  2899. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  2900. }
  2901. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  2902. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  2903. }
  2904. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  2905. dataType = Animation.ANIMATIONTYPE_COLOR3;
  2906. }
  2907. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  2908. dataType = Animation.ANIMATIONTYPE_SIZE;
  2909. }
  2910. if (dataType == undefined) {
  2911. return null;
  2912. }
  2913. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  2914. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  2915. animation.setKeys(keys);
  2916. if (easingFunction !== undefined) {
  2917. animation.setEasingFunction(easingFunction);
  2918. }
  2919. return animation;
  2920. };
  2921. /**
  2922. * Sets up an animation
  2923. * @param property The property to animate
  2924. * @param animationType The animation type to apply
  2925. * @param framePerSecond The frames per second of the animation
  2926. * @param easingFunction The easing function used in the animation
  2927. * @returns The created animation
  2928. */
  2929. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  2930. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  2931. animation.setEasingFunction(easingFunction);
  2932. return animation;
  2933. };
  2934. /**
  2935. * Create and start an animation on a node
  2936. * @param name defines the name of the global animation that will be run on all nodes
  2937. * @param node defines the root node where the animation will take place
  2938. * @param targetProperty defines property to animate
  2939. * @param framePerSecond defines the number of frame per second yo use
  2940. * @param totalFrame defines the number of frames in total
  2941. * @param from defines the initial value
  2942. * @param to defines the final value
  2943. * @param loopMode defines which loop mode you want to use (off by default)
  2944. * @param easingFunction defines the easing function to use (linear by default)
  2945. * @param onAnimationEnd defines the callback to call when animation end
  2946. * @returns the animatable created for this animation
  2947. */
  2948. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2949. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2950. if (!animation) {
  2951. return null;
  2952. }
  2953. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2954. };
  2955. /**
  2956. * Create and start an animation on a node and its descendants
  2957. * @param name defines the name of the global animation that will be run on all nodes
  2958. * @param node defines the root node where the animation will take place
  2959. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  2960. * @param targetProperty defines property to animate
  2961. * @param framePerSecond defines the number of frame per second to use
  2962. * @param totalFrame defines the number of frames in total
  2963. * @param from defines the initial value
  2964. * @param to defines the final value
  2965. * @param loopMode defines which loop mode you want to use (off by default)
  2966. * @param easingFunction defines the easing function to use (linear by default)
  2967. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2968. * @returns the list of animatables created for all nodes
  2969. * @example https://www.babylonjs-playground.com/#MH0VLI
  2970. */
  2971. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2972. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2973. if (!animation) {
  2974. return null;
  2975. }
  2976. var scene = node.getScene();
  2977. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2978. };
  2979. /**
  2980. * Creates a new animation, merges it with the existing animations and starts it
  2981. * @param name Name of the animation
  2982. * @param node Node which contains the scene that begins the animations
  2983. * @param targetProperty Specifies which property to animate
  2984. * @param framePerSecond The frames per second of the animation
  2985. * @param totalFrame The total number of frames
  2986. * @param from The frame at the beginning of the animation
  2987. * @param to The frame at the end of the animation
  2988. * @param loopMode Specifies the loop mode of the animation
  2989. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  2990. * @param onAnimationEnd Callback to run once the animation is complete
  2991. * @returns Nullable animation
  2992. */
  2993. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2994. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2995. if (!animation) {
  2996. return null;
  2997. }
  2998. node.animations.push(animation);
  2999. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3000. };
  3001. /**
  3002. * Transition property of an host to the target Value
  3003. * @param property The property to transition
  3004. * @param targetValue The target Value of the property
  3005. * @param host The object where the property to animate belongs
  3006. * @param scene Scene used to run the animation
  3007. * @param frameRate Framerate (in frame/s) to use
  3008. * @param transition The transition type we want to use
  3009. * @param duration The duration of the animation, in milliseconds
  3010. * @param onAnimationEnd Callback trigger at the end of the animation
  3011. * @returns Nullable animation
  3012. */
  3013. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3014. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3015. if (duration <= 0) {
  3016. host[property] = targetValue;
  3017. if (onAnimationEnd) {
  3018. onAnimationEnd();
  3019. }
  3020. return null;
  3021. }
  3022. var endFrame = frameRate * (duration / 1000);
  3023. transition.setKeys([{
  3024. frame: 0,
  3025. value: host[property].clone ? host[property].clone() : host[property]
  3026. },
  3027. {
  3028. frame: endFrame,
  3029. value: targetValue
  3030. }]);
  3031. if (!host.animations) {
  3032. host.animations = [];
  3033. }
  3034. host.animations.push(transition);
  3035. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3036. animation.onAnimationEnd = onAnimationEnd;
  3037. return animation;
  3038. };
  3039. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3040. /**
  3041. * Return the array of runtime animations currently using this animation
  3042. */
  3043. get: function () {
  3044. return this._runtimeAnimations;
  3045. },
  3046. enumerable: true,
  3047. configurable: true
  3048. });
  3049. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3050. /**
  3051. * Specifies if any of the runtime animations are currently running
  3052. */
  3053. get: function () {
  3054. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3055. var runtimeAnimation = _a[_i];
  3056. if (!runtimeAnimation.isStopped) {
  3057. return true;
  3058. }
  3059. }
  3060. return false;
  3061. },
  3062. enumerable: true,
  3063. configurable: true
  3064. });
  3065. // Methods
  3066. /**
  3067. * Converts the animation to a string
  3068. * @param fullDetails support for multiple levels of logging within scene loading
  3069. * @returns String form of the animation
  3070. */
  3071. Animation.prototype.toString = function (fullDetails) {
  3072. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3073. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3074. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3075. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3076. if (fullDetails) {
  3077. ret += ", Ranges: {";
  3078. var first = true;
  3079. for (var name in this._ranges) {
  3080. if (first) {
  3081. ret += ", ";
  3082. first = false;
  3083. }
  3084. ret += name;
  3085. }
  3086. ret += "}";
  3087. }
  3088. return ret;
  3089. };
  3090. /**
  3091. * Add an event to this animation
  3092. * @param event Event to add
  3093. */
  3094. Animation.prototype.addEvent = function (event) {
  3095. this._events.push(event);
  3096. };
  3097. /**
  3098. * Remove all events found at the given frame
  3099. * @param frame The frame to remove events from
  3100. */
  3101. Animation.prototype.removeEvents = function (frame) {
  3102. for (var index = 0; index < this._events.length; index++) {
  3103. if (this._events[index].frame === frame) {
  3104. this._events.splice(index, 1);
  3105. index--;
  3106. }
  3107. }
  3108. };
  3109. /**
  3110. * Retrieves all the events from the animation
  3111. * @returns Events from the animation
  3112. */
  3113. Animation.prototype.getEvents = function () {
  3114. return this._events;
  3115. };
  3116. /**
  3117. * Creates an animation range
  3118. * @param name Name of the animation range
  3119. * @param from Starting frame of the animation range
  3120. * @param to Ending frame of the animation
  3121. */
  3122. Animation.prototype.createRange = function (name, from, to) {
  3123. // check name not already in use; could happen for bones after serialized
  3124. if (!this._ranges[name]) {
  3125. this._ranges[name] = new AnimationRange(name, from, to);
  3126. }
  3127. };
  3128. /**
  3129. * Deletes an animation range by name
  3130. * @param name Name of the animation range to delete
  3131. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3132. */
  3133. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3134. if (deleteFrames === void 0) { deleteFrames = true; }
  3135. var range = this._ranges[name];
  3136. if (!range) {
  3137. return;
  3138. }
  3139. if (deleteFrames) {
  3140. var from = range.from;
  3141. var to = range.to;
  3142. // this loop MUST go high to low for multiple splices to work
  3143. for (var key = this._keys.length - 1; key >= 0; key--) {
  3144. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3145. this._keys.splice(key, 1);
  3146. }
  3147. }
  3148. }
  3149. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3150. };
  3151. /**
  3152. * Gets the animation range by name, or null if not defined
  3153. * @param name Name of the animation range
  3154. * @returns Nullable animation range
  3155. */
  3156. Animation.prototype.getRange = function (name) {
  3157. return this._ranges[name];
  3158. };
  3159. /**
  3160. * Gets the key frames from the animation
  3161. * @returns The key frames of the animation
  3162. */
  3163. Animation.prototype.getKeys = function () {
  3164. return this._keys;
  3165. };
  3166. /**
  3167. * Gets the highest frame rate of the animation
  3168. * @returns Highest frame rate of the animation
  3169. */
  3170. Animation.prototype.getHighestFrame = function () {
  3171. var ret = 0;
  3172. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3173. if (ret < this._keys[key].frame) {
  3174. ret = this._keys[key].frame;
  3175. }
  3176. }
  3177. return ret;
  3178. };
  3179. /**
  3180. * Gets the easing function of the animation
  3181. * @returns Easing function of the animation
  3182. */
  3183. Animation.prototype.getEasingFunction = function () {
  3184. return this._easingFunction;
  3185. };
  3186. /**
  3187. * Sets the easing function of the animation
  3188. * @param easingFunction A custom mathematical formula for animation
  3189. */
  3190. Animation.prototype.setEasingFunction = function (easingFunction) {
  3191. this._easingFunction = easingFunction;
  3192. };
  3193. /**
  3194. * Interpolates a scalar linearly
  3195. * @param startValue Start value of the animation curve
  3196. * @param endValue End value of the animation curve
  3197. * @param gradient Scalar amount to interpolate
  3198. * @returns Interpolated scalar value
  3199. */
  3200. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3201. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3202. };
  3203. /**
  3204. * Interpolates a scalar cubically
  3205. * @param startValue Start value of the animation curve
  3206. * @param outTangent End tangent of the animation
  3207. * @param endValue End value of the animation curve
  3208. * @param inTangent Start tangent of the animation curve
  3209. * @param gradient Scalar amount to interpolate
  3210. * @returns Interpolated scalar value
  3211. */
  3212. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3213. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3214. };
  3215. /**
  3216. * Interpolates a quaternion using a spherical linear interpolation
  3217. * @param startValue Start value of the animation curve
  3218. * @param endValue End value of the animation curve
  3219. * @param gradient Scalar amount to interpolate
  3220. * @returns Interpolated quaternion value
  3221. */
  3222. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3223. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3224. };
  3225. /**
  3226. * Interpolates a quaternion cubically
  3227. * @param startValue Start value of the animation curve
  3228. * @param outTangent End tangent of the animation curve
  3229. * @param endValue End value of the animation curve
  3230. * @param inTangent Start tangent of the animation curve
  3231. * @param gradient Scalar amount to interpolate
  3232. * @returns Interpolated quaternion value
  3233. */
  3234. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3235. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3236. };
  3237. /**
  3238. * Interpolates a Vector3 linearl
  3239. * @param startValue Start value of the animation curve
  3240. * @param endValue End value of the animation curve
  3241. * @param gradient Scalar amount to interpolate
  3242. * @returns Interpolated scalar value
  3243. */
  3244. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3245. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3246. };
  3247. /**
  3248. * Interpolates a Vector3 cubically
  3249. * @param startValue Start value of the animation curve
  3250. * @param outTangent End tangent of the animation
  3251. * @param endValue End value of the animation curve
  3252. * @param inTangent Start tangent of the animation curve
  3253. * @param gradient Scalar amount to interpolate
  3254. * @returns InterpolatedVector3 value
  3255. */
  3256. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3257. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3258. };
  3259. /**
  3260. * Interpolates a Vector2 linearly
  3261. * @param startValue Start value of the animation curve
  3262. * @param endValue End value of the animation curve
  3263. * @param gradient Scalar amount to interpolate
  3264. * @returns Interpolated Vector2 value
  3265. */
  3266. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3267. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3268. };
  3269. /**
  3270. * Interpolates a Vector2 cubically
  3271. * @param startValue Start value of the animation curve
  3272. * @param outTangent End tangent of the animation
  3273. * @param endValue End value of the animation curve
  3274. * @param inTangent Start tangent of the animation curve
  3275. * @param gradient Scalar amount to interpolate
  3276. * @returns Interpolated Vector2 value
  3277. */
  3278. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3279. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3280. };
  3281. /**
  3282. * Interpolates a size linearly
  3283. * @param startValue Start value of the animation curve
  3284. * @param endValue End value of the animation curve
  3285. * @param gradient Scalar amount to interpolate
  3286. * @returns Interpolated Size value
  3287. */
  3288. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3289. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3290. };
  3291. /**
  3292. * Interpolates a Color3 linearly
  3293. * @param startValue Start value of the animation curve
  3294. * @param endValue End value of the animation curve
  3295. * @param gradient Scalar amount to interpolate
  3296. * @returns Interpolated Color3 value
  3297. */
  3298. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3299. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3300. };
  3301. /**
  3302. * @hidden Internal use only
  3303. */
  3304. Animation.prototype._getKeyValue = function (value) {
  3305. if (typeof value === "function") {
  3306. return value();
  3307. }
  3308. return value;
  3309. };
  3310. /**
  3311. * @hidden Internal use only
  3312. */
  3313. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3314. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3315. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3316. }
  3317. var keys = this.getKeys();
  3318. // Try to get a hash to find the right key
  3319. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3320. if (keys[startKeyIndex].frame >= currentFrame) {
  3321. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3322. startKeyIndex--;
  3323. }
  3324. }
  3325. for (var key = startKeyIndex; key < keys.length; key++) {
  3326. var endKey = keys[key + 1];
  3327. if (endKey.frame >= currentFrame) {
  3328. var startKey = keys[key];
  3329. var startValue = this._getKeyValue(startKey.value);
  3330. if (startKey.interpolation === AnimationKeyInterpolation.STEP) {
  3331. return startValue;
  3332. }
  3333. var endValue = this._getKeyValue(endKey.value);
  3334. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3335. var frameDelta = endKey.frame - startKey.frame;
  3336. // gradient : percent of currentFrame between the frame inf and the frame sup
  3337. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3338. // check for easingFunction and correction of gradient
  3339. var easingFunction = this.getEasingFunction();
  3340. if (easingFunction != null) {
  3341. gradient = easingFunction.ease(gradient);
  3342. }
  3343. switch (this.dataType) {
  3344. // Float
  3345. case Animation.ANIMATIONTYPE_FLOAT:
  3346. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3347. switch (loopMode) {
  3348. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3349. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3350. return floatValue;
  3351. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3352. return offsetValue * repeatCount + floatValue;
  3353. }
  3354. break;
  3355. // Quaternion
  3356. case Animation.ANIMATIONTYPE_QUATERNION:
  3357. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3358. switch (loopMode) {
  3359. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3360. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3361. return quatValue;
  3362. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3363. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3364. }
  3365. return quatValue;
  3366. // Vector3
  3367. case Animation.ANIMATIONTYPE_VECTOR3:
  3368. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3369. switch (loopMode) {
  3370. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3371. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3372. return vec3Value;
  3373. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3374. return vec3Value.add(offsetValue.scale(repeatCount));
  3375. }
  3376. // Vector2
  3377. case Animation.ANIMATIONTYPE_VECTOR2:
  3378. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3379. switch (loopMode) {
  3380. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3381. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3382. return vec2Value;
  3383. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3384. return vec2Value.add(offsetValue.scale(repeatCount));
  3385. }
  3386. // Size
  3387. case Animation.ANIMATIONTYPE_SIZE:
  3388. switch (loopMode) {
  3389. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3390. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3391. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3392. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3393. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3394. }
  3395. // Color3
  3396. case Animation.ANIMATIONTYPE_COLOR3:
  3397. switch (loopMode) {
  3398. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3399. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3400. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3401. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3402. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3403. }
  3404. // Matrix
  3405. case Animation.ANIMATIONTYPE_MATRIX:
  3406. switch (loopMode) {
  3407. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3408. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3409. if (Animation.AllowMatricesInterpolation) {
  3410. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3411. }
  3412. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3413. return startValue;
  3414. }
  3415. default:
  3416. break;
  3417. }
  3418. break;
  3419. }
  3420. }
  3421. return this._getKeyValue(keys[keys.length - 1].value);
  3422. };
  3423. /**
  3424. * Defines the function to use to interpolate matrices
  3425. * @param startValue defines the start matrix
  3426. * @param endValue defines the end matrix
  3427. * @param gradient defines the gradient between both matrices
  3428. * @param result defines an optional target matrix where to store the interpolation
  3429. * @returns the interpolated matrix
  3430. */
  3431. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3432. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3433. if (result) {
  3434. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3435. return result;
  3436. }
  3437. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3438. }
  3439. if (result) {
  3440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3441. return result;
  3442. }
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Makes a copy of the animation
  3447. * @returns Cloned animation
  3448. */
  3449. Animation.prototype.clone = function () {
  3450. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3451. clone.enableBlending = this.enableBlending;
  3452. clone.blendingSpeed = this.blendingSpeed;
  3453. if (this._keys) {
  3454. clone.setKeys(this._keys);
  3455. }
  3456. if (this._ranges) {
  3457. clone._ranges = {};
  3458. for (var name in this._ranges) {
  3459. var range = this._ranges[name];
  3460. if (!range) {
  3461. continue;
  3462. }
  3463. clone._ranges[name] = range.clone();
  3464. }
  3465. }
  3466. return clone;
  3467. };
  3468. /**
  3469. * Sets the key frames of the animation
  3470. * @param values The animation key frames to set
  3471. */
  3472. Animation.prototype.setKeys = function (values) {
  3473. this._keys = values.slice(0);
  3474. };
  3475. /**
  3476. * Serializes the animation to an object
  3477. * @returns Serialized object
  3478. */
  3479. Animation.prototype.serialize = function () {
  3480. var serializationObject = {};
  3481. serializationObject.name = this.name;
  3482. serializationObject.property = this.targetProperty;
  3483. serializationObject.framePerSecond = this.framePerSecond;
  3484. serializationObject.dataType = this.dataType;
  3485. serializationObject.loopBehavior = this.loopMode;
  3486. serializationObject.enableBlending = this.enableBlending;
  3487. serializationObject.blendingSpeed = this.blendingSpeed;
  3488. var dataType = this.dataType;
  3489. serializationObject.keys = [];
  3490. var keys = this.getKeys();
  3491. for (var index = 0; index < keys.length; index++) {
  3492. var animationKey = keys[index];
  3493. var key = {};
  3494. key.frame = animationKey.frame;
  3495. switch (dataType) {
  3496. case Animation.ANIMATIONTYPE_FLOAT:
  3497. key.values = [animationKey.value];
  3498. break;
  3499. case Animation.ANIMATIONTYPE_QUATERNION:
  3500. case Animation.ANIMATIONTYPE_MATRIX:
  3501. case Animation.ANIMATIONTYPE_VECTOR3:
  3502. case Animation.ANIMATIONTYPE_COLOR3:
  3503. key.values = animationKey.value.asArray();
  3504. break;
  3505. }
  3506. serializationObject.keys.push(key);
  3507. }
  3508. serializationObject.ranges = [];
  3509. for (var name in this._ranges) {
  3510. var source = this._ranges[name];
  3511. if (!source) {
  3512. continue;
  3513. }
  3514. var range = {};
  3515. range.name = name;
  3516. range.from = source.from;
  3517. range.to = source.to;
  3518. serializationObject.ranges.push(range);
  3519. }
  3520. return serializationObject;
  3521. };
  3522. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3523. /**
  3524. * Get the float animation type
  3525. */
  3526. get: function () {
  3527. return Animation._ANIMATIONTYPE_FLOAT;
  3528. },
  3529. enumerable: true,
  3530. configurable: true
  3531. });
  3532. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3533. /**
  3534. * Get the Vector3 animation type
  3535. */
  3536. get: function () {
  3537. return Animation._ANIMATIONTYPE_VECTOR3;
  3538. },
  3539. enumerable: true,
  3540. configurable: true
  3541. });
  3542. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3543. /**
  3544. * Get the Vector2 animation type
  3545. */
  3546. get: function () {
  3547. return Animation._ANIMATIONTYPE_VECTOR2;
  3548. },
  3549. enumerable: true,
  3550. configurable: true
  3551. });
  3552. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3553. /**
  3554. * Get the Size animation type
  3555. */
  3556. get: function () {
  3557. return Animation._ANIMATIONTYPE_SIZE;
  3558. },
  3559. enumerable: true,
  3560. configurable: true
  3561. });
  3562. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3563. /**
  3564. * Get the Quaternion animation type
  3565. */
  3566. get: function () {
  3567. return Animation._ANIMATIONTYPE_QUATERNION;
  3568. },
  3569. enumerable: true,
  3570. configurable: true
  3571. });
  3572. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3573. /**
  3574. * Get the Matrix animation type
  3575. */
  3576. get: function () {
  3577. return Animation._ANIMATIONTYPE_MATRIX;
  3578. },
  3579. enumerable: true,
  3580. configurable: true
  3581. });
  3582. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3583. /**
  3584. * Get the Color3 animation type
  3585. */
  3586. get: function () {
  3587. return Animation._ANIMATIONTYPE_COLOR3;
  3588. },
  3589. enumerable: true,
  3590. configurable: true
  3591. });
  3592. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3593. /**
  3594. * Get the Relative Loop Mode
  3595. */
  3596. get: function () {
  3597. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3598. },
  3599. enumerable: true,
  3600. configurable: true
  3601. });
  3602. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3603. /**
  3604. * Get the Cycle Loop Mode
  3605. */
  3606. get: function () {
  3607. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3608. },
  3609. enumerable: true,
  3610. configurable: true
  3611. });
  3612. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3613. /**
  3614. * Get the Constant Loop Mode
  3615. */
  3616. get: function () {
  3617. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3618. },
  3619. enumerable: true,
  3620. configurable: true
  3621. });
  3622. /** @hidden */
  3623. Animation._UniversalLerp = function (left, right, amount) {
  3624. var constructor = left.constructor;
  3625. if (constructor.Lerp) { // Lerp supported
  3626. return constructor.Lerp(left, right, amount);
  3627. }
  3628. else if (constructor.Slerp) { // Slerp supported
  3629. return constructor.Slerp(left, right, amount);
  3630. }
  3631. else if (left.toFixed) { // Number
  3632. return left * (1.0 - amount) + amount * right;
  3633. }
  3634. else { // Blending not supported
  3635. return right;
  3636. }
  3637. };
  3638. /**
  3639. * Parses an animation object and creates an animation
  3640. * @param parsedAnimation Parsed animation object
  3641. * @returns Animation object
  3642. */
  3643. Animation.Parse = function (parsedAnimation) {
  3644. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3645. var dataType = parsedAnimation.dataType;
  3646. var keys = [];
  3647. var data;
  3648. var index;
  3649. if (parsedAnimation.enableBlending) {
  3650. animation.enableBlending = parsedAnimation.enableBlending;
  3651. }
  3652. if (parsedAnimation.blendingSpeed) {
  3653. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3654. }
  3655. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3656. var key = parsedAnimation.keys[index];
  3657. var inTangent;
  3658. var outTangent;
  3659. switch (dataType) {
  3660. case Animation.ANIMATIONTYPE_FLOAT:
  3661. data = key.values[0];
  3662. if (key.values.length >= 1) {
  3663. inTangent = key.values[1];
  3664. }
  3665. if (key.values.length >= 2) {
  3666. outTangent = key.values[2];
  3667. }
  3668. break;
  3669. case Animation.ANIMATIONTYPE_QUATERNION:
  3670. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3671. if (key.values.length >= 8) {
  3672. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3673. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3674. inTangent = _inTangent;
  3675. }
  3676. }
  3677. if (key.values.length >= 12) {
  3678. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3679. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3680. outTangent = _outTangent;
  3681. }
  3682. }
  3683. break;
  3684. case Animation.ANIMATIONTYPE_MATRIX:
  3685. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3686. break;
  3687. case Animation.ANIMATIONTYPE_COLOR3:
  3688. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3689. break;
  3690. case Animation.ANIMATIONTYPE_VECTOR3:
  3691. default:
  3692. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3693. break;
  3694. }
  3695. var keyData = {};
  3696. keyData.frame = key.frame;
  3697. keyData.value = data;
  3698. if (inTangent != undefined) {
  3699. keyData.inTangent = inTangent;
  3700. }
  3701. if (outTangent != undefined) {
  3702. keyData.outTangent = outTangent;
  3703. }
  3704. keys.push(keyData);
  3705. }
  3706. animation.setKeys(keys);
  3707. if (parsedAnimation.ranges) {
  3708. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3709. data = parsedAnimation.ranges[index];
  3710. animation.createRange(data.name, data.from, data.to);
  3711. }
  3712. }
  3713. return animation;
  3714. };
  3715. /**
  3716. * Appends the serialized animations from the source animations
  3717. * @param source Source containing the animations
  3718. * @param destination Target to store the animations
  3719. */
  3720. Animation.AppendSerializedAnimations = function (source, destination) {
  3721. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3722. };
  3723. /**
  3724. * Use matrix interpolation instead of using direct key value when animating matrices
  3725. */
  3726. Animation.AllowMatricesInterpolation = false;
  3727. /**
  3728. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3729. */
  3730. Animation.AllowMatrixDecomposeForInterpolation = true;
  3731. // Statics
  3732. /**
  3733. * Float animation type
  3734. */
  3735. Animation._ANIMATIONTYPE_FLOAT = 0;
  3736. /**
  3737. * Vector3 animation type
  3738. */
  3739. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3740. /**
  3741. * Quaternion animation type
  3742. */
  3743. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3744. /**
  3745. * Matrix animation type
  3746. */
  3747. Animation._ANIMATIONTYPE_MATRIX = 3;
  3748. /**
  3749. * Color3 animation type
  3750. */
  3751. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3752. /**
  3753. * Vector2 animation type
  3754. */
  3755. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3756. /**
  3757. * Size animation type
  3758. */
  3759. Animation._ANIMATIONTYPE_SIZE = 6;
  3760. /**
  3761. * Relative Loop Mode
  3762. */
  3763. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3764. /**
  3765. * Cycle Loop Mode
  3766. */
  3767. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3768. /**
  3769. * Constant Loop Mode
  3770. */
  3771. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3772. return Animation;
  3773. }());
  3774. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"]._AnimationParser = Animation.Parse;
  3775. _node__WEBPACK_IMPORTED_MODULE_2__["Node"]._AnimationRangeFactory = function (name, from, to) { return new AnimationRange(name, from, to); };
  3776. /***/ }),
  3777. /***/ "./Animations/animationGroup.ts":
  3778. /*!**************************************!*\
  3779. !*** ./Animations/animationGroup.ts ***!
  3780. \**************************************/
  3781. /*! exports provided: TargetedAnimation, AnimationGroup */
  3782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3783. "use strict";
  3784. __webpack_require__.r(__webpack_exports__);
  3785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  3786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  3787. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  3788. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  3789. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  3790. /**
  3791. * This class defines the direct association between an animation and a target
  3792. */
  3793. var TargetedAnimation = /** @class */ (function () {
  3794. function TargetedAnimation() {
  3795. }
  3796. return TargetedAnimation;
  3797. }());
  3798. /**
  3799. * Use this class to create coordinated animations on multiple targets
  3800. */
  3801. var AnimationGroup = /** @class */ (function () {
  3802. /**
  3803. * Instantiates a new Animation Group.
  3804. * This helps managing several animations at once.
  3805. * @see http://doc.babylonjs.com/how_to/group
  3806. * @param name Defines the name of the group
  3807. * @param scene Defines the scene the group belongs to
  3808. */
  3809. function AnimationGroup(
  3810. /** The name of the animation group */
  3811. name, scene) {
  3812. if (scene === void 0) { scene = null; }
  3813. this.name = name;
  3814. this._targetedAnimations = new Array();
  3815. this._animatables = new Array();
  3816. this._from = Number.MAX_VALUE;
  3817. this._to = -Number.MAX_VALUE;
  3818. this._speedRatio = 1;
  3819. /**
  3820. * This observable will notify when one animation have ended
  3821. */
  3822. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3823. /**
  3824. * Observer raised when one animation loops
  3825. */
  3826. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3827. /**
  3828. * This observable will notify when all animations have ended.
  3829. */
  3830. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3831. /**
  3832. * This observable will notify when all animations have paused.
  3833. */
  3834. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3835. /**
  3836. * This observable will notify when all animations are playing.
  3837. */
  3838. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3839. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  3840. this.uniqueId = this._scene.getUniqueId();
  3841. this._scene.animationGroups.push(this);
  3842. }
  3843. Object.defineProperty(AnimationGroup.prototype, "from", {
  3844. /**
  3845. * Gets the first frame
  3846. */
  3847. get: function () {
  3848. return this._from;
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(AnimationGroup.prototype, "to", {
  3854. /**
  3855. * Gets the last frame
  3856. */
  3857. get: function () {
  3858. return this._to;
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  3864. /**
  3865. * Define if the animations are started
  3866. */
  3867. get: function () {
  3868. return this._isStarted;
  3869. },
  3870. enumerable: true,
  3871. configurable: true
  3872. });
  3873. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  3874. /**
  3875. * Gets a value indicating that the current group is playing
  3876. */
  3877. get: function () {
  3878. return this._isStarted && !this._isPaused;
  3879. },
  3880. enumerable: true,
  3881. configurable: true
  3882. });
  3883. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  3884. /**
  3885. * Gets or sets the speed ratio to use for all animations
  3886. */
  3887. get: function () {
  3888. return this._speedRatio;
  3889. },
  3890. /**
  3891. * Gets or sets the speed ratio to use for all animations
  3892. */
  3893. set: function (value) {
  3894. if (this._speedRatio === value) {
  3895. return;
  3896. }
  3897. this._speedRatio = value;
  3898. for (var index = 0; index < this._animatables.length; index++) {
  3899. var animatable = this._animatables[index];
  3900. animatable.speedRatio = this._speedRatio;
  3901. }
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  3907. /**
  3908. * Gets the targeted animations for this animation group
  3909. */
  3910. get: function () {
  3911. return this._targetedAnimations;
  3912. },
  3913. enumerable: true,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  3917. /**
  3918. * returning the list of animatables controlled by this animation group.
  3919. */
  3920. get: function () {
  3921. return this._animatables;
  3922. },
  3923. enumerable: true,
  3924. configurable: true
  3925. });
  3926. /**
  3927. * Add an animation (with its target) in the group
  3928. * @param animation defines the animation we want to add
  3929. * @param target defines the target of the animation
  3930. * @returns the TargetedAnimation object
  3931. */
  3932. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  3933. var targetedAnimation = {
  3934. animation: animation,
  3935. target: target
  3936. };
  3937. var keys = animation.getKeys();
  3938. if (this._from > keys[0].frame) {
  3939. this._from = keys[0].frame;
  3940. }
  3941. if (this._to < keys[keys.length - 1].frame) {
  3942. this._to = keys[keys.length - 1].frame;
  3943. }
  3944. this._targetedAnimations.push(targetedAnimation);
  3945. return targetedAnimation;
  3946. };
  3947. /**
  3948. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3949. * It can add constant keys at begin or end
  3950. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3951. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3952. * @returns the animation group
  3953. */
  3954. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  3955. if (beginFrame === void 0) { beginFrame = null; }
  3956. if (endFrame === void 0) { endFrame = null; }
  3957. if (beginFrame == null) {
  3958. beginFrame = this._from;
  3959. }
  3960. if (endFrame == null) {
  3961. endFrame = this._to;
  3962. }
  3963. for (var index = 0; index < this._targetedAnimations.length; index++) {
  3964. var targetedAnimation = this._targetedAnimations[index];
  3965. var keys = targetedAnimation.animation.getKeys();
  3966. var startKey = keys[0];
  3967. var endKey = keys[keys.length - 1];
  3968. if (startKey.frame > beginFrame) {
  3969. var newKey = {
  3970. frame: beginFrame,
  3971. value: startKey.value,
  3972. inTangent: startKey.inTangent,
  3973. outTangent: startKey.outTangent,
  3974. interpolation: startKey.interpolation
  3975. };
  3976. keys.splice(0, 0, newKey);
  3977. }
  3978. if (endKey.frame < endFrame) {
  3979. var newKey = {
  3980. frame: endFrame,
  3981. value: endKey.value,
  3982. inTangent: endKey.outTangent,
  3983. outTangent: endKey.outTangent,
  3984. interpolation: endKey.interpolation
  3985. };
  3986. keys.push(newKey);
  3987. }
  3988. }
  3989. this._from = beginFrame;
  3990. this._to = endFrame;
  3991. return this;
  3992. };
  3993. /**
  3994. * Start all animations on given targets
  3995. * @param loop defines if animations must loop
  3996. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3997. * @param from defines the from key (optional)
  3998. * @param to defines the to key (optional)
  3999. * @returns the current animation group
  4000. */
  4001. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4002. var _this = this;
  4003. if (loop === void 0) { loop = false; }
  4004. if (speedRatio === void 0) { speedRatio = 1; }
  4005. if (this._isStarted || this._targetedAnimations.length === 0) {
  4006. return this;
  4007. }
  4008. var _loop_1 = function (targetedAnimation) {
  4009. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4010. animatable.onAnimationEnd = function () {
  4011. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4012. _this._checkAnimationGroupEnded(animatable);
  4013. };
  4014. animatable.onAnimationLoop = function () {
  4015. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4016. };
  4017. this_1._animatables.push(animatable);
  4018. };
  4019. var this_1 = this;
  4020. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4021. var targetedAnimation = _a[_i];
  4022. _loop_1(targetedAnimation);
  4023. }
  4024. this._speedRatio = speedRatio;
  4025. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4026. this._speedRatio = -speedRatio;
  4027. }
  4028. this._isStarted = true;
  4029. this._isPaused = false;
  4030. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4031. return this;
  4032. };
  4033. /**
  4034. * Pause all animations
  4035. * @returns the animation group
  4036. */
  4037. AnimationGroup.prototype.pause = function () {
  4038. if (!this._isStarted) {
  4039. return this;
  4040. }
  4041. this._isPaused = true;
  4042. for (var index = 0; index < this._animatables.length; index++) {
  4043. var animatable = this._animatables[index];
  4044. animatable.pause();
  4045. }
  4046. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4047. return this;
  4048. };
  4049. /**
  4050. * Play all animations to initial state
  4051. * This function will start() the animations if they were not started or will restart() them if they were paused
  4052. * @param loop defines if animations must loop
  4053. * @returns the animation group
  4054. */
  4055. AnimationGroup.prototype.play = function (loop) {
  4056. // only if all animatables are ready and exist
  4057. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4058. if (loop !== undefined) {
  4059. for (var index = 0; index < this._animatables.length; index++) {
  4060. var animatable = this._animatables[index];
  4061. animatable.loopAnimation = loop;
  4062. }
  4063. }
  4064. this.restart();
  4065. }
  4066. else {
  4067. this.stop();
  4068. this.start(loop, this._speedRatio);
  4069. }
  4070. this._isPaused = false;
  4071. return this;
  4072. };
  4073. /**
  4074. * Reset all animations to initial state
  4075. * @returns the animation group
  4076. */
  4077. AnimationGroup.prototype.reset = function () {
  4078. if (!this._isStarted) {
  4079. return this;
  4080. }
  4081. for (var index = 0; index < this._animatables.length; index++) {
  4082. var animatable = this._animatables[index];
  4083. animatable.reset();
  4084. }
  4085. return this;
  4086. };
  4087. /**
  4088. * Restart animations from key 0
  4089. * @returns the animation group
  4090. */
  4091. AnimationGroup.prototype.restart = function () {
  4092. if (!this._isStarted) {
  4093. return this;
  4094. }
  4095. for (var index = 0; index < this._animatables.length; index++) {
  4096. var animatable = this._animatables[index];
  4097. animatable.restart();
  4098. }
  4099. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4100. return this;
  4101. };
  4102. /**
  4103. * Stop all animations
  4104. * @returns the animation group
  4105. */
  4106. AnimationGroup.prototype.stop = function () {
  4107. if (!this._isStarted) {
  4108. return this;
  4109. }
  4110. var list = this._animatables.slice();
  4111. for (var index = 0; index < list.length; index++) {
  4112. list[index].stop();
  4113. }
  4114. this._isStarted = false;
  4115. return this;
  4116. };
  4117. /**
  4118. * Set animation weight for all animatables
  4119. * @param weight defines the weight to use
  4120. * @return the animationGroup
  4121. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4122. */
  4123. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4124. for (var index = 0; index < this._animatables.length; index++) {
  4125. var animatable = this._animatables[index];
  4126. animatable.weight = weight;
  4127. }
  4128. return this;
  4129. };
  4130. /**
  4131. * Synchronize and normalize all animatables with a source animatable
  4132. * @param root defines the root animatable to synchronize with
  4133. * @return the animationGroup
  4134. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4135. */
  4136. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4137. for (var index = 0; index < this._animatables.length; index++) {
  4138. var animatable = this._animatables[index];
  4139. animatable.syncWith(root);
  4140. }
  4141. return this;
  4142. };
  4143. /**
  4144. * Goes to a specific frame in this animation group
  4145. * @param frame the frame number to go to
  4146. * @return the animationGroup
  4147. */
  4148. AnimationGroup.prototype.goToFrame = function (frame) {
  4149. if (!this._isStarted) {
  4150. return this;
  4151. }
  4152. for (var index = 0; index < this._animatables.length; index++) {
  4153. var animatable = this._animatables[index];
  4154. animatable.goToFrame(frame);
  4155. }
  4156. return this;
  4157. };
  4158. /**
  4159. * Dispose all associated resources
  4160. */
  4161. AnimationGroup.prototype.dispose = function () {
  4162. this._targetedAnimations = [];
  4163. this._animatables = [];
  4164. var index = this._scene.animationGroups.indexOf(this);
  4165. if (index > -1) {
  4166. this._scene.animationGroups.splice(index, 1);
  4167. }
  4168. this.onAnimationEndObservable.clear();
  4169. this.onAnimationGroupEndObservable.clear();
  4170. this.onAnimationGroupPauseObservable.clear();
  4171. this.onAnimationGroupPlayObservable.clear();
  4172. this.onAnimationLoopObservable.clear();
  4173. };
  4174. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4175. // animatable should be taken out of the array
  4176. var idx = this._animatables.indexOf(animatable);
  4177. if (idx > -1) {
  4178. this._animatables.splice(idx, 1);
  4179. }
  4180. // all animatables were removed? animation group ended!
  4181. if (this._animatables.length === 0) {
  4182. this._isStarted = false;
  4183. this.onAnimationGroupEndObservable.notifyObservers(this);
  4184. }
  4185. };
  4186. // Statics
  4187. /**
  4188. * Returns a new AnimationGroup object parsed from the source provided.
  4189. * @param parsedAnimationGroup defines the source
  4190. * @param scene defines the scene that will receive the animationGroup
  4191. * @returns a new AnimationGroup
  4192. */
  4193. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4194. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4195. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4196. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4197. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4198. var id = targetedAnimation.targetId;
  4199. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4200. var morphTarget = scene.getMorphTargetById(id);
  4201. if (morphTarget) {
  4202. animationGroup.addTargetedAnimation(animation, morphTarget);
  4203. }
  4204. }
  4205. else {
  4206. var targetNode = scene.getNodeByID(id);
  4207. if (targetNode != null) {
  4208. animationGroup.addTargetedAnimation(animation, targetNode);
  4209. }
  4210. }
  4211. }
  4212. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4213. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4214. }
  4215. return animationGroup;
  4216. };
  4217. /**
  4218. * Returns the string "AnimationGroup"
  4219. * @returns "AnimationGroup"
  4220. */
  4221. AnimationGroup.prototype.getClassName = function () {
  4222. return "AnimationGroup";
  4223. };
  4224. /**
  4225. * Creates a detailled string about the object
  4226. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4227. * @returns a string representing the object
  4228. */
  4229. AnimationGroup.prototype.toString = function (fullDetails) {
  4230. var ret = "Name: " + this.name;
  4231. ret += ", type: " + this.getClassName();
  4232. if (fullDetails) {
  4233. ret += ", from: " + this._from;
  4234. ret += ", to: " + this._to;
  4235. ret += ", isStarted: " + this._isStarted;
  4236. ret += ", speedRatio: " + this._speedRatio;
  4237. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4238. ret += ", animatables length: " + this._animatables;
  4239. }
  4240. return ret;
  4241. };
  4242. return AnimationGroup;
  4243. }());
  4244. /***/ }),
  4245. /***/ "./Animations/animationPropertiesOverride.ts":
  4246. /*!***************************************************!*\
  4247. !*** ./Animations/animationPropertiesOverride.ts ***!
  4248. \***************************************************/
  4249. /*! exports provided: AnimationPropertiesOverride */
  4250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4251. "use strict";
  4252. __webpack_require__.r(__webpack_exports__);
  4253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4254. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4255. /**
  4256. * Class used to override all child animations of a given target
  4257. */
  4258. var AnimationPropertiesOverride = /** @class */ (function () {
  4259. function AnimationPropertiesOverride() {
  4260. /**
  4261. * Gets or sets a value indicating if animation blending must be used
  4262. */
  4263. this.enableBlending = false;
  4264. /**
  4265. * Gets or sets the blending speed to use when enableBlending is true
  4266. */
  4267. this.blendingSpeed = 0.01;
  4268. /**
  4269. * Gets or sets the default loop mode to use
  4270. */
  4271. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4272. }
  4273. return AnimationPropertiesOverride;
  4274. }());
  4275. /***/ }),
  4276. /***/ "./Animations/easing.ts":
  4277. /*!******************************!*\
  4278. !*** ./Animations/easing.ts ***!
  4279. \******************************/
  4280. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4282. "use strict";
  4283. __webpack_require__.r(__webpack_exports__);
  4284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4299. /**
  4300. * Base class used for every default easing function.
  4301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4302. */
  4303. var EasingFunction = /** @class */ (function () {
  4304. function EasingFunction() {
  4305. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4306. }
  4307. /**
  4308. * Sets the easing mode of the current function.
  4309. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4310. */
  4311. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4312. var n = Math.min(Math.max(easingMode, 0), 2);
  4313. this._easingMode = n;
  4314. };
  4315. /**
  4316. * Gets the current easing mode.
  4317. * @returns the easing mode
  4318. */
  4319. EasingFunction.prototype.getEasingMode = function () {
  4320. return this._easingMode;
  4321. };
  4322. /**
  4323. * @hidden
  4324. */
  4325. EasingFunction.prototype.easeInCore = function (gradient) {
  4326. throw new Error('You must implement this method');
  4327. };
  4328. /**
  4329. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4330. * of the easing function.
  4331. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4332. * @returns the corresponding value on the curve defined by the easing function
  4333. */
  4334. EasingFunction.prototype.ease = function (gradient) {
  4335. switch (this._easingMode) {
  4336. case EasingFunction.EASINGMODE_EASEIN:
  4337. return this.easeInCore(gradient);
  4338. case EasingFunction.EASINGMODE_EASEOUT:
  4339. return (1 - this.easeInCore(1 - gradient));
  4340. }
  4341. if (gradient >= 0.5) {
  4342. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4343. }
  4344. return (this.easeInCore(gradient * 2) * 0.5);
  4345. };
  4346. /**
  4347. * Interpolation follows the mathematical formula associated with the easing function.
  4348. */
  4349. EasingFunction.EASINGMODE_EASEIN = 0;
  4350. /**
  4351. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4352. */
  4353. EasingFunction.EASINGMODE_EASEOUT = 1;
  4354. /**
  4355. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4356. */
  4357. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4358. return EasingFunction;
  4359. }());
  4360. /**
  4361. * Easing function with a circle shape (see link below).
  4362. * @see https://easings.net/#easeInCirc
  4363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4364. */
  4365. var CircleEase = /** @class */ (function (_super) {
  4366. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4367. function CircleEase() {
  4368. return _super !== null && _super.apply(this, arguments) || this;
  4369. }
  4370. /** @hidden */
  4371. CircleEase.prototype.easeInCore = function (gradient) {
  4372. gradient = Math.max(0, Math.min(1, gradient));
  4373. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4374. };
  4375. return CircleEase;
  4376. }(EasingFunction));
  4377. /**
  4378. * Easing function with a ease back shape (see link below).
  4379. * @see https://easings.net/#easeInBack
  4380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4381. */
  4382. var BackEase = /** @class */ (function (_super) {
  4383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4384. /**
  4385. * Instantiates a back ease easing
  4386. * @see https://easings.net/#easeInBack
  4387. * @param amplitude Defines the amplitude of the function
  4388. */
  4389. function BackEase(
  4390. /** Defines the amplitude of the function */
  4391. amplitude) {
  4392. if (amplitude === void 0) { amplitude = 1; }
  4393. var _this = _super.call(this) || this;
  4394. _this.amplitude = amplitude;
  4395. return _this;
  4396. }
  4397. /** @hidden */
  4398. BackEase.prototype.easeInCore = function (gradient) {
  4399. var num = Math.max(0, this.amplitude);
  4400. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4401. };
  4402. return BackEase;
  4403. }(EasingFunction));
  4404. /**
  4405. * Easing function with a bouncing shape (see link below).
  4406. * @see https://easings.net/#easeInBounce
  4407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4408. */
  4409. var BounceEase = /** @class */ (function (_super) {
  4410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4411. /**
  4412. * Instantiates a bounce easing
  4413. * @see https://easings.net/#easeInBounce
  4414. * @param bounces Defines the number of bounces
  4415. * @param bounciness Defines the amplitude of the bounce
  4416. */
  4417. function BounceEase(
  4418. /** Defines the number of bounces */
  4419. bounces,
  4420. /** Defines the amplitude of the bounce */
  4421. bounciness) {
  4422. if (bounces === void 0) { bounces = 3; }
  4423. if (bounciness === void 0) { bounciness = 2; }
  4424. var _this = _super.call(this) || this;
  4425. _this.bounces = bounces;
  4426. _this.bounciness = bounciness;
  4427. return _this;
  4428. }
  4429. /** @hidden */
  4430. BounceEase.prototype.easeInCore = function (gradient) {
  4431. var y = Math.max(0.0, this.bounces);
  4432. var bounciness = this.bounciness;
  4433. if (bounciness <= 1.0) {
  4434. bounciness = 1.001;
  4435. }
  4436. var num9 = Math.pow(bounciness, y);
  4437. var num5 = 1.0 - bounciness;
  4438. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4439. var num15 = gradient * num4;
  4440. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4441. var num3 = Math.floor(num65);
  4442. var num13 = num3 + 1.0;
  4443. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4444. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4445. var num7 = (num8 + num12) * 0.5;
  4446. var num6 = gradient - num7;
  4447. var num2 = num7 - num8;
  4448. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4449. };
  4450. return BounceEase;
  4451. }(EasingFunction));
  4452. /**
  4453. * Easing function with a power of 3 shape (see link below).
  4454. * @see https://easings.net/#easeInCubic
  4455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4456. */
  4457. var CubicEase = /** @class */ (function (_super) {
  4458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4459. function CubicEase() {
  4460. return _super !== null && _super.apply(this, arguments) || this;
  4461. }
  4462. /** @hidden */
  4463. CubicEase.prototype.easeInCore = function (gradient) {
  4464. return (gradient * gradient * gradient);
  4465. };
  4466. return CubicEase;
  4467. }(EasingFunction));
  4468. /**
  4469. * Easing function with an elastic shape (see link below).
  4470. * @see https://easings.net/#easeInElastic
  4471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4472. */
  4473. var ElasticEase = /** @class */ (function (_super) {
  4474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4475. /**
  4476. * Instantiates an elastic easing function
  4477. * @see https://easings.net/#easeInElastic
  4478. * @param oscillations Defines the number of oscillations
  4479. * @param springiness Defines the amplitude of the oscillations
  4480. */
  4481. function ElasticEase(
  4482. /** Defines the number of oscillations*/
  4483. oscillations,
  4484. /** Defines the amplitude of the oscillations*/
  4485. springiness) {
  4486. if (oscillations === void 0) { oscillations = 3; }
  4487. if (springiness === void 0) { springiness = 3; }
  4488. var _this = _super.call(this) || this;
  4489. _this.oscillations = oscillations;
  4490. _this.springiness = springiness;
  4491. return _this;
  4492. }
  4493. /** @hidden */
  4494. ElasticEase.prototype.easeInCore = function (gradient) {
  4495. var num2;
  4496. var num3 = Math.max(0.0, this.oscillations);
  4497. var num = Math.max(0.0, this.springiness);
  4498. if (num == 0) {
  4499. num2 = gradient;
  4500. }
  4501. else {
  4502. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4503. }
  4504. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4505. };
  4506. return ElasticEase;
  4507. }(EasingFunction));
  4508. /**
  4509. * Easing function with an exponential shape (see link below).
  4510. * @see https://easings.net/#easeInExpo
  4511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4512. */
  4513. var ExponentialEase = /** @class */ (function (_super) {
  4514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4515. /**
  4516. * Instantiates an exponential easing function
  4517. * @see https://easings.net/#easeInExpo
  4518. * @param exponent Defines the exponent of the function
  4519. */
  4520. function ExponentialEase(
  4521. /** Defines the exponent of the function */
  4522. exponent) {
  4523. if (exponent === void 0) { exponent = 2; }
  4524. var _this = _super.call(this) || this;
  4525. _this.exponent = exponent;
  4526. return _this;
  4527. }
  4528. /** @hidden */
  4529. ExponentialEase.prototype.easeInCore = function (gradient) {
  4530. if (this.exponent <= 0) {
  4531. return gradient;
  4532. }
  4533. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4534. };
  4535. return ExponentialEase;
  4536. }(EasingFunction));
  4537. /**
  4538. * Easing function with a power shape (see link below).
  4539. * @see https://easings.net/#easeInQuad
  4540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4541. */
  4542. var PowerEase = /** @class */ (function (_super) {
  4543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4544. /**
  4545. * Instantiates an power base easing function
  4546. * @see https://easings.net/#easeInQuad
  4547. * @param power Defines the power of the function
  4548. */
  4549. function PowerEase(
  4550. /** Defines the power of the function */
  4551. power) {
  4552. if (power === void 0) { power = 2; }
  4553. var _this = _super.call(this) || this;
  4554. _this.power = power;
  4555. return _this;
  4556. }
  4557. /** @hidden */
  4558. PowerEase.prototype.easeInCore = function (gradient) {
  4559. var y = Math.max(0.0, this.power);
  4560. return Math.pow(gradient, y);
  4561. };
  4562. return PowerEase;
  4563. }(EasingFunction));
  4564. /**
  4565. * Easing function with a power of 2 shape (see link below).
  4566. * @see https://easings.net/#easeInQuad
  4567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4568. */
  4569. var QuadraticEase = /** @class */ (function (_super) {
  4570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4571. function QuadraticEase() {
  4572. return _super !== null && _super.apply(this, arguments) || this;
  4573. }
  4574. /** @hidden */
  4575. QuadraticEase.prototype.easeInCore = function (gradient) {
  4576. return (gradient * gradient);
  4577. };
  4578. return QuadraticEase;
  4579. }(EasingFunction));
  4580. /**
  4581. * Easing function with a power of 4 shape (see link below).
  4582. * @see https://easings.net/#easeInQuart
  4583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4584. */
  4585. var QuarticEase = /** @class */ (function (_super) {
  4586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4587. function QuarticEase() {
  4588. return _super !== null && _super.apply(this, arguments) || this;
  4589. }
  4590. /** @hidden */
  4591. QuarticEase.prototype.easeInCore = function (gradient) {
  4592. return (gradient * gradient * gradient * gradient);
  4593. };
  4594. return QuarticEase;
  4595. }(EasingFunction));
  4596. /**
  4597. * Easing function with a power of 5 shape (see link below).
  4598. * @see https://easings.net/#easeInQuint
  4599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4600. */
  4601. var QuinticEase = /** @class */ (function (_super) {
  4602. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4603. function QuinticEase() {
  4604. return _super !== null && _super.apply(this, arguments) || this;
  4605. }
  4606. /** @hidden */
  4607. QuinticEase.prototype.easeInCore = function (gradient) {
  4608. return (gradient * gradient * gradient * gradient * gradient);
  4609. };
  4610. return QuinticEase;
  4611. }(EasingFunction));
  4612. /**
  4613. * Easing function with a sin shape (see link below).
  4614. * @see https://easings.net/#easeInSine
  4615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4616. */
  4617. var SineEase = /** @class */ (function (_super) {
  4618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4619. function SineEase() {
  4620. return _super !== null && _super.apply(this, arguments) || this;
  4621. }
  4622. /** @hidden */
  4623. SineEase.prototype.easeInCore = function (gradient) {
  4624. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4625. };
  4626. return SineEase;
  4627. }(EasingFunction));
  4628. /**
  4629. * Easing function with a bezier shape (see link below).
  4630. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4632. */
  4633. var BezierCurveEase = /** @class */ (function (_super) {
  4634. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4635. /**
  4636. * Instantiates a bezier function
  4637. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4638. * @param x1 Defines the x component of the start tangent in the bezier curve
  4639. * @param y1 Defines the y component of the start tangent in the bezier curve
  4640. * @param x2 Defines the x component of the end tangent in the bezier curve
  4641. * @param y2 Defines the y component of the end tangent in the bezier curve
  4642. */
  4643. function BezierCurveEase(
  4644. /** Defines the x component of the start tangent in the bezier curve */
  4645. x1,
  4646. /** Defines the y component of the start tangent in the bezier curve */
  4647. y1,
  4648. /** Defines the x component of the end tangent in the bezier curve */
  4649. x2,
  4650. /** Defines the y component of the end tangent in the bezier curve */
  4651. y2) {
  4652. if (x1 === void 0) { x1 = 0; }
  4653. if (y1 === void 0) { y1 = 0; }
  4654. if (x2 === void 0) { x2 = 1; }
  4655. if (y2 === void 0) { y2 = 1; }
  4656. var _this = _super.call(this) || this;
  4657. _this.x1 = x1;
  4658. _this.y1 = y1;
  4659. _this.x2 = x2;
  4660. _this.y2 = y2;
  4661. return _this;
  4662. }
  4663. /** @hidden */
  4664. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4665. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4666. };
  4667. return BezierCurveEase;
  4668. }(EasingFunction));
  4669. /***/ }),
  4670. /***/ "./Animations/index.ts":
  4671. /*!*****************************!*\
  4672. !*** ./Animations/index.ts ***!
  4673. \*****************************/
  4674. /*! exports provided: Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation */
  4675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4676. "use strict";
  4677. __webpack_require__.r(__webpack_exports__);
  4678. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  4680. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationRange"]; });
  4682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationEvent"]; });
  4683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["PathCursor"]; });
  4684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationKeyInterpolation"]; });
  4685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  4686. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  4687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  4688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  4689. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  4690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  4691. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  4692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  4693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  4694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  4695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  4696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  4697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  4698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  4699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  4700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  4701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  4702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  4703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  4704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  4705. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  4706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  4707. /***/ }),
  4708. /***/ "./Animations/runtimeAnimation.ts":
  4709. /*!****************************************!*\
  4710. !*** ./Animations/runtimeAnimation.ts ***!
  4711. \****************************************/
  4712. /*! exports provided: RuntimeAnimation */
  4713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4714. "use strict";
  4715. __webpack_require__.r(__webpack_exports__);
  4716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  4717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4718. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4719. // Static values to help the garbage collector
  4720. // Quaternion
  4721. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  4722. // Vector3
  4723. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  4724. // Vector2
  4725. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  4726. // Size
  4727. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  4728. // Color3
  4729. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  4730. /**
  4731. * Defines a runtime animation
  4732. */
  4733. var RuntimeAnimation = /** @class */ (function () {
  4734. /**
  4735. * Create a new RuntimeAnimation object
  4736. * @param target defines the target of the animation
  4737. * @param animation defines the source animation object
  4738. * @param scene defines the hosting scene
  4739. * @param host defines the initiating Animatable
  4740. */
  4741. function RuntimeAnimation(target, animation, scene, host) {
  4742. var _this = this;
  4743. this._events = new Array();
  4744. /**
  4745. * The current frame of the runtime animation
  4746. */
  4747. this._currentFrame = 0;
  4748. /**
  4749. * The original value of the runtime animation
  4750. */
  4751. this._originalValue = new Array();
  4752. /**
  4753. * The offsets cache of the runtime animation
  4754. */
  4755. this._offsetsCache = {};
  4756. /**
  4757. * The high limits cache of the runtime animation
  4758. */
  4759. this._highLimitsCache = {};
  4760. /**
  4761. * Specifies if the runtime animation has been stopped
  4762. */
  4763. this._stopped = false;
  4764. /**
  4765. * The blending factor of the runtime animation
  4766. */
  4767. this._blendingFactor = 0;
  4768. /**
  4769. * The target path of the runtime animation
  4770. */
  4771. this._targetPath = "";
  4772. /**
  4773. * The weight of the runtime animation
  4774. */
  4775. this._weight = 1.0;
  4776. /**
  4777. * The ratio offset of the runtime animation
  4778. */
  4779. this._ratioOffset = 0;
  4780. /**
  4781. * The previous delay of the runtime animation
  4782. */
  4783. this._previousDelay = 0;
  4784. /**
  4785. * The previous ratio of the runtime animation
  4786. */
  4787. this._previousRatio = 0;
  4788. this._animation = animation;
  4789. this._target = target;
  4790. this._scene = scene;
  4791. this._host = host;
  4792. animation._runtimeAnimations.push(this);
  4793. // Cloning events locally
  4794. var events = animation.getEvents();
  4795. if (events && events.length > 0) {
  4796. events.forEach(function (e) {
  4797. _this._events.push(e._clone());
  4798. });
  4799. }
  4800. }
  4801. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  4802. /**
  4803. * Gets the current frame of the runtime animation
  4804. */
  4805. get: function () {
  4806. return this._currentFrame;
  4807. },
  4808. enumerable: true,
  4809. configurable: true
  4810. });
  4811. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  4812. /**
  4813. * Gets the weight of the runtime animation
  4814. */
  4815. get: function () {
  4816. return this._weight;
  4817. },
  4818. enumerable: true,
  4819. configurable: true
  4820. });
  4821. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  4822. /**
  4823. * Gets the current value of the runtime animation
  4824. */
  4825. get: function () {
  4826. return this._currentValue;
  4827. },
  4828. enumerable: true,
  4829. configurable: true
  4830. });
  4831. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  4832. /**
  4833. * Gets the target path of the runtime animation
  4834. */
  4835. get: function () {
  4836. return this._targetPath;
  4837. },
  4838. enumerable: true,
  4839. configurable: true
  4840. });
  4841. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  4842. /**
  4843. * Gets the actual target of the runtime animation
  4844. */
  4845. get: function () {
  4846. return this._activeTarget;
  4847. },
  4848. enumerable: true,
  4849. configurable: true
  4850. });
  4851. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  4852. /**
  4853. * Gets the animation from the runtime animation
  4854. */
  4855. get: function () {
  4856. return this._animation;
  4857. },
  4858. enumerable: true,
  4859. configurable: true
  4860. });
  4861. /**
  4862. * Resets the runtime animation to the beginning
  4863. * @param restoreOriginal defines whether to restore the target property to the original value
  4864. */
  4865. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  4866. if (restoreOriginal === void 0) { restoreOriginal = false; }
  4867. if (restoreOriginal) {
  4868. if (this._target instanceof Array) {
  4869. var index = 0;
  4870. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4871. var target = _a[_i];
  4872. if (this._originalValue[index] !== undefined) {
  4873. this._setValue(target, this._originalValue[index], -1);
  4874. }
  4875. index++;
  4876. }
  4877. }
  4878. else {
  4879. if (this._originalValue[0] !== undefined) {
  4880. this._setValue(this._target, this._originalValue[0], -1);
  4881. }
  4882. }
  4883. }
  4884. this._offsetsCache = {};
  4885. this._highLimitsCache = {};
  4886. this._currentFrame = 0;
  4887. this._blendingFactor = 0;
  4888. this._originalValue = new Array();
  4889. // Events
  4890. for (var index = 0; index < this._events.length; index++) {
  4891. this._events[index].isDone = false;
  4892. }
  4893. };
  4894. /**
  4895. * Specifies if the runtime animation is stopped
  4896. * @returns Boolean specifying if the runtime animation is stopped
  4897. */
  4898. RuntimeAnimation.prototype.isStopped = function () {
  4899. return this._stopped;
  4900. };
  4901. /**
  4902. * Disposes of the runtime animation
  4903. */
  4904. RuntimeAnimation.prototype.dispose = function () {
  4905. var index = this._animation.runtimeAnimations.indexOf(this);
  4906. if (index > -1) {
  4907. this._animation.runtimeAnimations.splice(index, 1);
  4908. }
  4909. };
  4910. /**
  4911. * Interpolates the animation from the current frame
  4912. * @param currentFrame The frame to interpolate the animation to
  4913. * @param repeatCount The number of times that the animation should loop
  4914. * @param loopMode The type of looping mode to use
  4915. * @param offsetValue Animation offset value
  4916. * @param highLimitValue The high limit value
  4917. * @returns The interpolated value
  4918. */
  4919. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  4920. this._currentFrame = currentFrame;
  4921. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  4922. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  4923. }
  4924. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  4925. };
  4926. /**
  4927. * Apply the interpolated value to the target
  4928. * @param currentValue defines the value computed by the animation
  4929. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4930. */
  4931. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  4932. if (weight === void 0) { weight = 1.0; }
  4933. if (this._target instanceof Array) {
  4934. var index = 0;
  4935. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4936. var target = _a[_i];
  4937. this._setValue(target, currentValue, weight, index);
  4938. index++;
  4939. }
  4940. }
  4941. else {
  4942. this._setValue(this._target, currentValue, weight);
  4943. }
  4944. };
  4945. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  4946. if (targetIndex === void 0) { targetIndex = 0; }
  4947. // Set value
  4948. var path;
  4949. var destination;
  4950. var targetPropertyPath = this._animation.targetPropertyPath;
  4951. if (targetPropertyPath.length > 1) {
  4952. var property = target[targetPropertyPath[0]];
  4953. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  4954. property = property[targetPropertyPath[index]];
  4955. }
  4956. path = targetPropertyPath[targetPropertyPath.length - 1];
  4957. destination = property;
  4958. }
  4959. else {
  4960. path = targetPropertyPath[0];
  4961. destination = target;
  4962. }
  4963. this._targetPath = path;
  4964. this._activeTarget = destination;
  4965. this._weight = weight;
  4966. if (this._originalValue[targetIndex] === undefined) {
  4967. var originalValue = void 0;
  4968. if (destination.getRestPose && path === "_matrix") { // For bones
  4969. originalValue = destination.getRestPose();
  4970. }
  4971. else {
  4972. originalValue = destination[path];
  4973. }
  4974. if (originalValue && originalValue.clone) {
  4975. this._originalValue[targetIndex] = originalValue.clone();
  4976. }
  4977. else {
  4978. this._originalValue[targetIndex] = originalValue;
  4979. }
  4980. }
  4981. // Blending
  4982. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  4983. if (enableBlending && this._blendingFactor <= 1.0) {
  4984. if (!this._originalBlendValue) {
  4985. var originalValue = destination[path];
  4986. if (originalValue.clone) {
  4987. this._originalBlendValue = originalValue.clone();
  4988. }
  4989. else {
  4990. this._originalBlendValue = originalValue;
  4991. }
  4992. }
  4993. if (this._originalBlendValue.m) { // Matrix
  4994. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  4995. if (this._currentValue) {
  4996. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  4997. }
  4998. else {
  4999. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5000. }
  5001. }
  5002. else {
  5003. if (this._currentValue) {
  5004. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5005. }
  5006. else {
  5007. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5008. }
  5009. }
  5010. }
  5011. else {
  5012. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5013. }
  5014. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5015. this._blendingFactor += blendingSpeed;
  5016. }
  5017. else {
  5018. this._currentValue = currentValue;
  5019. }
  5020. if (weight !== -1.0) {
  5021. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5022. }
  5023. else {
  5024. destination[path] = this._currentValue;
  5025. }
  5026. if (target.markAsDirty) {
  5027. target.markAsDirty(this._animation.targetProperty);
  5028. }
  5029. };
  5030. /**
  5031. * Gets the loop pmode of the runtime animation
  5032. * @returns Loop Mode
  5033. */
  5034. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5035. if (this._target && this._target.animationPropertiesOverride) {
  5036. return this._target.animationPropertiesOverride.loopMode;
  5037. }
  5038. return this._animation.loopMode;
  5039. };
  5040. /**
  5041. * Move the current animation to a given frame
  5042. * @param frame defines the frame to move to
  5043. */
  5044. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5045. var keys = this._animation.getKeys();
  5046. if (frame < keys[0].frame) {
  5047. frame = keys[0].frame;
  5048. }
  5049. else if (frame > keys[keys.length - 1].frame) {
  5050. frame = keys[keys.length - 1].frame;
  5051. }
  5052. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5053. this.setValue(currentValue, -1);
  5054. };
  5055. /**
  5056. * @hidden Internal use only
  5057. */
  5058. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5059. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5060. this._ratioOffset = this._previousRatio - newRatio;
  5061. };
  5062. /**
  5063. * Execute the current animation
  5064. * @param delay defines the delay to add to the current frame
  5065. * @param from defines the lower bound of the animation range
  5066. * @param to defines the upper bound of the animation range
  5067. * @param loop defines if the current animation must loop
  5068. * @param speedRatio defines the current speed ratio
  5069. * @param weight defines the weight of the animation (default is -1 so no weight)
  5070. * @param onLoop optional callback called when animation loops
  5071. * @returns a boolean indicating if the animation is running
  5072. */
  5073. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5074. if (weight === void 0) { weight = -1.0; }
  5075. var targetPropertyPath = this._animation.targetPropertyPath;
  5076. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5077. this._stopped = true;
  5078. return false;
  5079. }
  5080. var returnValue = true;
  5081. var keys = this._animation.getKeys();
  5082. // Adding a start key at frame 0 if missing
  5083. if (keys[0].frame !== 0) {
  5084. var newKey = { frame: 0, value: keys[0].value };
  5085. keys.splice(0, 0, newKey);
  5086. }
  5087. // Adding a duplicate key when there is only one key at frame zero
  5088. else if (keys.length === 1) {
  5089. var newKey = { frame: 0.001, value: keys[0].value };
  5090. keys.push(newKey);
  5091. }
  5092. // Check limits
  5093. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5094. from = keys[0].frame;
  5095. }
  5096. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5097. to = keys[keys.length - 1].frame;
  5098. }
  5099. //to and from cannot be the same key
  5100. if (from === to) {
  5101. if (from > keys[0].frame) {
  5102. from--;
  5103. }
  5104. else if (to < keys[keys.length - 1].frame) {
  5105. to++;
  5106. }
  5107. }
  5108. // Compute ratio
  5109. var range = to - from;
  5110. var offsetValue;
  5111. // ratio represents the frame delta between from and to
  5112. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5113. var highLimitValue = 0;
  5114. this._previousDelay = delay;
  5115. this._previousRatio = ratio;
  5116. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5117. returnValue = false;
  5118. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5119. }
  5120. else {
  5121. // Get max value if required
  5122. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5123. var keyOffset = to.toString() + from.toString();
  5124. if (!this._offsetsCache[keyOffset]) {
  5125. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5126. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5127. switch (this._animation.dataType) {
  5128. // Float
  5129. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5130. this._offsetsCache[keyOffset] = toValue - fromValue;
  5131. break;
  5132. // Quaternion
  5133. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5134. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5135. break;
  5136. // Vector3
  5137. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5138. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5139. // Vector2
  5140. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5141. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5142. // Size
  5143. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5144. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5145. // Color3
  5146. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5147. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5148. default:
  5149. break;
  5150. }
  5151. this._highLimitsCache[keyOffset] = toValue;
  5152. }
  5153. highLimitValue = this._highLimitsCache[keyOffset];
  5154. offsetValue = this._offsetsCache[keyOffset];
  5155. }
  5156. }
  5157. if (offsetValue === undefined) {
  5158. switch (this._animation.dataType) {
  5159. // Float
  5160. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5161. offsetValue = 0;
  5162. break;
  5163. // Quaternion
  5164. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5165. offsetValue = _staticOffsetValueQuaternion;
  5166. break;
  5167. // Vector3
  5168. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5169. offsetValue = _staticOffsetValueVector3;
  5170. break;
  5171. // Vector2
  5172. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5173. offsetValue = _staticOffsetValueVector2;
  5174. break;
  5175. // Size
  5176. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5177. offsetValue = _staticOffsetValueSize;
  5178. break;
  5179. // Color3
  5180. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5181. offsetValue = _staticOffsetValueColor3;
  5182. }
  5183. }
  5184. // Compute value
  5185. var repeatCount = (ratio / range) >> 0;
  5186. var currentFrame = returnValue ? from + ratio % range : to;
  5187. // Need to normalize?
  5188. if (this._host && this._host.syncRoot) {
  5189. var syncRoot = this._host.syncRoot;
  5190. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5191. currentFrame = from + (to - from) * hostNormalizedFrame;
  5192. }
  5193. // Reset events if looping
  5194. var events = this._events;
  5195. if (range > 0 && this.currentFrame > currentFrame ||
  5196. range < 0 && this.currentFrame < currentFrame) {
  5197. if (onLoop) {
  5198. onLoop();
  5199. }
  5200. // Need to reset animation events
  5201. for (var index = 0; index < events.length; index++) {
  5202. if (!events[index].onlyOnce) {
  5203. // reset event, the animation is looping
  5204. events[index].isDone = false;
  5205. }
  5206. }
  5207. }
  5208. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5209. // Set value
  5210. this.setValue(currentValue, weight);
  5211. // Check events
  5212. for (var index = 0; index < events.length; index++) {
  5213. // Make sure current frame has passed event frame and that event frame is within the current range
  5214. // Also, handle both forward and reverse animations
  5215. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5216. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5217. var event = events[index];
  5218. if (!event.isDone) {
  5219. // If event should be done only once, remove it.
  5220. if (event.onlyOnce) {
  5221. events.splice(index, 1);
  5222. index--;
  5223. }
  5224. event.isDone = true;
  5225. event.action(currentFrame);
  5226. } // Don't do anything if the event has already be done.
  5227. }
  5228. }
  5229. if (!returnValue) {
  5230. this._stopped = true;
  5231. }
  5232. return returnValue;
  5233. };
  5234. return RuntimeAnimation;
  5235. }());
  5236. /***/ }),
  5237. /***/ "./Audio/analyser.ts":
  5238. /*!***************************!*\
  5239. !*** ./Audio/analyser.ts ***!
  5240. \***************************/
  5241. /*! exports provided: Analyser */
  5242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5243. "use strict";
  5244. __webpack_require__.r(__webpack_exports__);
  5245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5246. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5247. /**
  5248. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5250. */
  5251. var Analyser = /** @class */ (function () {
  5252. /**
  5253. * Creates a new analyser
  5254. * @param scene defines hosting scene
  5255. */
  5256. function Analyser(scene) {
  5257. /**
  5258. * Gets or sets the smoothing
  5259. * @ignorenaming
  5260. */
  5261. this.SMOOTHING = 0.75;
  5262. /**
  5263. * Gets or sets the FFT table size
  5264. * @ignorenaming
  5265. */
  5266. this.FFT_SIZE = 512;
  5267. /**
  5268. * Gets or sets the bar graph amplitude
  5269. * @ignorenaming
  5270. */
  5271. this.BARGRAPHAMPLITUDE = 256;
  5272. /**
  5273. * Gets or sets the position of the debug canvas
  5274. * @ignorenaming
  5275. */
  5276. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5277. /**
  5278. * Gets or sets the debug canvas size
  5279. * @ignorenaming
  5280. */
  5281. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5282. this._scene = scene;
  5283. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5284. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5285. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5286. this._webAudioAnalyser.minDecibels = -140;
  5287. this._webAudioAnalyser.maxDecibels = 0;
  5288. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5289. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5290. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5291. }
  5292. }
  5293. /**
  5294. * Get the number of data values you will have to play with for the visualization
  5295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5296. * @returns a number
  5297. */
  5298. Analyser.prototype.getFrequencyBinCount = function () {
  5299. if (this._audioEngine.canUseWebAudio) {
  5300. return this._webAudioAnalyser.frequencyBinCount;
  5301. }
  5302. else {
  5303. return 0;
  5304. }
  5305. };
  5306. /**
  5307. * Gets the current frequency data as a byte array
  5308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5309. * @returns a Uint8Array
  5310. */
  5311. Analyser.prototype.getByteFrequencyData = function () {
  5312. if (this._audioEngine.canUseWebAudio) {
  5313. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5314. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5315. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5316. }
  5317. return this._byteFreqs;
  5318. };
  5319. /**
  5320. * Gets the current waveform as a byte array
  5321. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5322. * @returns a Uint8Array
  5323. */
  5324. Analyser.prototype.getByteTimeDomainData = function () {
  5325. if (this._audioEngine.canUseWebAudio) {
  5326. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5327. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5328. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5329. }
  5330. return this._byteTime;
  5331. };
  5332. /**
  5333. * Gets the current frequency data as a float array
  5334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5335. * @returns a Float32Array
  5336. */
  5337. Analyser.prototype.getFloatFrequencyData = function () {
  5338. if (this._audioEngine.canUseWebAudio) {
  5339. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5340. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5341. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5342. }
  5343. return this._floatFreqs;
  5344. };
  5345. /**
  5346. * Renders the debug canvas
  5347. */
  5348. Analyser.prototype.drawDebugCanvas = function () {
  5349. var _this = this;
  5350. if (this._audioEngine.canUseWebAudio) {
  5351. if (!this._debugCanvas) {
  5352. this._debugCanvas = document.createElement("canvas");
  5353. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5354. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5355. this._debugCanvas.style.position = "absolute";
  5356. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5357. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5358. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5359. document.body.appendChild(this._debugCanvas);
  5360. this._registerFunc = function () {
  5361. _this.drawDebugCanvas();
  5362. };
  5363. this._scene.registerBeforeRender(this._registerFunc);
  5364. }
  5365. if (this._registerFunc && this._debugCanvasContext) {
  5366. var workingArray = this.getByteFrequencyData();
  5367. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5368. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5369. // Draw the frequency domain chart.
  5370. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5371. var value = workingArray[i];
  5372. var percent = value / this.BARGRAPHAMPLITUDE;
  5373. var height = this.DEBUGCANVASSIZE.height * percent;
  5374. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5375. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5376. var hue = i / this.getFrequencyBinCount() * 360;
  5377. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5378. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5379. }
  5380. }
  5381. }
  5382. };
  5383. /**
  5384. * Stops rendering the debug canvas and removes it
  5385. */
  5386. Analyser.prototype.stopDebugCanvas = function () {
  5387. if (this._debugCanvas) {
  5388. if (this._registerFunc) {
  5389. this._scene.unregisterBeforeRender(this._registerFunc);
  5390. this._registerFunc = null;
  5391. }
  5392. document.body.removeChild(this._debugCanvas);
  5393. this._debugCanvas = null;
  5394. this._debugCanvasContext = null;
  5395. }
  5396. };
  5397. /**
  5398. * Connects two audio nodes
  5399. * @param inputAudioNode defines first node to connect
  5400. * @param outputAudioNode defines second node to connect
  5401. */
  5402. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5403. if (this._audioEngine.canUseWebAudio) {
  5404. inputAudioNode.connect(this._webAudioAnalyser);
  5405. this._webAudioAnalyser.connect(outputAudioNode);
  5406. }
  5407. };
  5408. /**
  5409. * Releases all associated resources
  5410. */
  5411. Analyser.prototype.dispose = function () {
  5412. if (this._audioEngine.canUseWebAudio) {
  5413. this._webAudioAnalyser.disconnect();
  5414. }
  5415. };
  5416. return Analyser;
  5417. }());
  5418. /***/ }),
  5419. /***/ "./Audio/audioEngine.ts":
  5420. /*!******************************!*\
  5421. !*** ./Audio/audioEngine.ts ***!
  5422. \******************************/
  5423. /*! exports provided: AudioEngine */
  5424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5425. "use strict";
  5426. __webpack_require__.r(__webpack_exports__);
  5427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5428. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5429. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5430. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5431. // Sets the default audio engine to Babylon.js
  5432. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5433. /**
  5434. * This represents the default audio engine used in babylon.
  5435. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5437. */
  5438. var AudioEngine = /** @class */ (function () {
  5439. /**
  5440. * Instantiates a new audio engine.
  5441. *
  5442. * There should be only one per page as some browsers restrict the number
  5443. * of audio contexts you can create.
  5444. * @param hostElement defines the host element where to display the mute icon if necessary
  5445. */
  5446. function AudioEngine(hostElement) {
  5447. if (hostElement === void 0) { hostElement = null; }
  5448. var _this = this;
  5449. this._audioContext = null;
  5450. this._audioContextInitialized = false;
  5451. this._muteButton = null;
  5452. /**
  5453. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5454. */
  5455. this.canUseWebAudio = false;
  5456. /**
  5457. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5458. * @ignoreNaming
  5459. */
  5460. this.WarnedWebAudioUnsupported = false;
  5461. /**
  5462. * Gets whether or not mp3 are supported by your browser.
  5463. */
  5464. this.isMP3supported = false;
  5465. /**
  5466. * Gets whether or not ogg are supported by your browser.
  5467. */
  5468. this.isOGGsupported = false;
  5469. /**
  5470. * Gets whether audio has been unlocked on the device.
  5471. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5472. * a user interaction has happened.
  5473. */
  5474. this.unlocked = true;
  5475. /**
  5476. * Defines if the audio engine relies on a custom unlocked button.
  5477. * In this case, the embedded button will not be displayed.
  5478. */
  5479. this.useCustomUnlockedButton = false;
  5480. /**
  5481. * Event raised when audio has been unlocked on the browser.
  5482. */
  5483. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5484. /**
  5485. * Event raised when audio has been locked on the browser.
  5486. */
  5487. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5488. this._tryToRun = false;
  5489. this._onResize = function () {
  5490. _this._moveButtonToTopLeft();
  5491. };
  5492. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5493. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5494. this.canUseWebAudio = true;
  5495. }
  5496. var audioElem = document.createElement('audio');
  5497. this._hostElement = hostElement;
  5498. try {
  5499. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5500. this.isMP3supported = true;
  5501. }
  5502. }
  5503. catch (e) {
  5504. // protect error during capability check.
  5505. }
  5506. try {
  5507. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5508. this.isOGGsupported = true;
  5509. }
  5510. }
  5511. catch (e) {
  5512. // protect error during capability check.
  5513. }
  5514. }
  5515. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5516. /**
  5517. * Gets the current AudioContext if available.
  5518. */
  5519. get: function () {
  5520. if (!this._audioContextInitialized) {
  5521. this._initializeAudioContext();
  5522. }
  5523. else {
  5524. if (!this.unlocked && !this._muteButton) {
  5525. this._displayMuteButton();
  5526. }
  5527. }
  5528. return this._audioContext;
  5529. },
  5530. enumerable: true,
  5531. configurable: true
  5532. });
  5533. /**
  5534. * Flags the audio engine in Locked state.
  5535. * This happens due to new browser policies preventing audio to autoplay.
  5536. */
  5537. AudioEngine.prototype.lock = function () {
  5538. this._triggerSuspendedState();
  5539. };
  5540. /**
  5541. * Unlocks the audio engine once a user action has been done on the dom.
  5542. * This is helpful to resume play once browser policies have been satisfied.
  5543. */
  5544. AudioEngine.prototype.unlock = function () {
  5545. this._triggerRunningState();
  5546. };
  5547. AudioEngine.prototype._resumeAudioContext = function () {
  5548. var result;
  5549. if (this._audioContext.resume) {
  5550. result = this._audioContext.resume();
  5551. }
  5552. return result || Promise.resolve();
  5553. };
  5554. AudioEngine.prototype._initializeAudioContext = function () {
  5555. try {
  5556. if (this.canUseWebAudio) {
  5557. this._audioContext = new AudioContext();
  5558. // create a global volume gain node
  5559. this.masterGain = this._audioContext.createGain();
  5560. this.masterGain.gain.value = 1;
  5561. this.masterGain.connect(this._audioContext.destination);
  5562. this._audioContextInitialized = true;
  5563. if (this._audioContext.state === "running") {
  5564. // Do not wait for the promise to unlock.
  5565. this._triggerRunningState();
  5566. }
  5567. }
  5568. }
  5569. catch (e) {
  5570. this.canUseWebAudio = false;
  5571. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5572. }
  5573. };
  5574. AudioEngine.prototype._triggerRunningState = function () {
  5575. var _this = this;
  5576. if (this._tryToRun) {
  5577. return;
  5578. }
  5579. this._tryToRun = true;
  5580. this._resumeAudioContext()
  5581. .then(function () {
  5582. _this._tryToRun = false;
  5583. if (_this._muteButton) {
  5584. _this._hideMuteButton();
  5585. }
  5586. }).catch(function () {
  5587. _this._tryToRun = false;
  5588. _this.unlocked = false;
  5589. });
  5590. // Notify users that the audio stack is unlocked/unmuted
  5591. this.unlocked = true;
  5592. this.onAudioUnlockedObservable.notifyObservers(this);
  5593. };
  5594. AudioEngine.prototype._triggerSuspendedState = function () {
  5595. this.unlocked = false;
  5596. this.onAudioLockedObservable.notifyObservers(this);
  5597. this._displayMuteButton();
  5598. };
  5599. AudioEngine.prototype._displayMuteButton = function () {
  5600. var _this = this;
  5601. if (this.useCustomUnlockedButton) {
  5602. return;
  5603. }
  5604. this._muteButton = document.createElement("BUTTON");
  5605. this._muteButton.className = "babylonUnmuteIcon";
  5606. this._muteButton.id = "babylonUnmuteIconBtn";
  5607. this._muteButton.title = "Unmute";
  5608. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5609. var style = document.createElement('style');
  5610. style.appendChild(document.createTextNode(css));
  5611. document.getElementsByTagName('head')[0].appendChild(style);
  5612. document.body.appendChild(this._muteButton);
  5613. this._moveButtonToTopLeft();
  5614. this._muteButton.addEventListener('touchend', function () {
  5615. _this._triggerRunningState();
  5616. }, true);
  5617. this._muteButton.addEventListener('click', function () {
  5618. _this._triggerRunningState();
  5619. }, true);
  5620. window.addEventListener("resize", this._onResize);
  5621. };
  5622. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5623. if (this._hostElement && this._muteButton) {
  5624. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5625. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5626. }
  5627. };
  5628. AudioEngine.prototype._hideMuteButton = function () {
  5629. if (this._muteButton) {
  5630. document.body.removeChild(this._muteButton);
  5631. this._muteButton = null;
  5632. }
  5633. };
  5634. /**
  5635. * Destroy and release the resources associated with the audio ccontext.
  5636. */
  5637. AudioEngine.prototype.dispose = function () {
  5638. if (this.canUseWebAudio && this._audioContextInitialized) {
  5639. if (this._connectedAnalyser && this._audioContext) {
  5640. this._connectedAnalyser.stopDebugCanvas();
  5641. this._connectedAnalyser.dispose();
  5642. this.masterGain.disconnect();
  5643. this.masterGain.connect(this._audioContext.destination);
  5644. this._connectedAnalyser = null;
  5645. }
  5646. this.masterGain.gain.value = 1;
  5647. }
  5648. this.WarnedWebAudioUnsupported = false;
  5649. this._hideMuteButton();
  5650. window.removeEventListener("resize", this._onResize);
  5651. this.onAudioUnlockedObservable.clear();
  5652. this.onAudioLockedObservable.clear();
  5653. };
  5654. /**
  5655. * Gets the global volume sets on the master gain.
  5656. * @returns the global volume if set or -1 otherwise
  5657. */
  5658. AudioEngine.prototype.getGlobalVolume = function () {
  5659. if (this.canUseWebAudio && this._audioContextInitialized) {
  5660. return this.masterGain.gain.value;
  5661. }
  5662. else {
  5663. return -1;
  5664. }
  5665. };
  5666. /**
  5667. * Sets the global volume of your experience (sets on the master gain).
  5668. * @param newVolume Defines the new global volume of the application
  5669. */
  5670. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5671. if (this.canUseWebAudio && this._audioContextInitialized) {
  5672. this.masterGain.gain.value = newVolume;
  5673. }
  5674. };
  5675. /**
  5676. * Connect the audio engine to an audio analyser allowing some amazing
  5677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5679. * @param analyser The analyser to connect to the engine
  5680. */
  5681. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  5682. if (this._connectedAnalyser) {
  5683. this._connectedAnalyser.stopDebugCanvas();
  5684. }
  5685. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  5686. this._connectedAnalyser = analyser;
  5687. this.masterGain.disconnect();
  5688. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  5689. }
  5690. };
  5691. return AudioEngine;
  5692. }());
  5693. /***/ }),
  5694. /***/ "./Audio/audioSceneComponent.ts":
  5695. /*!**************************************!*\
  5696. !*** ./Audio/audioSceneComponent.ts ***!
  5697. \**************************************/
  5698. /*! exports provided: AudioSceneComponent */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  5703. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  5704. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  5705. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5707. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  5708. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  5709. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  5710. // Adds the parser to the scene parsers.
  5711. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  5712. // TODO: add sound
  5713. var loadedSounds = [];
  5714. var loadedSound;
  5715. container.sounds = container.sounds || [];
  5716. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  5717. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  5718. var parsedSound = parsedData.sounds[index];
  5719. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  5720. if (!parsedSound.url) {
  5721. parsedSound.url = parsedSound.name;
  5722. }
  5723. if (!loadedSounds[parsedSound.url]) {
  5724. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  5725. loadedSounds[parsedSound.url] = loadedSound;
  5726. container.sounds.push(loadedSound);
  5727. }
  5728. else {
  5729. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  5730. }
  5731. }
  5732. else {
  5733. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  5734. }
  5735. }
  5736. }
  5737. loadedSounds = [];
  5738. });
  5739. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  5740. get: function () {
  5741. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5742. if (!compo) {
  5743. compo = new AudioSceneComponent(this);
  5744. this._addComponent(compo);
  5745. }
  5746. if (!this._mainSoundTrack) {
  5747. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  5748. }
  5749. return this._mainSoundTrack;
  5750. },
  5751. enumerable: true,
  5752. configurable: true
  5753. });
  5754. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  5755. var index;
  5756. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  5757. if (this.mainSoundTrack.soundCollection[index].name === name) {
  5758. return this.mainSoundTrack.soundCollection[index];
  5759. }
  5760. }
  5761. if (this.soundTracks) {
  5762. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  5763. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  5764. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  5765. return this.soundTracks[sdIndex].soundCollection[index];
  5766. }
  5767. }
  5768. }
  5769. }
  5770. return null;
  5771. };
  5772. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  5773. get: function () {
  5774. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5775. if (!compo) {
  5776. compo = new AudioSceneComponent(this);
  5777. this._addComponent(compo);
  5778. }
  5779. return compo.audioEnabled;
  5780. },
  5781. set: function (value) {
  5782. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5783. if (!compo) {
  5784. compo = new AudioSceneComponent(this);
  5785. this._addComponent(compo);
  5786. }
  5787. if (value) {
  5788. compo.enableAudio();
  5789. }
  5790. else {
  5791. compo.disableAudio();
  5792. }
  5793. },
  5794. enumerable: true,
  5795. configurable: true
  5796. });
  5797. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  5798. get: function () {
  5799. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5800. if (!compo) {
  5801. compo = new AudioSceneComponent(this);
  5802. this._addComponent(compo);
  5803. }
  5804. return compo.headphone;
  5805. },
  5806. set: function (value) {
  5807. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5808. if (!compo) {
  5809. compo = new AudioSceneComponent(this);
  5810. this._addComponent(compo);
  5811. }
  5812. if (value) {
  5813. compo.switchAudioModeForHeadphones();
  5814. }
  5815. else {
  5816. compo.switchAudioModeForNormalSpeakers();
  5817. }
  5818. },
  5819. enumerable: true,
  5820. configurable: true
  5821. });
  5822. /**
  5823. * Defines the sound scene component responsible to manage any sounds
  5824. * in a given scene.
  5825. */
  5826. var AudioSceneComponent = /** @class */ (function () {
  5827. /**
  5828. * Creates a new instance of the component for the given scene
  5829. * @param scene Defines the scene to register the component in
  5830. */
  5831. function AudioSceneComponent(scene) {
  5832. /**
  5833. * The component name helpfull to identify the component in the list of scene components.
  5834. */
  5835. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  5836. this._audioEnabled = true;
  5837. this._headphone = false;
  5838. this.scene = scene;
  5839. scene.soundTracks = new Array();
  5840. scene.sounds = new Array();
  5841. }
  5842. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  5843. /**
  5844. * Gets whether audio is enabled or not.
  5845. * Please use related enable/disable method to switch state.
  5846. */
  5847. get: function () {
  5848. return this._audioEnabled;
  5849. },
  5850. enumerable: true,
  5851. configurable: true
  5852. });
  5853. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  5854. /**
  5855. * Gets whether audio is outputing to headphone or not.
  5856. * Please use the according Switch methods to change output.
  5857. */
  5858. get: function () {
  5859. return this._headphone;
  5860. },
  5861. enumerable: true,
  5862. configurable: true
  5863. });
  5864. /**
  5865. * Registers the component in a given scene
  5866. */
  5867. AudioSceneComponent.prototype.register = function () {
  5868. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  5869. };
  5870. /**
  5871. * Rebuilds the elements related to this component in case of
  5872. * context lost for instance.
  5873. */
  5874. AudioSceneComponent.prototype.rebuild = function () {
  5875. // Nothing to do here. (Not rendering related)
  5876. };
  5877. /**
  5878. * Serializes the component data to the specified json object
  5879. * @param serializationObject The object to serialize to
  5880. */
  5881. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  5882. serializationObject.sounds = [];
  5883. if (this.scene.soundTracks) {
  5884. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  5885. var soundtrack = this.scene.soundTracks[index];
  5886. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  5887. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  5888. }
  5889. }
  5890. }
  5891. };
  5892. /**
  5893. * Adds all the element from the container to the scene
  5894. * @param container the container holding the elements
  5895. */
  5896. AudioSceneComponent.prototype.addFromContainer = function (container) {
  5897. var _this = this;
  5898. if (!container.sounds) {
  5899. return;
  5900. }
  5901. container.sounds.forEach(function (sound) {
  5902. sound.play();
  5903. sound.autoplay = true;
  5904. _this.scene.mainSoundTrack.AddSound(sound);
  5905. });
  5906. };
  5907. /**
  5908. * Removes all the elements in the container from the scene
  5909. * @param container contains the elements to remove
  5910. */
  5911. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  5912. var _this = this;
  5913. if (!container.sounds) {
  5914. return;
  5915. }
  5916. container.sounds.forEach(function (sound) {
  5917. sound.stop();
  5918. sound.autoplay = false;
  5919. _this.scene.mainSoundTrack.RemoveSound(sound);
  5920. });
  5921. };
  5922. /**
  5923. * Disposes the component and the associated ressources.
  5924. */
  5925. AudioSceneComponent.prototype.dispose = function () {
  5926. var scene = this.scene;
  5927. if (scene._mainSoundTrack) {
  5928. scene.mainSoundTrack.dispose();
  5929. }
  5930. if (scene.soundTracks) {
  5931. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  5932. scene.soundTracks[scIndex].dispose();
  5933. }
  5934. }
  5935. };
  5936. /**
  5937. * Disables audio in the associated scene.
  5938. */
  5939. AudioSceneComponent.prototype.disableAudio = function () {
  5940. var scene = this.scene;
  5941. this._audioEnabled = false;
  5942. var i;
  5943. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5944. scene.mainSoundTrack.soundCollection[i].pause();
  5945. }
  5946. if (scene.soundTracks) {
  5947. for (i = 0; i < scene.soundTracks.length; i++) {
  5948. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5949. scene.soundTracks[i].soundCollection[j].pause();
  5950. }
  5951. }
  5952. }
  5953. };
  5954. /**
  5955. * Enables audio in the associated scene.
  5956. */
  5957. AudioSceneComponent.prototype.enableAudio = function () {
  5958. var scene = this.scene;
  5959. this._audioEnabled = true;
  5960. var i;
  5961. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5962. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  5963. scene.mainSoundTrack.soundCollection[i].play();
  5964. }
  5965. }
  5966. if (scene.soundTracks) {
  5967. for (i = 0; i < scene.soundTracks.length; i++) {
  5968. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5969. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  5970. scene.soundTracks[i].soundCollection[j].play();
  5971. }
  5972. }
  5973. }
  5974. }
  5975. };
  5976. /**
  5977. * Switch audio to headphone output.
  5978. */
  5979. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  5980. var scene = this.scene;
  5981. this._headphone = true;
  5982. scene.mainSoundTrack.switchPanningModelToHRTF();
  5983. if (scene.soundTracks) {
  5984. for (var i = 0; i < scene.soundTracks.length; i++) {
  5985. scene.soundTracks[i].switchPanningModelToHRTF();
  5986. }
  5987. }
  5988. };
  5989. /**
  5990. * Switch audio to normal speakers.
  5991. */
  5992. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  5993. var scene = this.scene;
  5994. this._headphone = false;
  5995. scene.mainSoundTrack.switchPanningModelToEqualPower();
  5996. if (scene.soundTracks) {
  5997. for (var i = 0; i < scene.soundTracks.length; i++) {
  5998. scene.soundTracks[i].switchPanningModelToEqualPower();
  5999. }
  6000. }
  6001. };
  6002. AudioSceneComponent.prototype._afterRender = function () {
  6003. var scene = this.scene;
  6004. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6005. return;
  6006. }
  6007. var listeningCamera;
  6008. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6009. if (scene.activeCameras.length > 0) {
  6010. listeningCamera = scene.activeCameras[0];
  6011. }
  6012. else {
  6013. listeningCamera = scene.activeCamera;
  6014. }
  6015. if (listeningCamera && audioEngine.audioContext) {
  6016. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6017. // for VR cameras
  6018. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6019. listeningCamera = listeningCamera.rigCameras[0];
  6020. }
  6021. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6022. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6023. cameraDirection.normalize();
  6024. // To avoid some errors on GearVR
  6025. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6026. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6027. }
  6028. var i;
  6029. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6030. var sound = scene.mainSoundTrack.soundCollection[i];
  6031. if (sound.useCustomAttenuation) {
  6032. sound.updateDistanceFromListener();
  6033. }
  6034. }
  6035. if (scene.soundTracks) {
  6036. for (i = 0; i < scene.soundTracks.length; i++) {
  6037. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6038. sound = scene.soundTracks[i].soundCollection[j];
  6039. if (sound.useCustomAttenuation) {
  6040. sound.updateDistanceFromListener();
  6041. }
  6042. }
  6043. }
  6044. }
  6045. }
  6046. };
  6047. return AudioSceneComponent;
  6048. }());
  6049. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6050. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6051. if (!compo) {
  6052. compo = new AudioSceneComponent(scene);
  6053. scene._addComponent(compo);
  6054. }
  6055. };
  6056. /***/ }),
  6057. /***/ "./Audio/index.ts":
  6058. /*!************************!*\
  6059. !*** ./Audio/index.ts ***!
  6060. \************************/
  6061. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6063. "use strict";
  6064. __webpack_require__.r(__webpack_exports__);
  6065. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6067. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6069. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6071. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6073. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6075. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6077. /***/ }),
  6078. /***/ "./Audio/sound.ts":
  6079. /*!************************!*\
  6080. !*** ./Audio/sound.ts ***!
  6081. \************************/
  6082. /*! exports provided: Sound */
  6083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6084. "use strict";
  6085. __webpack_require__.r(__webpack_exports__);
  6086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6088. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6090. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6091. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6092. /**
  6093. * Defines a sound that can be played in the application.
  6094. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6096. */
  6097. var Sound = /** @class */ (function () {
  6098. /**
  6099. * Create a sound and attach it to a scene
  6100. * @param name Name of your sound
  6101. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6102. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6103. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6104. */
  6105. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6106. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6107. var _this = this;
  6108. /**
  6109. * Does the sound autoplay once loaded.
  6110. */
  6111. this.autoplay = false;
  6112. /**
  6113. * Does the sound loop after it finishes playing once.
  6114. */
  6115. this.loop = false;
  6116. /**
  6117. * Does the sound use a custom attenuation curve to simulate the falloff
  6118. * happening when the source gets further away from the camera.
  6119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6120. */
  6121. this.useCustomAttenuation = false;
  6122. /**
  6123. * Is this sound currently played.
  6124. */
  6125. this.isPlaying = false;
  6126. /**
  6127. * Is this sound currently paused.
  6128. */
  6129. this.isPaused = false;
  6130. /**
  6131. * Does this sound enables spatial sound.
  6132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6133. */
  6134. this.spatialSound = false;
  6135. /**
  6136. * Define the reference distance the sound should be heard perfectly.
  6137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6138. */
  6139. this.refDistance = 1;
  6140. /**
  6141. * Define the roll off factor of spatial sounds.
  6142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6143. */
  6144. this.rolloffFactor = 1;
  6145. /**
  6146. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6148. */
  6149. this.maxDistance = 100;
  6150. /**
  6151. * Define the distance attenuation model the sound will follow.
  6152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6153. */
  6154. this.distanceModel = "linear";
  6155. /**
  6156. * Observable event when the current playing sound finishes.
  6157. */
  6158. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6159. this._panningModel = "equalpower";
  6160. this._playbackRate = 1;
  6161. this._streaming = false;
  6162. this._startTime = 0;
  6163. this._startOffset = 0;
  6164. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6165. /** @hidden */
  6166. this._positionInEmitterSpace = false;
  6167. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6168. this._volume = 1;
  6169. this._isReadyToPlay = false;
  6170. this._isDirectional = false;
  6171. // Used if you'd like to create a directional sound.
  6172. // If not set, the sound will be omnidirectional
  6173. this._coneInnerAngle = 360;
  6174. this._coneOuterAngle = 360;
  6175. this._coneOuterGain = 0;
  6176. this._isOutputConnected = false;
  6177. this._urlType = "Unknown";
  6178. this.name = name;
  6179. this._scene = scene;
  6180. Sound._SceneComponentInitialization(scene);
  6181. this._readyToPlayCallback = readyToPlayCallback;
  6182. // Default custom attenuation function is a linear attenuation
  6183. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6184. if (currentDistance < maxDistance) {
  6185. return currentVolume * (1 - currentDistance / maxDistance);
  6186. }
  6187. else {
  6188. return 0;
  6189. }
  6190. };
  6191. if (options) {
  6192. this.autoplay = options.autoplay || false;
  6193. this.loop = options.loop || false;
  6194. // if volume === 0, we need another way to check this option
  6195. if (options.volume !== undefined) {
  6196. this._volume = options.volume;
  6197. }
  6198. this.spatialSound = options.spatialSound || false;
  6199. this.maxDistance = options.maxDistance || 100;
  6200. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6201. this.rolloffFactor = options.rolloffFactor || 1;
  6202. this.refDistance = options.refDistance || 1;
  6203. this.distanceModel = options.distanceModel || "linear";
  6204. this._playbackRate = options.playbackRate || 1;
  6205. this._streaming = options.streaming || false;
  6206. }
  6207. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6208. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6209. this._soundGain.gain.value = this._volume;
  6210. this._inputAudioNode = this._soundGain;
  6211. this._outputAudioNode = this._soundGain;
  6212. if (this.spatialSound) {
  6213. this._createSpatialParameters();
  6214. }
  6215. this._scene.mainSoundTrack.AddSound(this);
  6216. var validParameter = true;
  6217. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6218. if (urlOrArrayBuffer) {
  6219. try {
  6220. if (typeof (urlOrArrayBuffer) === "string") {
  6221. this._urlType = "String";
  6222. }
  6223. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6224. this._urlType = "ArrayBuffer";
  6225. }
  6226. else if (urlOrArrayBuffer instanceof MediaStream) {
  6227. this._urlType = "MediaStream";
  6228. }
  6229. else if (Array.isArray(urlOrArrayBuffer)) {
  6230. this._urlType = "Array";
  6231. }
  6232. var urls = [];
  6233. var codecSupportedFound = false;
  6234. switch (this._urlType) {
  6235. case "MediaStream":
  6236. this._streaming = true;
  6237. this._isReadyToPlay = true;
  6238. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6239. if (this.autoplay) {
  6240. this.play();
  6241. }
  6242. if (this._readyToPlayCallback) {
  6243. this._readyToPlayCallback();
  6244. }
  6245. break;
  6246. case "ArrayBuffer":
  6247. if (urlOrArrayBuffer.byteLength > 0) {
  6248. codecSupportedFound = true;
  6249. this._soundLoaded(urlOrArrayBuffer);
  6250. }
  6251. break;
  6252. case "String":
  6253. urls.push(urlOrArrayBuffer);
  6254. case "Array":
  6255. if (urls.length === 0) {
  6256. urls = urlOrArrayBuffer;
  6257. }
  6258. // If we found a supported format, we load it immediately and stop the loop
  6259. for (var i = 0; i < urls.length; i++) {
  6260. var url = urls[i];
  6261. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6262. codecSupportedFound = true;
  6263. }
  6264. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6265. codecSupportedFound = true;
  6266. }
  6267. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6268. codecSupportedFound = true;
  6269. }
  6270. if (url.indexOf("blob:") !== -1) {
  6271. codecSupportedFound = true;
  6272. }
  6273. if (codecSupportedFound) {
  6274. // Loading sound using XHR2
  6275. if (!this._streaming) {
  6276. this._scene._loadFile(url, function (data) {
  6277. _this._soundLoaded(data);
  6278. }, undefined, true, true, function (exception) {
  6279. if (exception) {
  6280. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6281. }
  6282. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6283. _this._scene.mainSoundTrack.RemoveSound(_this);
  6284. });
  6285. }
  6286. // Streaming sound using HTML5 Audio tag
  6287. else {
  6288. this._htmlAudioElement = new Audio(url);
  6289. this._htmlAudioElement.controls = false;
  6290. this._htmlAudioElement.loop = this.loop;
  6291. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6292. this._htmlAudioElement.preload = "auto";
  6293. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6294. _this._isReadyToPlay = true;
  6295. if (_this.autoplay) {
  6296. _this.play();
  6297. }
  6298. if (_this._readyToPlayCallback) {
  6299. _this._readyToPlayCallback();
  6300. }
  6301. });
  6302. document.body.appendChild(this._htmlAudioElement);
  6303. this._htmlAudioElement.load();
  6304. }
  6305. break;
  6306. }
  6307. }
  6308. break;
  6309. default:
  6310. validParameter = false;
  6311. break;
  6312. }
  6313. if (!validParameter) {
  6314. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6315. }
  6316. else {
  6317. if (!codecSupportedFound) {
  6318. this._isReadyToPlay = true;
  6319. // Simulating a ready to play event to avoid breaking code path
  6320. if (this._readyToPlayCallback) {
  6321. window.setTimeout(function () {
  6322. if (_this._readyToPlayCallback) {
  6323. _this._readyToPlayCallback();
  6324. }
  6325. }, 1000);
  6326. }
  6327. }
  6328. }
  6329. }
  6330. catch (ex) {
  6331. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6332. this._scene.mainSoundTrack.RemoveSound(this);
  6333. }
  6334. }
  6335. }
  6336. else {
  6337. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6338. this._scene.mainSoundTrack.AddSound(this);
  6339. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6340. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6341. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6342. }
  6343. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6344. if (this._readyToPlayCallback) {
  6345. window.setTimeout(function () {
  6346. if (_this._readyToPlayCallback) {
  6347. _this._readyToPlayCallback();
  6348. }
  6349. }, 1000);
  6350. }
  6351. }
  6352. }
  6353. /**
  6354. * Release the sound and its associated resources
  6355. */
  6356. Sound.prototype.dispose = function () {
  6357. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6358. if (this.isPlaying) {
  6359. this.stop();
  6360. }
  6361. this._isReadyToPlay = false;
  6362. if (this.soundTrackId === -1) {
  6363. this._scene.mainSoundTrack.RemoveSound(this);
  6364. }
  6365. else if (this._scene.soundTracks) {
  6366. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6367. }
  6368. if (this._soundGain) {
  6369. this._soundGain.disconnect();
  6370. this._soundGain = null;
  6371. }
  6372. if (this._soundPanner) {
  6373. this._soundPanner.disconnect();
  6374. this._soundPanner = null;
  6375. }
  6376. if (this._soundSource) {
  6377. this._soundSource.disconnect();
  6378. this._soundSource = null;
  6379. }
  6380. this._audioBuffer = null;
  6381. if (this._htmlAudioElement) {
  6382. this._htmlAudioElement.pause();
  6383. this._htmlAudioElement.src = "";
  6384. document.body.removeChild(this._htmlAudioElement);
  6385. }
  6386. if (this._streamingSource) {
  6387. this._streamingSource.disconnect();
  6388. }
  6389. if (this._connectedTransformNode && this._registerFunc) {
  6390. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6391. this._connectedTransformNode = null;
  6392. }
  6393. }
  6394. };
  6395. /**
  6396. * Gets if the sounds is ready to be played or not.
  6397. * @returns true if ready, otherwise false
  6398. */
  6399. Sound.prototype.isReady = function () {
  6400. return this._isReadyToPlay;
  6401. };
  6402. Sound.prototype._soundLoaded = function (audioData) {
  6403. var _this = this;
  6404. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6405. return;
  6406. }
  6407. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6408. _this._audioBuffer = buffer;
  6409. _this._isReadyToPlay = true;
  6410. if (_this.autoplay) {
  6411. _this.play();
  6412. }
  6413. if (_this._readyToPlayCallback) {
  6414. _this._readyToPlayCallback();
  6415. }
  6416. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6417. };
  6418. /**
  6419. * Sets the data of the sound from an audiobuffer
  6420. * @param audioBuffer The audioBuffer containing the data
  6421. */
  6422. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6423. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6424. this._audioBuffer = audioBuffer;
  6425. this._isReadyToPlay = true;
  6426. }
  6427. };
  6428. /**
  6429. * Updates the current sounds options such as maxdistance, loop...
  6430. * @param options A JSON object containing values named as the object properties
  6431. */
  6432. Sound.prototype.updateOptions = function (options) {
  6433. if (options) {
  6434. this.loop = options.loop || this.loop;
  6435. this.maxDistance = options.maxDistance || this.maxDistance;
  6436. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6437. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6438. this.refDistance = options.refDistance || this.refDistance;
  6439. this.distanceModel = options.distanceModel || this.distanceModel;
  6440. this._playbackRate = options.playbackRate || this._playbackRate;
  6441. this._updateSpatialParameters();
  6442. if (this.isPlaying) {
  6443. if (this._streaming && this._htmlAudioElement) {
  6444. this._htmlAudioElement.playbackRate = this._playbackRate;
  6445. }
  6446. else {
  6447. if (this._soundSource) {
  6448. this._soundSource.playbackRate.value = this._playbackRate;
  6449. }
  6450. }
  6451. }
  6452. }
  6453. };
  6454. Sound.prototype._createSpatialParameters = function () {
  6455. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6456. if (this._scene.headphone) {
  6457. this._panningModel = "HRTF";
  6458. }
  6459. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6460. this._updateSpatialParameters();
  6461. this._soundPanner.connect(this._outputAudioNode);
  6462. this._inputAudioNode = this._soundPanner;
  6463. }
  6464. };
  6465. Sound.prototype._updateSpatialParameters = function () {
  6466. if (this.spatialSound && this._soundPanner) {
  6467. if (this.useCustomAttenuation) {
  6468. // Tricks to disable in a way embedded Web Audio attenuation
  6469. this._soundPanner.distanceModel = "linear";
  6470. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6471. this._soundPanner.refDistance = 1;
  6472. this._soundPanner.rolloffFactor = 1;
  6473. this._soundPanner.panningModel = this._panningModel;
  6474. }
  6475. else {
  6476. this._soundPanner.distanceModel = this.distanceModel;
  6477. this._soundPanner.maxDistance = this.maxDistance;
  6478. this._soundPanner.refDistance = this.refDistance;
  6479. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6480. this._soundPanner.panningModel = this._panningModel;
  6481. }
  6482. }
  6483. };
  6484. /**
  6485. * Switch the panning model to HRTF:
  6486. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6488. */
  6489. Sound.prototype.switchPanningModelToHRTF = function () {
  6490. this._panningModel = "HRTF";
  6491. this._switchPanningModel();
  6492. };
  6493. /**
  6494. * Switch the panning model to Equal Power:
  6495. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6497. */
  6498. Sound.prototype.switchPanningModelToEqualPower = function () {
  6499. this._panningModel = "equalpower";
  6500. this._switchPanningModel();
  6501. };
  6502. Sound.prototype._switchPanningModel = function () {
  6503. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6504. this._soundPanner.panningModel = this._panningModel;
  6505. }
  6506. };
  6507. /**
  6508. * Connect this sound to a sound track audio node like gain...
  6509. * @param soundTrackAudioNode the sound track audio node to connect to
  6510. */
  6511. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6512. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6513. if (this._isOutputConnected) {
  6514. this._outputAudioNode.disconnect();
  6515. }
  6516. this._outputAudioNode.connect(soundTrackAudioNode);
  6517. this._isOutputConnected = true;
  6518. }
  6519. };
  6520. /**
  6521. * Transform this sound into a directional source
  6522. * @param coneInnerAngle Size of the inner cone in degree
  6523. * @param coneOuterAngle Size of the outer cone in degree
  6524. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6525. */
  6526. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6527. if (coneOuterAngle < coneInnerAngle) {
  6528. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6529. return;
  6530. }
  6531. this._coneInnerAngle = coneInnerAngle;
  6532. this._coneOuterAngle = coneOuterAngle;
  6533. this._coneOuterGain = coneOuterGain;
  6534. this._isDirectional = true;
  6535. if (this.isPlaying && this.loop) {
  6536. this.stop();
  6537. this.play();
  6538. }
  6539. };
  6540. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6541. /**
  6542. * Gets or sets the inner angle for the directional cone.
  6543. */
  6544. get: function () {
  6545. return this._coneInnerAngle;
  6546. },
  6547. /**
  6548. * Gets or sets the inner angle for the directional cone.
  6549. */
  6550. set: function (value) {
  6551. if (value != this._coneInnerAngle) {
  6552. if (this._coneOuterAngle < value) {
  6553. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6554. return;
  6555. }
  6556. this._coneInnerAngle = value;
  6557. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6558. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6559. }
  6560. }
  6561. },
  6562. enumerable: true,
  6563. configurable: true
  6564. });
  6565. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6566. /**
  6567. * Gets or sets the outer angle for the directional cone.
  6568. */
  6569. get: function () {
  6570. return this._coneOuterAngle;
  6571. },
  6572. /**
  6573. * Gets or sets the outer angle for the directional cone.
  6574. */
  6575. set: function (value) {
  6576. if (value != this._coneOuterAngle) {
  6577. if (value < this._coneInnerAngle) {
  6578. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6579. return;
  6580. }
  6581. this._coneOuterAngle = value;
  6582. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6583. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6584. }
  6585. }
  6586. },
  6587. enumerable: true,
  6588. configurable: true
  6589. });
  6590. /**
  6591. * Sets the position of the emitter if spatial sound is enabled
  6592. * @param newPosition Defines the new posisiton
  6593. */
  6594. Sound.prototype.setPosition = function (newPosition) {
  6595. this._position = newPosition;
  6596. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6597. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6598. }
  6599. };
  6600. /**
  6601. * Sets the local direction of the emitter if spatial sound is enabled
  6602. * @param newLocalDirection Defines the new local direction
  6603. */
  6604. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6605. this._localDirection = newLocalDirection;
  6606. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6607. this._updateDirection();
  6608. }
  6609. };
  6610. Sound.prototype._updateDirection = function () {
  6611. if (!this._connectedTransformNode || !this._soundPanner) {
  6612. return;
  6613. }
  6614. var mat = this._connectedTransformNode.getWorldMatrix();
  6615. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6616. direction.normalize();
  6617. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6618. };
  6619. /** @hidden */
  6620. Sound.prototype.updateDistanceFromListener = function () {
  6621. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6622. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6623. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6624. }
  6625. };
  6626. /**
  6627. * Sets a new custom attenuation function for the sound.
  6628. * @param callback Defines the function used for the attenuation
  6629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6630. */
  6631. Sound.prototype.setAttenuationFunction = function (callback) {
  6632. this._customAttenuationFunction = callback;
  6633. };
  6634. /**
  6635. * Play the sound
  6636. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6637. * @param offset (optional) Start the sound setting it at a specific time
  6638. */
  6639. Sound.prototype.play = function (time, offset) {
  6640. var _this = this;
  6641. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6642. try {
  6643. if (this._startOffset < 0) {
  6644. time = -this._startOffset;
  6645. this._startOffset = 0;
  6646. }
  6647. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6648. if (!this._soundSource || !this._streamingSource) {
  6649. if (this.spatialSound && this._soundPanner) {
  6650. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6651. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6652. }
  6653. if (this._isDirectional) {
  6654. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6655. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6656. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6657. if (this._connectedTransformNode) {
  6658. this._updateDirection();
  6659. }
  6660. else {
  6661. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6662. }
  6663. }
  6664. }
  6665. }
  6666. if (this._streaming) {
  6667. if (!this._streamingSource) {
  6668. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6669. this._htmlAudioElement.onended = function () { _this._onended(); };
  6670. this._htmlAudioElement.playbackRate = this._playbackRate;
  6671. }
  6672. this._streamingSource.disconnect();
  6673. this._streamingSource.connect(this._inputAudioNode);
  6674. if (this._htmlAudioElement) {
  6675. // required to manage properly the new suspended default state of Chrome
  6676. // When the option 'streaming: true' is used, we need first to wait for
  6677. // the audio engine to be unlocked by a user gesture before trying to play
  6678. // an HTML Audio elememt
  6679. var tryToPlay = function () {
  6680. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  6681. var playPromise = _this._htmlAudioElement.play();
  6682. // In browsers that don’t yet support this functionality,
  6683. // playPromise won’t be defined.
  6684. if (playPromise !== undefined) {
  6685. playPromise.catch(function (error) {
  6686. // Automatic playback failed.
  6687. // Waiting for the audio engine to be unlocked by user click on unmute
  6688. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  6689. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6690. });
  6691. }
  6692. }
  6693. else {
  6694. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6695. }
  6696. };
  6697. tryToPlay();
  6698. }
  6699. }
  6700. else {
  6701. this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  6702. this._soundSource.buffer = this._audioBuffer;
  6703. this._soundSource.connect(this._inputAudioNode);
  6704. this._soundSource.loop = this.loop;
  6705. this._soundSource.playbackRate.value = this._playbackRate;
  6706. this._soundSource.onended = function () { _this._onended(); };
  6707. if (this._soundSource.buffer) {
  6708. this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : offset ? offset : 0);
  6709. }
  6710. }
  6711. this._startTime = startTime;
  6712. this.isPlaying = true;
  6713. this.isPaused = false;
  6714. }
  6715. catch (ex) {
  6716. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  6717. }
  6718. }
  6719. };
  6720. Sound.prototype._onended = function () {
  6721. this.isPlaying = false;
  6722. if (this.onended) {
  6723. this.onended();
  6724. }
  6725. this.onEndedObservable.notifyObservers(this);
  6726. };
  6727. /**
  6728. * Stop the sound
  6729. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  6730. */
  6731. Sound.prototype.stop = function (time) {
  6732. if (this.isPlaying) {
  6733. if (this._streaming) {
  6734. if (this._htmlAudioElement) {
  6735. this._htmlAudioElement.pause();
  6736. // Test needed for Firefox or it will generate an Invalid State Error
  6737. if (this._htmlAudioElement.currentTime > 0) {
  6738. this._htmlAudioElement.currentTime = 0;
  6739. }
  6740. }
  6741. else {
  6742. this._streamingSource.disconnect();
  6743. }
  6744. }
  6745. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  6746. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6747. this._soundSource.stop(stopTime);
  6748. this._soundSource.onended = function () { };
  6749. if (!this.isPaused) {
  6750. this._startOffset = 0;
  6751. }
  6752. }
  6753. this.isPlaying = false;
  6754. }
  6755. };
  6756. /**
  6757. * Put the sound in pause
  6758. */
  6759. Sound.prototype.pause = function () {
  6760. if (this.isPlaying) {
  6761. this.isPaused = true;
  6762. if (this._streaming) {
  6763. if (this._htmlAudioElement) {
  6764. this._htmlAudioElement.pause();
  6765. }
  6766. else {
  6767. this._streamingSource.disconnect();
  6768. }
  6769. }
  6770. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6771. this.stop(0);
  6772. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  6773. }
  6774. }
  6775. };
  6776. /**
  6777. * Sets a dedicated volume for this sounds
  6778. * @param newVolume Define the new volume of the sound
  6779. * @param time Define in how long the sound should be at this value
  6780. */
  6781. Sound.prototype.setVolume = function (newVolume, time) {
  6782. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  6783. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6784. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6785. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6786. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  6787. }
  6788. else {
  6789. this._soundGain.gain.value = newVolume;
  6790. }
  6791. }
  6792. this._volume = newVolume;
  6793. };
  6794. /**
  6795. * Set the sound play back rate
  6796. * @param newPlaybackRate Define the playback rate the sound should be played at
  6797. */
  6798. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  6799. this._playbackRate = newPlaybackRate;
  6800. if (this.isPlaying) {
  6801. if (this._streaming && this._htmlAudioElement) {
  6802. this._htmlAudioElement.playbackRate = this._playbackRate;
  6803. }
  6804. else if (this._soundSource) {
  6805. this._soundSource.playbackRate.value = this._playbackRate;
  6806. }
  6807. }
  6808. };
  6809. /**
  6810. * Gets the volume of the sound.
  6811. * @returns the volume of the sound
  6812. */
  6813. Sound.prototype.getVolume = function () {
  6814. return this._volume;
  6815. };
  6816. /**
  6817. * Attach the sound to a dedicated mesh
  6818. * @param transformNode The transform node to connect the sound with
  6819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6820. */
  6821. Sound.prototype.attachToMesh = function (transformNode) {
  6822. var _this = this;
  6823. if (this._connectedTransformNode && this._registerFunc) {
  6824. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6825. this._registerFunc = null;
  6826. }
  6827. this._connectedTransformNode = transformNode;
  6828. if (!this.spatialSound) {
  6829. this.spatialSound = true;
  6830. this._createSpatialParameters();
  6831. if (this.isPlaying && this.loop) {
  6832. this.stop();
  6833. this.play();
  6834. }
  6835. }
  6836. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  6837. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  6838. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  6839. };
  6840. /**
  6841. * Detach the sound from the previously attached mesh
  6842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6843. */
  6844. Sound.prototype.detachFromMesh = function () {
  6845. if (this._connectedTransformNode && this._registerFunc) {
  6846. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6847. this._registerFunc = null;
  6848. this._connectedTransformNode = null;
  6849. }
  6850. };
  6851. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  6852. if (!node.getBoundingInfo) {
  6853. return;
  6854. }
  6855. var mesh = node;
  6856. if (this._positionInEmitterSpace) {
  6857. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  6858. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  6859. }
  6860. else {
  6861. var boundingInfo = mesh.getBoundingInfo();
  6862. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  6863. }
  6864. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  6865. this._updateDirection();
  6866. }
  6867. };
  6868. /**
  6869. * Clone the current sound in the scene.
  6870. * @returns the new sound clone
  6871. */
  6872. Sound.prototype.clone = function () {
  6873. var _this = this;
  6874. if (!this._streaming) {
  6875. var setBufferAndRun = function () {
  6876. if (_this._isReadyToPlay) {
  6877. clonedSound._audioBuffer = _this.getAudioBuffer();
  6878. clonedSound._isReadyToPlay = true;
  6879. if (clonedSound.autoplay) {
  6880. clonedSound.play();
  6881. }
  6882. }
  6883. else {
  6884. window.setTimeout(setBufferAndRun, 300);
  6885. }
  6886. };
  6887. var currentOptions = {
  6888. autoplay: this.autoplay, loop: this.loop,
  6889. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  6890. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  6891. refDistance: this.refDistance, distanceModel: this.distanceModel
  6892. };
  6893. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  6894. if (this.useCustomAttenuation) {
  6895. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  6896. }
  6897. clonedSound.setPosition(this._position);
  6898. clonedSound.setPlaybackRate(this._playbackRate);
  6899. setBufferAndRun();
  6900. return clonedSound;
  6901. }
  6902. // Can't clone a streaming sound
  6903. else {
  6904. return null;
  6905. }
  6906. };
  6907. /**
  6908. * Gets the current underlying audio buffer containing the data
  6909. * @returns the audio buffer
  6910. */
  6911. Sound.prototype.getAudioBuffer = function () {
  6912. return this._audioBuffer;
  6913. };
  6914. /**
  6915. * Serializes the Sound in a JSON representation
  6916. * @returns the JSON representation of the sound
  6917. */
  6918. Sound.prototype.serialize = function () {
  6919. var serializationObject = {
  6920. name: this.name,
  6921. url: this.name,
  6922. autoplay: this.autoplay,
  6923. loop: this.loop,
  6924. volume: this._volume,
  6925. spatialSound: this.spatialSound,
  6926. maxDistance: this.maxDistance,
  6927. rolloffFactor: this.rolloffFactor,
  6928. refDistance: this.refDistance,
  6929. distanceModel: this.distanceModel,
  6930. playbackRate: this._playbackRate,
  6931. panningModel: this._panningModel,
  6932. soundTrackId: this.soundTrackId
  6933. };
  6934. if (this.spatialSound) {
  6935. if (this._connectedTransformNode) {
  6936. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  6937. }
  6938. serializationObject.position = this._position.asArray();
  6939. serializationObject.refDistance = this.refDistance;
  6940. serializationObject.distanceModel = this.distanceModel;
  6941. serializationObject.isDirectional = this._isDirectional;
  6942. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  6943. serializationObject.coneInnerAngle = this._coneInnerAngle;
  6944. serializationObject.coneOuterAngle = this._coneOuterAngle;
  6945. serializationObject.coneOuterGain = this._coneOuterGain;
  6946. }
  6947. return serializationObject;
  6948. };
  6949. /**
  6950. * Parse a JSON representation of a sound to innstantiate in a given scene
  6951. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  6952. * @param scene Define the scene the new parsed sound should be created in
  6953. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  6954. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  6955. * @returns the newly parsed sound
  6956. */
  6957. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  6958. var soundName = parsedSound.name;
  6959. var soundUrl;
  6960. if (parsedSound.url) {
  6961. soundUrl = rootUrl + parsedSound.url;
  6962. }
  6963. else {
  6964. soundUrl = rootUrl + soundName;
  6965. }
  6966. var options = {
  6967. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  6968. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  6969. rolloffFactor: parsedSound.rolloffFactor,
  6970. refDistance: parsedSound.refDistance,
  6971. distanceModel: parsedSound.distanceModel,
  6972. playbackRate: parsedSound.playbackRate
  6973. };
  6974. var newSound;
  6975. if (!sourceSound) {
  6976. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  6977. scene._addPendingData(newSound);
  6978. }
  6979. else {
  6980. var setBufferAndRun = function () {
  6981. if (sourceSound._isReadyToPlay) {
  6982. newSound._audioBuffer = sourceSound.getAudioBuffer();
  6983. newSound._isReadyToPlay = true;
  6984. if (newSound.autoplay) {
  6985. newSound.play();
  6986. }
  6987. }
  6988. else {
  6989. window.setTimeout(setBufferAndRun, 300);
  6990. }
  6991. };
  6992. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  6993. setBufferAndRun();
  6994. }
  6995. if (parsedSound.position) {
  6996. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  6997. newSound.setPosition(soundPosition);
  6998. }
  6999. if (parsedSound.isDirectional) {
  7000. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7001. if (parsedSound.localDirectionToMesh) {
  7002. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7003. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7004. }
  7005. }
  7006. if (parsedSound.connectedMeshId) {
  7007. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7008. if (connectedMesh) {
  7009. newSound.attachToMesh(connectedMesh);
  7010. }
  7011. }
  7012. return newSound;
  7013. };
  7014. /** @hidden */
  7015. Sound._SceneComponentInitialization = function (_) {
  7016. throw "Import AudioSceneComponent before creating sound.";
  7017. };
  7018. return Sound;
  7019. }());
  7020. /***/ }),
  7021. /***/ "./Audio/soundTrack.ts":
  7022. /*!*****************************!*\
  7023. !*** ./Audio/soundTrack.ts ***!
  7024. \*****************************/
  7025. /*! exports provided: SoundTrack */
  7026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7027. "use strict";
  7028. __webpack_require__.r(__webpack_exports__);
  7029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7030. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7031. /**
  7032. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7033. * It will be also used in a future release to apply effects on a specific track.
  7034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7035. */
  7036. var SoundTrack = /** @class */ (function () {
  7037. /**
  7038. * Creates a new sound track.
  7039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7040. * @param scene Define the scene the sound track belongs to
  7041. * @param options
  7042. */
  7043. function SoundTrack(scene, options) {
  7044. if (options === void 0) { options = {}; }
  7045. /**
  7046. * The unique identifier of the sound track in the scene.
  7047. */
  7048. this.id = -1;
  7049. this._isMainTrack = false;
  7050. this._isInitialized = false;
  7051. this._scene = scene;
  7052. this.soundCollection = new Array();
  7053. this._options = options;
  7054. if (!this._isMainTrack && this._scene.soundTracks) {
  7055. this._scene.soundTracks.push(this);
  7056. this.id = this._scene.soundTracks.length - 1;
  7057. }
  7058. }
  7059. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7060. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7061. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7062. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7063. if (this._options) {
  7064. if (this._options.volume) {
  7065. this._outputAudioNode.gain.value = this._options.volume;
  7066. }
  7067. if (this._options.mainTrack) {
  7068. this._isMainTrack = this._options.mainTrack;
  7069. }
  7070. }
  7071. this._isInitialized = true;
  7072. }
  7073. };
  7074. /**
  7075. * Release the sound track and its associated resources
  7076. */
  7077. SoundTrack.prototype.dispose = function () {
  7078. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7079. if (this._connectedAnalyser) {
  7080. this._connectedAnalyser.stopDebugCanvas();
  7081. }
  7082. while (this.soundCollection.length) {
  7083. this.soundCollection[0].dispose();
  7084. }
  7085. if (this._outputAudioNode) {
  7086. this._outputAudioNode.disconnect();
  7087. }
  7088. this._outputAudioNode = null;
  7089. }
  7090. };
  7091. /**
  7092. * Adds a sound to this sound track
  7093. * @param sound define the cound to add
  7094. * @ignoreNaming
  7095. */
  7096. SoundTrack.prototype.AddSound = function (sound) {
  7097. if (!this._isInitialized) {
  7098. this._initializeSoundTrackAudioGraph();
  7099. }
  7100. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7101. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7102. }
  7103. if (sound.soundTrackId) {
  7104. if (sound.soundTrackId === -1) {
  7105. this._scene.mainSoundTrack.RemoveSound(sound);
  7106. }
  7107. else if (this._scene.soundTracks) {
  7108. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7109. }
  7110. }
  7111. this.soundCollection.push(sound);
  7112. sound.soundTrackId = this.id;
  7113. };
  7114. /**
  7115. * Removes a sound to this sound track
  7116. * @param sound define the cound to remove
  7117. * @ignoreNaming
  7118. */
  7119. SoundTrack.prototype.RemoveSound = function (sound) {
  7120. var index = this.soundCollection.indexOf(sound);
  7121. if (index !== -1) {
  7122. this.soundCollection.splice(index, 1);
  7123. }
  7124. };
  7125. /**
  7126. * Set a global volume for the full sound track.
  7127. * @param newVolume Define the new volume of the sound track
  7128. */
  7129. SoundTrack.prototype.setVolume = function (newVolume) {
  7130. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7131. this._outputAudioNode.gain.value = newVolume;
  7132. }
  7133. };
  7134. /**
  7135. * Switch the panning model to HRTF:
  7136. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7138. */
  7139. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7140. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7141. for (var i = 0; i < this.soundCollection.length; i++) {
  7142. this.soundCollection[i].switchPanningModelToHRTF();
  7143. }
  7144. }
  7145. };
  7146. /**
  7147. * Switch the panning model to Equal Power:
  7148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7150. */
  7151. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7152. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7153. for (var i = 0; i < this.soundCollection.length; i++) {
  7154. this.soundCollection[i].switchPanningModelToEqualPower();
  7155. }
  7156. }
  7157. };
  7158. /**
  7159. * Connect the sound track to an audio analyser allowing some amazing
  7160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7162. * @param analyser The analyser to connect to the engine
  7163. */
  7164. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7165. if (this._connectedAnalyser) {
  7166. this._connectedAnalyser.stopDebugCanvas();
  7167. }
  7168. this._connectedAnalyser = analyser;
  7169. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7170. this._outputAudioNode.disconnect();
  7171. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7172. }
  7173. };
  7174. return SoundTrack;
  7175. }());
  7176. /***/ }),
  7177. /***/ "./Audio/weightedsound.ts":
  7178. /*!********************************!*\
  7179. !*** ./Audio/weightedsound.ts ***!
  7180. \********************************/
  7181. /*! exports provided: WeightedSound */
  7182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7183. "use strict";
  7184. __webpack_require__.r(__webpack_exports__);
  7185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7186. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7187. /**
  7188. * Wraps one or more Sound objects and selects one with random weight for playback.
  7189. */
  7190. var WeightedSound = /** @class */ (function () {
  7191. /**
  7192. * Creates a new WeightedSound from the list of sounds given.
  7193. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7194. * @param sounds Array of Sounds that will be selected from.
  7195. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7196. */
  7197. function WeightedSound(loop, sounds, weights) {
  7198. var _this = this;
  7199. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7200. this.loop = false;
  7201. this._coneInnerAngle = 360;
  7202. this._coneOuterAngle = 360;
  7203. this._volume = 1;
  7204. /** A Sound is currently playing. */
  7205. this.isPlaying = false;
  7206. /** A Sound is currently paused. */
  7207. this.isPaused = false;
  7208. this._sounds = [];
  7209. this._weights = [];
  7210. if (sounds.length !== weights.length) {
  7211. throw new Error('Sounds length does not equal weights length');
  7212. }
  7213. this.loop = loop;
  7214. this._weights = weights;
  7215. // Normalize the weights
  7216. var weightSum = 0;
  7217. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7218. var weight = weights_1[_i];
  7219. weightSum += weight;
  7220. }
  7221. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7222. for (var i = 0; i < this._weights.length; i++) {
  7223. this._weights[i] *= invWeightSum;
  7224. }
  7225. this._sounds = sounds;
  7226. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7227. var sound = _b[_a];
  7228. sound.onEndedObservable.add(function () { _this._onended(); });
  7229. }
  7230. }
  7231. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7232. /**
  7233. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7234. */
  7235. get: function () {
  7236. return this._coneInnerAngle;
  7237. },
  7238. /**
  7239. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7240. */
  7241. set: function (value) {
  7242. if (value !== this._coneInnerAngle) {
  7243. if (this._coneOuterAngle < value) {
  7244. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7245. return;
  7246. }
  7247. this._coneInnerAngle = value;
  7248. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7249. var sound = _a[_i];
  7250. sound.directionalConeInnerAngle = value;
  7251. }
  7252. }
  7253. },
  7254. enumerable: true,
  7255. configurable: true
  7256. });
  7257. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7258. /**
  7259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7261. */
  7262. get: function () {
  7263. return this._coneOuterAngle;
  7264. },
  7265. /**
  7266. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7267. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7268. */
  7269. set: function (value) {
  7270. if (value !== this._coneOuterAngle) {
  7271. if (value < this._coneInnerAngle) {
  7272. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7273. return;
  7274. }
  7275. this._coneOuterAngle = value;
  7276. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7277. var sound = _a[_i];
  7278. sound.directionalConeOuterAngle = value;
  7279. }
  7280. }
  7281. },
  7282. enumerable: true,
  7283. configurable: true
  7284. });
  7285. Object.defineProperty(WeightedSound.prototype, "volume", {
  7286. /**
  7287. * Playback volume.
  7288. */
  7289. get: function () {
  7290. return this._volume;
  7291. },
  7292. /**
  7293. * Playback volume.
  7294. */
  7295. set: function (value) {
  7296. if (value !== this._volume) {
  7297. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7298. var sound = _a[_i];
  7299. sound.setVolume(value);
  7300. }
  7301. }
  7302. },
  7303. enumerable: true,
  7304. configurable: true
  7305. });
  7306. WeightedSound.prototype._onended = function () {
  7307. if (this._currentIndex !== undefined) {
  7308. this._sounds[this._currentIndex].autoplay = false;
  7309. }
  7310. if (this.loop && this.isPlaying) {
  7311. this.play();
  7312. }
  7313. else {
  7314. this.isPlaying = false;
  7315. }
  7316. };
  7317. /**
  7318. * Suspend playback
  7319. */
  7320. WeightedSound.prototype.pause = function () {
  7321. this.isPaused = true;
  7322. if (this._currentIndex !== undefined) {
  7323. this._sounds[this._currentIndex].pause();
  7324. }
  7325. };
  7326. /**
  7327. * Stop playback
  7328. */
  7329. WeightedSound.prototype.stop = function () {
  7330. this.isPlaying = false;
  7331. if (this._currentIndex !== undefined) {
  7332. this._sounds[this._currentIndex].stop();
  7333. }
  7334. };
  7335. /**
  7336. * Start playback.
  7337. * @param startOffset Position the clip head at a specific time in seconds.
  7338. */
  7339. WeightedSound.prototype.play = function (startOffset) {
  7340. if (!this.isPaused) {
  7341. this.stop();
  7342. var randomValue = Math.random();
  7343. var total = 0;
  7344. for (var i = 0; i < this._weights.length; i++) {
  7345. total += this._weights[i];
  7346. if (randomValue <= total) {
  7347. this._currentIndex = i;
  7348. break;
  7349. }
  7350. }
  7351. }
  7352. var sound = this._sounds[this._currentIndex];
  7353. if (sound.isReady()) {
  7354. sound.play(0, this.isPaused ? undefined : startOffset);
  7355. }
  7356. else {
  7357. sound.autoplay = true;
  7358. }
  7359. this.isPlaying = true;
  7360. this.isPaused = false;
  7361. };
  7362. return WeightedSound;
  7363. }());
  7364. /***/ }),
  7365. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7366. /*!***************************************************!*\
  7367. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7368. \***************************************************/
  7369. /*! exports provided: AutoRotationBehavior */
  7370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7371. "use strict";
  7372. __webpack_require__.r(__webpack_exports__);
  7373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7374. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7375. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7376. /**
  7377. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7379. */
  7380. var AutoRotationBehavior = /** @class */ (function () {
  7381. function AutoRotationBehavior() {
  7382. this._zoomStopsAnimation = false;
  7383. this._idleRotationSpeed = 0.05;
  7384. this._idleRotationWaitTime = 2000;
  7385. this._idleRotationSpinupTime = 2000;
  7386. this._isPointerDown = false;
  7387. this._lastFrameTime = null;
  7388. this._lastInteractionTime = -Infinity;
  7389. this._cameraRotationSpeed = 0;
  7390. this._lastFrameRadius = 0;
  7391. }
  7392. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7393. /**
  7394. * Gets the name of the behavior.
  7395. */
  7396. get: function () {
  7397. return "AutoRotation";
  7398. },
  7399. enumerable: true,
  7400. configurable: true
  7401. });
  7402. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7403. /**
  7404. * Gets the flag that indicates if user zooming should stop animation.
  7405. */
  7406. get: function () {
  7407. return this._zoomStopsAnimation;
  7408. },
  7409. /**
  7410. * Sets the flag that indicates if user zooming should stop animation.
  7411. */
  7412. set: function (flag) {
  7413. this._zoomStopsAnimation = flag;
  7414. },
  7415. enumerable: true,
  7416. configurable: true
  7417. });
  7418. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7419. /**
  7420. * Gets the default speed at which the camera rotates around the model.
  7421. */
  7422. get: function () {
  7423. return this._idleRotationSpeed;
  7424. },
  7425. /**
  7426. * Sets the default speed at which the camera rotates around the model.
  7427. */
  7428. set: function (speed) {
  7429. this._idleRotationSpeed = speed;
  7430. },
  7431. enumerable: true,
  7432. configurable: true
  7433. });
  7434. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7435. /**
  7436. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7437. */
  7438. get: function () {
  7439. return this._idleRotationWaitTime;
  7440. },
  7441. /**
  7442. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7443. */
  7444. set: function (time) {
  7445. this._idleRotationWaitTime = time;
  7446. },
  7447. enumerable: true,
  7448. configurable: true
  7449. });
  7450. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7451. /**
  7452. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7453. */
  7454. get: function () {
  7455. return this._idleRotationSpinupTime;
  7456. },
  7457. /**
  7458. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7459. */
  7460. set: function (time) {
  7461. this._idleRotationSpinupTime = time;
  7462. },
  7463. enumerable: true,
  7464. configurable: true
  7465. });
  7466. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7467. /**
  7468. * Gets a value indicating if the camera is currently rotating because of this behavior
  7469. */
  7470. get: function () {
  7471. return Math.abs(this._cameraRotationSpeed) > 0;
  7472. },
  7473. enumerable: true,
  7474. configurable: true
  7475. });
  7476. /**
  7477. * Initializes the behavior.
  7478. */
  7479. AutoRotationBehavior.prototype.init = function () {
  7480. // Do notihng
  7481. };
  7482. /**
  7483. * Attaches the behavior to its arc rotate camera.
  7484. * @param camera Defines the camera to attach the behavior to
  7485. */
  7486. AutoRotationBehavior.prototype.attach = function (camera) {
  7487. var _this = this;
  7488. this._attachedCamera = camera;
  7489. var scene = this._attachedCamera.getScene();
  7490. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7491. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7492. _this._isPointerDown = true;
  7493. return;
  7494. }
  7495. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7496. _this._isPointerDown = false;
  7497. }
  7498. });
  7499. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7500. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7501. var dt = 0;
  7502. if (_this._lastFrameTime != null) {
  7503. dt = now - _this._lastFrameTime;
  7504. }
  7505. _this._lastFrameTime = now;
  7506. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7507. _this._applyUserInteraction();
  7508. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7509. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7510. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7511. // Step camera rotation by rotation speed
  7512. if (_this._attachedCamera) {
  7513. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7514. }
  7515. });
  7516. };
  7517. /**
  7518. * Detaches the behavior from its current arc rotate camera.
  7519. */
  7520. AutoRotationBehavior.prototype.detach = function () {
  7521. if (!this._attachedCamera) {
  7522. return;
  7523. }
  7524. var scene = this._attachedCamera.getScene();
  7525. if (this._onPrePointerObservableObserver) {
  7526. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7527. }
  7528. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7529. this._attachedCamera = null;
  7530. };
  7531. /**
  7532. * Returns true if user is scrolling.
  7533. * @return true if user is scrolling.
  7534. */
  7535. AutoRotationBehavior.prototype._userIsZooming = function () {
  7536. if (!this._attachedCamera) {
  7537. return false;
  7538. }
  7539. return this._attachedCamera.inertialRadiusOffset !== 0;
  7540. };
  7541. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7542. if (!this._attachedCamera) {
  7543. return false;
  7544. }
  7545. var zoomHasHitLimit = false;
  7546. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7547. zoomHasHitLimit = true;
  7548. }
  7549. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7550. this._lastFrameRadius = this._attachedCamera.radius;
  7551. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7552. };
  7553. /**
  7554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7555. */
  7556. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7557. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7558. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7559. }
  7560. };
  7561. // Tools
  7562. AutoRotationBehavior.prototype._userIsMoving = function () {
  7563. if (!this._attachedCamera) {
  7564. return false;
  7565. }
  7566. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7567. this._attachedCamera.inertialBetaOffset !== 0 ||
  7568. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7569. this._attachedCamera.inertialPanningX !== 0 ||
  7570. this._attachedCamera.inertialPanningY !== 0 ||
  7571. this._isPointerDown;
  7572. };
  7573. return AutoRotationBehavior;
  7574. }());
  7575. /***/ }),
  7576. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7577. /*!***********************************************!*\
  7578. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7579. \***********************************************/
  7580. /*! exports provided: BouncingBehavior */
  7581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7582. "use strict";
  7583. __webpack_require__.r(__webpack_exports__);
  7584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7585. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7586. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7587. /**
  7588. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7590. */
  7591. var BouncingBehavior = /** @class */ (function () {
  7592. function BouncingBehavior() {
  7593. /**
  7594. * The duration of the animation, in milliseconds
  7595. */
  7596. this.transitionDuration = 450;
  7597. /**
  7598. * Length of the distance animated by the transition when lower radius is reached
  7599. */
  7600. this.lowerRadiusTransitionRange = 2;
  7601. /**
  7602. * Length of the distance animated by the transition when upper radius is reached
  7603. */
  7604. this.upperRadiusTransitionRange = -2;
  7605. this._autoTransitionRange = false;
  7606. // Animations
  7607. this._radiusIsAnimating = false;
  7608. this._radiusBounceTransition = null;
  7609. this._animatables = new Array();
  7610. }
  7611. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7612. /**
  7613. * Gets the name of the behavior.
  7614. */
  7615. get: function () {
  7616. return "Bouncing";
  7617. },
  7618. enumerable: true,
  7619. configurable: true
  7620. });
  7621. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7622. /**
  7623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7624. */
  7625. get: function () {
  7626. return this._autoTransitionRange;
  7627. },
  7628. /**
  7629. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7630. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7631. */
  7632. set: function (value) {
  7633. var _this = this;
  7634. if (this._autoTransitionRange === value) {
  7635. return;
  7636. }
  7637. this._autoTransitionRange = value;
  7638. var camera = this._attachedCamera;
  7639. if (!camera) {
  7640. return;
  7641. }
  7642. if (value) {
  7643. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7644. if (!mesh) {
  7645. return;
  7646. }
  7647. mesh.computeWorldMatrix(true);
  7648. var diagonal = mesh.getBoundingInfo().diagonalLength;
  7649. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  7650. _this.upperRadiusTransitionRange = diagonal * 0.05;
  7651. });
  7652. }
  7653. else if (this._onMeshTargetChangedObserver) {
  7654. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7655. }
  7656. },
  7657. enumerable: true,
  7658. configurable: true
  7659. });
  7660. /**
  7661. * Initializes the behavior.
  7662. */
  7663. BouncingBehavior.prototype.init = function () {
  7664. // Do notihng
  7665. };
  7666. /**
  7667. * Attaches the behavior to its arc rotate camera.
  7668. * @param camera Defines the camera to attach the behavior to
  7669. */
  7670. BouncingBehavior.prototype.attach = function (camera) {
  7671. var _this = this;
  7672. this._attachedCamera = camera;
  7673. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7674. if (!_this._attachedCamera) {
  7675. return;
  7676. }
  7677. // Add the bounce animation to the lower radius limit
  7678. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  7679. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  7680. }
  7681. // Add the bounce animation to the upper radius limit
  7682. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  7683. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  7684. }
  7685. });
  7686. };
  7687. /**
  7688. * Detaches the behavior from its current arc rotate camera.
  7689. */
  7690. BouncingBehavior.prototype.detach = function () {
  7691. if (!this._attachedCamera) {
  7692. return;
  7693. }
  7694. if (this._onAfterCheckInputsObserver) {
  7695. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7696. }
  7697. if (this._onMeshTargetChangedObserver) {
  7698. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7699. }
  7700. this._attachedCamera = null;
  7701. };
  7702. /**
  7703. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  7704. * @param radiusLimit The limit to check against.
  7705. * @return Bool to indicate if at limit.
  7706. */
  7707. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  7708. if (!this._attachedCamera) {
  7709. return false;
  7710. }
  7711. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  7712. return true;
  7713. }
  7714. return false;
  7715. };
  7716. /**
  7717. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  7718. * @param radiusDelta The delta by which to animate to. Can be negative.
  7719. */
  7720. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  7721. var _this = this;
  7722. if (!this._attachedCamera) {
  7723. return;
  7724. }
  7725. if (!this._radiusBounceTransition) {
  7726. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  7727. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  7728. }
  7729. // Prevent zoom until bounce has completed
  7730. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  7731. this._attachedCamera.wheelPrecision = Infinity;
  7732. this._attachedCamera.inertialRadiusOffset = 0;
  7733. // Animate to the radius limit
  7734. this.stopAllAnimations();
  7735. this._radiusIsAnimating = true;
  7736. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function () { return _this._clearAnimationLocks(); });
  7737. if (animatable) {
  7738. this._animatables.push(animatable);
  7739. }
  7740. };
  7741. /**
  7742. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  7743. */
  7744. BouncingBehavior.prototype._clearAnimationLocks = function () {
  7745. this._radiusIsAnimating = false;
  7746. if (this._attachedCamera) {
  7747. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  7748. }
  7749. };
  7750. /**
  7751. * Stops and removes all animations that have been applied to the camera
  7752. */
  7753. BouncingBehavior.prototype.stopAllAnimations = function () {
  7754. if (this._attachedCamera) {
  7755. this._attachedCamera.animations = [];
  7756. }
  7757. while (this._animatables.length) {
  7758. this._animatables[0].onAnimationEnd = null;
  7759. this._animatables[0].stop();
  7760. this._animatables.shift();
  7761. }
  7762. };
  7763. /**
  7764. * The easing function used by animations
  7765. */
  7766. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  7767. /**
  7768. * The easing mode used by animations
  7769. */
  7770. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  7771. return BouncingBehavior;
  7772. }());
  7773. /***/ }),
  7774. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  7775. /*!**********************************************!*\
  7776. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  7777. \**********************************************/
  7778. /*! exports provided: FramingBehavior */
  7779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7780. "use strict";
  7781. __webpack_require__.r(__webpack_exports__);
  7782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  7783. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7784. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7785. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  7786. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  7788. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7789. /**
  7790. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  7791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7792. */
  7793. var FramingBehavior = /** @class */ (function () {
  7794. function FramingBehavior() {
  7795. this._mode = FramingBehavior.FitFrustumSidesMode;
  7796. this._radiusScale = 1.0;
  7797. this._positionScale = 0.5;
  7798. this._defaultElevation = 0.3;
  7799. this._elevationReturnTime = 1500;
  7800. this._elevationReturnWaitTime = 1000;
  7801. this._zoomStopsAnimation = false;
  7802. this._framingTime = 1500;
  7803. /**
  7804. * Define if the behavior should automatically change the configured
  7805. * camera limits and sensibilities.
  7806. */
  7807. this.autoCorrectCameraLimitsAndSensibility = true;
  7808. this._isPointerDown = false;
  7809. this._lastInteractionTime = -Infinity;
  7810. // Framing control
  7811. this._animatables = new Array();
  7812. this._betaIsAnimating = false;
  7813. }
  7814. Object.defineProperty(FramingBehavior.prototype, "name", {
  7815. /**
  7816. * Gets the name of the behavior.
  7817. */
  7818. get: function () {
  7819. return "Framing";
  7820. },
  7821. enumerable: true,
  7822. configurable: true
  7823. });
  7824. Object.defineProperty(FramingBehavior.prototype, "mode", {
  7825. /**
  7826. * Gets current mode used by the behavior.
  7827. */
  7828. get: function () {
  7829. return this._mode;
  7830. },
  7831. /**
  7832. * Sets the current mode used by the behavior
  7833. */
  7834. set: function (mode) {
  7835. this._mode = mode;
  7836. },
  7837. enumerable: true,
  7838. configurable: true
  7839. });
  7840. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  7841. /**
  7842. * Gets the scale applied to the radius
  7843. */
  7844. get: function () {
  7845. return this._radiusScale;
  7846. },
  7847. /**
  7848. * Sets the scale applied to the radius (1 by default)
  7849. */
  7850. set: function (radius) {
  7851. this._radiusScale = radius;
  7852. },
  7853. enumerable: true,
  7854. configurable: true
  7855. });
  7856. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  7857. /**
  7858. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7859. */
  7860. get: function () {
  7861. return this._positionScale;
  7862. },
  7863. /**
  7864. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7865. */
  7866. set: function (scale) {
  7867. this._positionScale = scale;
  7868. },
  7869. enumerable: true,
  7870. configurable: true
  7871. });
  7872. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  7873. /**
  7874. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7875. * behaviour is triggered, in radians.
  7876. */
  7877. get: function () {
  7878. return this._defaultElevation;
  7879. },
  7880. /**
  7881. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7882. * behaviour is triggered, in radians.
  7883. */
  7884. set: function (elevation) {
  7885. this._defaultElevation = elevation;
  7886. },
  7887. enumerable: true,
  7888. configurable: true
  7889. });
  7890. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  7891. /**
  7892. * Gets the time (in milliseconds) taken to return to the default beta position.
  7893. * Negative value indicates camera should not return to default.
  7894. */
  7895. get: function () {
  7896. return this._elevationReturnTime;
  7897. },
  7898. /**
  7899. * Sets the time (in milliseconds) taken to return to the default beta position.
  7900. * Negative value indicates camera should not return to default.
  7901. */
  7902. set: function (speed) {
  7903. this._elevationReturnTime = speed;
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  7909. /**
  7910. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7911. */
  7912. get: function () {
  7913. return this._elevationReturnWaitTime;
  7914. },
  7915. /**
  7916. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7917. */
  7918. set: function (time) {
  7919. this._elevationReturnWaitTime = time;
  7920. },
  7921. enumerable: true,
  7922. configurable: true
  7923. });
  7924. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  7925. /**
  7926. * Gets the flag that indicates if user zooming should stop animation.
  7927. */
  7928. get: function () {
  7929. return this._zoomStopsAnimation;
  7930. },
  7931. /**
  7932. * Sets the flag that indicates if user zooming should stop animation.
  7933. */
  7934. set: function (flag) {
  7935. this._zoomStopsAnimation = flag;
  7936. },
  7937. enumerable: true,
  7938. configurable: true
  7939. });
  7940. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  7941. /**
  7942. * Gets the transition time when framing the mesh, in milliseconds
  7943. */
  7944. get: function () {
  7945. return this._framingTime;
  7946. },
  7947. /**
  7948. * Sets the transition time when framing the mesh, in milliseconds
  7949. */
  7950. set: function (time) {
  7951. this._framingTime = time;
  7952. },
  7953. enumerable: true,
  7954. configurable: true
  7955. });
  7956. /**
  7957. * Initializes the behavior.
  7958. */
  7959. FramingBehavior.prototype.init = function () {
  7960. // Do notihng
  7961. };
  7962. /**
  7963. * Attaches the behavior to its arc rotate camera.
  7964. * @param camera Defines the camera to attach the behavior to
  7965. */
  7966. FramingBehavior.prototype.attach = function (camera) {
  7967. var _this = this;
  7968. this._attachedCamera = camera;
  7969. var scene = this._attachedCamera.getScene();
  7970. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  7971. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7972. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  7973. _this._isPointerDown = true;
  7974. return;
  7975. }
  7976. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  7977. _this._isPointerDown = false;
  7978. }
  7979. });
  7980. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7981. if (mesh) {
  7982. _this.zoomOnMesh(mesh);
  7983. }
  7984. });
  7985. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7986. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7987. _this._applyUserInteraction();
  7988. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  7989. // back to the default position after a given timeout
  7990. _this._maintainCameraAboveGround();
  7991. });
  7992. };
  7993. /**
  7994. * Detaches the behavior from its current arc rotate camera.
  7995. */
  7996. FramingBehavior.prototype.detach = function () {
  7997. if (!this._attachedCamera) {
  7998. return;
  7999. }
  8000. var scene = this._attachedCamera.getScene();
  8001. if (this._onPrePointerObservableObserver) {
  8002. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8003. }
  8004. if (this._onAfterCheckInputsObserver) {
  8005. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8006. }
  8007. if (this._onMeshTargetChangedObserver) {
  8008. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8009. }
  8010. this._attachedCamera = null;
  8011. };
  8012. /**
  8013. * Targets the given mesh and updates zoom level accordingly.
  8014. * @param mesh The mesh to target.
  8015. * @param radius Optional. If a cached radius position already exists, overrides default.
  8016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8019. */
  8020. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8021. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8022. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8023. mesh.computeWorldMatrix(true);
  8024. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8025. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8026. };
  8027. /**
  8028. * Targets the given mesh with its children and updates zoom level accordingly.
  8029. * @param mesh The mesh to target.
  8030. * @param radius Optional. If a cached radius position already exists, overrides default.
  8031. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8032. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8033. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8034. */
  8035. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8036. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8037. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8038. mesh.computeWorldMatrix(true);
  8039. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8040. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8041. };
  8042. /**
  8043. * Targets the given meshes with their children and updates zoom level accordingly.
  8044. * @param meshes The mesh to target.
  8045. * @param radius Optional. If a cached radius position already exists, overrides default.
  8046. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8047. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8048. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8049. */
  8050. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8051. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8052. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8053. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8054. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8055. for (var i = 0; i < meshes.length; i++) {
  8056. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8057. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8058. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8059. }
  8060. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8061. };
  8062. /**
  8063. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8064. * @param minimumWorld Determines the smaller position of the bounding box extend
  8065. * @param maximumWorld Determines the bigger position of the bounding box extend
  8066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8068. */
  8069. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8070. var _this = this;
  8071. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8072. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8073. var zoomTarget;
  8074. if (!this._attachedCamera) {
  8075. return;
  8076. }
  8077. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8078. var bottom = minimumWorld.y;
  8079. var top = maximumWorld.y;
  8080. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8081. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8082. if (focusOnOriginXZ) {
  8083. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8084. }
  8085. else {
  8086. var centerWorld = minimumWorld.add(radiusWorld);
  8087. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8088. }
  8089. if (!this._vectorTransition) {
  8090. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8091. }
  8092. this._betaIsAnimating = true;
  8093. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8094. if (animatable) {
  8095. this._animatables.push(animatable);
  8096. }
  8097. // sets the radius and lower radius bounds
  8098. // Small delta ensures camera is not always at lower zoom limit.
  8099. var radius = 0;
  8100. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8101. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8102. if (this.autoCorrectCameraLimitsAndSensibility) {
  8103. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8104. }
  8105. radius = position;
  8106. }
  8107. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8108. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8109. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8110. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8111. }
  8112. }
  8113. // Set sensibilities
  8114. if (this.autoCorrectCameraLimitsAndSensibility) {
  8115. var extend = maximumWorld.subtract(minimumWorld).length();
  8116. this._attachedCamera.panningSensibility = 5000 / extend;
  8117. this._attachedCamera.wheelPrecision = 100 / radius;
  8118. }
  8119. // transition to new radius
  8120. if (!this._radiusTransition) {
  8121. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8122. }
  8123. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8124. _this.stopAllAnimations();
  8125. if (onAnimationEnd) {
  8126. onAnimationEnd();
  8127. }
  8128. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8129. _this._attachedCamera.storeState();
  8130. }
  8131. });
  8132. if (animatable) {
  8133. this._animatables.push(animatable);
  8134. }
  8135. };
  8136. /**
  8137. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8138. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8139. * frustum width.
  8140. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8141. * to fully enclose the mesh in the viewing frustum.
  8142. */
  8143. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8144. var size = maximumWorld.subtract(minimumWorld);
  8145. var boxVectorGlobalDiagonal = size.length();
  8146. var frustumSlope = this._getFrustumSlope();
  8147. // Formula for setting distance
  8148. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8149. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8150. // Horizon distance
  8151. var radius = radiusWithoutFraming * this._radiusScale;
  8152. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8153. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8154. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8155. var camera = this._attachedCamera;
  8156. if (!camera) {
  8157. return 0;
  8158. }
  8159. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8160. // Don't exceed the requested limit
  8161. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8162. }
  8163. // Don't exceed the upper radius limit
  8164. if (camera.upperRadiusLimit) {
  8165. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8166. }
  8167. return distance;
  8168. };
  8169. /**
  8170. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8171. * is automatically returned to its default position (expected to be above ground plane).
  8172. */
  8173. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8174. var _this = this;
  8175. if (this._elevationReturnTime < 0) {
  8176. return;
  8177. }
  8178. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8179. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8180. var limitBeta = Math.PI * 0.5;
  8181. // Bring the camera back up if below the ground plane
  8182. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8183. this._betaIsAnimating = true;
  8184. //Transition to new position
  8185. this.stopAllAnimations();
  8186. if (!this._betaTransition) {
  8187. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8188. }
  8189. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8190. _this._clearAnimationLocks();
  8191. _this.stopAllAnimations();
  8192. });
  8193. if (animatabe) {
  8194. this._animatables.push(animatabe);
  8195. }
  8196. }
  8197. };
  8198. /**
  8199. * Returns the frustum slope based on the canvas ratio and camera FOV
  8200. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8201. */
  8202. FramingBehavior.prototype._getFrustumSlope = function () {
  8203. // Calculate the viewport ratio
  8204. // Aspect Ratio is Height/Width.
  8205. var camera = this._attachedCamera;
  8206. if (!camera) {
  8207. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8208. }
  8209. var engine = camera.getScene().getEngine();
  8210. var aspectRatio = engine.getAspectRatio(camera);
  8211. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8212. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8213. var frustumSlopeY = Math.tan(camera.fov / 2);
  8214. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8215. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8216. // along the forward vector.
  8217. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8218. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8219. };
  8220. /**
  8221. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8222. */
  8223. FramingBehavior.prototype._clearAnimationLocks = function () {
  8224. this._betaIsAnimating = false;
  8225. };
  8226. /**
  8227. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8228. */
  8229. FramingBehavior.prototype._applyUserInteraction = function () {
  8230. if (this.isUserIsMoving) {
  8231. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8232. this.stopAllAnimations();
  8233. this._clearAnimationLocks();
  8234. }
  8235. };
  8236. /**
  8237. * Stops and removes all animations that have been applied to the camera
  8238. */
  8239. FramingBehavior.prototype.stopAllAnimations = function () {
  8240. if (this._attachedCamera) {
  8241. this._attachedCamera.animations = [];
  8242. }
  8243. while (this._animatables.length) {
  8244. if (this._animatables[0]) {
  8245. this._animatables[0].onAnimationEnd = null;
  8246. this._animatables[0].stop();
  8247. }
  8248. this._animatables.shift();
  8249. }
  8250. };
  8251. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8252. /**
  8253. * Gets a value indicating if the user is moving the camera
  8254. */
  8255. get: function () {
  8256. if (!this._attachedCamera) {
  8257. return false;
  8258. }
  8259. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8260. this._attachedCamera.inertialBetaOffset !== 0 ||
  8261. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8262. this._attachedCamera.inertialPanningX !== 0 ||
  8263. this._attachedCamera.inertialPanningY !== 0 ||
  8264. this._isPointerDown;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. /**
  8270. * The easing function used by animations
  8271. */
  8272. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8273. /**
  8274. * The easing mode used by animations
  8275. */
  8276. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8277. // Statics
  8278. /**
  8279. * The camera can move all the way towards the mesh.
  8280. */
  8281. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8282. /**
  8283. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8284. */
  8285. FramingBehavior.FitFrustumSidesMode = 1;
  8286. return FramingBehavior;
  8287. }());
  8288. /***/ }),
  8289. /***/ "./Behaviors/Cameras/index.ts":
  8290. /*!************************************!*\
  8291. !*** ./Behaviors/Cameras/index.ts ***!
  8292. \************************************/
  8293. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8295. "use strict";
  8296. __webpack_require__.r(__webpack_exports__);
  8297. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8299. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8301. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8303. /***/ }),
  8304. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8305. /*!*************************************************!*\
  8306. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8307. \*************************************************/
  8308. /*! exports provided: AttachToBoxBehavior */
  8309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8310. "use strict";
  8311. __webpack_require__.r(__webpack_exports__);
  8312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8314. /**
  8315. * @hidden
  8316. */
  8317. var FaceDirectionInfo = /** @class */ (function () {
  8318. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8319. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8320. if (diff === void 0) { diff = 0; }
  8321. if (ignore === void 0) { ignore = false; }
  8322. this.direction = direction;
  8323. this.rotatedDirection = rotatedDirection;
  8324. this.diff = diff;
  8325. this.ignore = ignore;
  8326. }
  8327. return FaceDirectionInfo;
  8328. }());
  8329. /**
  8330. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8331. */
  8332. var AttachToBoxBehavior = /** @class */ (function () {
  8333. /**
  8334. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8335. * @param ui The transform node that should be attched to the mesh
  8336. */
  8337. function AttachToBoxBehavior(ui) {
  8338. this.ui = ui;
  8339. /**
  8340. * The name of the behavior
  8341. */
  8342. this.name = "AttachToBoxBehavior";
  8343. /**
  8344. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8345. */
  8346. this.distanceAwayFromFace = 0.15;
  8347. /**
  8348. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8349. */
  8350. this.distanceAwayFromBottomOfFace = 0.15;
  8351. this._faceVectors = [new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Down()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Left()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward()), new FaceDirectionInfo(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward().scaleInPlace(-1))];
  8352. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8353. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8354. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8355. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8356. /* Does nothing */
  8357. }
  8358. /**
  8359. * Initializes the behavior
  8360. */
  8361. AttachToBoxBehavior.prototype.init = function () {
  8362. /* Does nothing */
  8363. };
  8364. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8365. var _this = this;
  8366. // Go over each face and calculate the angle between the face's normal and targetDirection
  8367. this._faceVectors.forEach(function (v) {
  8368. if (!_this._target.rotationQuaternion) {
  8369. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8370. }
  8371. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8372. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8373. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8374. });
  8375. // Return the face information of the one with the normal closeset to target direction
  8376. return this._faceVectors.reduce(function (min, p) {
  8377. if (min.ignore) {
  8378. return p;
  8379. }
  8380. else if (p.ignore) {
  8381. return min;
  8382. }
  8383. else {
  8384. return min.diff < p.diff ? min : p;
  8385. }
  8386. }, this._faceVectors[0]);
  8387. };
  8388. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8389. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8390. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8391. this._lookAtTmpMatrix.invert();
  8392. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8393. };
  8394. /**
  8395. * Attaches the AttachToBoxBehavior to the passed in mesh
  8396. * @param target The mesh that the specified node will be attached to
  8397. */
  8398. AttachToBoxBehavior.prototype.attach = function (target) {
  8399. var _this = this;
  8400. this._target = target;
  8401. this._scene = this._target.getScene();
  8402. // Every frame, update the app bars position
  8403. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8404. if (!_this._scene.activeCamera) {
  8405. return;
  8406. }
  8407. // Find the face closest to the cameras position
  8408. var cameraPos = _this._scene.activeCamera.position;
  8409. if (_this._scene.activeCamera.devicePosition) {
  8410. cameraPos = _this._scene.activeCamera.devicePosition;
  8411. }
  8412. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8413. if (_this._scene.activeCamera.leftCamera) {
  8414. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8415. }
  8416. else {
  8417. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8418. }
  8419. // Get camera up direction
  8420. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8421. // Ignore faces to not select a parrelel face for the up vector of the UI
  8422. _this._faceVectors.forEach(function (v) {
  8423. if (facing.direction.x && v.direction.x) {
  8424. v.ignore = true;
  8425. }
  8426. if (facing.direction.y && v.direction.y) {
  8427. v.ignore = true;
  8428. }
  8429. if (facing.direction.z && v.direction.z) {
  8430. v.ignore = true;
  8431. }
  8432. });
  8433. var facingUp = _this._closestFace(_this._tmpVector);
  8434. // Unignore faces
  8435. _this._faceVectors.forEach(function (v) {
  8436. v.ignore = false;
  8437. });
  8438. // Position the app bar on that face
  8439. _this.ui.position.copyFrom(target.position);
  8440. if (facing.direction.x) {
  8441. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8442. _this.ui.position.addInPlace(_this._tmpVector);
  8443. }
  8444. if (facing.direction.y) {
  8445. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8446. _this.ui.position.addInPlace(_this._tmpVector);
  8447. }
  8448. if (facing.direction.z) {
  8449. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8450. _this.ui.position.addInPlace(_this._tmpVector);
  8451. }
  8452. // Rotate to be oriented properly to the camera
  8453. if (!_this.ui.rotationQuaternion) {
  8454. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8455. }
  8456. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8457. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8458. // Place ui the correct distance from the bottom of the mesh
  8459. if (facingUp.direction.x) {
  8460. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8461. }
  8462. if (facingUp.direction.y) {
  8463. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8464. }
  8465. if (facingUp.direction.z) {
  8466. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8467. }
  8468. _this.ui.position.addInPlace(_this._tmpVector);
  8469. });
  8470. };
  8471. /**
  8472. * Detaches the behavior from the mesh
  8473. */
  8474. AttachToBoxBehavior.prototype.detach = function () {
  8475. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8476. };
  8477. return AttachToBoxBehavior;
  8478. }());
  8479. /***/ }),
  8480. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8481. /*!***********************************************!*\
  8482. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8483. \***********************************************/
  8484. /*! exports provided: FadeInOutBehavior */
  8485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8486. "use strict";
  8487. __webpack_require__.r(__webpack_exports__);
  8488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8489. /**
  8490. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8491. */
  8492. var FadeInOutBehavior = /** @class */ (function () {
  8493. /**
  8494. * Instatiates the FadeInOutBehavior
  8495. */
  8496. function FadeInOutBehavior() {
  8497. var _this = this;
  8498. /**
  8499. * Time in milliseconds to delay before fading in (Default: 0)
  8500. */
  8501. this.delay = 0;
  8502. /**
  8503. * Time in milliseconds for the mesh to fade in (Default: 300)
  8504. */
  8505. this.fadeInTime = 300;
  8506. this._millisecondsPerFrame = 1000 / 60;
  8507. this._hovered = false;
  8508. this._hoverValue = 0;
  8509. this._ownerNode = null;
  8510. this._update = function () {
  8511. if (_this._ownerNode) {
  8512. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8513. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8514. if (_this._ownerNode.visibility > 1) {
  8515. _this._setAllVisibility(_this._ownerNode, 1);
  8516. _this._hoverValue = _this.fadeInTime + _this.delay;
  8517. return;
  8518. }
  8519. else if (_this._ownerNode.visibility < 0) {
  8520. _this._setAllVisibility(_this._ownerNode, 0);
  8521. if (_this._hoverValue < 0) {
  8522. _this._hoverValue = 0;
  8523. return;
  8524. }
  8525. }
  8526. setTimeout(_this._update, _this._millisecondsPerFrame);
  8527. }
  8528. };
  8529. }
  8530. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8531. /**
  8532. * The name of the behavior
  8533. */
  8534. get: function () {
  8535. return "FadeInOut";
  8536. },
  8537. enumerable: true,
  8538. configurable: true
  8539. });
  8540. /**
  8541. * Initializes the behavior
  8542. */
  8543. FadeInOutBehavior.prototype.init = function () {
  8544. };
  8545. /**
  8546. * Attaches the fade behavior on the passed in mesh
  8547. * @param ownerNode The mesh that will be faded in/out once attached
  8548. */
  8549. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8550. this._ownerNode = ownerNode;
  8551. this._setAllVisibility(this._ownerNode, 0);
  8552. };
  8553. /**
  8554. * Detaches the behavior from the mesh
  8555. */
  8556. FadeInOutBehavior.prototype.detach = function () {
  8557. this._ownerNode = null;
  8558. };
  8559. /**
  8560. * Triggers the mesh to begin fading in or out
  8561. * @param value if the object should fade in or out (true to fade in)
  8562. */
  8563. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8564. this._hovered = value;
  8565. this._update();
  8566. };
  8567. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8568. var _this = this;
  8569. mesh.visibility = value;
  8570. mesh.getChildMeshes().forEach(function (c) {
  8571. _this._setAllVisibility(c, value);
  8572. });
  8573. };
  8574. return FadeInOutBehavior;
  8575. }());
  8576. /***/ }),
  8577. /***/ "./Behaviors/Meshes/index.ts":
  8578. /*!***********************************!*\
  8579. !*** ./Behaviors/Meshes/index.ts ***!
  8580. \***********************************/
  8581. /*! exports provided: PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  8582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8583. "use strict";
  8584. __webpack_require__.r(__webpack_exports__);
  8585. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8587. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8589. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8591. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8593. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8595. /***/ }),
  8596. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8597. /*!*******************************************************!*\
  8598. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8599. \*******************************************************/
  8600. /*! exports provided: MultiPointerScaleBehavior */
  8601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8602. "use strict";
  8603. __webpack_require__.r(__webpack_exports__);
  8604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8605. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8606. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8607. /**
  8608. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8609. */
  8610. var MultiPointerScaleBehavior = /** @class */ (function () {
  8611. /**
  8612. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8613. */
  8614. function MultiPointerScaleBehavior() {
  8615. this._startDistance = 0;
  8616. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8617. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8618. this._sceneRenderObserver = null;
  8619. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8620. this._dragBehaviorA.moveAttached = false;
  8621. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8622. this._dragBehaviorB.moveAttached = false;
  8623. }
  8624. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8625. /**
  8626. * The name of the behavior
  8627. */
  8628. get: function () {
  8629. return "MultiPointerScale";
  8630. },
  8631. enumerable: true,
  8632. configurable: true
  8633. });
  8634. /**
  8635. * Initializes the behavior
  8636. */
  8637. MultiPointerScaleBehavior.prototype.init = function () { };
  8638. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8639. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8640. };
  8641. /**
  8642. * Attaches the scale behavior the passed in mesh
  8643. * @param ownerNode The mesh that will be scaled around once attached
  8644. */
  8645. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8646. var _this = this;
  8647. this._ownerNode = ownerNode;
  8648. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  8649. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  8650. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8651. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8652. _this._dragBehaviorA.releaseDrag();
  8653. }
  8654. else {
  8655. _this._initialScale.copyFrom(ownerNode.scaling);
  8656. _this._startDistance = _this._getCurrentDistance();
  8657. }
  8658. }
  8659. });
  8660. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  8661. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8662. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8663. _this._dragBehaviorB.releaseDrag();
  8664. }
  8665. else {
  8666. _this._initialScale.copyFrom(ownerNode.scaling);
  8667. _this._startDistance = _this._getCurrentDistance();
  8668. }
  8669. }
  8670. });
  8671. // Once both drag behaviors are active scale based on the distance between the two pointers
  8672. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8673. behavior.onDragObservable.add(function () {
  8674. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8675. var ratio = _this._getCurrentDistance() / _this._startDistance;
  8676. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  8677. }
  8678. });
  8679. });
  8680. ownerNode.addBehavior(this._dragBehaviorA);
  8681. ownerNode.addBehavior(this._dragBehaviorB);
  8682. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  8683. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  8684. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8685. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  8686. if (change.length() > 0.01) {
  8687. ownerNode.scaling.addInPlace(change);
  8688. }
  8689. }
  8690. });
  8691. };
  8692. /**
  8693. * Detaches the behavior from the mesh
  8694. */
  8695. MultiPointerScaleBehavior.prototype.detach = function () {
  8696. var _this = this;
  8697. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  8698. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8699. behavior.onDragStartObservable.clear();
  8700. behavior.onDragObservable.clear();
  8701. _this._ownerNode.removeBehavior(behavior);
  8702. });
  8703. };
  8704. return MultiPointerScaleBehavior;
  8705. }());
  8706. /***/ }),
  8707. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  8708. /*!*************************************************!*\
  8709. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  8710. \*************************************************/
  8711. /*! exports provided: PointerDragBehavior */
  8712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8713. "use strict";
  8714. __webpack_require__.r(__webpack_exports__);
  8715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  8716. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  8717. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  8718. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  8719. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8720. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8721. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  8722. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  8723. /**
  8724. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  8725. */
  8726. var PointerDragBehavior = /** @class */ (function () {
  8727. /**
  8728. * Creates a pointer drag behavior that can be attached to a mesh
  8729. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  8730. */
  8731. function PointerDragBehavior(options) {
  8732. /**
  8733. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  8734. */
  8735. this.maxDragAngle = 0;
  8736. /**
  8737. * @hidden
  8738. */
  8739. this._useAlternatePickedPointAboveMaxDragAngle = false;
  8740. /**
  8741. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  8742. */
  8743. this.currentDraggingPointerID = -1;
  8744. /**
  8745. * If the behavior is currently in a dragging state
  8746. */
  8747. this.dragging = false;
  8748. /**
  8749. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  8750. */
  8751. this.dragDeltaRatio = 0.2;
  8752. /**
  8753. * If the drag plane orientation should be updated during the dragging (Default: true)
  8754. */
  8755. this.updateDragPlane = true;
  8756. // Debug mode will display drag planes to help visualize behavior
  8757. this._debugMode = false;
  8758. this._moving = false;
  8759. /**
  8760. * Fires each time the attached mesh is dragged with the pointer
  8761. * * delta between last drag position and current drag position in world space
  8762. * * dragDistance along the drag axis
  8763. * * dragPlaneNormal normal of the current drag plane used during the drag
  8764. * * dragPlanePoint in world space where the drag intersects the drag plane
  8765. */
  8766. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8767. /**
  8768. * Fires each time a drag begins (eg. mouse down on mesh)
  8769. */
  8770. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8771. /**
  8772. * Fires each time a drag ends (eg. mouse release after drag)
  8773. */
  8774. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8775. /**
  8776. * If the attached mesh should be moved when dragged
  8777. */
  8778. this.moveAttached = true;
  8779. /**
  8780. * If the drag behavior will react to drag events (Default: true)
  8781. */
  8782. this.enabled = true;
  8783. /**
  8784. * If camera controls should be detached during the drag
  8785. */
  8786. this.detachCameraControls = true;
  8787. /**
  8788. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  8789. */
  8790. this.useObjectOrienationForDragging = true;
  8791. /**
  8792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  8793. */
  8794. this.validateDrag = function (targetPosition) { return true; };
  8795. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8796. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8797. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8798. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8799. this._attachedElement = null;
  8800. this._startDragRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  8801. this._lastPointerRay = {};
  8802. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  8803. // Variables to avoid instantiation in the below method
  8804. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8805. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8806. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8807. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8808. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8809. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8810. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8811. this._options = options ? options : {};
  8812. var optionCount = 0;
  8813. if (this._options.dragAxis) {
  8814. optionCount++;
  8815. }
  8816. if (this._options.dragPlaneNormal) {
  8817. optionCount++;
  8818. }
  8819. if (optionCount > 1) {
  8820. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  8821. }
  8822. }
  8823. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  8824. /**
  8825. * The name of the behavior
  8826. */
  8827. get: function () {
  8828. return "PointerDrag";
  8829. },
  8830. enumerable: true,
  8831. configurable: true
  8832. });
  8833. /**
  8834. * Initializes the behavior
  8835. */
  8836. PointerDragBehavior.prototype.init = function () { };
  8837. /**
  8838. * Attaches the drag behavior the passed in mesh
  8839. * @param ownerNode The mesh that will be dragged around once attached
  8840. */
  8841. PointerDragBehavior.prototype.attach = function (ownerNode) {
  8842. var _this = this;
  8843. this._scene = ownerNode.getScene();
  8844. this._attachedNode = ownerNode;
  8845. // Initialize drag plane to not interfere with existing scene
  8846. if (!PointerDragBehavior._planeScene) {
  8847. if (this._debugMode) {
  8848. PointerDragBehavior._planeScene = this._scene;
  8849. }
  8850. else {
  8851. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  8852. PointerDragBehavior._planeScene.detachControl();
  8853. this._scene.getEngine().scenes.pop();
  8854. this._scene.onDisposeObservable.addOnce(function () {
  8855. PointerDragBehavior._planeScene.dispose();
  8856. PointerDragBehavior._planeScene = null;
  8857. });
  8858. }
  8859. }
  8860. this._dragPlane = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane("pointerDragPlane", this._debugMode ? 1 : 10000, PointerDragBehavior._planeScene, false, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].DOUBLESIDE);
  8861. // State of the drag
  8862. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8863. var pickPredicate = function (m) {
  8864. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  8865. };
  8866. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  8867. if (!_this.enabled) {
  8868. return;
  8869. }
  8870. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  8871. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  8872. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  8873. }
  8874. }
  8875. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  8876. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  8877. _this.releaseDrag();
  8878. }
  8879. }
  8880. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  8881. var pointerId = pointerInfo.event.pointerId;
  8882. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  8883. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  8884. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  8885. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  8886. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  8887. }
  8888. _this.currentDraggingPointerID = pointerId;
  8889. }
  8890. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  8891. if (!_this._lastPointerRay[pointerId]) {
  8892. _this._lastPointerRay[pointerId] = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]());
  8893. }
  8894. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  8895. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  8896. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  8897. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  8898. _this._moveDrag(pointerInfo.pickInfo.ray);
  8899. }
  8900. }
  8901. }
  8902. });
  8903. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8904. if (_this._moving && _this.moveAttached) {
  8905. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  8906. // Slowly move mesh to avoid jitter
  8907. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  8908. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  8909. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  8910. if (_this.validateDrag(_this._tmpVector)) {
  8911. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  8912. }
  8913. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  8914. }
  8915. });
  8916. };
  8917. /**
  8918. * Force relase the drag action by code.
  8919. */
  8920. PointerDragBehavior.prototype.releaseDrag = function () {
  8921. this.dragging = false;
  8922. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  8923. this.currentDraggingPointerID = -1;
  8924. this._moving = false;
  8925. // Reattach camera controls
  8926. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8927. this._scene.activeCamera.attachControl(this._attachedElement, true);
  8928. }
  8929. };
  8930. /**
  8931. * Simulates the start of a pointer drag event on the behavior
  8932. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  8933. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  8934. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  8935. */
  8936. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  8937. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  8938. this._startDrag(pointerId, fromRay, startPickedPoint);
  8939. var lastRay = this._lastPointerRay[pointerId];
  8940. if (pointerId === PointerDragBehavior._AnyMouseID) {
  8941. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  8942. }
  8943. if (lastRay) {
  8944. // if there was a last pointer ray drag the object there
  8945. this._moveDrag(lastRay);
  8946. }
  8947. };
  8948. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  8949. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  8950. return;
  8951. }
  8952. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  8953. // Create start ray from the camera to the object
  8954. if (fromRay) {
  8955. this._startDragRay.direction.copyFrom(fromRay.direction);
  8956. this._startDragRay.origin.copyFrom(fromRay.origin);
  8957. }
  8958. else {
  8959. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  8960. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  8961. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  8962. }
  8963. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  8964. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  8965. if (pickedPoint) {
  8966. this.dragging = true;
  8967. this.currentDraggingPointerID = pointerId;
  8968. this.lastDragPosition.copyFrom(pickedPoint);
  8969. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  8970. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  8971. // Detatch camera controls
  8972. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8973. if (this._scene.activeCamera.inputs.attachedElement) {
  8974. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  8975. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  8976. }
  8977. else {
  8978. this._attachedElement = null;
  8979. }
  8980. }
  8981. }
  8982. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  8983. };
  8984. PointerDragBehavior.prototype._moveDrag = function (ray) {
  8985. this._moving = true;
  8986. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  8987. if (pickedPoint) {
  8988. if (this.updateDragPlane) {
  8989. this._updateDragPlanePosition(ray, pickedPoint);
  8990. }
  8991. var dragLength = 0;
  8992. // depending on the drag mode option drag accordingly
  8993. if (this._options.dragAxis) {
  8994. // Convert local drag axis to world
  8995. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  8996. // Project delta drag from the drag plane onto the drag axis
  8997. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  8998. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  8999. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9000. }
  9001. else {
  9002. dragLength = this._dragDelta.length();
  9003. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9004. }
  9005. this._targetPosition.addInPlace(this._dragDelta);
  9006. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9007. this.lastDragPosition.copyFrom(pickedPoint);
  9008. }
  9009. };
  9010. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9011. var _this = this;
  9012. if (!ray) {
  9013. return null;
  9014. }
  9015. // Calculate angle between plane normal and ray
  9016. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9017. // Correct if ray is casted from oposite side
  9018. if (angle > Math.PI / 2) {
  9019. angle = Math.PI - angle;
  9020. }
  9021. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9022. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9023. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9024. // Invert ray direction along the towards object axis
  9025. this._tmpVector.copyFrom(ray.direction);
  9026. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9027. this._alternatePickedPoint.normalize();
  9028. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9029. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9030. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9031. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9032. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9033. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9034. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9035. return this._alternatePickedPoint;
  9036. }
  9037. else {
  9038. return null;
  9039. }
  9040. }
  9041. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9042. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9043. return pickResult.pickedPoint;
  9044. }
  9045. else {
  9046. return null;
  9047. }
  9048. };
  9049. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9050. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9051. this._pointA.copyFrom(dragPlanePosition);
  9052. if (this._options.dragAxis) {
  9053. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis);
  9054. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9055. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9056. ray.origin.subtractToRef(this._pointA, this._pointC);
  9057. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9058. // Get perpendicular line from direction to camera and drag axis
  9059. this._pointB.subtractToRef(this._pointA, this._lineA);
  9060. this._pointC.subtractToRef(this._pointA, this._lineB);
  9061. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9062. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9064. this._lookAt.normalize();
  9065. this._dragPlane.position.copyFrom(this._pointA);
  9066. this._pointA.addToRef(this._lookAt, this._lookAt);
  9067. this._dragPlane.lookAt(this._lookAt);
  9068. }
  9069. else if (this._options.dragPlaneNormal) {
  9070. this.useObjectOrienationForDragging ? _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
  9071. this._dragPlane.position.copyFrom(this._pointA);
  9072. this._pointA.addToRef(this._localAxis, this._lookAt);
  9073. this._dragPlane.lookAt(this._lookAt);
  9074. }
  9075. else {
  9076. this._dragPlane.position.copyFrom(this._pointA);
  9077. this._dragPlane.lookAt(ray.origin);
  9078. }
  9079. this._dragPlane.computeWorldMatrix(true);
  9080. };
  9081. /**
  9082. * Detaches the behavior from the mesh
  9083. */
  9084. PointerDragBehavior.prototype.detach = function () {
  9085. if (this._pointerObserver) {
  9086. this._scene.onPointerObservable.remove(this._pointerObserver);
  9087. }
  9088. if (this._beforeRenderObserver) {
  9089. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9090. }
  9091. };
  9092. PointerDragBehavior._AnyMouseID = -2;
  9093. return PointerDragBehavior;
  9094. }());
  9095. /***/ }),
  9096. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9097. /*!************************************************!*\
  9098. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9099. \************************************************/
  9100. /*! exports provided: SixDofDragBehavior */
  9101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9102. "use strict";
  9103. __webpack_require__.r(__webpack_exports__);
  9104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9105. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9106. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9107. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9108. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9109. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9110. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9111. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9112. /**
  9113. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9114. */
  9115. var SixDofDragBehavior = /** @class */ (function () {
  9116. /**
  9117. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9118. */
  9119. function SixDofDragBehavior() {
  9120. this._sceneRenderObserver = null;
  9121. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9122. this._moving = false;
  9123. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9124. /**
  9125. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  9126. */
  9127. this.zDragFactor = 3;
  9128. /**
  9129. * If the object should rotate to face the drag origin
  9130. */
  9131. this.rotateDraggedObject = true;
  9132. /**
  9133. * If the behavior is currently in a dragging state
  9134. */
  9135. this.dragging = false;
  9136. /**
  9137. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  9138. */
  9139. this.dragDeltaRatio = 0.2;
  9140. /**
  9141. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9142. */
  9143. this.currentDraggingPointerID = -1;
  9144. /**
  9145. * If camera controls should be detached during the drag
  9146. */
  9147. this.detachCameraControls = true;
  9148. /**
  9149. * Fires each time a drag starts
  9150. */
  9151. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9152. /**
  9153. * Fires each time a drag ends (eg. mouse release after drag)
  9154. */
  9155. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9156. }
  9157. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9158. /**
  9159. * The name of the behavior
  9160. */
  9161. get: function () {
  9162. return "SixDofDrag";
  9163. },
  9164. enumerable: true,
  9165. configurable: true
  9166. });
  9167. /**
  9168. * Initializes the behavior
  9169. */
  9170. SixDofDragBehavior.prototype.init = function () { };
  9171. /**
  9172. * Attaches the scale behavior the passed in mesh
  9173. * @param ownerNode The mesh that will be scaled around once attached
  9174. */
  9175. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9176. var _this = this;
  9177. this._ownerNode = ownerNode;
  9178. this._scene = this._ownerNode.getScene();
  9179. if (!SixDofDragBehavior._virtualScene) {
  9180. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9181. SixDofDragBehavior._virtualScene.detachControl();
  9182. this._scene.getEngine().scenes.pop();
  9183. }
  9184. var pickedMesh = null;
  9185. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9186. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9187. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9188. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9189. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9190. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9191. var pickPredicate = function (m) {
  9192. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9193. };
  9194. var attachedElement = null;
  9195. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9196. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9197. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9198. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9199. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9200. }
  9201. pickedMesh = _this._ownerNode;
  9202. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9203. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9204. // Set position and orientation of the controller
  9205. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9206. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9207. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9208. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9209. pickedMesh.computeWorldMatrix();
  9210. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9211. if (!pickedMesh.rotationQuaternion) {
  9212. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9213. }
  9214. var oldParent = pickedMesh.parent;
  9215. pickedMesh.setParent(null);
  9216. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9217. pickedMesh.setParent(oldParent);
  9218. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9219. // Update state
  9220. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9221. _this.dragging = true;
  9222. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9223. // Detatch camera controls
  9224. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9225. if (_this._scene.activeCamera.inputs.attachedElement) {
  9226. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9227. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9228. }
  9229. else {
  9230. attachedElement = null;
  9231. }
  9232. }
  9233. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9234. _this.onDragStartObservable.notifyObservers({});
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9238. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9239. _this.dragging = false;
  9240. _this._moving = false;
  9241. _this.currentDraggingPointerID = -1;
  9242. pickedMesh = null;
  9243. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9244. // Reattach camera controls
  9245. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9246. _this._scene.activeCamera.attachControl(attachedElement, true);
  9247. }
  9248. _this.onDragEndObservable.notifyObservers({});
  9249. }
  9250. }
  9251. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9252. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9253. var zDragFactor = _this.zDragFactor;
  9254. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9255. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9256. zDragFactor = 0;
  9257. }
  9258. // Calculate controller drag distance in controller space
  9259. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9260. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9261. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9262. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9263. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9264. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9265. if (_this._virtualDragMesh.position.z < 0) {
  9266. _this._virtualDragMesh.position.z = 0;
  9267. }
  9268. // Update the controller position
  9269. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9270. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9271. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9272. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9273. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9274. if (pickedMesh.parent) {
  9275. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9276. }
  9277. if (!_this._moving) {
  9278. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9279. }
  9280. _this._moving = true;
  9281. }
  9282. }
  9283. });
  9284. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9285. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9286. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9287. if (_this.dragging && _this._moving && pickedMesh) {
  9288. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9289. // Slowly move mesh to avoid jitter
  9290. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9291. if (_this.rotateDraggedObject) {
  9292. // Get change in rotation
  9293. tmpQuaternion.copyFrom(_this._startingOrientation);
  9294. tmpQuaternion.x = -tmpQuaternion.x;
  9295. tmpQuaternion.y = -tmpQuaternion.y;
  9296. tmpQuaternion.z = -tmpQuaternion.z;
  9297. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9298. // Convert change in rotation to only y axis rotation
  9299. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9300. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9301. // Slowly move mesh to avoid jitter
  9302. var oldParent = pickedMesh.parent;
  9303. // Only rotate the mesh if it's parent has uniform scaling
  9304. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9305. pickedMesh.setParent(null);
  9306. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9307. pickedMesh.setParent(oldParent);
  9308. }
  9309. }
  9310. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9311. }
  9312. });
  9313. };
  9314. /**
  9315. * Detaches the behavior from the mesh
  9316. */
  9317. SixDofDragBehavior.prototype.detach = function () {
  9318. if (this._scene) {
  9319. this._scene.onPointerObservable.remove(this._pointerObserver);
  9320. }
  9321. if (this._ownerNode) {
  9322. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9323. }
  9324. if (this._virtualOriginMesh) {
  9325. this._virtualOriginMesh.dispose();
  9326. }
  9327. if (this._virtualDragMesh) {
  9328. this._virtualDragMesh.dispose();
  9329. }
  9330. this.onDragEndObservable.clear();
  9331. this.onDragStartObservable.clear();
  9332. };
  9333. return SixDofDragBehavior;
  9334. }());
  9335. /***/ }),
  9336. /***/ "./Behaviors/index.ts":
  9337. /*!****************************!*\
  9338. !*** ./Behaviors/index.ts ***!
  9339. \****************************/
  9340. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  9341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9342. "use strict";
  9343. __webpack_require__.r(__webpack_exports__);
  9344. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9348. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9354. /***/ }),
  9355. /***/ "./Bones/bone.ts":
  9356. /*!***********************!*\
  9357. !*** ./Bones/bone.ts ***!
  9358. \***********************/
  9359. /*! exports provided: Bone */
  9360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9361. "use strict";
  9362. __webpack_require__.r(__webpack_exports__);
  9363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9365. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9366. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9367. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  9368. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  9369. /**
  9370. * Class used to store bone information
  9371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9372. */
  9373. var Bone = /** @class */ (function (_super) {
  9374. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9375. /**
  9376. * Create a new bone
  9377. * @param name defines the bone name
  9378. * @param skeleton defines the parent skeleton
  9379. * @param parentBone defines the parent (can be null if the bone is the root)
  9380. * @param localMatrix defines the local matrix
  9381. * @param restPose defines the rest pose matrix
  9382. * @param baseMatrix defines the base matrix
  9383. * @param index defines index of the bone in the hiearchy
  9384. */
  9385. function Bone(
  9386. /**
  9387. * defines the bone name
  9388. */
  9389. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9390. if (parentBone === void 0) { parentBone = null; }
  9391. if (localMatrix === void 0) { localMatrix = null; }
  9392. if (restPose === void 0) { restPose = null; }
  9393. if (baseMatrix === void 0) { baseMatrix = null; }
  9394. if (index === void 0) { index = null; }
  9395. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9396. _this.name = name;
  9397. /**
  9398. * Gets the list of child bones
  9399. */
  9400. _this.children = new Array();
  9401. /** Gets the animations associated with this bone */
  9402. _this.animations = new Array();
  9403. /**
  9404. * @hidden Internal only
  9405. * Set this value to map this bone to a different index in the transform matrices
  9406. * Set this value to -1 to exclude the bone from the transform matrices
  9407. */
  9408. _this._index = null;
  9409. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9410. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9411. _this._scalingDeterminant = 1;
  9412. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9413. _this._needToDecompose = true;
  9414. _this._needToCompose = false;
  9415. /** @hidden */
  9416. _this._linkedTransformNode = null;
  9417. _this._skeleton = skeleton;
  9418. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9419. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9420. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9421. _this._index = index;
  9422. skeleton.bones.push(_this);
  9423. _this.setParent(parentBone, false);
  9424. if (baseMatrix || localMatrix) {
  9425. _this._updateDifferenceMatrix();
  9426. }
  9427. return _this;
  9428. }
  9429. Object.defineProperty(Bone.prototype, "_matrix", {
  9430. /** @hidden */
  9431. get: function () {
  9432. this._compose();
  9433. return this._localMatrix;
  9434. },
  9435. /** @hidden */
  9436. set: function (value) {
  9437. this._localMatrix.copyFrom(value);
  9438. this._needToDecompose = true;
  9439. },
  9440. enumerable: true,
  9441. configurable: true
  9442. });
  9443. // Members
  9444. /**
  9445. * Gets the parent skeleton
  9446. * @returns a skeleton
  9447. */
  9448. Bone.prototype.getSkeleton = function () {
  9449. return this._skeleton;
  9450. };
  9451. /**
  9452. * Gets parent bone
  9453. * @returns a bone or null if the bone is the root of the bone hierarchy
  9454. */
  9455. Bone.prototype.getParent = function () {
  9456. return this._parent;
  9457. };
  9458. /**
  9459. * Sets the parent bone
  9460. * @param parent defines the parent (can be null if the bone is the root)
  9461. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9462. */
  9463. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9464. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9465. if (this._parent === parent) {
  9466. return;
  9467. }
  9468. if (this._parent) {
  9469. var index = this._parent.children.indexOf(this);
  9470. if (index !== -1) {
  9471. this._parent.children.splice(index, 1);
  9472. }
  9473. }
  9474. this._parent = parent;
  9475. if (this._parent) {
  9476. this._parent.children.push(this);
  9477. }
  9478. if (updateDifferenceMatrix) {
  9479. this._updateDifferenceMatrix();
  9480. }
  9481. this.markAsDirty();
  9482. };
  9483. /**
  9484. * Gets the local matrix
  9485. * @returns a matrix
  9486. */
  9487. Bone.prototype.getLocalMatrix = function () {
  9488. this._compose();
  9489. return this._localMatrix;
  9490. };
  9491. /**
  9492. * Gets the base matrix (initial matrix which remains unchanged)
  9493. * @returns a matrix
  9494. */
  9495. Bone.prototype.getBaseMatrix = function () {
  9496. return this._baseMatrix;
  9497. };
  9498. /**
  9499. * Gets the rest pose matrix
  9500. * @returns a matrix
  9501. */
  9502. Bone.prototype.getRestPose = function () {
  9503. return this._restPose;
  9504. };
  9505. /**
  9506. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9507. */
  9508. Bone.prototype.getWorldMatrix = function () {
  9509. return this._worldTransform;
  9510. };
  9511. /**
  9512. * Sets the local matrix to rest pose matrix
  9513. */
  9514. Bone.prototype.returnToRest = function () {
  9515. this.updateMatrix(this._restPose.clone());
  9516. };
  9517. /**
  9518. * Gets the inverse of the absolute transform matrix.
  9519. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9520. * @returns a matrix
  9521. */
  9522. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9523. return this._invertedAbsoluteTransform;
  9524. };
  9525. /**
  9526. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9527. * @returns a matrix
  9528. */
  9529. Bone.prototype.getAbsoluteTransform = function () {
  9530. return this._absoluteTransform;
  9531. };
  9532. /**
  9533. * Links with the given transform node.
  9534. * The local matrix of this bone is copied from the transform node every frame.
  9535. * @param transformNode defines the transform node to link to
  9536. */
  9537. Bone.prototype.linkTransformNode = function (transformNode) {
  9538. if (this._linkedTransformNode) {
  9539. this._skeleton._numBonesWithLinkedTransformNode--;
  9540. }
  9541. this._linkedTransformNode = transformNode;
  9542. if (this._linkedTransformNode) {
  9543. this._skeleton._numBonesWithLinkedTransformNode++;
  9544. }
  9545. };
  9546. Object.defineProperty(Bone.prototype, "position", {
  9547. // Properties (matches AbstractMesh properties)
  9548. /** Gets or sets current position (in local space) */
  9549. get: function () {
  9550. this._decompose();
  9551. return this._localPosition;
  9552. },
  9553. set: function (newPosition) {
  9554. this._decompose();
  9555. this._localPosition.copyFrom(newPosition);
  9556. this._markAsDirtyAndCompose();
  9557. },
  9558. enumerable: true,
  9559. configurable: true
  9560. });
  9561. Object.defineProperty(Bone.prototype, "rotation", {
  9562. /** Gets or sets current rotation (in local space) */
  9563. get: function () {
  9564. return this.getRotation();
  9565. },
  9566. set: function (newRotation) {
  9567. this.setRotation(newRotation);
  9568. },
  9569. enumerable: true,
  9570. configurable: true
  9571. });
  9572. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9573. /** Gets or sets current rotation quaternion (in local space) */
  9574. get: function () {
  9575. this._decompose();
  9576. return this._localRotation;
  9577. },
  9578. set: function (newRotation) {
  9579. this.setRotationQuaternion(newRotation);
  9580. },
  9581. enumerable: true,
  9582. configurable: true
  9583. });
  9584. Object.defineProperty(Bone.prototype, "scaling", {
  9585. /** Gets or sets current scaling (in local space) */
  9586. get: function () {
  9587. return this.getScale();
  9588. },
  9589. set: function (newScaling) {
  9590. this.setScale(newScaling);
  9591. },
  9592. enumerable: true,
  9593. configurable: true
  9594. });
  9595. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9596. /**
  9597. * Gets the animation properties override
  9598. */
  9599. get: function () {
  9600. return this._skeleton.animationPropertiesOverride;
  9601. },
  9602. enumerable: true,
  9603. configurable: true
  9604. });
  9605. // Methods
  9606. Bone.prototype._decompose = function () {
  9607. if (!this._needToDecompose) {
  9608. return;
  9609. }
  9610. this._needToDecompose = false;
  9611. if (!this._localScaling) {
  9612. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9613. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9614. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9615. }
  9616. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9617. };
  9618. Bone.prototype._compose = function () {
  9619. if (!this._needToCompose) {
  9620. return;
  9621. }
  9622. this._needToCompose = false;
  9623. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9624. };
  9625. /**
  9626. * Update the base and local matrices
  9627. * @param matrix defines the new base or local matrix
  9628. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9629. * @param updateLocalMatrix defines if the local matrix should be updated
  9630. */
  9631. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9632. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9633. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9634. this._baseMatrix.copyFrom(matrix);
  9635. if (updateDifferenceMatrix) {
  9636. this._updateDifferenceMatrix();
  9637. }
  9638. if (updateLocalMatrix) {
  9639. this._localMatrix.copyFrom(matrix);
  9640. this._markAsDirtyAndDecompose();
  9641. }
  9642. else {
  9643. this.markAsDirty();
  9644. }
  9645. };
  9646. /** @hidden */
  9647. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  9648. if (updateChildren === void 0) { updateChildren = true; }
  9649. if (!rootMatrix) {
  9650. rootMatrix = this._baseMatrix;
  9651. }
  9652. if (this._parent) {
  9653. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  9654. }
  9655. else {
  9656. this._absoluteTransform.copyFrom(rootMatrix);
  9657. }
  9658. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  9659. if (updateChildren) {
  9660. for (var index = 0; index < this.children.length; index++) {
  9661. this.children[index]._updateDifferenceMatrix();
  9662. }
  9663. }
  9664. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  9665. };
  9666. /**
  9667. * Flag the bone as dirty (Forcing it to update everything)
  9668. */
  9669. Bone.prototype.markAsDirty = function () {
  9670. this._currentRenderId++;
  9671. this._childRenderId++;
  9672. this._skeleton._markAsDirty();
  9673. };
  9674. Bone.prototype._markAsDirtyAndCompose = function () {
  9675. this.markAsDirty();
  9676. this._needToCompose = true;
  9677. };
  9678. Bone.prototype._markAsDirtyAndDecompose = function () {
  9679. this.markAsDirty();
  9680. this._needToDecompose = true;
  9681. };
  9682. /**
  9683. * Copy an animation range from another bone
  9684. * @param source defines the source bone
  9685. * @param rangeName defines the range name to copy
  9686. * @param frameOffset defines the frame offset
  9687. * @param rescaleAsRequired defines if rescaling must be applied if required
  9688. * @param skelDimensionsRatio defines the scaling ratio
  9689. * @returns true if operation was successful
  9690. */
  9691. Bone.prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  9692. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  9693. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  9694. // all animation may be coming from a library skeleton, so may need to create animation
  9695. if (this.animations.length === 0) {
  9696. this.animations.push(new _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  9697. this.animations[0].setKeys([]);
  9698. }
  9699. // get animation info / verify there is such a range from the source bone
  9700. var sourceRange = source.animations[0].getRange(rangeName);
  9701. if (!sourceRange) {
  9702. return false;
  9703. }
  9704. var from = sourceRange.from;
  9705. var to = sourceRange.to;
  9706. var sourceKeys = source.animations[0].getKeys();
  9707. // rescaling prep
  9708. var sourceBoneLength = source.length;
  9709. var sourceParent = source.getParent();
  9710. var parent = this.getParent();
  9711. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  9712. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  9713. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  9714. var destKeys = this.animations[0].getKeys();
  9715. // loop vars declaration
  9716. var orig;
  9717. var origTranslation;
  9718. var mat;
  9719. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  9720. orig = sourceKeys[key];
  9721. if (orig.frame >= from && orig.frame <= to) {
  9722. if (rescaleAsRequired) {
  9723. mat = orig.value.clone();
  9724. // scale based on parent ratio, when bone has parent
  9725. if (parentScalingReqd) {
  9726. origTranslation = mat.getTranslation();
  9727. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  9728. // scale based on skeleton dimension ratio when root bone, and value is passed
  9729. }
  9730. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  9731. origTranslation = mat.getTranslation();
  9732. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  9733. // use original when root bone, and no data for skelDimensionsRatio
  9734. }
  9735. else {
  9736. mat = orig.value;
  9737. }
  9738. }
  9739. else {
  9740. mat = orig.value;
  9741. }
  9742. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  9743. }
  9744. }
  9745. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  9746. return true;
  9747. };
  9748. /**
  9749. * Translate the bone in local or world space
  9750. * @param vec The amount to translate the bone
  9751. * @param space The space that the translation is in
  9752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9753. */
  9754. Bone.prototype.translate = function (vec, space, mesh) {
  9755. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9756. var lm = this.getLocalMatrix();
  9757. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9758. lm.addAtIndex(12, vec.x);
  9759. lm.addAtIndex(13, vec.y);
  9760. lm.addAtIndex(14, vec.z);
  9761. }
  9762. else {
  9763. var wm = null;
  9764. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9765. if (mesh) {
  9766. wm = mesh.getWorldMatrix();
  9767. }
  9768. this._skeleton.computeAbsoluteTransforms();
  9769. var tmat = Bone._tmpMats[0];
  9770. var tvec = Bone._tmpVecs[0];
  9771. if (this._parent) {
  9772. if (mesh && wm) {
  9773. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9774. tmat.multiplyToRef(wm, tmat);
  9775. }
  9776. else {
  9777. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9778. }
  9779. }
  9780. tmat.setTranslationFromFloats(0, 0, 0);
  9781. tmat.invert();
  9782. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  9783. lm.addAtIndex(12, tvec.x);
  9784. lm.addAtIndex(13, tvec.y);
  9785. lm.addAtIndex(14, tvec.z);
  9786. }
  9787. this._markAsDirtyAndDecompose();
  9788. };
  9789. /**
  9790. * Set the postion of the bone in local or world space
  9791. * @param position The position to set the bone
  9792. * @param space The space that the position is in
  9793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9794. */
  9795. Bone.prototype.setPosition = function (position, space, mesh) {
  9796. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9797. var lm = this.getLocalMatrix();
  9798. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9799. lm.setTranslationFromFloats(position.x, position.y, position.z);
  9800. }
  9801. else {
  9802. var wm = null;
  9803. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9804. if (mesh) {
  9805. wm = mesh.getWorldMatrix();
  9806. }
  9807. this._skeleton.computeAbsoluteTransforms();
  9808. var tmat = Bone._tmpMats[0];
  9809. var vec = Bone._tmpVecs[0];
  9810. if (this._parent) {
  9811. if (mesh && wm) {
  9812. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9813. tmat.multiplyToRef(wm, tmat);
  9814. }
  9815. else {
  9816. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9817. }
  9818. }
  9819. tmat.invert();
  9820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  9821. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  9822. }
  9823. this._markAsDirtyAndDecompose();
  9824. };
  9825. /**
  9826. * Set the absolute position of the bone (world space)
  9827. * @param position The position to set the bone
  9828. * @param mesh The mesh that this bone is attached to
  9829. */
  9830. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  9831. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  9832. };
  9833. /**
  9834. * Scale the bone on the x, y and z axes (in local space)
  9835. * @param x The amount to scale the bone on the x axis
  9836. * @param y The amount to scale the bone on the y axis
  9837. * @param z The amount to scale the bone on the z axis
  9838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9839. */
  9840. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  9841. if (scaleChildren === void 0) { scaleChildren = false; }
  9842. var locMat = this.getLocalMatrix();
  9843. // Apply new scaling on top of current local matrix
  9844. var scaleMat = Bone._tmpMats[0];
  9845. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  9846. scaleMat.multiplyToRef(locMat, locMat);
  9847. // Invert scaling matrix and apply the inverse to all children
  9848. scaleMat.invert();
  9849. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9850. var child = _a[_i];
  9851. var cm = child.getLocalMatrix();
  9852. cm.multiplyToRef(scaleMat, cm);
  9853. cm.multiplyAtIndex(12, x);
  9854. cm.multiplyAtIndex(13, y);
  9855. cm.multiplyAtIndex(14, z);
  9856. child._markAsDirtyAndDecompose();
  9857. }
  9858. this._markAsDirtyAndDecompose();
  9859. if (scaleChildren) {
  9860. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  9861. var child = _c[_b];
  9862. child.scale(x, y, z, scaleChildren);
  9863. }
  9864. }
  9865. };
  9866. /**
  9867. * Set the bone scaling in local space
  9868. * @param scale defines the scaling vector
  9869. */
  9870. Bone.prototype.setScale = function (scale) {
  9871. this._decompose();
  9872. this._localScaling.copyFrom(scale);
  9873. this._markAsDirtyAndCompose();
  9874. };
  9875. /**
  9876. * Gets the current scaling in local space
  9877. * @returns the current scaling vector
  9878. */
  9879. Bone.prototype.getScale = function () {
  9880. this._decompose();
  9881. return this._localScaling;
  9882. };
  9883. /**
  9884. * Gets the current scaling in local space and stores it in a target vector
  9885. * @param result defines the target vector
  9886. */
  9887. Bone.prototype.getScaleToRef = function (result) {
  9888. this._decompose();
  9889. result.copyFrom(this._localScaling);
  9890. };
  9891. /**
  9892. * Set the yaw, pitch, and roll of the bone in local or world space
  9893. * @param yaw The rotation of the bone on the y axis
  9894. * @param pitch The rotation of the bone on the x axis
  9895. * @param roll The rotation of the bone on the z axis
  9896. * @param space The space that the axes of rotation are in
  9897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9898. */
  9899. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  9900. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9901. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9902. var quat = Bone._tmpQuat;
  9903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  9904. this.setRotationQuaternion(quat, space, mesh);
  9905. return;
  9906. }
  9907. var rotMatInv = Bone._tmpMats[0];
  9908. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9909. return;
  9910. }
  9911. var rotMat = Bone._tmpMats[1];
  9912. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  9913. rotMatInv.multiplyToRef(rotMat, rotMat);
  9914. this._rotateWithMatrix(rotMat, space, mesh);
  9915. };
  9916. /**
  9917. * Add a rotation to the bone on an axis in local or world space
  9918. * @param axis The axis to rotate the bone on
  9919. * @param amount The amount to rotate the bone
  9920. * @param space The space that the axis is in
  9921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9922. */
  9923. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  9924. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9925. var rmat = Bone._tmpMats[0];
  9926. rmat.setTranslationFromFloats(0, 0, 0);
  9927. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  9928. this._rotateWithMatrix(rmat, space, mesh);
  9929. };
  9930. /**
  9931. * Set the rotation of the bone to a particular axis angle in local or world space
  9932. * @param axis The axis to rotate the bone on
  9933. * @param angle The angle that the bone should be rotated to
  9934. * @param space The space that the axis is in
  9935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9936. */
  9937. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  9938. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9939. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9940. var quat = Bone._tmpQuat;
  9941. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  9942. this.setRotationQuaternion(quat, space, mesh);
  9943. return;
  9944. }
  9945. var rotMatInv = Bone._tmpMats[0];
  9946. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9947. return;
  9948. }
  9949. var rotMat = Bone._tmpMats[1];
  9950. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  9951. rotMatInv.multiplyToRef(rotMat, rotMat);
  9952. this._rotateWithMatrix(rotMat, space, mesh);
  9953. };
  9954. /**
  9955. * Set the euler rotation of the bone in local of world space
  9956. * @param rotation The euler rotation that the bone should be set to
  9957. * @param space The space that the rotation is in
  9958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9959. */
  9960. Bone.prototype.setRotation = function (rotation, space, mesh) {
  9961. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9962. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  9963. };
  9964. /**
  9965. * Set the quaternion rotation of the bone in local of world space
  9966. * @param quat The quaternion rotation that the bone should be set to
  9967. * @param space The space that the rotation is in
  9968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9969. */
  9970. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  9971. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9972. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9973. this._decompose();
  9974. this._localRotation.copyFrom(quat);
  9975. this._markAsDirtyAndCompose();
  9976. return;
  9977. }
  9978. var rotMatInv = Bone._tmpMats[0];
  9979. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9980. return;
  9981. }
  9982. var rotMat = Bone._tmpMats[1];
  9983. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  9984. rotMatInv.multiplyToRef(rotMat, rotMat);
  9985. this._rotateWithMatrix(rotMat, space, mesh);
  9986. };
  9987. /**
  9988. * Set the rotation matrix of the bone in local of world space
  9989. * @param rotMat The rotation matrix that the bone should be set to
  9990. * @param space The space that the rotation is in
  9991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9992. */
  9993. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  9994. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9995. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9996. var quat = Bone._tmpQuat;
  9997. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  9998. this.setRotationQuaternion(quat, space, mesh);
  9999. return;
  10000. }
  10001. var rotMatInv = Bone._tmpMats[0];
  10002. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10003. return;
  10004. }
  10005. var rotMat2 = Bone._tmpMats[1];
  10006. rotMat2.copyFrom(rotMat);
  10007. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10008. this._rotateWithMatrix(rotMat2, space, mesh);
  10009. };
  10010. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10011. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10012. var lmat = this.getLocalMatrix();
  10013. var lx = lmat.m[12];
  10014. var ly = lmat.m[13];
  10015. var lz = lmat.m[14];
  10016. var parent = this.getParent();
  10017. var parentScale = Bone._tmpMats[3];
  10018. var parentScaleInv = Bone._tmpMats[4];
  10019. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10020. if (mesh) {
  10021. parentScale.copyFrom(mesh.getWorldMatrix());
  10022. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10023. }
  10024. else {
  10025. parentScale.copyFrom(parent.getAbsoluteTransform());
  10026. }
  10027. parentScaleInv.copyFrom(parentScale);
  10028. parentScaleInv.invert();
  10029. lmat.multiplyToRef(parentScale, lmat);
  10030. lmat.multiplyToRef(rmat, lmat);
  10031. lmat.multiplyToRef(parentScaleInv, lmat);
  10032. }
  10033. else {
  10034. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10035. parentScale.copyFrom(mesh.getWorldMatrix());
  10036. parentScaleInv.copyFrom(parentScale);
  10037. parentScaleInv.invert();
  10038. lmat.multiplyToRef(parentScale, lmat);
  10039. lmat.multiplyToRef(rmat, lmat);
  10040. lmat.multiplyToRef(parentScaleInv, lmat);
  10041. }
  10042. else {
  10043. lmat.multiplyToRef(rmat, lmat);
  10044. }
  10045. }
  10046. lmat.setTranslationFromFloats(lx, ly, lz);
  10047. this.computeAbsoluteTransforms();
  10048. this._markAsDirtyAndDecompose();
  10049. };
  10050. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10051. var scaleMatrix = Bone._tmpMats[2];
  10052. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10053. if (mesh) {
  10054. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10056. }
  10057. rotMatInv.invert();
  10058. if (isNaN(rotMatInv.m[0])) {
  10059. // Matrix failed to invert.
  10060. // This can happen if scale is zero for example.
  10061. return false;
  10062. }
  10063. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10064. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10065. return true;
  10066. };
  10067. /**
  10068. * Get the position of the bone in local or world space
  10069. * @param space The space that the returned position is in
  10070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10071. * @returns The position of the bone
  10072. */
  10073. Bone.prototype.getPosition = function (space, mesh) {
  10074. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10075. if (mesh === void 0) { mesh = null; }
  10076. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10077. this.getPositionToRef(space, mesh, pos);
  10078. return pos;
  10079. };
  10080. /**
  10081. * Copy the position of the bone to a vector3 in local or world space
  10082. * @param space The space that the returned position is in
  10083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10084. * @param result The vector3 to copy the position to
  10085. */
  10086. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10087. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10088. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10089. var lm = this.getLocalMatrix();
  10090. result.x = lm.m[12];
  10091. result.y = lm.m[13];
  10092. result.z = lm.m[14];
  10093. }
  10094. else {
  10095. var wm = null;
  10096. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10097. if (mesh) {
  10098. wm = mesh.getWorldMatrix();
  10099. }
  10100. this._skeleton.computeAbsoluteTransforms();
  10101. var tmat = Bone._tmpMats[0];
  10102. if (mesh && wm) {
  10103. tmat.copyFrom(this.getAbsoluteTransform());
  10104. tmat.multiplyToRef(wm, tmat);
  10105. }
  10106. else {
  10107. tmat = this.getAbsoluteTransform();
  10108. }
  10109. result.x = tmat.m[12];
  10110. result.y = tmat.m[13];
  10111. result.z = tmat.m[14];
  10112. }
  10113. };
  10114. /**
  10115. * Get the absolute position of the bone (world space)
  10116. * @param mesh The mesh that this bone is attached to
  10117. * @returns The absolute position of the bone
  10118. */
  10119. Bone.prototype.getAbsolutePosition = function (mesh) {
  10120. if (mesh === void 0) { mesh = null; }
  10121. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10122. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10123. return pos;
  10124. };
  10125. /**
  10126. * Copy the absolute position of the bone (world space) to the result param
  10127. * @param mesh The mesh that this bone is attached to
  10128. * @param result The vector3 to copy the absolute position to
  10129. */
  10130. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10131. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10132. };
  10133. /**
  10134. * Compute the absolute transforms of this bone and its children
  10135. */
  10136. Bone.prototype.computeAbsoluteTransforms = function () {
  10137. this._compose();
  10138. if (this._parent) {
  10139. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10140. }
  10141. else {
  10142. this._absoluteTransform.copyFrom(this._localMatrix);
  10143. var poseMatrix = this._skeleton.getPoseMatrix();
  10144. if (poseMatrix) {
  10145. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10146. }
  10147. }
  10148. var children = this.children;
  10149. var len = children.length;
  10150. for (var i = 0; i < len; i++) {
  10151. children[i].computeAbsoluteTransforms();
  10152. }
  10153. };
  10154. /**
  10155. * Get the world direction from an axis that is in the local space of the bone
  10156. * @param localAxis The local direction that is used to compute the world direction
  10157. * @param mesh The mesh that this bone is attached to
  10158. * @returns The world direction
  10159. */
  10160. Bone.prototype.getDirection = function (localAxis, mesh) {
  10161. if (mesh === void 0) { mesh = null; }
  10162. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10163. this.getDirectionToRef(localAxis, mesh, result);
  10164. return result;
  10165. };
  10166. /**
  10167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10168. * @param localAxis The local direction that is used to compute the world direction
  10169. * @param mesh The mesh that this bone is attached to
  10170. * @param result The vector3 that the world direction will be copied to
  10171. */
  10172. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10173. if (mesh === void 0) { mesh = null; }
  10174. var wm = null;
  10175. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10176. if (mesh) {
  10177. wm = mesh.getWorldMatrix();
  10178. }
  10179. this._skeleton.computeAbsoluteTransforms();
  10180. var mat = Bone._tmpMats[0];
  10181. mat.copyFrom(this.getAbsoluteTransform());
  10182. if (mesh && wm) {
  10183. mat.multiplyToRef(wm, mat);
  10184. }
  10185. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10186. result.normalize();
  10187. };
  10188. /**
  10189. * Get the euler rotation of the bone in local or world space
  10190. * @param space The space that the rotation should be in
  10191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10192. * @returns The euler rotation
  10193. */
  10194. Bone.prototype.getRotation = function (space, mesh) {
  10195. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10196. if (mesh === void 0) { mesh = null; }
  10197. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10198. this.getRotationToRef(space, mesh, result);
  10199. return result;
  10200. };
  10201. /**
  10202. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10203. * @param space The space that the rotation should be in
  10204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10205. * @param result The vector3 that the rotation should be copied to
  10206. */
  10207. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10208. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10209. if (mesh === void 0) { mesh = null; }
  10210. var quat = Bone._tmpQuat;
  10211. this.getRotationQuaternionToRef(space, mesh, quat);
  10212. quat.toEulerAnglesToRef(result);
  10213. };
  10214. /**
  10215. * Get the quaternion rotation of the bone in either local or world space
  10216. * @param space The space that the rotation should be in
  10217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10218. * @returns The quaternion rotation
  10219. */
  10220. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10221. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10222. if (mesh === void 0) { mesh = null; }
  10223. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10224. this.getRotationQuaternionToRef(space, mesh, result);
  10225. return result;
  10226. };
  10227. /**
  10228. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10229. * @param space The space that the rotation should be in
  10230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10231. * @param result The quaternion that the rotation should be copied to
  10232. */
  10233. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10234. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10235. if (mesh === void 0) { mesh = null; }
  10236. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10237. this._decompose();
  10238. result.copyFrom(this._localRotation);
  10239. }
  10240. else {
  10241. var mat = Bone._tmpMats[0];
  10242. var amat = this.getAbsoluteTransform();
  10243. if (mesh) {
  10244. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10245. }
  10246. else {
  10247. mat.copyFrom(amat);
  10248. }
  10249. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10250. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10251. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10252. mat.decompose(undefined, result, undefined);
  10253. }
  10254. };
  10255. /**
  10256. * Get the rotation matrix of the bone in local or world space
  10257. * @param space The space that the rotation should be in
  10258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10259. * @returns The rotation matrix
  10260. */
  10261. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10262. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10263. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10264. this.getRotationMatrixToRef(space, mesh, result);
  10265. return result;
  10266. };
  10267. /**
  10268. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10269. * @param space The space that the rotation should be in
  10270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10271. * @param result The quaternion that the rotation should be copied to
  10272. */
  10273. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10274. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10275. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10276. this.getLocalMatrix().getRotationMatrixToRef(result);
  10277. }
  10278. else {
  10279. var mat = Bone._tmpMats[0];
  10280. var amat = this.getAbsoluteTransform();
  10281. if (mesh) {
  10282. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10283. }
  10284. else {
  10285. mat.copyFrom(amat);
  10286. }
  10287. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10288. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10289. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10290. mat.getRotationMatrixToRef(result);
  10291. }
  10292. };
  10293. /**
  10294. * Get the world position of a point that is in the local space of the bone
  10295. * @param position The local position
  10296. * @param mesh The mesh that this bone is attached to
  10297. * @returns The world position
  10298. */
  10299. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10300. if (mesh === void 0) { mesh = null; }
  10301. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10302. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10303. return result;
  10304. };
  10305. /**
  10306. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10307. * @param position The local position
  10308. * @param mesh The mesh that this bone is attached to
  10309. * @param result The vector3 that the world position should be copied to
  10310. */
  10311. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10312. if (mesh === void 0) { mesh = null; }
  10313. var wm = null;
  10314. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10315. if (mesh) {
  10316. wm = mesh.getWorldMatrix();
  10317. }
  10318. this._skeleton.computeAbsoluteTransforms();
  10319. var tmat = Bone._tmpMats[0];
  10320. if (mesh && wm) {
  10321. tmat.copyFrom(this.getAbsoluteTransform());
  10322. tmat.multiplyToRef(wm, tmat);
  10323. }
  10324. else {
  10325. tmat = this.getAbsoluteTransform();
  10326. }
  10327. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10328. };
  10329. /**
  10330. * Get the local position of a point that is in world space
  10331. * @param position The world position
  10332. * @param mesh The mesh that this bone is attached to
  10333. * @returns The local position
  10334. */
  10335. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10336. if (mesh === void 0) { mesh = null; }
  10337. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10338. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10339. return result;
  10340. };
  10341. /**
  10342. * Get the local position of a point that is in world space and copy it to the result param
  10343. * @param position The world position
  10344. * @param mesh The mesh that this bone is attached to
  10345. * @param result The vector3 that the local position should be copied to
  10346. */
  10347. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10348. if (mesh === void 0) { mesh = null; }
  10349. var wm = null;
  10350. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10351. if (mesh) {
  10352. wm = mesh.getWorldMatrix();
  10353. }
  10354. this._skeleton.computeAbsoluteTransforms();
  10355. var tmat = Bone._tmpMats[0];
  10356. tmat.copyFrom(this.getAbsoluteTransform());
  10357. if (mesh && wm) {
  10358. tmat.multiplyToRef(wm, tmat);
  10359. }
  10360. tmat.invert();
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10362. };
  10363. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10364. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10365. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10366. return Bone;
  10367. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  10368. /***/ }),
  10369. /***/ "./Bones/boneIKController.ts":
  10370. /*!***********************************!*\
  10371. !*** ./Bones/boneIKController.ts ***!
  10372. \***********************************/
  10373. /*! exports provided: BoneIKController */
  10374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10375. "use strict";
  10376. __webpack_require__.r(__webpack_exports__);
  10377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10379. /**
  10380. * Class used to apply inverse kinematics to bones
  10381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10382. */
  10383. var BoneIKController = /** @class */ (function () {
  10384. /**
  10385. * Creates a new BoneIKController
  10386. * @param mesh defines the mesh to control
  10387. * @param bone defines the bone to control
  10388. * @param options defines options to set up the controller
  10389. */
  10390. function BoneIKController(mesh, bone, options) {
  10391. /**
  10392. * Gets or sets the target position
  10393. */
  10394. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10395. /**
  10396. * Gets or sets the pole target position
  10397. */
  10398. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10399. /**
  10400. * Gets or sets the pole target local offset
  10401. */
  10402. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10403. /**
  10404. * Gets or sets the pole angle
  10405. */
  10406. this.poleAngle = 0;
  10407. /**
  10408. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10409. */
  10410. this.slerpAmount = 1;
  10411. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10412. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10413. this._bone2Ang = Math.PI;
  10414. this._maxAngle = Math.PI;
  10415. this._rightHandedSystem = false;
  10416. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10417. this._slerping = false;
  10418. this._adjustRoll = 0;
  10419. this._bone2 = bone;
  10420. this._bone1 = bone.getParent();
  10421. if (!this._bone1) {
  10422. return;
  10423. }
  10424. this.mesh = mesh;
  10425. var bonePos = bone.getPosition();
  10426. if (bone.getAbsoluteTransform().determinant() > 0) {
  10427. this._rightHandedSystem = true;
  10428. this._bendAxis.x = 0;
  10429. this._bendAxis.y = 0;
  10430. this._bendAxis.z = -1;
  10431. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10432. this._adjustRoll = Math.PI * .5;
  10433. this._bendAxis.z = 1;
  10434. }
  10435. }
  10436. if (this._bone1.length) {
  10437. var boneScale1 = this._bone1.getScale();
  10438. var boneScale2 = this._bone2.getScale();
  10439. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10440. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10441. }
  10442. else if (this._bone1.children[0]) {
  10443. mesh.computeWorldMatrix(true);
  10444. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10445. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10446. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10447. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10448. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10449. }
  10450. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10451. this.maxAngle = Math.PI;
  10452. if (options) {
  10453. if (options.targetMesh) {
  10454. this.targetMesh = options.targetMesh;
  10455. this.targetMesh.computeWorldMatrix(true);
  10456. }
  10457. if (options.poleTargetMesh) {
  10458. this.poleTargetMesh = options.poleTargetMesh;
  10459. this.poleTargetMesh.computeWorldMatrix(true);
  10460. }
  10461. else if (options.poleTargetBone) {
  10462. this.poleTargetBone = options.poleTargetBone;
  10463. }
  10464. else if (this._bone1.getParent()) {
  10465. this.poleTargetBone = this._bone1.getParent();
  10466. }
  10467. if (options.poleTargetLocalOffset) {
  10468. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10469. }
  10470. if (options.poleAngle) {
  10471. this.poleAngle = options.poleAngle;
  10472. }
  10473. if (options.bendAxis) {
  10474. this._bendAxis.copyFrom(options.bendAxis);
  10475. }
  10476. if (options.maxAngle) {
  10477. this.maxAngle = options.maxAngle;
  10478. }
  10479. if (options.slerpAmount) {
  10480. this.slerpAmount = options.slerpAmount;
  10481. }
  10482. }
  10483. }
  10484. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10485. /**
  10486. * Gets or sets maximum allowed angle
  10487. */
  10488. get: function () {
  10489. return this._maxAngle;
  10490. },
  10491. set: function (value) {
  10492. this._setMaxAngle(value);
  10493. },
  10494. enumerable: true,
  10495. configurable: true
  10496. });
  10497. BoneIKController.prototype._setMaxAngle = function (ang) {
  10498. if (ang < 0) {
  10499. ang = 0;
  10500. }
  10501. if (ang > Math.PI || ang == undefined) {
  10502. ang = Math.PI;
  10503. }
  10504. this._maxAngle = ang;
  10505. var a = this._bone1Length;
  10506. var b = this._bone2Length;
  10507. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10508. };
  10509. /**
  10510. * Force the controller to update the bones
  10511. */
  10512. BoneIKController.prototype.update = function () {
  10513. var bone1 = this._bone1;
  10514. if (!bone1) {
  10515. return;
  10516. }
  10517. var target = this.targetPosition;
  10518. var poleTarget = this.poleTargetPosition;
  10519. var mat1 = BoneIKController._tmpMats[0];
  10520. var mat2 = BoneIKController._tmpMats[1];
  10521. if (this.targetMesh) {
  10522. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10523. }
  10524. if (this.poleTargetBone) {
  10525. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10526. }
  10527. else if (this.poleTargetMesh) {
  10528. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10529. }
  10530. var bonePos = BoneIKController._tmpVecs[0];
  10531. var zaxis = BoneIKController._tmpVecs[1];
  10532. var xaxis = BoneIKController._tmpVecs[2];
  10533. var yaxis = BoneIKController._tmpVecs[3];
  10534. var upAxis = BoneIKController._tmpVecs[4];
  10535. var _tmpQuat = BoneIKController._tmpQuat;
  10536. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10537. poleTarget.subtractToRef(bonePos, upAxis);
  10538. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10539. upAxis.y = 1;
  10540. }
  10541. else {
  10542. upAxis.normalize();
  10543. }
  10544. target.subtractToRef(bonePos, yaxis);
  10545. yaxis.normalize();
  10546. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10547. zaxis.normalize();
  10548. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10549. xaxis.normalize();
  10550. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10551. var a = this._bone1Length;
  10552. var b = this._bone2Length;
  10553. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10554. if (this._maxReach > 0) {
  10555. c = Math.min(this._maxReach, c);
  10556. }
  10557. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10558. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10559. if (acosa > 1) {
  10560. acosa = 1;
  10561. }
  10562. if (acosb > 1) {
  10563. acosb = 1;
  10564. }
  10565. if (acosa < -1) {
  10566. acosa = -1;
  10567. }
  10568. if (acosb < -1) {
  10569. acosb = -1;
  10570. }
  10571. var angA = Math.acos(acosa);
  10572. var angB = Math.acos(acosb);
  10573. var angC = -angA - angB;
  10574. if (this._rightHandedSystem) {
  10575. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10576. mat2.multiplyToRef(mat1, mat1);
  10577. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10578. mat2.multiplyToRef(mat1, mat1);
  10579. }
  10580. else {
  10581. var _tmpVec = BoneIKController._tmpVecs[5];
  10582. _tmpVec.copyFrom(this._bendAxis);
  10583. _tmpVec.x *= -1;
  10584. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10585. mat2.multiplyToRef(mat1, mat1);
  10586. }
  10587. if (this.poleAngle) {
  10588. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10589. mat1.multiplyToRef(mat2, mat1);
  10590. }
  10591. if (this._bone1) {
  10592. if (this.slerpAmount < 1) {
  10593. if (!this._slerping) {
  10594. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10595. }
  10596. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10597. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10598. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10599. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10600. this._slerping = true;
  10601. }
  10602. else {
  10603. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10604. this._bone1Mat.copyFrom(mat1);
  10605. this._slerping = false;
  10606. }
  10607. }
  10608. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10609. this._bone2Ang = angC;
  10610. };
  10611. BoneIKController._tmpVecs = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  10612. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10613. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10614. return BoneIKController;
  10615. }());
  10616. /***/ }),
  10617. /***/ "./Bones/boneLookController.ts":
  10618. /*!*************************************!*\
  10619. !*** ./Bones/boneLookController.ts ***!
  10620. \*************************************/
  10621. /*! exports provided: BoneLookController */
  10622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10623. "use strict";
  10624. __webpack_require__.r(__webpack_exports__);
  10625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10626. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10627. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10628. /**
  10629. * Class used to make a bone look toward a point in space
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10631. */
  10632. var BoneLookController = /** @class */ (function () {
  10633. /**
  10634. * Create a BoneLookController
  10635. * @param mesh the mesh that the bone belongs to
  10636. * @param bone the bone that will be looking to the target
  10637. * @param target the target Vector3 to look at
  10638. * @param settings optional settings:
  10639. * * maxYaw: the maximum angle the bone will yaw to
  10640. * * minYaw: the minimum angle the bone will yaw to
  10641. * * maxPitch: the maximum angle the bone will pitch to
  10642. * * minPitch: the minimum angle the bone will yaw to
  10643. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10644. * * upAxis: the up axis of the coordinate system
  10645. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10646. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10647. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10648. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10649. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10650. * * adjustRoll: used to make an adjustment to the roll of the bone
  10651. **/
  10652. function BoneLookController(mesh, bone, target, options) {
  10653. /**
  10654. * The up axis of the coordinate system that is used when the bone is rotated
  10655. */
  10656. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10657. /**
  10658. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10659. */
  10660. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10661. /**
  10662. * Used to make an adjustment to the yaw of the bone
  10663. */
  10664. this.adjustYaw = 0;
  10665. /**
  10666. * Used to make an adjustment to the pitch of the bone
  10667. */
  10668. this.adjustPitch = 0;
  10669. /**
  10670. * Used to make an adjustment to the roll of the bone
  10671. */
  10672. this.adjustRoll = 0;
  10673. /**
  10674. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  10675. */
  10676. this.slerpAmount = 1;
  10677. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10678. this._slerping = false;
  10679. this._firstFrameSkipped = false;
  10680. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10681. this.mesh = mesh;
  10682. this.bone = bone;
  10683. this.target = target;
  10684. if (options) {
  10685. if (options.adjustYaw) {
  10686. this.adjustYaw = options.adjustYaw;
  10687. }
  10688. if (options.adjustPitch) {
  10689. this.adjustPitch = options.adjustPitch;
  10690. }
  10691. if (options.adjustRoll) {
  10692. this.adjustRoll = options.adjustRoll;
  10693. }
  10694. if (options.maxYaw != null) {
  10695. this.maxYaw = options.maxYaw;
  10696. }
  10697. else {
  10698. this.maxYaw = Math.PI;
  10699. }
  10700. if (options.minYaw != null) {
  10701. this.minYaw = options.minYaw;
  10702. }
  10703. else {
  10704. this.minYaw = -Math.PI;
  10705. }
  10706. if (options.maxPitch != null) {
  10707. this.maxPitch = options.maxPitch;
  10708. }
  10709. else {
  10710. this.maxPitch = Math.PI;
  10711. }
  10712. if (options.minPitch != null) {
  10713. this.minPitch = options.minPitch;
  10714. }
  10715. else {
  10716. this.minPitch = -Math.PI;
  10717. }
  10718. if (options.slerpAmount != null) {
  10719. this.slerpAmount = options.slerpAmount;
  10720. }
  10721. if (options.upAxis != null) {
  10722. this.upAxis = options.upAxis;
  10723. }
  10724. if (options.upAxisSpace != null) {
  10725. this.upAxisSpace = options.upAxisSpace;
  10726. }
  10727. if (options.yawAxis != null || options.pitchAxis != null) {
  10728. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  10729. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  10730. if (options.yawAxis != null) {
  10731. newYawAxis = options.yawAxis.clone();
  10732. newYawAxis.normalize();
  10733. }
  10734. if (options.pitchAxis != null) {
  10735. newPitchAxis = options.pitchAxis.clone();
  10736. newPitchAxis.normalize();
  10737. }
  10738. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  10739. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10740. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  10741. this._transformYawPitchInv = this._transformYawPitch.clone();
  10742. this._transformYawPitch.invert();
  10743. }
  10744. }
  10745. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  10746. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10747. }
  10748. }
  10749. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  10750. /**
  10751. * Gets or sets the minimum yaw angle that the bone can look to
  10752. */
  10753. get: function () {
  10754. return this._minYaw;
  10755. },
  10756. set: function (value) {
  10757. this._minYaw = value;
  10758. this._minYawSin = Math.sin(value);
  10759. this._minYawCos = Math.cos(value);
  10760. if (this._maxYaw != null) {
  10761. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10762. this._yawRange = this._maxYaw - this._minYaw;
  10763. }
  10764. },
  10765. enumerable: true,
  10766. configurable: true
  10767. });
  10768. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  10769. /**
  10770. * Gets or sets the maximum yaw angle that the bone can look to
  10771. */
  10772. get: function () {
  10773. return this._maxYaw;
  10774. },
  10775. set: function (value) {
  10776. this._maxYaw = value;
  10777. this._maxYawSin = Math.sin(value);
  10778. this._maxYawCos = Math.cos(value);
  10779. if (this._minYaw != null) {
  10780. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10781. this._yawRange = this._maxYaw - this._minYaw;
  10782. }
  10783. },
  10784. enumerable: true,
  10785. configurable: true
  10786. });
  10787. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  10788. /**
  10789. * Gets or sets the minimum pitch angle that the bone can look to
  10790. */
  10791. get: function () {
  10792. return this._minPitch;
  10793. },
  10794. set: function (value) {
  10795. this._minPitch = value;
  10796. this._minPitchTan = Math.tan(value);
  10797. },
  10798. enumerable: true,
  10799. configurable: true
  10800. });
  10801. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  10802. /**
  10803. * Gets or sets the maximum pitch angle that the bone can look to
  10804. */
  10805. get: function () {
  10806. return this._maxPitch;
  10807. },
  10808. set: function (value) {
  10809. this._maxPitch = value;
  10810. this._maxPitchTan = Math.tan(value);
  10811. },
  10812. enumerable: true,
  10813. configurable: true
  10814. });
  10815. /**
  10816. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  10817. */
  10818. BoneLookController.prototype.update = function () {
  10819. //skip the first frame when slerping so that the mesh rotation is correct
  10820. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  10821. this._firstFrameSkipped = true;
  10822. return;
  10823. }
  10824. var bone = this.bone;
  10825. var bonePos = BoneLookController._tmpVecs[0];
  10826. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  10827. var target = this.target;
  10828. var _tmpMat1 = BoneLookController._tmpMats[0];
  10829. var _tmpMat2 = BoneLookController._tmpMats[1];
  10830. var mesh = this.mesh;
  10831. var parentBone = bone.getParent();
  10832. var upAxis = BoneLookController._tmpVecs[1];
  10833. upAxis.copyFrom(this.upAxis);
  10834. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  10835. if (this._transformYawPitch) {
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  10837. }
  10838. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  10839. }
  10840. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10841. mesh.getDirectionToRef(upAxis, upAxis);
  10842. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  10843. upAxis.normalize();
  10844. }
  10845. }
  10846. var checkYaw = false;
  10847. var checkPitch = false;
  10848. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  10849. checkYaw = true;
  10850. }
  10851. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  10852. checkPitch = true;
  10853. }
  10854. if (checkYaw || checkPitch) {
  10855. var spaceMat = BoneLookController._tmpMats[2];
  10856. var spaceMatInv = BoneLookController._tmpMats[3];
  10857. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  10858. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  10859. }
  10860. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  10861. spaceMat.copyFrom(mesh.getWorldMatrix());
  10862. }
  10863. else {
  10864. var forwardAxis = BoneLookController._tmpVecs[2];
  10865. forwardAxis.copyFrom(this._fowardAxis);
  10866. if (this._transformYawPitch) {
  10867. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  10868. }
  10869. if (parentBone) {
  10870. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  10871. }
  10872. else {
  10873. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  10874. }
  10875. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  10876. rightAxis.normalize();
  10877. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  10878. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  10879. }
  10880. spaceMat.invertToRef(spaceMatInv);
  10881. var xzlen = null;
  10882. if (checkPitch) {
  10883. var localTarget = BoneLookController._tmpVecs[3];
  10884. target.subtractToRef(bonePos, localTarget);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10886. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10887. var pitch = Math.atan2(localTarget.y, xzlen);
  10888. var newPitch = pitch;
  10889. if (pitch > this._maxPitch) {
  10890. localTarget.y = this._maxPitchTan * xzlen;
  10891. newPitch = this._maxPitch;
  10892. }
  10893. else if (pitch < this._minPitch) {
  10894. localTarget.y = this._minPitchTan * xzlen;
  10895. newPitch = this._minPitch;
  10896. }
  10897. if (pitch != newPitch) {
  10898. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10899. localTarget.addInPlace(bonePos);
  10900. target = localTarget;
  10901. }
  10902. }
  10903. if (checkYaw) {
  10904. var localTarget = BoneLookController._tmpVecs[4];
  10905. target.subtractToRef(bonePos, localTarget);
  10906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10907. var yaw = Math.atan2(localTarget.x, localTarget.z);
  10908. var newYaw = yaw;
  10909. if (yaw > this._maxYaw || yaw < this._minYaw) {
  10910. if (xzlen == null) {
  10911. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10912. }
  10913. if (this._yawRange > Math.PI) {
  10914. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  10915. localTarget.z = this._maxYawCos * xzlen;
  10916. localTarget.x = this._maxYawSin * xzlen;
  10917. newYaw = this._maxYaw;
  10918. }
  10919. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  10920. localTarget.z = this._minYawCos * xzlen;
  10921. localTarget.x = this._minYawSin * xzlen;
  10922. newYaw = this._minYaw;
  10923. }
  10924. }
  10925. else {
  10926. if (yaw > this._maxYaw) {
  10927. localTarget.z = this._maxYawCos * xzlen;
  10928. localTarget.x = this._maxYawSin * xzlen;
  10929. newYaw = this._maxYaw;
  10930. }
  10931. else if (yaw < this._minYaw) {
  10932. localTarget.z = this._minYawCos * xzlen;
  10933. localTarget.x = this._minYawSin * xzlen;
  10934. newYaw = this._minYaw;
  10935. }
  10936. }
  10937. }
  10938. if (this._slerping && this._yawRange > Math.PI) {
  10939. //are we going to be crossing into the min/max region?
  10940. var boneFwd = BoneLookController._tmpVecs[8];
  10941. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  10942. if (this._transformYawPitch) {
  10943. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  10944. }
  10945. var boneRotMat = BoneLookController._tmpMats[4];
  10946. this._boneQuat.toRotationMatrix(boneRotMat);
  10947. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  10948. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  10949. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  10950. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  10951. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  10952. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  10953. if (angBtwTar > angBtwMidYaw) {
  10954. if (xzlen == null) {
  10955. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10956. }
  10957. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  10958. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  10959. if (angBtwMin < angBtwMax) {
  10960. newYaw = boneYaw + Math.PI * .75;
  10961. localTarget.z = Math.cos(newYaw) * xzlen;
  10962. localTarget.x = Math.sin(newYaw) * xzlen;
  10963. }
  10964. else {
  10965. newYaw = boneYaw - Math.PI * .75;
  10966. localTarget.z = Math.cos(newYaw) * xzlen;
  10967. localTarget.x = Math.sin(newYaw) * xzlen;
  10968. }
  10969. }
  10970. }
  10971. if (yaw != newYaw) {
  10972. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10973. localTarget.addInPlace(bonePos);
  10974. target = localTarget;
  10975. }
  10976. }
  10977. }
  10978. var zaxis = BoneLookController._tmpVecs[5];
  10979. var xaxis = BoneLookController._tmpVecs[6];
  10980. var yaxis = BoneLookController._tmpVecs[7];
  10981. var _tmpQuat = BoneLookController._tmpQuat;
  10982. target.subtractToRef(bonePos, zaxis);
  10983. zaxis.normalize();
  10984. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  10985. xaxis.normalize();
  10986. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  10987. yaxis.normalize();
  10988. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  10989. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  10990. return;
  10991. }
  10992. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  10993. return;
  10994. }
  10995. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  10996. return;
  10997. }
  10998. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  10999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11000. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11001. }
  11002. if (this.slerpAmount < 1) {
  11003. if (!this._slerping) {
  11004. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11005. }
  11006. if (this._transformYawPitch) {
  11007. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11008. }
  11009. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11010. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11011. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11012. this._slerping = true;
  11013. }
  11014. else {
  11015. if (this._transformYawPitch) {
  11016. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11017. }
  11018. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11019. this._slerping = false;
  11020. }
  11021. };
  11022. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11023. var angDiff = ang2 - ang1;
  11024. angDiff %= Math.PI * 2;
  11025. if (angDiff > Math.PI) {
  11026. angDiff -= Math.PI * 2;
  11027. }
  11028. else if (angDiff < -Math.PI) {
  11029. angDiff += Math.PI * 2;
  11030. }
  11031. return angDiff;
  11032. };
  11033. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11034. ang1 %= (2 * Math.PI);
  11035. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11036. ang2 %= (2 * Math.PI);
  11037. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11038. var ab = 0;
  11039. if (ang1 < ang2) {
  11040. ab = ang2 - ang1;
  11041. }
  11042. else {
  11043. ab = ang1 - ang2;
  11044. }
  11045. if (ab > Math.PI) {
  11046. ab = Math.PI * 2 - ab;
  11047. }
  11048. return ab;
  11049. };
  11050. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11051. ang %= (2 * Math.PI);
  11052. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11053. ang1 %= (2 * Math.PI);
  11054. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11055. ang2 %= (2 * Math.PI);
  11056. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11057. if (ang1 < ang2) {
  11058. if (ang > ang1 && ang < ang2) {
  11059. return true;
  11060. }
  11061. }
  11062. else {
  11063. if (ang > ang2 && ang < ang1) {
  11064. return true;
  11065. }
  11066. }
  11067. return false;
  11068. };
  11069. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11070. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11071. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11072. return BoneLookController;
  11073. }());
  11074. /***/ }),
  11075. /***/ "./Bones/index.ts":
  11076. /*!************************!*\
  11077. !*** ./Bones/index.ts ***!
  11078. \************************/
  11079. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11081. "use strict";
  11082. __webpack_require__.r(__webpack_exports__);
  11083. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11085. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11087. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11089. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11091. /***/ }),
  11092. /***/ "./Bones/skeleton.ts":
  11093. /*!***************************!*\
  11094. !*** ./Bones/skeleton.ts ***!
  11095. \***************************/
  11096. /*! exports provided: Skeleton */
  11097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11098. "use strict";
  11099. __webpack_require__.r(__webpack_exports__);
  11100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11101. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11102. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11104. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11105. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11106. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11107. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11108. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11109. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11110. /**
  11111. * Class used to handle skinning animations
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11113. */
  11114. var Skeleton = /** @class */ (function () {
  11115. /**
  11116. * Creates a new skeleton
  11117. * @param name defines the skeleton name
  11118. * @param id defines the skeleton Id
  11119. * @param scene defines the hosting scene
  11120. */
  11121. function Skeleton(
  11122. /** defines the skeleton name */
  11123. name,
  11124. /** defines the skeleton Id */
  11125. id, scene) {
  11126. this.name = name;
  11127. this.id = id;
  11128. /**
  11129. * Defines the list of child bones
  11130. */
  11131. this.bones = new Array();
  11132. /**
  11133. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11134. */
  11135. this.needInitialSkinMatrix = false;
  11136. /**
  11137. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11138. */
  11139. this.overrideMesh = null;
  11140. this._isDirty = true;
  11141. this._meshesWithPoseMatrix = new Array();
  11142. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11143. this._ranges = {};
  11144. this._lastAbsoluteTransformsUpdateId = -1;
  11145. this._canUseTextureForBones = false;
  11146. /** @hidden */
  11147. this._numBonesWithLinkedTransformNode = 0;
  11148. /**
  11149. * Specifies if the skeleton should be serialized
  11150. */
  11151. this.doNotSerialize = false;
  11152. /**
  11153. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11154. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11155. */
  11156. this.useTextureToStoreBoneMatrices = true;
  11157. this._animationPropertiesOverride = null;
  11158. // Events
  11159. /**
  11160. * An observable triggered before computing the skeleton's matrices
  11161. */
  11162. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11163. this.bones = [];
  11164. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  11165. this._scene.skeletons.push(this);
  11166. //make sure it will recalculate the matrix next time prepare is called.
  11167. this._isDirty = true;
  11168. var engineCaps = this._scene.getEngine().getCaps();
  11169. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11170. }
  11171. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11172. /**
  11173. * Gets or sets the animation properties override
  11174. */
  11175. get: function () {
  11176. if (!this._animationPropertiesOverride) {
  11177. return this._scene.animationPropertiesOverride;
  11178. }
  11179. return this._animationPropertiesOverride;
  11180. },
  11181. set: function (value) {
  11182. this._animationPropertiesOverride = value;
  11183. },
  11184. enumerable: true,
  11185. configurable: true
  11186. });
  11187. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11188. /**
  11189. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11190. */
  11191. get: function () {
  11192. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11193. },
  11194. enumerable: true,
  11195. configurable: true
  11196. });
  11197. // Members
  11198. /**
  11199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11201. * @returns a Float32Array containing matrices data
  11202. */
  11203. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11204. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11205. return mesh._bonesTransformMatrices;
  11206. }
  11207. if (!this._transformMatrices) {
  11208. this.prepare();
  11209. }
  11210. return this._transformMatrices;
  11211. };
  11212. /**
  11213. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11214. * @returns a raw texture containing the data
  11215. */
  11216. Skeleton.prototype.getTransformMatrixTexture = function () {
  11217. return this._transformMatrixTexture;
  11218. };
  11219. /**
  11220. * Gets the current hosting scene
  11221. * @returns a scene object
  11222. */
  11223. Skeleton.prototype.getScene = function () {
  11224. return this._scene;
  11225. };
  11226. // Methods
  11227. /**
  11228. * Gets a string representing the current skeleton data
  11229. * @param fullDetails defines a boolean indicating if we want a verbose version
  11230. * @returns a string representing the current skeleton data
  11231. */
  11232. Skeleton.prototype.toString = function (fullDetails) {
  11233. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11234. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11235. if (fullDetails) {
  11236. ret += ", Ranges: {";
  11237. var first = true;
  11238. for (var name_1 in this._ranges) {
  11239. if (first) {
  11240. ret += ", ";
  11241. first = false;
  11242. }
  11243. ret += name_1;
  11244. }
  11245. ret += "}";
  11246. }
  11247. return ret;
  11248. };
  11249. /**
  11250. * Get bone's index searching by name
  11251. * @param name defines bone's name to search for
  11252. * @return the indice of the bone. Returns -1 if not found
  11253. */
  11254. Skeleton.prototype.getBoneIndexByName = function (name) {
  11255. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11256. if (this.bones[boneIndex].name === name) {
  11257. return boneIndex;
  11258. }
  11259. }
  11260. return -1;
  11261. };
  11262. /**
  11263. * Creater a new animation range
  11264. * @param name defines the name of the range
  11265. * @param from defines the start key
  11266. * @param to defines the end key
  11267. */
  11268. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11269. // check name not already in use
  11270. if (!this._ranges[name]) {
  11271. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, from, to);
  11272. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11273. if (this.bones[i].animations[0]) {
  11274. this.bones[i].animations[0].createRange(name, from, to);
  11275. }
  11276. }
  11277. }
  11278. };
  11279. /**
  11280. * Delete a specific animation range
  11281. * @param name defines the name of the range
  11282. * @param deleteFrames defines if frames must be removed as well
  11283. */
  11284. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11285. if (deleteFrames === void 0) { deleteFrames = true; }
  11286. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11287. if (this.bones[i].animations[0]) {
  11288. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11289. }
  11290. }
  11291. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11292. };
  11293. /**
  11294. * Gets a specific animation range
  11295. * @param name defines the name of the range to look for
  11296. * @returns the requested animation range or null if not found
  11297. */
  11298. Skeleton.prototype.getAnimationRange = function (name) {
  11299. return this._ranges[name];
  11300. };
  11301. /**
  11302. * Gets the list of all animation ranges defined on this skeleton
  11303. * @returns an array
  11304. */
  11305. Skeleton.prototype.getAnimationRanges = function () {
  11306. var animationRanges = [];
  11307. var name;
  11308. var i = 0;
  11309. for (name in this._ranges) {
  11310. animationRanges[i] = this._ranges[name];
  11311. i++;
  11312. }
  11313. return animationRanges;
  11314. };
  11315. /**
  11316. * Copy animation range from a source skeleton.
  11317. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11318. * @param source defines the source skeleton
  11319. * @param name defines the name of the range to copy
  11320. * @param rescaleAsRequired defines if rescaling must be applied if required
  11321. * @returns true if operation was successful
  11322. */
  11323. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11324. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11325. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11326. return false;
  11327. }
  11328. var ret = true;
  11329. var frameOffset = this._getHighestAnimationFrame() + 1;
  11330. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11331. var boneDict = {};
  11332. var sourceBones = source.bones;
  11333. var nBones;
  11334. var i;
  11335. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11336. boneDict[sourceBones[i].name] = sourceBones[i];
  11337. }
  11338. if (this.bones.length !== sourceBones.length) {
  11339. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11340. ret = false;
  11341. }
  11342. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11343. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11344. var boneName = this.bones[i].name;
  11345. var sourceBone = boneDict[boneName];
  11346. if (sourceBone) {
  11347. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11348. }
  11349. else {
  11350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11351. ret = false;
  11352. }
  11353. }
  11354. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11355. var range = source.getAnimationRange(name);
  11356. if (range) {
  11357. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11358. }
  11359. return ret;
  11360. };
  11361. /**
  11362. * Forces the skeleton to go to rest pose
  11363. */
  11364. Skeleton.prototype.returnToRest = function () {
  11365. for (var index = 0; index < this.bones.length; index++) {
  11366. this.bones[index].returnToRest();
  11367. }
  11368. };
  11369. Skeleton.prototype._getHighestAnimationFrame = function () {
  11370. var ret = 0;
  11371. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11372. if (this.bones[i].animations[0]) {
  11373. var highest = this.bones[i].animations[0].getHighestFrame();
  11374. if (ret < highest) {
  11375. ret = highest;
  11376. }
  11377. }
  11378. }
  11379. return ret;
  11380. };
  11381. /**
  11382. * Begin a specific animation range
  11383. * @param name defines the name of the range to start
  11384. * @param loop defines if looping must be turned on (false by default)
  11385. * @param speedRatio defines the speed ratio to apply (1 by default)
  11386. * @param onAnimationEnd defines a callback which will be called when animation will end
  11387. * @returns a new animatable
  11388. */
  11389. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11390. var range = this.getAnimationRange(name);
  11391. if (!range) {
  11392. return null;
  11393. }
  11394. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11395. };
  11396. /** @hidden */
  11397. Skeleton.prototype._markAsDirty = function () {
  11398. this._isDirty = true;
  11399. };
  11400. /** @hidden */
  11401. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11402. this._meshesWithPoseMatrix.push(mesh);
  11403. };
  11404. /** @hidden */
  11405. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11406. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11407. if (index > -1) {
  11408. this._meshesWithPoseMatrix.splice(index, 1);
  11409. }
  11410. };
  11411. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11412. this.onBeforeComputeObservable.notifyObservers(this);
  11413. for (var index = 0; index < this.bones.length; index++) {
  11414. var bone = this.bones[index];
  11415. var parentBone = bone.getParent();
  11416. if (parentBone) {
  11417. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11418. }
  11419. else {
  11420. if (initialSkinMatrix) {
  11421. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11422. }
  11423. else {
  11424. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11425. }
  11426. }
  11427. if (bone._index !== -1) {
  11428. var mappedIndex = bone._index === null ? index : bone._index;
  11429. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11430. }
  11431. }
  11432. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11433. };
  11434. /**
  11435. * Build all resources required to render a skeleton
  11436. */
  11437. Skeleton.prototype.prepare = function () {
  11438. // Update the local matrix of bones with linked transform nodes.
  11439. if (this._numBonesWithLinkedTransformNode > 0) {
  11440. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11441. var bone_1 = _a[_i];
  11442. if (bone_1._linkedTransformNode) {
  11443. // Computing the world matrix also computes the local matrix.
  11444. bone_1._linkedTransformNode.computeWorldMatrix();
  11445. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11446. bone_1.markAsDirty();
  11447. }
  11448. }
  11449. }
  11450. if (!this._isDirty) {
  11451. return;
  11452. }
  11453. if (this.needInitialSkinMatrix) {
  11454. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11455. var mesh = this._meshesWithPoseMatrix[index];
  11456. var poseMatrix = mesh.getPoseMatrix();
  11457. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11458. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11459. }
  11460. if (this._synchronizedWithMesh !== mesh) {
  11461. this._synchronizedWithMesh = mesh;
  11462. // Prepare bones
  11463. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11464. var bone = this.bones[boneIndex];
  11465. if (!bone.getParent()) {
  11466. var matrix = bone.getBaseMatrix();
  11467. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11468. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11469. }
  11470. }
  11471. }
  11472. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11473. }
  11474. }
  11475. else {
  11476. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11477. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11478. if (this.isUsingTextureForMatrices) {
  11479. if (this._transformMatrixTexture) {
  11480. this._transformMatrixTexture.dispose();
  11481. }
  11482. this._transformMatrixTexture = _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__["RawTexture"].CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT);
  11483. }
  11484. }
  11485. this._computeTransformMatrices(this._transformMatrices, null);
  11486. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11487. this._transformMatrixTexture.update(this._transformMatrices);
  11488. }
  11489. }
  11490. this._isDirty = false;
  11491. this._scene._activeBones.addCount(this.bones.length, false);
  11492. };
  11493. /**
  11494. * Gets the list of animatables currently running for this skeleton
  11495. * @returns an array of animatables
  11496. */
  11497. Skeleton.prototype.getAnimatables = function () {
  11498. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11499. this._animatables = [];
  11500. for (var index = 0; index < this.bones.length; index++) {
  11501. this._animatables.push(this.bones[index]);
  11502. }
  11503. }
  11504. return this._animatables;
  11505. };
  11506. /**
  11507. * Clone the current skeleton
  11508. * @param name defines the name of the new skeleton
  11509. * @param id defines the id of the enw skeleton
  11510. * @returns the new skeleton
  11511. */
  11512. Skeleton.prototype.clone = function (name, id) {
  11513. var result = new Skeleton(name, id || name, this._scene);
  11514. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11515. for (var index = 0; index < this.bones.length; index++) {
  11516. var source = this.bones[index];
  11517. var parentBone = null;
  11518. var parent_1 = source.getParent();
  11519. if (parent_1) {
  11520. var parentIndex = this.bones.indexOf(parent_1);
  11521. parentBone = result.bones[parentIndex];
  11522. }
  11523. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11524. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11525. }
  11526. if (this._ranges) {
  11527. result._ranges = {};
  11528. for (var rangeName in this._ranges) {
  11529. var range = this._ranges[rangeName];
  11530. if (range) {
  11531. result._ranges[rangeName] = range.clone();
  11532. }
  11533. }
  11534. }
  11535. this._isDirty = true;
  11536. return result;
  11537. };
  11538. /**
  11539. * Enable animation blending for this skeleton
  11540. * @param blendingSpeed defines the blending speed to apply
  11541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11542. */
  11543. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11544. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11545. this.bones.forEach(function (bone) {
  11546. bone.animations.forEach(function (animation) {
  11547. animation.enableBlending = true;
  11548. animation.blendingSpeed = blendingSpeed;
  11549. });
  11550. });
  11551. };
  11552. /**
  11553. * Releases all resources associated with the current skeleton
  11554. */
  11555. Skeleton.prototype.dispose = function () {
  11556. this._meshesWithPoseMatrix = [];
  11557. // Animations
  11558. this.getScene().stopAnimation(this);
  11559. // Remove from scene
  11560. this.getScene().removeSkeleton(this);
  11561. if (this._transformMatrixTexture) {
  11562. this._transformMatrixTexture.dispose();
  11563. this._transformMatrixTexture = null;
  11564. }
  11565. };
  11566. /**
  11567. * Serialize the skeleton in a JSON object
  11568. * @returns a JSON object
  11569. */
  11570. Skeleton.prototype.serialize = function () {
  11571. var serializationObject = {};
  11572. serializationObject.name = this.name;
  11573. serializationObject.id = this.id;
  11574. if (this.dimensionsAtRest) {
  11575. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11576. }
  11577. serializationObject.bones = [];
  11578. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11579. for (var index = 0; index < this.bones.length; index++) {
  11580. var bone = this.bones[index];
  11581. var parent_2 = bone.getParent();
  11582. var serializedBone = {
  11583. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11584. name: bone.name,
  11585. matrix: bone.getBaseMatrix().toArray(),
  11586. rest: bone.getRestPose().toArray()
  11587. };
  11588. serializationObject.bones.push(serializedBone);
  11589. if (bone.length) {
  11590. serializedBone.length = bone.length;
  11591. }
  11592. if (bone.metadata) {
  11593. serializedBone.metadata = bone.metadata;
  11594. }
  11595. if (bone.animations && bone.animations.length > 0) {
  11596. serializedBone.animation = bone.animations[0].serialize();
  11597. }
  11598. serializationObject.ranges = [];
  11599. for (var name in this._ranges) {
  11600. var source = this._ranges[name];
  11601. if (!source) {
  11602. continue;
  11603. }
  11604. var range = {};
  11605. range.name = name;
  11606. range.from = source.from;
  11607. range.to = source.to;
  11608. serializationObject.ranges.push(range);
  11609. }
  11610. }
  11611. return serializationObject;
  11612. };
  11613. /**
  11614. * Creates a new skeleton from serialized data
  11615. * @param parsedSkeleton defines the serialized data
  11616. * @param scene defines the hosting scene
  11617. * @returns a new skeleton
  11618. */
  11619. Skeleton.Parse = function (parsedSkeleton, scene) {
  11620. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11621. if (parsedSkeleton.dimensionsAtRest) {
  11622. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11623. }
  11624. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11625. var index;
  11626. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11627. var parsedBone = parsedSkeleton.bones[index];
  11628. var parentBone = null;
  11629. if (parsedBone.parentBoneIndex > -1) {
  11630. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11631. }
  11632. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11633. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11634. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11635. bone.id = parsedBone.id;
  11636. }
  11637. if (parsedBone.length) {
  11638. bone.length = parsedBone.length;
  11639. }
  11640. if (parsedBone.metadata) {
  11641. bone.metadata = parsedBone.metadata;
  11642. }
  11643. if (parsedBone.animation) {
  11644. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11645. }
  11646. }
  11647. // placed after bones, so createAnimationRange can cascade down
  11648. if (parsedSkeleton.ranges) {
  11649. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11650. var data = parsedSkeleton.ranges[index];
  11651. skeleton.createAnimationRange(data.name, data.from, data.to);
  11652. }
  11653. }
  11654. return skeleton;
  11655. };
  11656. /**
  11657. * Compute all node absolute transforms
  11658. * @param forceUpdate defines if computation must be done even if cache is up to date
  11659. */
  11660. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11661. if (forceUpdate === void 0) { forceUpdate = false; }
  11662. var renderId = this._scene.getRenderId();
  11663. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11664. this.bones[0].computeAbsoluteTransforms();
  11665. this._lastAbsoluteTransformsUpdateId = renderId;
  11666. }
  11667. };
  11668. /**
  11669. * Gets the root pose matrix
  11670. * @returns a matrix
  11671. */
  11672. Skeleton.prototype.getPoseMatrix = function () {
  11673. var poseMatrix = null;
  11674. if (this._meshesWithPoseMatrix.length > 0) {
  11675. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11676. }
  11677. return poseMatrix;
  11678. };
  11679. /**
  11680. * Sorts bones per internal index
  11681. */
  11682. Skeleton.prototype.sortBones = function () {
  11683. var bones = new Array();
  11684. var visited = new Array(this.bones.length);
  11685. for (var index = 0; index < this.bones.length; index++) {
  11686. this._sortBones(index, bones, visited);
  11687. }
  11688. this.bones = bones;
  11689. };
  11690. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11691. if (visited[index]) {
  11692. return;
  11693. }
  11694. visited[index] = true;
  11695. var bone = this.bones[index];
  11696. if (bone._index === undefined) {
  11697. bone._index = index;
  11698. }
  11699. var parentBone = bone.getParent();
  11700. if (parentBone) {
  11701. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11702. }
  11703. bones.push(bone);
  11704. };
  11705. return Skeleton;
  11706. }());
  11707. /***/ }),
  11708. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11709. /*!*******************************************************!*\
  11710. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  11711. \*******************************************************/
  11712. /*! exports provided: ArcRotateCameraGamepadInput */
  11713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11714. "use strict";
  11715. __webpack_require__.r(__webpack_exports__);
  11716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  11717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11718. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11719. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11720. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  11721. /**
  11722. * Manage the gamepad inputs to control an arc rotate camera.
  11723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11724. */
  11725. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  11726. function ArcRotateCameraGamepadInput() {
  11727. /**
  11728. * Defines the gamepad rotation sensiblity.
  11729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  11730. */
  11731. this.gamepadRotationSensibility = 80;
  11732. /**
  11733. * Defines the gamepad move sensiblity.
  11734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  11735. */
  11736. this.gamepadMoveSensibility = 40;
  11737. }
  11738. /**
  11739. * Attach the input controls to a specific dom element to get the input from.
  11740. * @param element Defines the element the controls should be listened from
  11741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11742. */
  11743. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  11744. var _this = this;
  11745. var manager = this.camera.getScene().gamepadManager;
  11746. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  11747. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  11748. // prioritize XBOX gamepads.
  11749. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  11750. _this.gamepad = gamepad;
  11751. }
  11752. }
  11753. });
  11754. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  11755. if (_this.gamepad === gamepad) {
  11756. _this.gamepad = null;
  11757. }
  11758. });
  11759. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  11760. };
  11761. /**
  11762. * Detach the current controls from the specified dom element.
  11763. * @param element Defines the element to stop listening the inputs from
  11764. */
  11765. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  11766. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  11767. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  11768. this.gamepad = null;
  11769. };
  11770. /**
  11771. * Update the current camera state depending on the inputs that have been used this frame.
  11772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11773. */
  11774. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  11775. if (this.gamepad) {
  11776. var camera = this.camera;
  11777. var RSValues = this.gamepad.rightStick;
  11778. if (RSValues) {
  11779. if (RSValues.x != 0) {
  11780. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  11781. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  11782. camera.inertialAlphaOffset += normalizedRX;
  11783. }
  11784. }
  11785. if (RSValues.y != 0) {
  11786. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  11787. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  11788. camera.inertialBetaOffset += normalizedRY;
  11789. }
  11790. }
  11791. }
  11792. var LSValues = this.gamepad.leftStick;
  11793. if (LSValues && LSValues.y != 0) {
  11794. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  11795. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  11796. this.camera.inertialRadiusOffset -= normalizedLY;
  11797. }
  11798. }
  11799. }
  11800. };
  11801. /**
  11802. * Gets the class name of the current intput.
  11803. * @returns the class name
  11804. */
  11805. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  11806. return "ArcRotateCameraGamepadInput";
  11807. };
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  11813. return "gamepad";
  11814. };
  11815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11817. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  11818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11820. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  11821. return ArcRotateCameraGamepadInput;
  11822. }());
  11823. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  11824. /***/ }),
  11825. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  11826. /*!************************************************************!*\
  11827. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  11828. \************************************************************/
  11829. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  11830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11831. "use strict";
  11832. __webpack_require__.r(__webpack_exports__);
  11833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  11834. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11835. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11836. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11837. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  11838. /**
  11839. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  11840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11841. */
  11842. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  11843. function ArcRotateCameraKeyboardMoveInput() {
  11844. /**
  11845. * Defines the list of key codes associated with the up action (increase alpha)
  11846. */
  11847. this.keysUp = [38];
  11848. /**
  11849. * Defines the list of key codes associated with the down action (decrease alpha)
  11850. */
  11851. this.keysDown = [40];
  11852. /**
  11853. * Defines the list of key codes associated with the left action (increase beta)
  11854. */
  11855. this.keysLeft = [37];
  11856. /**
  11857. * Defines the list of key codes associated with the right action (decrease beta)
  11858. */
  11859. this.keysRight = [39];
  11860. /**
  11861. * Defines the list of key codes associated with the reset action.
  11862. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  11863. */
  11864. this.keysReset = [220];
  11865. /**
  11866. * Defines the panning sensibility of the inputs.
  11867. * (How fast is the camera paning)
  11868. */
  11869. this.panningSensibility = 50.0;
  11870. /**
  11871. * Defines the zooming sensibility of the inputs.
  11872. * (How fast is the camera zooming)
  11873. */
  11874. this.zoomingSensibility = 25.0;
  11875. /**
  11876. * Defines wether maintaining the alt key down switch the movement mode from
  11877. * orientation to zoom.
  11878. */
  11879. this.useAltToZoom = true;
  11880. /**
  11881. * Rotation speed of the camera
  11882. */
  11883. this.angularSpeed = 0.01;
  11884. this._keys = new Array();
  11885. }
  11886. /**
  11887. * Attach the input controls to a specific dom element to get the input from.
  11888. * @param element Defines the element the controls should be listened from
  11889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11890. */
  11891. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  11892. var _this = this;
  11893. if (this._onCanvasBlurObserver) {
  11894. return;
  11895. }
  11896. this._scene = this.camera.getScene();
  11897. this._engine = this._scene.getEngine();
  11898. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  11899. _this._keys = [];
  11900. });
  11901. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  11902. var evt = info.event;
  11903. if (!evt.metaKey) {
  11904. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  11905. _this._ctrlPressed = evt.ctrlKey;
  11906. _this._altPressed = evt.altKey;
  11907. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11908. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11909. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11910. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11911. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11912. var index = _this._keys.indexOf(evt.keyCode);
  11913. if (index === -1) {
  11914. _this._keys.push(evt.keyCode);
  11915. }
  11916. if (evt.preventDefault) {
  11917. if (!noPreventDefault) {
  11918. evt.preventDefault();
  11919. }
  11920. }
  11921. }
  11922. }
  11923. else {
  11924. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11925. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11926. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11927. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11928. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11929. var index = _this._keys.indexOf(evt.keyCode);
  11930. if (index >= 0) {
  11931. _this._keys.splice(index, 1);
  11932. }
  11933. if (evt.preventDefault) {
  11934. if (!noPreventDefault) {
  11935. evt.preventDefault();
  11936. }
  11937. }
  11938. }
  11939. }
  11940. }
  11941. });
  11942. };
  11943. /**
  11944. * Detach the current controls from the specified dom element.
  11945. * @param element Defines the element to stop listening the inputs from
  11946. */
  11947. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  11948. if (this._scene) {
  11949. if (this._onKeyboardObserver) {
  11950. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  11951. }
  11952. if (this._onCanvasBlurObserver) {
  11953. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  11954. }
  11955. this._onKeyboardObserver = null;
  11956. this._onCanvasBlurObserver = null;
  11957. }
  11958. this._keys = [];
  11959. };
  11960. /**
  11961. * Update the current camera state depending on the inputs that have been used this frame.
  11962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11963. */
  11964. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  11965. if (this._onKeyboardObserver) {
  11966. var camera = this.camera;
  11967. for (var index = 0; index < this._keys.length; index++) {
  11968. var keyCode = this._keys[index];
  11969. if (this.keysLeft.indexOf(keyCode) !== -1) {
  11970. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11971. camera.inertialPanningX -= 1 / this.panningSensibility;
  11972. }
  11973. else {
  11974. camera.inertialAlphaOffset -= this.angularSpeed;
  11975. }
  11976. }
  11977. else if (this.keysUp.indexOf(keyCode) !== -1) {
  11978. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11979. camera.inertialPanningY += 1 / this.panningSensibility;
  11980. }
  11981. else if (this._altPressed && this.useAltToZoom) {
  11982. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  11983. }
  11984. else {
  11985. camera.inertialBetaOffset -= this.angularSpeed;
  11986. }
  11987. }
  11988. else if (this.keysRight.indexOf(keyCode) !== -1) {
  11989. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11990. camera.inertialPanningX += 1 / this.panningSensibility;
  11991. }
  11992. else {
  11993. camera.inertialAlphaOffset += this.angularSpeed;
  11994. }
  11995. }
  11996. else if (this.keysDown.indexOf(keyCode) !== -1) {
  11997. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11998. camera.inertialPanningY -= 1 / this.panningSensibility;
  11999. }
  12000. else if (this._altPressed && this.useAltToZoom) {
  12001. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12002. }
  12003. else {
  12004. camera.inertialBetaOffset += this.angularSpeed;
  12005. }
  12006. }
  12007. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12008. if (camera.useInputToRestoreState) {
  12009. camera.restoreState();
  12010. }
  12011. }
  12012. }
  12013. }
  12014. };
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12020. return "ArcRotateCameraKeyboardMoveInput";
  12021. };
  12022. /**
  12023. * Get the friendly name associated with the input class.
  12024. * @returns the input friendly name
  12025. */
  12026. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12027. return "keyboard";
  12028. };
  12029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12031. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12034. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12037. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12040. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12043. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12046. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12049. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12052. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12055. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12056. return ArcRotateCameraKeyboardMoveInput;
  12057. }());
  12058. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12059. /***/ }),
  12060. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12061. /*!**********************************************************!*\
  12062. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12063. \**********************************************************/
  12064. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12066. "use strict";
  12067. __webpack_require__.r(__webpack_exports__);
  12068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12070. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12071. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12072. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12073. /**
  12074. * Manage the mouse wheel inputs to control an arc rotate camera.
  12075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12076. */
  12077. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12078. function ArcRotateCameraMouseWheelInput() {
  12079. /**
  12080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12081. */
  12082. this.wheelPrecision = 3.0;
  12083. /**
  12084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12086. */
  12087. this.wheelDeltaPercentage = 0;
  12088. }
  12089. /**
  12090. * Attach the input controls to a specific dom element to get the input from.
  12091. * @param element Defines the element the controls should be listened from
  12092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12093. */
  12094. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12095. var _this = this;
  12096. this._wheel = function (p, s) {
  12097. //sanity check - this should be a PointerWheel event.
  12098. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12099. return;
  12100. }
  12101. var event = p.event;
  12102. var delta = 0;
  12103. var mouseWheelLegacyEvent = event;
  12104. if (mouseWheelLegacyEvent.wheelDelta) {
  12105. if (_this.wheelDeltaPercentage) {
  12106. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12107. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12108. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12109. }
  12110. else {
  12111. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12112. }
  12113. }
  12114. else {
  12115. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12116. }
  12117. }
  12118. else {
  12119. var deltaValue = event.deltaY || event.detail;
  12120. delta = -deltaValue / _this.wheelPrecision;
  12121. }
  12122. if (delta) {
  12123. _this.camera.inertialRadiusOffset += delta;
  12124. }
  12125. if (event.preventDefault) {
  12126. if (!noPreventDefault) {
  12127. event.preventDefault();
  12128. }
  12129. }
  12130. };
  12131. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12132. };
  12133. /**
  12134. * Detach the current controls from the specified dom element.
  12135. * @param element Defines the element to stop listening the inputs from
  12136. */
  12137. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12138. if (this._observer && element) {
  12139. this.camera.getScene().onPointerObservable.remove(this._observer);
  12140. this._observer = null;
  12141. this._wheel = null;
  12142. }
  12143. };
  12144. /**
  12145. * Gets the class name of the current intput.
  12146. * @returns the class name
  12147. */
  12148. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12149. return "ArcRotateCameraMouseWheelInput";
  12150. };
  12151. /**
  12152. * Get the friendly name associated with the input class.
  12153. * @returns the input friendly name
  12154. */
  12155. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12156. return "mousewheel";
  12157. };
  12158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12160. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12163. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12164. return ArcRotateCameraMouseWheelInput;
  12165. }());
  12166. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12167. /***/ }),
  12168. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12169. /*!********************************************************!*\
  12170. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12171. \********************************************************/
  12172. /*! exports provided: ArcRotateCameraPointersInput */
  12173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12174. "use strict";
  12175. __webpack_require__.r(__webpack_exports__);
  12176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12178. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12179. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12180. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12181. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12182. /**
  12183. * Manage the pointers inputs to control an arc rotate camera.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12187. function ArcRotateCameraPointersInput() {
  12188. /**
  12189. * Defines the buttons associated with the input to handle camera move.
  12190. */
  12191. this.buttons = [0, 1, 2];
  12192. /**
  12193. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12194. */
  12195. this.angularSensibilityX = 1000.0;
  12196. /**
  12197. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12198. */
  12199. this.angularSensibilityY = 1000.0;
  12200. /**
  12201. * Defines the pointer pinch precision or how fast is the camera zooming.
  12202. */
  12203. this.pinchPrecision = 12.0;
  12204. /**
  12205. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12206. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12207. */
  12208. this.pinchDeltaPercentage = 0;
  12209. /**
  12210. * Defines the pointer panning sensibility or how fast is the camera moving.
  12211. */
  12212. this.panningSensibility = 1000.0;
  12213. /**
  12214. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12215. */
  12216. this.multiTouchPanning = true;
  12217. /**
  12218. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12219. */
  12220. this.multiTouchPanAndZoom = true;
  12221. /**
  12222. * Revers pinch action direction.
  12223. */
  12224. this.pinchInwards = true;
  12225. this._isPanClick = false;
  12226. }
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12233. var _this = this;
  12234. var engine = this.camera.getEngine();
  12235. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12236. var pointA = null;
  12237. var pointB = null;
  12238. var previousPinchSquaredDistance = 0;
  12239. var initialDistance = 0;
  12240. var twoFingerActivityCount = 0;
  12241. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12242. this._pointerInput = function (p, s) {
  12243. var evt = p.event;
  12244. var isTouch = p.event.pointerType === "touch";
  12245. if (engine.isInVRExclusivePointerMode) {
  12246. return;
  12247. }
  12248. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12249. return;
  12250. }
  12251. var srcElement = (evt.srcElement || evt.target);
  12252. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12253. try {
  12254. srcElement.setPointerCapture(evt.pointerId);
  12255. }
  12256. catch (e) {
  12257. //Nothing to do with the error. Execution will continue.
  12258. }
  12259. // Manage panning with pan button click
  12260. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12261. // manage pointers
  12262. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12263. if (pointA === null) {
  12264. pointA = cacheSoloPointer;
  12265. }
  12266. else if (pointB === null) {
  12267. pointB = cacheSoloPointer;
  12268. }
  12269. if (!noPreventDefault) {
  12270. evt.preventDefault();
  12271. element.focus();
  12272. }
  12273. }
  12274. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12275. if (_this.camera.useInputToRestoreState) {
  12276. _this.camera.restoreState();
  12277. }
  12278. }
  12279. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12280. try {
  12281. srcElement.releasePointerCapture(evt.pointerId);
  12282. }
  12283. catch (e) {
  12284. //Nothing to do with the error.
  12285. }
  12286. cacheSoloPointer = null;
  12287. previousPinchSquaredDistance = 0;
  12288. previousMultiTouchPanPosition.isPaning = false;
  12289. previousMultiTouchPanPosition.isPinching = false;
  12290. twoFingerActivityCount = 0;
  12291. initialDistance = 0;
  12292. if (!isTouch) {
  12293. pointB = null; // Mouse and pen are mono pointer
  12294. }
  12295. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12296. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12297. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12298. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12299. if (engine._badOS) {
  12300. pointA = pointB = null;
  12301. }
  12302. else {
  12303. //only remove the impacted pointer in case of multitouch allowing on most
  12304. //platforms switching from rotate to zoom and pan seamlessly.
  12305. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12306. pointA = pointB;
  12307. pointB = null;
  12308. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12309. }
  12310. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12311. pointB = null;
  12312. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12313. }
  12314. else {
  12315. pointA = pointB = null;
  12316. }
  12317. }
  12318. if (!noPreventDefault) {
  12319. evt.preventDefault();
  12320. }
  12321. }
  12322. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12323. if (!noPreventDefault) {
  12324. evt.preventDefault();
  12325. }
  12326. // One button down
  12327. if (pointA && pointB === null && cacheSoloPointer) {
  12328. if (_this.panningSensibility !== 0 &&
  12329. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12330. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12331. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12332. }
  12333. else {
  12334. var offsetX = evt.clientX - cacheSoloPointer.x;
  12335. var offsetY = evt.clientY - cacheSoloPointer.y;
  12336. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12337. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12338. }
  12339. cacheSoloPointer.x = evt.clientX;
  12340. cacheSoloPointer.y = evt.clientY;
  12341. }
  12342. // Two buttons down: pinch/pan
  12343. else if (pointA && pointB) {
  12344. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12345. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12346. ed.x = evt.clientX;
  12347. ed.y = evt.clientY;
  12348. var direction = _this.pinchInwards ? 1 : -1;
  12349. var distX = pointA.x - pointB.x;
  12350. var distY = pointA.y - pointB.y;
  12351. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12352. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12353. if (previousPinchSquaredDistance === 0) {
  12354. initialDistance = pinchDistance;
  12355. previousPinchSquaredDistance = pinchSquaredDistance;
  12356. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12357. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12358. return;
  12359. }
  12360. if (_this.multiTouchPanAndZoom) {
  12361. if (_this.pinchDeltaPercentage) {
  12362. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12363. }
  12364. else {
  12365. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12366. (_this.pinchPrecision *
  12367. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12368. direction);
  12369. }
  12370. if (_this.panningSensibility !== 0) {
  12371. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12372. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12373. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12374. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12375. previousMultiTouchPanPosition.x = pointersCenterX;
  12376. previousMultiTouchPanPosition.y = pointersCenterY;
  12377. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12378. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12379. }
  12380. }
  12381. else {
  12382. twoFingerActivityCount++;
  12383. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12384. if (_this.pinchDeltaPercentage) {
  12385. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12386. }
  12387. else {
  12388. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12389. (_this.pinchPrecision *
  12390. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12391. direction);
  12392. }
  12393. previousMultiTouchPanPosition.isPaning = false;
  12394. previousMultiTouchPanPosition.isPinching = true;
  12395. }
  12396. else {
  12397. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12398. if (!previousMultiTouchPanPosition.isPaning) {
  12399. previousMultiTouchPanPosition.isPaning = true;
  12400. previousMultiTouchPanPosition.isPinching = false;
  12401. previousMultiTouchPanPosition.x = ed.x;
  12402. previousMultiTouchPanPosition.y = ed.y;
  12403. return;
  12404. }
  12405. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12406. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12407. }
  12408. }
  12409. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12410. previousMultiTouchPanPosition.x = ed.x;
  12411. previousMultiTouchPanPosition.y = ed.y;
  12412. }
  12413. }
  12414. previousPinchSquaredDistance = pinchSquaredDistance;
  12415. }
  12416. }
  12417. };
  12418. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12419. this._onContextMenu = function (evt) {
  12420. evt.preventDefault();
  12421. };
  12422. if (!this.camera._useCtrlForPanning) {
  12423. element.addEventListener("contextmenu", this._onContextMenu, false);
  12424. }
  12425. this._onLostFocus = function () {
  12426. //this._keys = [];
  12427. pointA = pointB = null;
  12428. previousPinchSquaredDistance = 0;
  12429. previousMultiTouchPanPosition.isPaning = false;
  12430. previousMultiTouchPanPosition.isPinching = false;
  12431. twoFingerActivityCount = 0;
  12432. cacheSoloPointer = null;
  12433. initialDistance = 0;
  12434. };
  12435. this._onMouseMove = function (evt) {
  12436. if (!engine.isPointerLock) {
  12437. return;
  12438. }
  12439. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12440. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12441. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12442. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12443. if (!noPreventDefault) {
  12444. evt.preventDefault();
  12445. }
  12446. };
  12447. this._onGestureStart = function (e) {
  12448. if (window.MSGesture === undefined) {
  12449. return;
  12450. }
  12451. if (!_this._MSGestureHandler) {
  12452. _this._MSGestureHandler = new MSGesture();
  12453. _this._MSGestureHandler.target = element;
  12454. }
  12455. _this._MSGestureHandler.addPointer(e.pointerId);
  12456. };
  12457. this._onGesture = function (e) {
  12458. _this.camera.radius *= e.scale;
  12459. if (e.preventDefault) {
  12460. if (!noPreventDefault) {
  12461. e.stopPropagation();
  12462. e.preventDefault();
  12463. }
  12464. }
  12465. };
  12466. element.addEventListener("mousemove", this._onMouseMove, false);
  12467. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12468. element.addEventListener("MSGestureChange", this._onGesture, false);
  12469. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12470. { name: "blur", handler: this._onLostFocus }
  12471. ]);
  12472. };
  12473. /**
  12474. * Detach the current controls from the specified dom element.
  12475. * @param element Defines the element to stop listening the inputs from
  12476. */
  12477. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12478. if (this._onLostFocus) {
  12479. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12480. { name: "blur", handler: this._onLostFocus }
  12481. ]);
  12482. }
  12483. if (element && this._observer) {
  12484. this.camera.getScene().onPointerObservable.remove(this._observer);
  12485. this._observer = null;
  12486. if (this._onContextMenu) {
  12487. element.removeEventListener("contextmenu", this._onContextMenu);
  12488. }
  12489. if (this._onMouseMove) {
  12490. element.removeEventListener("mousemove", this._onMouseMove);
  12491. }
  12492. if (this._onGestureStart) {
  12493. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12494. }
  12495. if (this._onGesture) {
  12496. element.removeEventListener("MSGestureChange", this._onGesture);
  12497. }
  12498. this._isPanClick = false;
  12499. this.pinchInwards = true;
  12500. this._onMouseMove = null;
  12501. this._onGestureStart = null;
  12502. this._onGesture = null;
  12503. this._MSGestureHandler = null;
  12504. this._onLostFocus = null;
  12505. this._onContextMenu = null;
  12506. }
  12507. };
  12508. /**
  12509. * Gets the class name of the current intput.
  12510. * @returns the class name
  12511. */
  12512. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12513. return "ArcRotateCameraPointersInput";
  12514. };
  12515. /**
  12516. * Get the friendly name associated with the input class.
  12517. * @returns the input friendly name
  12518. */
  12519. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12520. return "pointers";
  12521. };
  12522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12524. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12527. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12530. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12533. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12536. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12539. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12542. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12545. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12546. return ArcRotateCameraPointersInput;
  12547. }());
  12548. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12549. /***/ }),
  12550. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12551. /*!*******************************************************************!*\
  12552. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12553. \*******************************************************************/
  12554. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12556. "use strict";
  12557. __webpack_require__.r(__webpack_exports__);
  12558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12559. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12560. /**
  12561. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12563. */
  12564. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12565. /**
  12566. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12567. */
  12568. function ArcRotateCameraVRDeviceOrientationInput() {
  12569. /**
  12570. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12571. */
  12572. this.alphaCorrection = 1;
  12573. /**
  12574. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12575. */
  12576. this.gammaCorrection = 1;
  12577. this._alpha = 0;
  12578. this._gamma = 0;
  12579. this._dirty = false;
  12580. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12581. }
  12582. /**
  12583. * Attach the input controls to a specific dom element to get the input from.
  12584. * @param element Defines the element the controls should be listened from
  12585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12586. */
  12587. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12588. this.camera.attachControl(element, noPreventDefault);
  12589. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12590. };
  12591. /** @hidden */
  12592. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12593. if (evt.alpha !== null) {
  12594. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12595. }
  12596. if (evt.gamma !== null) {
  12597. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12598. }
  12599. this._dirty = true;
  12600. };
  12601. /**
  12602. * Update the current camera state depending on the inputs that have been used this frame.
  12603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12604. */
  12605. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12606. if (this._dirty) {
  12607. this._dirty = false;
  12608. if (this._gamma < 0) {
  12609. this._gamma = 180 + this._gamma;
  12610. }
  12611. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12612. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12613. }
  12614. };
  12615. /**
  12616. * Detach the current controls from the specified dom element.
  12617. * @param element Defines the element to stop listening the inputs from
  12618. */
  12619. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12620. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12621. };
  12622. /**
  12623. * Gets the class name of the current intput.
  12624. * @returns the class name
  12625. */
  12626. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12627. return "ArcRotateCameraVRDeviceOrientationInput";
  12628. };
  12629. /**
  12630. * Get the friendly name associated with the input class.
  12631. * @returns the input friendly name
  12632. */
  12633. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12634. return "VRDeviceOrientation";
  12635. };
  12636. return ArcRotateCameraVRDeviceOrientationInput;
  12637. }());
  12638. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12639. /***/ }),
  12640. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12641. /*!**************************************************!*\
  12642. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12643. \**************************************************/
  12644. /*! exports provided: FlyCameraKeyboardInput */
  12645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12646. "use strict";
  12647. __webpack_require__.r(__webpack_exports__);
  12648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12649. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12650. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12651. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12652. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12654. /**
  12655. * Listen to keyboard events to control the camera.
  12656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12657. */
  12658. var FlyCameraKeyboardInput = /** @class */ (function () {
  12659. function FlyCameraKeyboardInput() {
  12660. /**
  12661. * The list of keyboard keys used to control the forward move of the camera.
  12662. */
  12663. this.keysForward = [87];
  12664. /**
  12665. * The list of keyboard keys used to control the backward move of the camera.
  12666. */
  12667. this.keysBackward = [83];
  12668. /**
  12669. * The list of keyboard keys used to control the forward move of the camera.
  12670. */
  12671. this.keysUp = [69];
  12672. /**
  12673. * The list of keyboard keys used to control the backward move of the camera.
  12674. */
  12675. this.keysDown = [81];
  12676. /**
  12677. * The list of keyboard keys used to control the right strafe move of the camera.
  12678. */
  12679. this.keysRight = [68];
  12680. /**
  12681. * The list of keyboard keys used to control the left strafe move of the camera.
  12682. */
  12683. this.keysLeft = [65];
  12684. this._keys = new Array();
  12685. }
  12686. /**
  12687. * Attach the input controls to a specific dom element to get the input from.
  12688. * @param element Defines the element the controls should be listened from
  12689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12690. */
  12691. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12692. var _this = this;
  12693. if (this._onCanvasBlurObserver) {
  12694. return;
  12695. }
  12696. this._scene = this.camera.getScene();
  12697. this._engine = this._scene.getEngine();
  12698. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12699. _this._keys = [];
  12700. });
  12701. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12702. var evt = info.event;
  12703. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12704. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12705. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12706. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12707. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12708. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12709. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12710. var index = _this._keys.indexOf(evt.keyCode);
  12711. if (index === -1) {
  12712. _this._keys.push(evt.keyCode);
  12713. }
  12714. if (!noPreventDefault) {
  12715. evt.preventDefault();
  12716. }
  12717. }
  12718. }
  12719. else {
  12720. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12721. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12722. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12723. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12724. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12725. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12726. var index = _this._keys.indexOf(evt.keyCode);
  12727. if (index >= 0) {
  12728. _this._keys.splice(index, 1);
  12729. }
  12730. if (!noPreventDefault) {
  12731. evt.preventDefault();
  12732. }
  12733. }
  12734. }
  12735. });
  12736. };
  12737. /**
  12738. * Detach the current controls from the specified dom element.
  12739. * @param element Defines the element to stop listening the inputs from
  12740. */
  12741. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  12742. if (this._scene) {
  12743. if (this._onKeyboardObserver) {
  12744. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12745. }
  12746. if (this._onCanvasBlurObserver) {
  12747. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12748. }
  12749. this._onKeyboardObserver = null;
  12750. this._onCanvasBlurObserver = null;
  12751. }
  12752. this._keys = [];
  12753. };
  12754. /**
  12755. * Gets the class name of the current intput.
  12756. * @returns the class name
  12757. */
  12758. FlyCameraKeyboardInput.prototype.getClassName = function () {
  12759. return "FlyCameraKeyboardInput";
  12760. };
  12761. /** @hidden */
  12762. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  12763. this._keys = [];
  12764. };
  12765. /**
  12766. * Get the friendly name associated with the input class.
  12767. * @returns the input friendly name
  12768. */
  12769. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  12770. return "keyboard";
  12771. };
  12772. /**
  12773. * Update the current camera state depending on the inputs that have been used this frame.
  12774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12775. */
  12776. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  12777. if (this._onKeyboardObserver) {
  12778. var camera = this.camera;
  12779. // Keyboard
  12780. for (var index = 0; index < this._keys.length; index++) {
  12781. var keyCode = this._keys[index];
  12782. var speed = camera._computeLocalCameraSpeed();
  12783. if (this.keysForward.indexOf(keyCode) !== -1) {
  12784. camera._localDirection.copyFromFloats(0, 0, speed);
  12785. }
  12786. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  12787. camera._localDirection.copyFromFloats(0, 0, -speed);
  12788. }
  12789. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12790. camera._localDirection.copyFromFloats(0, speed, 0);
  12791. }
  12792. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12793. camera._localDirection.copyFromFloats(0, -speed, 0);
  12794. }
  12795. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12796. camera._localDirection.copyFromFloats(speed, 0, 0);
  12797. }
  12798. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  12799. camera._localDirection.copyFromFloats(-speed, 0, 0);
  12800. }
  12801. if (camera.getScene().useRightHandedSystem) {
  12802. camera._localDirection.z *= -1;
  12803. }
  12804. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  12805. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  12806. camera.cameraDirection.addInPlace(camera._transformedDirection);
  12807. }
  12808. }
  12809. };
  12810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12812. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  12813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12815. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  12816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12818. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  12819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12821. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  12822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12824. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  12825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12827. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  12828. return FlyCameraKeyboardInput;
  12829. }());
  12830. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  12831. /***/ }),
  12832. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  12833. /*!***********************************************!*\
  12834. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  12835. \***********************************************/
  12836. /*! exports provided: FlyCameraMouseInput */
  12837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12838. "use strict";
  12839. __webpack_require__.r(__webpack_exports__);
  12840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  12841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12842. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12843. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12844. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12845. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12846. /**
  12847. * Listen to mouse events to control the camera.
  12848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12849. */
  12850. var FlyCameraMouseInput = /** @class */ (function () {
  12851. /**
  12852. * Listen to mouse events to control the camera.
  12853. * @param touchEnabled Define if touch is enabled. (Default is true.)
  12854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12855. */
  12856. function FlyCameraMouseInput(touchEnabled) {
  12857. if (touchEnabled === void 0) { touchEnabled = true; }
  12858. /**
  12859. * Defines the buttons associated with the input to handle camera rotation.
  12860. */
  12861. this.buttons = [0, 1, 2];
  12862. /**
  12863. * Assign buttons for Yaw control.
  12864. */
  12865. this.buttonsYaw = [-1, 0, 1];
  12866. /**
  12867. * Assign buttons for Pitch control.
  12868. */
  12869. this.buttonsPitch = [-1, 0, 1];
  12870. /**
  12871. * Assign buttons for Roll control.
  12872. */
  12873. this.buttonsRoll = [2];
  12874. /**
  12875. * Detect if any button is being pressed while mouse is moved.
  12876. * -1 = Mouse locked.
  12877. * 0 = Left button.
  12878. * 1 = Middle Button.
  12879. * 2 = Right Button.
  12880. */
  12881. this.activeButton = -1;
  12882. /**
  12883. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  12884. * Higher values reduce its sensitivity.
  12885. */
  12886. this.angularSensibility = 1000.0;
  12887. this.previousPosition = null;
  12888. }
  12889. /**
  12890. * Attach the mouse control to the HTML DOM element.
  12891. * @param element Defines the element that listens to the input events.
  12892. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  12893. */
  12894. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  12895. var _this = this;
  12896. this.element = element;
  12897. this.noPreventDefault = noPreventDefault;
  12898. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  12899. _this._pointerInput(p, s);
  12900. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12901. // Correct Roll by rate, if enabled.
  12902. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  12903. if (_this.camera.rollCorrect) {
  12904. _this.camera.restoreRoll(_this.camera.rollCorrect);
  12905. }
  12906. });
  12907. // Helper function to keep 'this'.
  12908. this._mousemoveCallback = function (e) {
  12909. _this._onMouseMove(e);
  12910. };
  12911. element.addEventListener("mousemove", this._mousemoveCallback, false);
  12912. };
  12913. /**
  12914. * Detach the current controls from the specified dom element.
  12915. * @param element Defines the element to stop listening the inputs from
  12916. */
  12917. FlyCameraMouseInput.prototype.detachControl = function (element) {
  12918. if (this._observer && element) {
  12919. this.camera.getScene().onPointerObservable.remove(this._observer);
  12920. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  12921. if (this._mousemoveCallback) {
  12922. element.removeEventListener("mousemove", this._mousemoveCallback);
  12923. }
  12924. this._observer = null;
  12925. this._rollObserver = null;
  12926. this.previousPosition = null;
  12927. this.noPreventDefault = undefined;
  12928. }
  12929. };
  12930. /**
  12931. * Gets the class name of the current input.
  12932. * @returns the class name.
  12933. */
  12934. FlyCameraMouseInput.prototype.getClassName = function () {
  12935. return "FlyCameraMouseInput";
  12936. };
  12937. /**
  12938. * Get the friendly name associated with the input class.
  12939. * @returns the input's friendly name.
  12940. */
  12941. FlyCameraMouseInput.prototype.getSimpleName = function () {
  12942. return "mouse";
  12943. };
  12944. // Track mouse movement, when the pointer is not locked.
  12945. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  12946. var e = p.event;
  12947. var camera = this.camera;
  12948. var engine = camera.getEngine();
  12949. if (engine.isInVRExclusivePointerMode) {
  12950. return;
  12951. }
  12952. if (!this.touchEnabled && e.pointerType === "touch") {
  12953. return;
  12954. }
  12955. // Mouse is moved but an unknown mouse button is pressed.
  12956. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  12957. return;
  12958. }
  12959. var srcElement = (e.srcElement || e.target);
  12960. // Mouse down.
  12961. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12962. try {
  12963. srcElement.setPointerCapture(e.pointerId);
  12964. }
  12965. catch (e) {
  12966. // Nothing to do with the error. Execution continues.
  12967. }
  12968. this.previousPosition = {
  12969. x: e.clientX,
  12970. y: e.clientY
  12971. };
  12972. this.activeButton = e.button;
  12973. if (!this.noPreventDefault) {
  12974. e.preventDefault();
  12975. this.element.focus();
  12976. }
  12977. }
  12978. else
  12979. // Mouse up.
  12980. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12981. try {
  12982. srcElement.releasePointerCapture(e.pointerId);
  12983. }
  12984. catch (e) {
  12985. // Nothing to do with the error. Execution continues.
  12986. }
  12987. this.activeButton = -1;
  12988. this.previousPosition = null;
  12989. if (!this.noPreventDefault) {
  12990. e.preventDefault();
  12991. }
  12992. }
  12993. else
  12994. // Mouse move.
  12995. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12996. if (!this.previousPosition || engine.isPointerLock) {
  12997. return;
  12998. }
  12999. var offsetX = e.clientX - this.previousPosition.x;
  13000. var offsetY = e.clientY - this.previousPosition.y;
  13001. this.rotateCamera(offsetX, offsetY);
  13002. this.previousPosition = {
  13003. x: e.clientX,
  13004. y: e.clientY
  13005. };
  13006. if (!this.noPreventDefault) {
  13007. e.preventDefault();
  13008. }
  13009. }
  13010. };
  13011. // Track mouse movement, when pointer is locked.
  13012. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13013. var camera = this.camera;
  13014. var engine = camera.getEngine();
  13015. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13016. return;
  13017. }
  13018. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13019. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13020. this.rotateCamera(offsetX, offsetY);
  13021. this.previousPosition = null;
  13022. if (!this.noPreventDefault) {
  13023. e.preventDefault();
  13024. }
  13025. };
  13026. /**
  13027. * Rotate camera by mouse offset.
  13028. */
  13029. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13030. var _this = this;
  13031. var camera = this.camera;
  13032. var scene = this.camera.getScene();
  13033. if (scene.useRightHandedSystem) {
  13034. offsetX *= -1;
  13035. }
  13036. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13037. offsetX *= -1;
  13038. }
  13039. var x = offsetX / this.angularSensibility;
  13040. var y = offsetY / this.angularSensibility;
  13041. // Initialize to current rotation.
  13042. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13043. var rotationChange;
  13044. // Pitch.
  13045. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13046. // Apply change in Radians to vector Angle.
  13047. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13048. // Apply Pitch to quaternion.
  13049. currentRotation.multiplyInPlace(rotationChange);
  13050. }
  13051. // Yaw.
  13052. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13053. // Apply change in Radians to vector Angle.
  13054. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13055. // Apply Yaw to quaternion.
  13056. currentRotation.multiplyInPlace(rotationChange);
  13057. // Add Roll, if banked turning is enabled, within Roll limit.
  13058. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13059. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13060. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13061. // Apply change in Radians to vector Angle.
  13062. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13063. // Apply Yaw to quaternion.
  13064. currentRotation.multiplyInPlace(rotationChange);
  13065. }
  13066. }
  13067. // Roll.
  13068. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13069. // Apply change in Radians to vector Angle.
  13070. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13071. // Track Rolling.
  13072. camera._trackRoll -= x;
  13073. // Apply Pitch to quaternion.
  13074. currentRotation.multiplyInPlace(rotationChange);
  13075. }
  13076. // Apply rotationQuaternion to Euler camera.rotation.
  13077. currentRotation.toEulerAnglesToRef(camera.rotation);
  13078. };
  13079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13081. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13084. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13085. return FlyCameraMouseInput;
  13086. }());
  13087. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13088. /***/ }),
  13089. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13090. /*!*********************************************************!*\
  13091. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13092. \*********************************************************/
  13093. /*! exports provided: FollowCameraKeyboardMoveInput */
  13094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13095. "use strict";
  13096. __webpack_require__.r(__webpack_exports__);
  13097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13099. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13100. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13101. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13102. /**
  13103. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  13104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13105. */
  13106. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13107. function FollowCameraKeyboardMoveInput() {
  13108. /**
  13109. * Defines the list of key codes associated with the up action (increase heightOffset)
  13110. */
  13111. this.keysUp = [38];
  13112. /**
  13113. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13114. */
  13115. this.keysDown = [40];
  13116. /**
  13117. * Defines the list of key codes associated with the left action (increase rotation)
  13118. */
  13119. this.keysLeft = [37];
  13120. /**
  13121. * Defines the list of key codes associated with the right action (decrease rotation)
  13122. */
  13123. this.keysRight = [39];
  13124. /**
  13125. * Defines the rate of change of heightOffset.
  13126. */
  13127. this.heightSensibility = 1;
  13128. /**
  13129. * Defines the rate of change of rotationOffset.
  13130. */
  13131. this.rotationSensibility = 1;
  13132. /**
  13133. * Defines the rate of change of radius.
  13134. */
  13135. this.radiusSensibility = 1;
  13136. /**
  13137. * Defines the minimum heightOffset value.
  13138. */
  13139. this.minHeightOffset = 0;
  13140. /**
  13141. * Defines the minimum radius value.
  13142. */
  13143. this.minRadius = 0;
  13144. this._keys = new Array();
  13145. }
  13146. /**
  13147. * Attach the input controls to a specific dom element to get the input from.
  13148. * @param element Defines the element the controls should be listened from
  13149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13150. */
  13151. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13152. var _this = this;
  13153. if (this._onCanvasBlurObserver) {
  13154. return;
  13155. }
  13156. this._scene = this.camera.getScene();
  13157. this._engine = this._scene.getEngine();
  13158. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13159. _this._keys = [];
  13160. });
  13161. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13162. var evt = info.event;
  13163. if (!evt.metaKey) {
  13164. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13165. // this._ctrlPressed = evt.ctrlKey;
  13166. _this._altPressed = evt.altKey;
  13167. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13168. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13169. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13170. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13171. var index = _this._keys.indexOf(evt.keyCode);
  13172. if (index === -1) {
  13173. _this._keys.push(evt.keyCode);
  13174. }
  13175. if (evt.preventDefault) {
  13176. if (!noPreventDefault) {
  13177. evt.preventDefault();
  13178. }
  13179. }
  13180. }
  13181. }
  13182. else {
  13183. if (_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 >= 0) {
  13189. _this._keys.splice(index, 1);
  13190. }
  13191. if (evt.preventDefault) {
  13192. if (!noPreventDefault) {
  13193. evt.preventDefault();
  13194. }
  13195. }
  13196. }
  13197. }
  13198. }
  13199. });
  13200. };
  13201. /**
  13202. * Detach the current controls from the specified dom element.
  13203. * @param element Defines the element to stop listening the inputs from
  13204. */
  13205. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13206. if (this._scene) {
  13207. if (this._onKeyboardObserver) {
  13208. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13209. }
  13210. if (this._onCanvasBlurObserver) {
  13211. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13212. }
  13213. this._onKeyboardObserver = null;
  13214. this._onCanvasBlurObserver = null;
  13215. }
  13216. this._keys = [];
  13217. };
  13218. /**
  13219. * Update the current camera state depending on the inputs that have been used this frame.
  13220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13221. */
  13222. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13223. if (this._onKeyboardObserver) {
  13224. for (var index = 0; index < this._keys.length; index++) {
  13225. var keyCode = this._keys[index];
  13226. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13227. this.camera.rotationOffset += this.rotationSensibility;
  13228. this.camera.rotationOffset %= 360;
  13229. }
  13230. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13231. if (this._altPressed) {
  13232. this.camera.radius += this.radiusSensibility;
  13233. }
  13234. else {
  13235. this.camera.heightOffset += this.heightSensibility;
  13236. }
  13237. }
  13238. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13239. this.camera.rotationOffset -= this.rotationSensibility;
  13240. this.camera.rotationOffset %= 360;
  13241. }
  13242. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13243. if (this._altPressed) {
  13244. this.camera.radius -= this.radiusSensibility;
  13245. this.camera.radius =
  13246. Math.max(this.minRadius, this.camera.radius);
  13247. }
  13248. else {
  13249. this.camera.heightOffset -= this.heightSensibility;
  13250. this.camera.heightOffset =
  13251. Math.max(this.minHeightOffset, this.camera.heightOffset);
  13252. }
  13253. }
  13254. }
  13255. }
  13256. };
  13257. /**
  13258. * Gets the class name of the current intput.
  13259. * @returns the class name
  13260. */
  13261. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13262. return "FollowCameraKeyboardMoveInput";
  13263. };
  13264. /**
  13265. * Get the friendly name associated with the input class.
  13266. * @returns the input friendly name
  13267. */
  13268. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13269. return "keyboard";
  13270. };
  13271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13273. ], FollowCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13276. ], FollowCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13279. ], FollowCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13282. ], FollowCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13285. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13288. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13291. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13294. ], FollowCameraKeyboardMoveInput.prototype, "minHeightOffset", void 0);
  13295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13297. ], FollowCameraKeyboardMoveInput.prototype, "minRadius", void 0);
  13298. return FollowCameraKeyboardMoveInput;
  13299. }());
  13300. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13301. /***/ }),
  13302. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13303. /*!************************************************************!*\
  13304. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13305. \************************************************************/
  13306. /*! exports provided: FreeCameraDeviceOrientationInput */
  13307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13308. "use strict";
  13309. __webpack_require__.r(__webpack_exports__);
  13310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13311. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13313. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13314. /**
  13315. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13316. * Screen rotation is taken into account.
  13317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13318. */
  13319. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13320. /**
  13321. * Instantiates a new input
  13322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13323. */
  13324. function FreeCameraDeviceOrientationInput() {
  13325. var _this = this;
  13326. this._screenOrientationAngle = 0;
  13327. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13328. this._alpha = 0;
  13329. this._beta = 0;
  13330. this._gamma = 0;
  13331. this._orientationChanged = function () {
  13332. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13333. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13334. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13335. };
  13336. this._deviceOrientation = function (evt) {
  13337. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13338. _this._beta = evt.beta !== null ? evt.beta : 0;
  13339. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13340. };
  13341. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13342. this._orientationChanged();
  13343. }
  13344. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13345. /**
  13346. * Define the camera controlled by the input.
  13347. */
  13348. get: function () {
  13349. return this._camera;
  13350. },
  13351. set: function (camera) {
  13352. this._camera = camera;
  13353. if (this._camera != null && !this._camera.rotationQuaternion) {
  13354. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13355. }
  13356. },
  13357. enumerable: true,
  13358. configurable: true
  13359. });
  13360. /**
  13361. * Attach the input controls to a specific dom element to get the input from.
  13362. * @param element Defines the element the controls should be listened from
  13363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13364. */
  13365. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13366. window.addEventListener("orientationchange", this._orientationChanged);
  13367. window.addEventListener("deviceorientation", this._deviceOrientation);
  13368. //In certain cases, the attach control is called AFTER orientation was changed,
  13369. //So this is needed.
  13370. this._orientationChanged();
  13371. };
  13372. /**
  13373. * Detach the current controls from the specified dom element.
  13374. * @param element Defines the element to stop listening the inputs from
  13375. */
  13376. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13377. window.removeEventListener("orientationchange", this._orientationChanged);
  13378. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13379. };
  13380. /**
  13381. * Update the current camera state depending on the inputs that have been used this frame.
  13382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13383. */
  13384. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13385. //if no device orientation provided, don't update the rotation.
  13386. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13387. if (!this._alpha) {
  13388. return;
  13389. }
  13390. _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);
  13391. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13392. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13393. //Mirror on XY Plane
  13394. this._camera.rotationQuaternion.z *= -1;
  13395. this._camera.rotationQuaternion.w *= -1;
  13396. };
  13397. /**
  13398. * Gets the class name of the current intput.
  13399. * @returns the class name
  13400. */
  13401. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13402. return "FreeCameraDeviceOrientationInput";
  13403. };
  13404. /**
  13405. * Get the friendly name associated with the input class.
  13406. * @returns the input friendly name
  13407. */
  13408. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13409. return "deviceOrientation";
  13410. };
  13411. return FreeCameraDeviceOrientationInput;
  13412. }());
  13413. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13414. /***/ }),
  13415. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13416. /*!**************************************************!*\
  13417. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13418. \**************************************************/
  13419. /*! exports provided: FreeCameraGamepadInput */
  13420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13421. "use strict";
  13422. __webpack_require__.r(__webpack_exports__);
  13423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13424. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13425. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13426. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13427. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13428. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13429. /**
  13430. * Manage the gamepad inputs to control a free camera.
  13431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13432. */
  13433. var FreeCameraGamepadInput = /** @class */ (function () {
  13434. function FreeCameraGamepadInput() {
  13435. /**
  13436. * Defines the gamepad rotation sensiblity.
  13437. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13438. */
  13439. this.gamepadAngularSensibility = 200;
  13440. /**
  13441. * Defines the gamepad move sensiblity.
  13442. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13443. */
  13444. this.gamepadMoveSensibility = 40;
  13445. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13446. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13447. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13448. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  13449. }
  13450. /**
  13451. * Attach the input controls to a specific dom element to get the input from.
  13452. * @param element Defines the element the controls should be listened from
  13453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13454. */
  13455. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  13456. var _this = this;
  13457. var manager = this.camera.getScene().gamepadManager;
  13458. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  13459. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  13460. // prioritize XBOX gamepads.
  13461. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  13462. _this.gamepad = gamepad;
  13463. }
  13464. }
  13465. });
  13466. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  13467. if (_this.gamepad === gamepad) {
  13468. _this.gamepad = null;
  13469. }
  13470. });
  13471. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  13472. };
  13473. /**
  13474. * Detach the current controls from the specified dom element.
  13475. * @param element Defines the element to stop listening the inputs from
  13476. */
  13477. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  13478. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  13479. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  13480. this.gamepad = null;
  13481. };
  13482. /**
  13483. * Update the current camera state depending on the inputs that have been used this frame.
  13484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13485. */
  13486. FreeCameraGamepadInput.prototype.checkInputs = function () {
  13487. if (this.gamepad && this.gamepad.leftStick) {
  13488. var camera = this.camera;
  13489. var LSValues = this.gamepad.leftStick;
  13490. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  13491. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  13492. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  13493. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  13494. var RSValues = this.gamepad.rightStick;
  13495. if (RSValues) {
  13496. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  13497. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  13498. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  13499. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  13500. }
  13501. else {
  13502. RSValues = { x: 0, y: 0 };
  13503. }
  13504. if (!camera.rotationQuaternion) {
  13505. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  13506. }
  13507. else {
  13508. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  13509. }
  13510. var speed = camera._computeLocalCameraSpeed() * 50.0;
  13511. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  13512. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  13513. camera.cameraDirection.addInPlace(this._deltaTransform);
  13514. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  13515. camera.cameraRotation.addInPlace(this._vector2);
  13516. }
  13517. };
  13518. /**
  13519. * Gets the class name of the current intput.
  13520. * @returns the class name
  13521. */
  13522. FreeCameraGamepadInput.prototype.getClassName = function () {
  13523. return "FreeCameraGamepadInput";
  13524. };
  13525. /**
  13526. * Get the friendly name associated with the input class.
  13527. * @returns the input friendly name
  13528. */
  13529. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  13530. return "gamepad";
  13531. };
  13532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13534. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  13535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13537. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  13538. return FreeCameraGamepadInput;
  13539. }());
  13540. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  13541. /***/ }),
  13542. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  13543. /*!*******************************************************!*\
  13544. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  13545. \*******************************************************/
  13546. /*! exports provided: FreeCameraKeyboardMoveInput */
  13547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13548. "use strict";
  13549. __webpack_require__.r(__webpack_exports__);
  13550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  13551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13552. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13553. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13554. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13555. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13556. /**
  13557. * Manage the keyboard inputs to control the movement of a free camera.
  13558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13559. */
  13560. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  13561. function FreeCameraKeyboardMoveInput() {
  13562. /**
  13563. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  13564. */
  13565. this.keysUp = [38];
  13566. /**
  13567. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  13568. */
  13569. this.keysDown = [40];
  13570. /**
  13571. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  13572. */
  13573. this.keysLeft = [37];
  13574. /**
  13575. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  13576. */
  13577. this.keysRight = [39];
  13578. this._keys = new Array();
  13579. }
  13580. /**
  13581. * Attach the input controls to a specific dom element to get the input from.
  13582. * @param element Defines the element the controls should be listened from
  13583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13584. */
  13585. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13586. var _this = this;
  13587. if (this._onCanvasBlurObserver) {
  13588. return;
  13589. }
  13590. this._scene = this.camera.getScene();
  13591. this._engine = this._scene.getEngine();
  13592. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13593. _this._keys = [];
  13594. });
  13595. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13596. var evt = info.event;
  13597. if (!evt.metaKey) {
  13598. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13599. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13600. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13601. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13602. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13603. var index = _this._keys.indexOf(evt.keyCode);
  13604. if (index === -1) {
  13605. _this._keys.push(evt.keyCode);
  13606. }
  13607. if (!noPreventDefault) {
  13608. evt.preventDefault();
  13609. }
  13610. }
  13611. }
  13612. else {
  13613. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13614. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13615. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13616. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13617. var index = _this._keys.indexOf(evt.keyCode);
  13618. if (index >= 0) {
  13619. _this._keys.splice(index, 1);
  13620. }
  13621. if (!noPreventDefault) {
  13622. evt.preventDefault();
  13623. }
  13624. }
  13625. }
  13626. }
  13627. });
  13628. };
  13629. /**
  13630. * Detach the current controls from the specified dom element.
  13631. * @param element Defines the element to stop listening the inputs from
  13632. */
  13633. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13634. if (this._scene) {
  13635. if (this._onKeyboardObserver) {
  13636. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13637. }
  13638. if (this._onCanvasBlurObserver) {
  13639. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13640. }
  13641. this._onKeyboardObserver = null;
  13642. this._onCanvasBlurObserver = null;
  13643. }
  13644. this._keys = [];
  13645. };
  13646. /**
  13647. * Update the current camera state depending on the inputs that have been used this frame.
  13648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13649. */
  13650. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13651. if (this._onKeyboardObserver) {
  13652. var camera = this.camera;
  13653. // Keyboard
  13654. for (var index = 0; index < this._keys.length; index++) {
  13655. var keyCode = this._keys[index];
  13656. var speed = camera._computeLocalCameraSpeed();
  13657. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13658. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13659. }
  13660. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13661. camera._localDirection.copyFromFloats(0, 0, speed);
  13662. }
  13663. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13664. camera._localDirection.copyFromFloats(speed, 0, 0);
  13665. }
  13666. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13667. camera._localDirection.copyFromFloats(0, 0, -speed);
  13668. }
  13669. if (camera.getScene().useRightHandedSystem) {
  13670. camera._localDirection.z *= -1;
  13671. }
  13672. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13673. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13674. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13675. }
  13676. }
  13677. };
  13678. /**
  13679. * Gets the class name of the current intput.
  13680. * @returns the class name
  13681. */
  13682. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  13683. return "FreeCameraKeyboardMoveInput";
  13684. };
  13685. /** @hidden */
  13686. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  13687. this._keys = [];
  13688. };
  13689. /**
  13690. * Get the friendly name associated with the input class.
  13691. * @returns the input friendly name
  13692. */
  13693. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13694. return "keyboard";
  13695. };
  13696. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13697. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13698. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13699. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13700. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13701. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13704. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13707. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13708. return FreeCameraKeyboardMoveInput;
  13709. }());
  13710. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  13711. /***/ }),
  13712. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  13713. /*!************************************************!*\
  13714. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  13715. \************************************************/
  13716. /*! exports provided: FreeCameraMouseInput */
  13717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13718. "use strict";
  13719. __webpack_require__.r(__webpack_exports__);
  13720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  13721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13722. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13723. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13724. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13725. /**
  13726. * Manage the mouse inputs to control the movement of a free camera.
  13727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13728. */
  13729. var FreeCameraMouseInput = /** @class */ (function () {
  13730. /**
  13731. * Manage the mouse inputs to control the movement of a free camera.
  13732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13733. * @param touchEnabled Defines if touch is enabled or not
  13734. */
  13735. function FreeCameraMouseInput(
  13736. /**
  13737. * Define if touch is enabled in the mouse input
  13738. */
  13739. touchEnabled) {
  13740. if (touchEnabled === void 0) { touchEnabled = true; }
  13741. this.touchEnabled = touchEnabled;
  13742. /**
  13743. * Defines the buttons associated with the input to handle camera move.
  13744. */
  13745. this.buttons = [0, 1, 2];
  13746. /**
  13747. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  13748. */
  13749. this.angularSensibility = 2000.0;
  13750. this.previousPosition = null;
  13751. }
  13752. /**
  13753. * Attach the input controls to a specific dom element to get the input from.
  13754. * @param element Defines the element the controls should be listened from
  13755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13756. */
  13757. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13758. var _this = this;
  13759. var engine = this.camera.getEngine();
  13760. if (!this._pointerInput) {
  13761. this._pointerInput = function (p) {
  13762. var evt = p.event;
  13763. if (engine.isInVRExclusivePointerMode) {
  13764. return;
  13765. }
  13766. if (!_this.touchEnabled && evt.pointerType === "touch") {
  13767. return;
  13768. }
  13769. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  13770. return;
  13771. }
  13772. var srcElement = (evt.srcElement || evt.target);
  13773. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13774. try {
  13775. srcElement.setPointerCapture(evt.pointerId);
  13776. }
  13777. catch (e) {
  13778. //Nothing to do with the error. Execution will continue.
  13779. }
  13780. _this.previousPosition = {
  13781. x: evt.clientX,
  13782. y: evt.clientY
  13783. };
  13784. if (!noPreventDefault) {
  13785. evt.preventDefault();
  13786. element.focus();
  13787. }
  13788. }
  13789. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13790. try {
  13791. srcElement.releasePointerCapture(evt.pointerId);
  13792. }
  13793. catch (e) {
  13794. //Nothing to do with the error.
  13795. }
  13796. _this.previousPosition = null;
  13797. if (!noPreventDefault) {
  13798. evt.preventDefault();
  13799. }
  13800. }
  13801. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13802. if (!_this.previousPosition || engine.isPointerLock) {
  13803. return;
  13804. }
  13805. var offsetX = evt.clientX - _this.previousPosition.x;
  13806. if (_this.camera.getScene().useRightHandedSystem) {
  13807. offsetX *= -1;
  13808. }
  13809. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  13810. offsetX *= -1;
  13811. }
  13812. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  13813. var offsetY = evt.clientY - _this.previousPosition.y;
  13814. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  13815. _this.previousPosition = {
  13816. x: evt.clientX,
  13817. y: evt.clientY
  13818. };
  13819. if (!noPreventDefault) {
  13820. evt.preventDefault();
  13821. }
  13822. }
  13823. };
  13824. }
  13825. this._onMouseMove = function (evt) {
  13826. if (!engine.isPointerLock) {
  13827. return;
  13828. }
  13829. if (engine.isInVRExclusivePointerMode) {
  13830. return;
  13831. }
  13832. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  13833. if (_this.camera.getScene().useRightHandedSystem) {
  13834. offsetX *= -1;
  13835. }
  13836. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  13837. offsetX *= -1;
  13838. }
  13839. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  13840. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  13841. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  13842. _this.previousPosition = null;
  13843. if (!noPreventDefault) {
  13844. evt.preventDefault();
  13845. }
  13846. };
  13847. 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);
  13848. element.addEventListener("mousemove", this._onMouseMove, false);
  13849. };
  13850. /**
  13851. * Detach the current controls from the specified dom element.
  13852. * @param element Defines the element to stop listening the inputs from
  13853. */
  13854. FreeCameraMouseInput.prototype.detachControl = function (element) {
  13855. if (this._observer && element) {
  13856. this.camera.getScene().onPointerObservable.remove(this._observer);
  13857. if (this._onMouseMove) {
  13858. element.removeEventListener("mousemove", this._onMouseMove);
  13859. }
  13860. this._observer = null;
  13861. this._onMouseMove = null;
  13862. this.previousPosition = null;
  13863. }
  13864. };
  13865. /**
  13866. * Gets the class name of the current intput.
  13867. * @returns the class name
  13868. */
  13869. FreeCameraMouseInput.prototype.getClassName = function () {
  13870. return "FreeCameraMouseInput";
  13871. };
  13872. /**
  13873. * Get the friendly name associated with the input class.
  13874. * @returns the input friendly name
  13875. */
  13876. FreeCameraMouseInput.prototype.getSimpleName = function () {
  13877. return "mouse";
  13878. };
  13879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13881. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  13882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13884. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  13885. return FreeCameraMouseInput;
  13886. }());
  13887. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  13888. /***/ }),
  13889. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  13890. /*!************************************************!*\
  13891. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  13892. \************************************************/
  13893. /*! exports provided: FreeCameraTouchInput */
  13894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13895. "use strict";
  13896. __webpack_require__.r(__webpack_exports__);
  13897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  13898. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13899. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13900. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13901. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13903. /**
  13904. * Manage the touch inputs to control the movement of a free camera.
  13905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13906. */
  13907. var FreeCameraTouchInput = /** @class */ (function () {
  13908. function FreeCameraTouchInput() {
  13909. /**
  13910. * Defines the touch sensibility for rotation.
  13911. * The higher the faster.
  13912. */
  13913. this.touchAngularSensibility = 200000.0;
  13914. /**
  13915. * Defines the touch sensibility for move.
  13916. * The higher the faster.
  13917. */
  13918. this.touchMoveSensibility = 250.0;
  13919. this._offsetX = null;
  13920. this._offsetY = null;
  13921. this._pointerPressed = new Array();
  13922. }
  13923. /**
  13924. * Attach the input controls to a specific dom element to get the input from.
  13925. * @param element Defines the element the controls should be listened from
  13926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13927. */
  13928. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  13929. var _this = this;
  13930. var previousPosition = null;
  13931. if (this._pointerInput === undefined) {
  13932. this._onLostFocus = function () {
  13933. _this._offsetX = null;
  13934. _this._offsetY = null;
  13935. };
  13936. this._pointerInput = function (p) {
  13937. var evt = p.event;
  13938. if (evt.pointerType === "mouse") {
  13939. return;
  13940. }
  13941. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  13942. if (!noPreventDefault) {
  13943. evt.preventDefault();
  13944. }
  13945. _this._pointerPressed.push(evt.pointerId);
  13946. if (_this._pointerPressed.length !== 1) {
  13947. return;
  13948. }
  13949. previousPosition = {
  13950. x: evt.clientX,
  13951. y: evt.clientY
  13952. };
  13953. }
  13954. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  13955. if (!noPreventDefault) {
  13956. evt.preventDefault();
  13957. }
  13958. var index = _this._pointerPressed.indexOf(evt.pointerId);
  13959. if (index === -1) {
  13960. return;
  13961. }
  13962. _this._pointerPressed.splice(index, 1);
  13963. if (index != 0) {
  13964. return;
  13965. }
  13966. previousPosition = null;
  13967. _this._offsetX = null;
  13968. _this._offsetY = null;
  13969. }
  13970. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13971. if (!noPreventDefault) {
  13972. evt.preventDefault();
  13973. }
  13974. if (!previousPosition) {
  13975. return;
  13976. }
  13977. var index = _this._pointerPressed.indexOf(evt.pointerId);
  13978. if (index != 0) {
  13979. return;
  13980. }
  13981. _this._offsetX = evt.clientX - previousPosition.x;
  13982. _this._offsetY = -(evt.clientY - previousPosition.y);
  13983. }
  13984. };
  13985. }
  13986. 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);
  13987. if (this._onLostFocus) {
  13988. element.addEventListener("blur", this._onLostFocus);
  13989. }
  13990. };
  13991. /**
  13992. * Detach the current controls from the specified dom element.
  13993. * @param element Defines the element to stop listening the inputs from
  13994. */
  13995. FreeCameraTouchInput.prototype.detachControl = function (element) {
  13996. if (this._pointerInput && element) {
  13997. if (this._observer) {
  13998. this.camera.getScene().onPointerObservable.remove(this._observer);
  13999. this._observer = null;
  14000. }
  14001. if (this._onLostFocus) {
  14002. element.removeEventListener("blur", this._onLostFocus);
  14003. this._onLostFocus = null;
  14004. }
  14005. this._pointerPressed = [];
  14006. this._offsetX = null;
  14007. this._offsetY = null;
  14008. }
  14009. };
  14010. /**
  14011. * Update the current camera state depending on the inputs that have been used this frame.
  14012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14013. */
  14014. FreeCameraTouchInput.prototype.checkInputs = function () {
  14015. if (this._offsetX && this._offsetY) {
  14016. var camera = this.camera;
  14017. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14018. if (this._pointerPressed.length > 1) {
  14019. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14020. }
  14021. else {
  14022. var speed = camera._computeLocalCameraSpeed();
  14023. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14024. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14025. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14026. }
  14027. }
  14028. };
  14029. /**
  14030. * Gets the class name of the current intput.
  14031. * @returns the class name
  14032. */
  14033. FreeCameraTouchInput.prototype.getClassName = function () {
  14034. return "FreeCameraTouchInput";
  14035. };
  14036. /**
  14037. * Get the friendly name associated with the input class.
  14038. * @returns the input friendly name
  14039. */
  14040. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14041. return "touch";
  14042. };
  14043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14045. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14048. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14049. return FreeCameraTouchInput;
  14050. }());
  14051. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14052. /***/ }),
  14053. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14054. /*!**********************************************************!*\
  14055. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14056. \**********************************************************/
  14057. /*! exports provided: FreeCameraVirtualJoystickInput */
  14058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14059. "use strict";
  14060. __webpack_require__.r(__webpack_exports__);
  14061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14062. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14063. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14064. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14065. /**
  14066. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14068. */
  14069. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14070. function FreeCameraVirtualJoystickInput() {
  14071. }
  14072. /**
  14073. * Gets the left stick of the virtual joystick.
  14074. * @returns The virtual Joystick
  14075. */
  14076. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14077. return this._leftjoystick;
  14078. };
  14079. /**
  14080. * Gets the right stick of the virtual joystick.
  14081. * @returns The virtual Joystick
  14082. */
  14083. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14084. return this._rightjoystick;
  14085. };
  14086. /**
  14087. * Update the current camera state depending on the inputs that have been used this frame.
  14088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14089. */
  14090. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14091. if (this._leftjoystick) {
  14092. var camera = this.camera;
  14093. var speed = camera._computeLocalCameraSpeed() * 50;
  14094. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14095. 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);
  14096. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14097. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14098. if (!this._leftjoystick.pressed) {
  14099. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14100. }
  14101. if (!this._rightjoystick.pressed) {
  14102. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14103. }
  14104. }
  14105. };
  14106. /**
  14107. * Attach the input controls to a specific dom element to get the input from.
  14108. * @param element Defines the element the controls should be listened from
  14109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14110. */
  14111. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14112. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14113. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14114. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14115. this._leftjoystick.setJoystickSensibility(0.15);
  14116. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14117. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14118. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14119. this._rightjoystick.reverseUpDown = true;
  14120. this._rightjoystick.setJoystickSensibility(0.05);
  14121. this._rightjoystick.setJoystickColor("yellow");
  14122. };
  14123. /**
  14124. * Detach the current controls from the specified dom element.
  14125. * @param element Defines the element to stop listening the inputs from
  14126. */
  14127. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14128. this._leftjoystick.releaseCanvas();
  14129. this._rightjoystick.releaseCanvas();
  14130. };
  14131. /**
  14132. * Gets the class name of the current intput.
  14133. * @returns the class name
  14134. */
  14135. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14136. return "FreeCameraVirtualJoystickInput";
  14137. };
  14138. /**
  14139. * Get the friendly name associated with the input class.
  14140. * @returns the input friendly name
  14141. */
  14142. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14143. return "virtualJoystick";
  14144. };
  14145. return FreeCameraVirtualJoystickInput;
  14146. }());
  14147. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14148. /***/ }),
  14149. /***/ "./Cameras/Inputs/index.ts":
  14150. /*!*********************************!*\
  14151. !*** ./Cameras/Inputs/index.ts ***!
  14152. \*********************************/
  14153. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14155. "use strict";
  14156. __webpack_require__.r(__webpack_exports__);
  14157. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14159. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14161. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14163. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14165. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14167. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14169. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14171. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14173. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14175. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14177. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14179. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14181. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14183. /***/ }),
  14184. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14185. /*!*********************************************************!*\
  14186. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14187. \*********************************************************/
  14188. /*! exports provided: AnaglyphArcRotateCamera */
  14189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14190. "use strict";
  14191. __webpack_require__.r(__webpack_exports__);
  14192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14193. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14194. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14195. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14196. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14197. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14198. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14199. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14200. });
  14201. /**
  14202. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14203. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14204. */
  14205. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14207. /**
  14208. * Creates a new AnaglyphArcRotateCamera
  14209. * @param name defines camera name
  14210. * @param alpha defines alpha angle (in radians)
  14211. * @param beta defines beta angle (in radians)
  14212. * @param radius defines radius
  14213. * @param target defines camera target
  14214. * @param interaxialDistance defines distance between each color axis
  14215. * @param scene defines the hosting scene
  14216. */
  14217. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14218. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14219. _this.interaxialDistance = interaxialDistance;
  14220. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14221. return _this;
  14222. }
  14223. /**
  14224. * Gets camera class name
  14225. * @returns AnaglyphArcRotateCamera
  14226. */
  14227. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14228. return "AnaglyphArcRotateCamera";
  14229. };
  14230. return AnaglyphArcRotateCamera;
  14231. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14232. /***/ }),
  14233. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14234. /*!****************************************************!*\
  14235. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14236. \****************************************************/
  14237. /*! exports provided: AnaglyphFreeCamera */
  14238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14239. "use strict";
  14240. __webpack_require__.r(__webpack_exports__);
  14241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14242. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14243. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14244. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14245. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14246. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14247. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14248. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14249. });
  14250. /**
  14251. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14252. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14253. */
  14254. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14255. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14256. /**
  14257. * Creates a new AnaglyphFreeCamera
  14258. * @param name defines camera name
  14259. * @param position defines initial position
  14260. * @param interaxialDistance defines distance between each color axis
  14261. * @param scene defines the hosting scene
  14262. */
  14263. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14264. var _this = _super.call(this, name, position, scene) || this;
  14265. _this.interaxialDistance = interaxialDistance;
  14266. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14267. return _this;
  14268. }
  14269. /**
  14270. * Gets camera class name
  14271. * @returns AnaglyphFreeCamera
  14272. */
  14273. AnaglyphFreeCamera.prototype.getClassName = function () {
  14274. return "AnaglyphFreeCamera";
  14275. };
  14276. return AnaglyphFreeCamera;
  14277. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14278. /***/ }),
  14279. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14280. /*!*******************************************************!*\
  14281. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14282. \*******************************************************/
  14283. /*! exports provided: AnaglyphGamepadCamera */
  14284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14285. "use strict";
  14286. __webpack_require__.r(__webpack_exports__);
  14287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14288. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14289. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14290. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14291. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14292. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14293. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14294. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14295. });
  14296. /**
  14297. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14298. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14299. */
  14300. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14302. /**
  14303. * Creates a new AnaglyphGamepadCamera
  14304. * @param name defines camera name
  14305. * @param position defines initial position
  14306. * @param interaxialDistance defines distance between each color axis
  14307. * @param scene defines the hosting scene
  14308. */
  14309. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14310. var _this = _super.call(this, name, position, scene) || this;
  14311. _this.interaxialDistance = interaxialDistance;
  14312. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14313. return _this;
  14314. }
  14315. /**
  14316. * Gets camera class name
  14317. * @returns AnaglyphGamepadCamera
  14318. */
  14319. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14320. return "AnaglyphGamepadCamera";
  14321. };
  14322. return AnaglyphGamepadCamera;
  14323. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14324. /***/ }),
  14325. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  14326. /*!*********************************************************!*\
  14327. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  14328. \*********************************************************/
  14329. /*! exports provided: AnaglyphUniversalCamera */
  14330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14331. "use strict";
  14332. __webpack_require__.r(__webpack_exports__);
  14333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  14334. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14335. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14336. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14337. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14338. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14339. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  14340. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14341. });
  14342. /**
  14343. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  14344. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14345. */
  14346. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  14347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  14348. /**
  14349. * Creates a new AnaglyphUniversalCamera
  14350. * @param name defines camera name
  14351. * @param position defines initial position
  14352. * @param interaxialDistance defines distance between each color axis
  14353. * @param scene defines the hosting scene
  14354. */
  14355. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  14356. var _this = _super.call(this, name, position, scene) || this;
  14357. _this.interaxialDistance = interaxialDistance;
  14358. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14359. return _this;
  14360. }
  14361. /**
  14362. * Gets camera class name
  14363. * @returns AnaglyphUniversalCamera
  14364. */
  14365. AnaglyphUniversalCamera.prototype.getClassName = function () {
  14366. return "AnaglyphUniversalCamera";
  14367. };
  14368. return AnaglyphUniversalCamera;
  14369. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14370. /***/ }),
  14371. /***/ "./Cameras/Stereoscopic/index.ts":
  14372. /*!***************************************!*\
  14373. !*** ./Cameras/Stereoscopic/index.ts ***!
  14374. \***************************************/
  14375. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  14376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14377. "use strict";
  14378. __webpack_require__.r(__webpack_exports__);
  14379. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  14380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  14381. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  14382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  14383. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  14384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  14385. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  14386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  14387. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  14388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  14389. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  14390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  14391. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  14392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  14393. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  14394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  14395. /***/ }),
  14396. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  14397. /*!*************************************************************!*\
  14398. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  14399. \*************************************************************/
  14400. /*! exports provided: StereoscopicArcRotateCamera */
  14401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14402. "use strict";
  14403. __webpack_require__.r(__webpack_exports__);
  14404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  14405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14406. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14407. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14408. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14409. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14410. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  14411. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14412. });
  14413. /**
  14414. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  14415. * @see http://doc.babylonjs.com/features/cameras
  14416. */
  14417. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  14418. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  14419. /**
  14420. * Creates a new StereoscopicArcRotateCamera
  14421. * @param name defines camera name
  14422. * @param alpha defines alpha angle (in radians)
  14423. * @param beta defines beta angle (in radians)
  14424. * @param radius defines radius
  14425. * @param target defines camera target
  14426. * @param interaxialDistance defines distance between each color axis
  14427. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14428. * @param scene defines the hosting scene
  14429. */
  14430. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  14431. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14432. _this.interaxialDistance = interaxialDistance;
  14433. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14434. _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 });
  14435. return _this;
  14436. }
  14437. /**
  14438. * Gets camera class name
  14439. * @returns StereoscopicArcRotateCamera
  14440. */
  14441. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  14442. return "StereoscopicArcRotateCamera";
  14443. };
  14444. return StereoscopicArcRotateCamera;
  14445. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14446. /***/ }),
  14447. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  14448. /*!********************************************************!*\
  14449. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  14450. \********************************************************/
  14451. /*! exports provided: StereoscopicFreeCamera */
  14452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14453. "use strict";
  14454. __webpack_require__.r(__webpack_exports__);
  14455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  14456. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14457. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14458. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14459. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14460. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14461. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14462. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14463. });
  14464. /**
  14465. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  14466. * @see http://doc.babylonjs.com/features/cameras
  14467. */
  14468. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  14469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  14470. /**
  14471. * Creates a new StereoscopicFreeCamera
  14472. * @param name defines camera name
  14473. * @param position defines initial position
  14474. * @param interaxialDistance defines distance between each color axis
  14475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14476. * @param scene defines the hosting scene
  14477. */
  14478. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14479. var _this = _super.call(this, name, position, scene) || this;
  14480. _this.interaxialDistance = interaxialDistance;
  14481. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14482. _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 });
  14483. return _this;
  14484. }
  14485. /**
  14486. * Gets camera class name
  14487. * @returns StereoscopicFreeCamera
  14488. */
  14489. StereoscopicFreeCamera.prototype.getClassName = function () {
  14490. return "StereoscopicFreeCamera";
  14491. };
  14492. return StereoscopicFreeCamera;
  14493. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14494. /***/ }),
  14495. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  14496. /*!***********************************************************!*\
  14497. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  14498. \***********************************************************/
  14499. /*! exports provided: StereoscopicGamepadCamera */
  14500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14501. "use strict";
  14502. __webpack_require__.r(__webpack_exports__);
  14503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  14504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14505. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14506. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14507. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14508. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14509. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  14510. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14511. });
  14512. /**
  14513. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  14514. * @see http://doc.babylonjs.com/features/cameras
  14515. */
  14516. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  14517. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  14518. /**
  14519. * Creates a new StereoscopicGamepadCamera
  14520. * @param name defines camera name
  14521. * @param position defines initial position
  14522. * @param interaxialDistance defines distance between each color axis
  14523. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14524. * @param scene defines the hosting scene
  14525. */
  14526. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14527. var _this = _super.call(this, name, position, scene) || this;
  14528. _this.interaxialDistance = interaxialDistance;
  14529. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14530. _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 });
  14531. return _this;
  14532. }
  14533. /**
  14534. * Gets camera class name
  14535. * @returns StereoscopicGamepadCamera
  14536. */
  14537. StereoscopicGamepadCamera.prototype.getClassName = function () {
  14538. return "StereoscopicGamepadCamera";
  14539. };
  14540. return StereoscopicGamepadCamera;
  14541. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14542. /***/ }),
  14543. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  14544. /*!*************************************************************!*\
  14545. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  14546. \*************************************************************/
  14547. /*! exports provided: StereoscopicUniversalCamera */
  14548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14549. "use strict";
  14550. __webpack_require__.r(__webpack_exports__);
  14551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  14552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14553. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14554. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14555. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14556. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14557. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14558. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14559. });
  14560. /**
  14561. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  14562. * @see http://doc.babylonjs.com/features/cameras
  14563. */
  14564. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  14565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  14566. /**
  14567. * Creates a new StereoscopicUniversalCamera
  14568. * @param name defines camera name
  14569. * @param position defines initial position
  14570. * @param interaxialDistance defines distance between each color axis
  14571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14572. * @param scene defines the hosting scene
  14573. */
  14574. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14575. var _this = _super.call(this, name, position, scene) || this;
  14576. _this.interaxialDistance = interaxialDistance;
  14577. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14578. _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 });
  14579. return _this;
  14580. }
  14581. /**
  14582. * Gets camera class name
  14583. * @returns StereoscopicUniversalCamera
  14584. */
  14585. StereoscopicUniversalCamera.prototype.getClassName = function () {
  14586. return "StereoscopicUniversalCamera";
  14587. };
  14588. return StereoscopicUniversalCamera;
  14589. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14590. /***/ }),
  14591. /***/ "./Cameras/VR/index.ts":
  14592. /*!*****************************!*\
  14593. !*** ./Cameras/VR/index.ts ***!
  14594. \*****************************/
  14595. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  14596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14597. "use strict";
  14598. __webpack_require__.r(__webpack_exports__);
  14599. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  14601. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  14603. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  14605. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  14607. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  14609. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  14611. /***/ }),
  14612. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  14613. /*!***************************************!*\
  14614. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  14615. \***************************************/
  14616. /*! exports provided: VRCameraMetrics */
  14617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14618. "use strict";
  14619. __webpack_require__.r(__webpack_exports__);
  14620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  14621. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14622. /**
  14623. * This represents all the required metrics to create a VR camera.
  14624. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  14625. */
  14626. var VRCameraMetrics = /** @class */ (function () {
  14627. function VRCameraMetrics() {
  14628. /**
  14629. * Define if the current vr camera should compensate the distortion of the lense or not.
  14630. */
  14631. this.compensateDistortion = true;
  14632. }
  14633. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  14634. /**
  14635. * Gets the rendering aspect ratio based on the provided resolutions.
  14636. */
  14637. get: function () {
  14638. return this.hResolution / (2 * this.vResolution);
  14639. },
  14640. enumerable: true,
  14641. configurable: true
  14642. });
  14643. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  14644. /**
  14645. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  14646. */
  14647. get: function () {
  14648. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  14649. },
  14650. enumerable: true,
  14651. configurable: true
  14652. });
  14653. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  14654. /**
  14655. * @hidden
  14656. */
  14657. get: function () {
  14658. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14659. var h = (4 * meters) / this.hScreenSize;
  14660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  14661. },
  14662. enumerable: true,
  14663. configurable: true
  14664. });
  14665. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  14666. /**
  14667. * @hidden
  14668. */
  14669. get: function () {
  14670. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14671. var h = (4 * meters) / this.hScreenSize;
  14672. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  14673. },
  14674. enumerable: true,
  14675. configurable: true
  14676. });
  14677. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  14678. /**
  14679. * @hidden
  14680. */
  14681. get: function () {
  14682. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  14683. },
  14684. enumerable: true,
  14685. configurable: true
  14686. });
  14687. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  14688. /**
  14689. * @hidden
  14690. */
  14691. get: function () {
  14692. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  14693. },
  14694. enumerable: true,
  14695. configurable: true
  14696. });
  14697. /**
  14698. * Get the default VRMetrics based on the most generic setup.
  14699. * @returns the default vr metrics
  14700. */
  14701. VRCameraMetrics.GetDefault = function () {
  14702. var result = new VRCameraMetrics();
  14703. result.hResolution = 1280;
  14704. result.vResolution = 800;
  14705. result.hScreenSize = 0.149759993;
  14706. result.vScreenSize = 0.0935999975;
  14707. result.vScreenCenter = 0.0467999987;
  14708. result.eyeToScreenDistance = 0.0410000011;
  14709. result.lensSeparationDistance = 0.0635000020;
  14710. result.interpupillaryDistance = 0.0640000030;
  14711. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  14712. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  14713. result.postProcessScaleFactor = 1.714605507808412;
  14714. result.lensCenterOffset = 0.151976421;
  14715. return result;
  14716. };
  14717. return VRCameraMetrics;
  14718. }());
  14719. /***/ }),
  14720. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  14721. /*!**********************************************************!*\
  14722. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  14723. \**********************************************************/
  14724. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  14725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14726. "use strict";
  14727. __webpack_require__.r(__webpack_exports__);
  14728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  14729. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14730. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14731. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14732. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14733. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14734. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14735. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  14736. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  14737. });
  14738. /**
  14739. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  14740. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  14741. */
  14742. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  14743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  14744. /**
  14745. * Creates a new VRDeviceOrientationArcRotateCamera
  14746. * @param name defines camera name
  14747. * @param alpha defines the camera rotation along the logitudinal axis
  14748. * @param beta defines the camera rotation along the latitudinal axis
  14749. * @param radius defines the camera distance from its target
  14750. * @param target defines the camera target
  14751. * @param scene defines the scene the camera belongs to
  14752. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  14753. * @param vrCameraMetrics defines the vr metrics associated to the camera
  14754. */
  14755. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  14756. if (compensateDistortion === void 0) { compensateDistortion = true; }
  14757. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  14758. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14759. vrCameraMetrics.compensateDistortion = compensateDistortion;
  14760. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  14761. _this.inputs.addVRDeviceOrientation();
  14762. return _this;
  14763. }
  14764. /**
  14765. * Gets camera class name
  14766. * @returns VRDeviceOrientationArcRotateCamera
  14767. */
  14768. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  14769. return "VRDeviceOrientationArcRotateCamera";
  14770. };
  14771. return VRDeviceOrientationArcRotateCamera;
  14772. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14773. /***/ }),
  14774. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  14775. /*!*****************************************************!*\
  14776. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  14777. \*****************************************************/
  14778. /*! exports provided: VRDeviceOrientationFreeCamera */
  14779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14780. "use strict";
  14781. __webpack_require__.r(__webpack_exports__);
  14782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  14783. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14784. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14785. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  14786. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14788. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14789. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  14790. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  14791. });
  14792. /**
  14793. * Camera used to simulate VR rendering (based on FreeCamera)
  14794. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  14795. */
  14796. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  14797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  14798. /**
  14799. * Creates a new VRDeviceOrientationFreeCamera
  14800. * @param name defines camera name
  14801. * @param position defines the start position of the camera
  14802. * @param scene defines the scene the camera belongs to
  14803. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  14804. * @param vrCameraMetrics defines the vr metrics associated to the camera
  14805. */
  14806. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  14807. if (compensateDistortion === void 0) { compensateDistortion = true; }
  14808. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  14809. var _this = _super.call(this, name, position, scene) || this;
  14810. vrCameraMetrics.compensateDistortion = compensateDistortion;
  14811. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  14812. return _this;
  14813. }
  14814. /**
  14815. * Gets camera class name
  14816. * @returns VRDeviceOrientationFreeCamera
  14817. */
  14818. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  14819. return "VRDeviceOrientationFreeCamera";
  14820. };
  14821. return VRDeviceOrientationFreeCamera;
  14822. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  14823. /***/ }),
  14824. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  14825. /*!********************************************************!*\
  14826. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  14827. \********************************************************/
  14828. /*! exports provided: VRDeviceOrientationGamepadCamera */
  14829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14830. "use strict";
  14831. __webpack_require__.r(__webpack_exports__);
  14832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  14833. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14834. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14835. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14836. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14837. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14838. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  14839. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  14840. });
  14841. /**
  14842. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  14843. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  14844. */
  14845. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  14846. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  14847. /**
  14848. * Creates a new VRDeviceOrientationGamepadCamera
  14849. * @param name defines camera name
  14850. * @param position defines the start position of the camera
  14851. * @param scene defines the scene the camera belongs to
  14852. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  14853. * @param vrCameraMetrics defines the vr metrics associated to the camera
  14854. */
  14855. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  14856. if (compensateDistortion === void 0) { compensateDistortion = true; }
  14857. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  14858. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  14859. _this.inputs.addGamepad();
  14860. return _this;
  14861. }
  14862. /**
  14863. * Gets camera class name
  14864. * @returns VRDeviceOrientationGamepadCamera
  14865. */
  14866. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  14867. return "VRDeviceOrientationGamepadCamera";
  14868. };
  14869. return VRDeviceOrientationGamepadCamera;
  14870. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  14871. /***/ }),
  14872. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  14873. /*!******************************************!*\
  14874. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  14875. \******************************************/
  14876. /*! exports provided: VRExperienceHelper */
  14877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14878. "use strict";
  14879. __webpack_require__.r(__webpack_exports__);
  14880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  14881. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14882. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  14883. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14884. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14885. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  14886. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  14887. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14888. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  14889. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14890. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14891. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14892. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  14893. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  14894. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  14895. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  14896. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  14897. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  14898. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  14899. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  14900. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  14901. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  14902. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  14903. var VRExperienceHelperGazer = /** @class */ (function () {
  14904. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  14905. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  14906. this.scene = scene;
  14907. /** @hidden */
  14908. this._pointerDownOnMeshAsked = false;
  14909. /** @hidden */
  14910. this._isActionableMesh = false;
  14911. /** @hidden */
  14912. this._teleportationRequestInitiated = false;
  14913. /** @hidden */
  14914. this._teleportationBackRequestInitiated = false;
  14915. /** @hidden */
  14916. this._rotationRightAsked = false;
  14917. /** @hidden */
  14918. this._rotationLeftAsked = false;
  14919. /** @hidden */
  14920. this._dpadPressed = true;
  14921. /** @hidden */
  14922. this._activePointer = false;
  14923. this._id = VRExperienceHelperGazer._idCounter++;
  14924. // Gaze tracker
  14925. if (!gazeTrackerToClone) {
  14926. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  14927. this._gazeTracker.bakeCurrentTransformIntoVertices();
  14928. this._gazeTracker.isPickable = false;
  14929. this._gazeTracker.isVisible = false;
  14930. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  14931. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  14932. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  14933. targetMat.backFaceCulling = false;
  14934. this._gazeTracker.material = targetMat;
  14935. }
  14936. else {
  14937. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  14938. }
  14939. }
  14940. /** @hidden */
  14941. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  14942. 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));
  14943. };
  14944. /** @hidden */
  14945. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  14946. this._pointerDownOnMeshAsked = true;
  14947. if (this._currentHit) {
  14948. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  14949. }
  14950. };
  14951. /** @hidden */
  14952. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  14953. if (this._currentHit) {
  14954. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  14955. }
  14956. this._pointerDownOnMeshAsked = false;
  14957. };
  14958. /** @hidden */
  14959. VRExperienceHelperGazer.prototype._activatePointer = function () {
  14960. this._activePointer = true;
  14961. };
  14962. /** @hidden */
  14963. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  14964. this._activePointer = false;
  14965. };
  14966. /** @hidden */
  14967. VRExperienceHelperGazer.prototype._updatePointerDistance = function () {
  14968. };
  14969. VRExperienceHelperGazer.prototype.dispose = function () {
  14970. this._interactionsEnabled = false;
  14971. this._teleportationEnabled = false;
  14972. if (this._gazeTracker) {
  14973. this._gazeTracker.dispose();
  14974. }
  14975. };
  14976. VRExperienceHelperGazer._idCounter = 0;
  14977. return VRExperienceHelperGazer;
  14978. }());
  14979. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  14980. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  14981. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  14982. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  14983. _this.webVRController = webVRController;
  14984. // Laser pointer
  14985. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  14986. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  14987. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  14988. laserPointerMaterial.alpha = 0.6;
  14989. _this._laserPointer.material = laserPointerMaterial;
  14990. _this._laserPointer.rotation.x = Math.PI / 2;
  14991. _this._laserPointer.position.z = -0.5;
  14992. _this._laserPointer.isVisible = false;
  14993. _this._laserPointer.isPickable = false;
  14994. if (!webVRController.mesh) {
  14995. // Create an empty mesh that is used prior to loading the high quality model
  14996. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  14997. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  14998. preloadPointerPose.rotation.x = -0.7;
  14999. preloadMesh.addChild(preloadPointerPose);
  15000. webVRController.attachToMesh(preloadMesh);
  15001. }
  15002. _this._setLaserPointerParent(webVRController.mesh);
  15003. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15004. _this._setLaserPointerParent(mesh);
  15005. });
  15006. return _this;
  15007. }
  15008. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15009. return this.webVRController.getForwardRay(length);
  15010. };
  15011. /** @hidden */
  15012. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15013. _super.prototype._activatePointer.call(this);
  15014. this._laserPointer.isVisible = true;
  15015. };
  15016. /** @hidden */
  15017. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15018. _super.prototype._deactivatePointer.call(this);
  15019. this._laserPointer.isVisible = false;
  15020. };
  15021. /** @hidden */
  15022. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15023. this._laserPointer.material.emissiveColor = color;
  15024. };
  15025. /** @hidden */
  15026. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15027. var makeNotPick = function (root) {
  15028. root.isPickable = false;
  15029. root.getChildMeshes().forEach(function (c) {
  15030. makeNotPick(c);
  15031. });
  15032. };
  15033. makeNotPick(mesh);
  15034. var meshChildren = mesh.getChildren(undefined, false);
  15035. var laserParent = mesh;
  15036. this.webVRController._pointingPoseNode = null;
  15037. for (var i = 0; i < meshChildren.length; i++) {
  15038. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15039. laserParent = meshChildren[i];
  15040. this.webVRController._pointingPoseNode = laserParent;
  15041. break;
  15042. }
  15043. }
  15044. this._laserPointer.parent = laserParent;
  15045. };
  15046. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15047. if (distance === void 0) { distance = 100; }
  15048. this._laserPointer.scaling.y = distance;
  15049. this._laserPointer.position.z = -distance / 2;
  15050. };
  15051. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15052. _super.prototype.dispose.call(this);
  15053. this._laserPointer.dispose();
  15054. if (this._meshAttachedObserver) {
  15055. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15056. }
  15057. };
  15058. return VRExperienceHelperControllerGazer;
  15059. }(VRExperienceHelperGazer));
  15060. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15061. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15062. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15063. var _this = _super.call(this, scene) || this;
  15064. _this.getCamera = getCamera;
  15065. return _this;
  15066. }
  15067. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15068. var camera = this.getCamera();
  15069. if (camera) {
  15070. return camera.getForwardRay(length);
  15071. }
  15072. else {
  15073. 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());
  15074. }
  15075. };
  15076. return VRExperienceHelperCameraGazer;
  15077. }(VRExperienceHelperGazer));
  15078. /**
  15079. * Helps to quickly add VR support to an existing scene.
  15080. * See http://doc.babylonjs.com/how_to/webvr_helper
  15081. */
  15082. var VRExperienceHelper = /** @class */ (function () {
  15083. /**
  15084. * Instantiates a VRExperienceHelper.
  15085. * Helps to quickly add VR support to an existing scene.
  15086. * @param scene The scene the VRExperienceHelper belongs to.
  15087. * @param webVROptions Options to modify the vr experience helper's behavior.
  15088. */
  15089. function VRExperienceHelper(scene,
  15090. /** Options to modify the vr experience helper's behavior. */
  15091. webVROptions) {
  15092. if (webVROptions === void 0) { webVROptions = {}; }
  15093. var _this = this;
  15094. this.webVROptions = webVROptions;
  15095. // Can the system support WebVR, even if a headset isn't plugged in?
  15096. this._webVRsupported = false;
  15097. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15098. this._webVRready = false;
  15099. // Are we waiting for the requestPresent callback to complete?
  15100. this._webVRrequesting = false;
  15101. // Are we presenting to the headset right now? (this is the vrDevice state)
  15102. this._webVRpresenting = false;
  15103. // Are we presenting in the fullscreen fallback?
  15104. this._fullscreenVRpresenting = false;
  15105. /**
  15106. * Observable raised when entering VR.
  15107. */
  15108. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15109. /**
  15110. * Observable raised when exiting VR.
  15111. */
  15112. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15113. /**
  15114. * Observable raised when controller mesh is loaded.
  15115. */
  15116. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15117. this._useCustomVRButton = false;
  15118. this._teleportationRequested = false;
  15119. this._teleportActive = false;
  15120. this._floorMeshesCollection = [];
  15121. this._rotationAllowed = true;
  15122. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15123. this._isDefaultTeleportationTarget = true;
  15124. this._teleportationFillColor = "#444444";
  15125. this._teleportationBorderColor = "#FFFFFF";
  15126. this._rotationAngle = 0;
  15127. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15128. this._padSensibilityUp = 0.65;
  15129. this._padSensibilityDown = 0.35;
  15130. this._leftController = null;
  15131. this._rightController = null;
  15132. /**
  15133. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15134. */
  15135. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15136. /**
  15137. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15138. */
  15139. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15140. /**
  15141. * Observable raised before camera teleportation
  15142. */
  15143. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15144. /**
  15145. * Observable raised after camera teleportation
  15146. */
  15147. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15148. /**
  15149. * Observable raised when current selected mesh gets unselected
  15150. */
  15151. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15152. /**
  15153. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15154. */
  15155. this.teleportationEnabled = true;
  15156. this._teleportationInitialized = false;
  15157. this._interactionsEnabled = false;
  15158. this._interactionsRequested = false;
  15159. this._displayGaze = true;
  15160. this._displayLaserPointer = true;
  15161. /**
  15162. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15163. */
  15164. this.updateGazeTrackerScale = true;
  15165. /**
  15166. * If the gaze trackers color should be updated when selecting meshes
  15167. */
  15168. this.updateGazeTrackerColor = true;
  15169. this._onResize = function () {
  15170. _this.moveButtonToBottomRight();
  15171. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15172. _this.exitVR();
  15173. }
  15174. };
  15175. this._onFullscreenChange = function () {
  15176. if (document.fullscreen !== undefined) {
  15177. _this._fullscreenVRpresenting = document.fullscreen;
  15178. }
  15179. else if (document.mozFullScreen !== undefined) {
  15180. _this._fullscreenVRpresenting = document.mozFullScreen;
  15181. }
  15182. else if (document.webkitIsFullScreen !== undefined) {
  15183. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15184. }
  15185. else if (document.msIsFullScreen !== undefined) {
  15186. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15187. }
  15188. else if (document.msFullscreenElement !== undefined) {
  15189. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15190. }
  15191. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15192. _this.exitVR();
  15193. if (!_this._useCustomVRButton) {
  15194. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15195. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15196. }
  15197. }
  15198. };
  15199. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15200. this.beforeRender = function () {
  15201. if (_this._leftController && _this._leftController._activePointer) {
  15202. _this._castRayAndSelectObject(_this._leftController);
  15203. }
  15204. if (_this._rightController && _this._rightController._activePointer) {
  15205. _this._castRayAndSelectObject(_this._rightController);
  15206. }
  15207. if (_this._noControllerIsActive) {
  15208. _this._castRayAndSelectObject(_this._cameraGazer);
  15209. }
  15210. else {
  15211. _this._cameraGazer._gazeTracker.isVisible = false;
  15212. }
  15213. };
  15214. this._onNewGamepadConnected = function (gamepad) {
  15215. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15216. if (gamepad.leftStick) {
  15217. gamepad.onleftstickchanged(function (stickValues) {
  15218. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15219. // Listening to classic/xbox gamepad only if no VR controller is active
  15220. if ((!_this._leftController && !_this._rightController) ||
  15221. ((_this._leftController && !_this._leftController._activePointer) &&
  15222. (_this._rightController && !_this._rightController._activePointer))) {
  15223. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15224. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15225. }
  15226. }
  15227. });
  15228. }
  15229. if (gamepad.rightStick) {
  15230. gamepad.onrightstickchanged(function (stickValues) {
  15231. if (_this._teleportationInitialized) {
  15232. _this._checkRotate(stickValues, _this._cameraGazer);
  15233. }
  15234. });
  15235. }
  15236. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15237. gamepad.onbuttondown(function (buttonPressed) {
  15238. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15239. _this._cameraGazer._selectionPointerDown();
  15240. }
  15241. });
  15242. gamepad.onbuttonup(function (buttonPressed) {
  15243. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15244. _this._cameraGazer._selectionPointerUp();
  15245. }
  15246. });
  15247. }
  15248. }
  15249. else {
  15250. var webVRController = gamepad;
  15251. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15252. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15253. _this._rightController = controller;
  15254. }
  15255. else {
  15256. _this._leftController = controller;
  15257. }
  15258. _this._tryEnableInteractionOnController(controller);
  15259. }
  15260. };
  15261. // 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
  15262. this._tryEnableInteractionOnController = function (controller) {
  15263. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15264. _this._enableInteractionOnController(controller);
  15265. }
  15266. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15267. _this._enableTeleportationOnController(controller);
  15268. }
  15269. };
  15270. this._onNewGamepadDisconnected = function (gamepad) {
  15271. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15272. if (gamepad.hand === "left" && _this._leftController != null) {
  15273. _this._leftController.dispose();
  15274. _this._leftController = null;
  15275. }
  15276. if (gamepad.hand === "right" && _this._rightController != null) {
  15277. _this._rightController.dispose();
  15278. _this._rightController = null;
  15279. }
  15280. }
  15281. };
  15282. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15283. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15284. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15285. this._scene = scene;
  15286. this._canvas = scene.getEngine().getRenderingCanvas();
  15287. // Parse options
  15288. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15289. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15290. }
  15291. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15292. webVROptions.createDeviceOrientationCamera = true;
  15293. }
  15294. if (webVROptions.laserToggle === undefined) {
  15295. webVROptions.laserToggle = true;
  15296. }
  15297. if (webVROptions.defaultHeight === undefined) {
  15298. webVROptions.defaultHeight = 1.7;
  15299. }
  15300. if (webVROptions.useCustomVRButton) {
  15301. this._useCustomVRButton = true;
  15302. if (webVROptions.customVRButton) {
  15303. this._btnVR = webVROptions.customVRButton;
  15304. }
  15305. }
  15306. if (webVROptions.rayLength) {
  15307. this._rayLength = webVROptions.rayLength;
  15308. }
  15309. this._defaultHeight = webVROptions.defaultHeight;
  15310. if (webVROptions.positionScale) {
  15311. this._rayLength *= webVROptions.positionScale;
  15312. this._defaultHeight *= webVROptions.positionScale;
  15313. }
  15314. this._hasEnteredVR = false;
  15315. // Set position
  15316. if (this._scene.activeCamera) {
  15317. this._position = this._scene.activeCamera.position.clone();
  15318. }
  15319. else {
  15320. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  15321. }
  15322. // Set non-vr camera
  15323. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  15324. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  15325. // Copy data from existing camera
  15326. if (this._scene.activeCamera) {
  15327. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  15328. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  15329. // Set rotation from previous camera
  15330. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  15331. var targetCamera = this._scene.activeCamera;
  15332. if (targetCamera.rotationQuaternion) {
  15333. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  15334. }
  15335. else {
  15336. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  15337. }
  15338. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  15339. }
  15340. }
  15341. this._scene.activeCamera = this._deviceOrientationCamera;
  15342. if (this._canvas) {
  15343. this._scene.activeCamera.attachControl(this._canvas);
  15344. }
  15345. }
  15346. else {
  15347. this._existingCamera = this._scene.activeCamera;
  15348. }
  15349. // Create VR cameras
  15350. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15351. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene);
  15352. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  15353. }
  15354. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  15355. this._webVRCamera.useStandingMatrix();
  15356. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  15357. // Create default button
  15358. if (!this._useCustomVRButton) {
  15359. this._btnVR = document.createElement("BUTTON");
  15360. this._btnVR.className = "babylonVRicon";
  15361. this._btnVR.id = "babylonVRiconbtn";
  15362. this._btnVR.title = "Click to switch to VR";
  15363. 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) }";
  15364. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  15365. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  15366. // css += ".babylonVRicon.vrdisplaysupported { }";
  15367. // css += ".babylonVRicon.vrdisplayready { }";
  15368. // css += ".babylonVRicon.vrdisplayrequesting { }";
  15369. var style = document.createElement('style');
  15370. style.appendChild(document.createTextNode(css));
  15371. document.getElementsByTagName('head')[0].appendChild(style);
  15372. this.moveButtonToBottomRight();
  15373. }
  15374. // VR button click event
  15375. if (this._btnVR) {
  15376. this._btnVR.addEventListener("click", function () {
  15377. if (!_this.isInVRMode) {
  15378. _this.enterVR();
  15379. }
  15380. else {
  15381. _this.exitVR();
  15382. }
  15383. });
  15384. }
  15385. // Window events
  15386. window.addEventListener("resize", this._onResize);
  15387. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  15388. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  15389. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  15390. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  15391. document.onmsfullscreenchange = this._onFullscreenChange;
  15392. // Display vr button when headset is connected
  15393. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15394. this.displayVRButton();
  15395. }
  15396. else {
  15397. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  15398. if (e.vrDisplay) {
  15399. _this.displayVRButton();
  15400. }
  15401. });
  15402. }
  15403. // Exiting VR mode using 'ESC' key on desktop
  15404. this._onKeyDown = function (event) {
  15405. if (event.keyCode === 27 && _this.isInVRMode) {
  15406. _this.exitVR();
  15407. }
  15408. };
  15409. document.addEventListener("keydown", this._onKeyDown);
  15410. // Exiting VR mode double tapping the touch screen
  15411. this._scene.onPrePointerObservable.add(function () {
  15412. if (_this.isInVRMode) {
  15413. _this.exitVR();
  15414. if (_this._fullscreenVRpresenting) {
  15415. _this._scene.getEngine().switchFullscreen(true);
  15416. }
  15417. }
  15418. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  15419. // Listen for WebVR display changes
  15420. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  15421. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  15422. this._onVRRequestPresentStart = function () {
  15423. _this._webVRrequesting = true;
  15424. _this.updateButtonVisibility();
  15425. };
  15426. this._onVRRequestPresentComplete = function () {
  15427. _this._webVRrequesting = false;
  15428. _this.updateButtonVisibility();
  15429. };
  15430. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  15431. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  15432. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  15433. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  15434. scene.onDisposeObservable.add(function () {
  15435. _this.dispose();
  15436. });
  15437. // Gamepad connection events
  15438. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  15439. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  15440. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  15441. this.updateButtonVisibility();
  15442. //create easing functions
  15443. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  15444. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  15445. if (this.webVROptions.floorMeshes) {
  15446. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  15447. }
  15448. }
  15449. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  15450. /** Return this.onEnteringVRObservable
  15451. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  15452. */
  15453. get: function () {
  15454. return this.onEnteringVRObservable;
  15455. },
  15456. enumerable: true,
  15457. configurable: true
  15458. });
  15459. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  15460. /** Return this.onExitingVRObservable
  15461. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  15462. */
  15463. get: function () {
  15464. return this.onExitingVRObservable;
  15465. },
  15466. enumerable: true,
  15467. configurable: true
  15468. });
  15469. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  15470. /** Return this.onControllerMeshLoadedObservable
  15471. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  15472. */
  15473. get: function () {
  15474. return this.onControllerMeshLoadedObservable;
  15475. },
  15476. enumerable: true,
  15477. configurable: true
  15478. });
  15479. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  15480. /**
  15481. * The mesh used to display where the user is going to teleport.
  15482. */
  15483. get: function () {
  15484. return this._teleportationTarget;
  15485. },
  15486. /**
  15487. * Sets the mesh to be used to display where the user is going to teleport.
  15488. */
  15489. set: function (value) {
  15490. if (value) {
  15491. value.name = "teleportationTarget";
  15492. this._isDefaultTeleportationTarget = false;
  15493. this._teleportationTarget = value;
  15494. }
  15495. },
  15496. enumerable: true,
  15497. configurable: true
  15498. });
  15499. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  15500. /**
  15501. * 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
  15502. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  15503. * See http://doc.babylonjs.com/resources/baking_transformations
  15504. */
  15505. get: function () {
  15506. return this._cameraGazer._gazeTracker;
  15507. },
  15508. set: function (value) {
  15509. if (value) {
  15510. // Dispose of existing meshes
  15511. if (this._cameraGazer._gazeTracker) {
  15512. this._cameraGazer._gazeTracker.dispose();
  15513. }
  15514. if (this._leftController && this._leftController._gazeTracker) {
  15515. this._leftController._gazeTracker.dispose();
  15516. }
  15517. if (this._rightController && this._rightController._gazeTracker) {
  15518. this._rightController._gazeTracker.dispose();
  15519. }
  15520. // Set and create gaze trackers on head and controllers
  15521. this._cameraGazer._gazeTracker = value;
  15522. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  15523. this._cameraGazer._gazeTracker.isPickable = false;
  15524. this._cameraGazer._gazeTracker.isVisible = false;
  15525. this._cameraGazer._gazeTracker.name = "gazeTracker";
  15526. if (this._leftController) {
  15527. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15528. }
  15529. if (this._rightController) {
  15530. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15531. }
  15532. }
  15533. },
  15534. enumerable: true,
  15535. configurable: true
  15536. });
  15537. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  15538. /**
  15539. * The gaze tracking mesh corresponding to the left controller
  15540. */
  15541. get: function () {
  15542. if (this._leftController) {
  15543. return this._leftController._gazeTracker;
  15544. }
  15545. return null;
  15546. },
  15547. enumerable: true,
  15548. configurable: true
  15549. });
  15550. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  15551. /**
  15552. * The gaze tracking mesh corresponding to the right controller
  15553. */
  15554. get: function () {
  15555. if (this._rightController) {
  15556. return this._rightController._gazeTracker;
  15557. }
  15558. return null;
  15559. },
  15560. enumerable: true,
  15561. configurable: true
  15562. });
  15563. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  15564. /**
  15565. * If the ray of the gaze should be displayed.
  15566. */
  15567. get: function () {
  15568. return this._displayGaze;
  15569. },
  15570. /**
  15571. * Sets if the ray of the gaze should be displayed.
  15572. */
  15573. set: function (value) {
  15574. this._displayGaze = value;
  15575. if (!value) {
  15576. this._cameraGazer._gazeTracker.isVisible = false;
  15577. if (this._leftController) {
  15578. this._leftController._gazeTracker.isVisible = false;
  15579. }
  15580. if (this._rightController) {
  15581. this._rightController._gazeTracker.isVisible = false;
  15582. }
  15583. }
  15584. },
  15585. enumerable: true,
  15586. configurable: true
  15587. });
  15588. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  15589. /**
  15590. * If the ray of the LaserPointer should be displayed.
  15591. */
  15592. get: function () {
  15593. return this._displayLaserPointer;
  15594. },
  15595. /**
  15596. * Sets if the ray of the LaserPointer should be displayed.
  15597. */
  15598. set: function (value) {
  15599. this._displayLaserPointer = value;
  15600. if (!value) {
  15601. if (this._rightController) {
  15602. this._rightController._deactivatePointer();
  15603. this._rightController._gazeTracker.isVisible = false;
  15604. }
  15605. if (this._leftController) {
  15606. this._leftController._deactivatePointer();
  15607. this._leftController._gazeTracker.isVisible = false;
  15608. }
  15609. }
  15610. else {
  15611. if (this._rightController) {
  15612. this._rightController._activatePointer();
  15613. }
  15614. if (this._leftController) {
  15615. this._leftController._activatePointer();
  15616. }
  15617. }
  15618. },
  15619. enumerable: true,
  15620. configurable: true
  15621. });
  15622. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  15623. /**
  15624. * The deviceOrientationCamera used as the camera when not in VR.
  15625. */
  15626. get: function () {
  15627. return this._deviceOrientationCamera;
  15628. },
  15629. enumerable: true,
  15630. configurable: true
  15631. });
  15632. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  15633. /**
  15634. * Based on the current WebVR support, returns the current VR camera used.
  15635. */
  15636. get: function () {
  15637. if (this._webVRready) {
  15638. return this._webVRCamera;
  15639. }
  15640. else {
  15641. return this._scene.activeCamera;
  15642. }
  15643. },
  15644. enumerable: true,
  15645. configurable: true
  15646. });
  15647. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  15648. /**
  15649. * The webVRCamera which is used when in VR.
  15650. */
  15651. get: function () {
  15652. return this._webVRCamera;
  15653. },
  15654. enumerable: true,
  15655. configurable: true
  15656. });
  15657. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  15658. /**
  15659. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  15660. */
  15661. get: function () {
  15662. return this._vrDeviceOrientationCamera;
  15663. },
  15664. enumerable: true,
  15665. configurable: true
  15666. });
  15667. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  15668. get: function () {
  15669. var result = this._cameraGazer._teleportationRequestInitiated
  15670. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  15671. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  15672. return result;
  15673. },
  15674. enumerable: true,
  15675. configurable: true
  15676. });
  15677. // Raised when one of the controller has loaded successfully its associated default mesh
  15678. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  15679. if (this._leftController && this._leftController.webVRController == webVRController) {
  15680. if (webVRController.mesh) {
  15681. this._leftController._setLaserPointerParent(webVRController.mesh);
  15682. }
  15683. }
  15684. if (this._rightController && this._rightController.webVRController == webVRController) {
  15685. if (webVRController.mesh) {
  15686. this._rightController._setLaserPointerParent(webVRController.mesh);
  15687. }
  15688. }
  15689. try {
  15690. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  15691. }
  15692. catch (err) {
  15693. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  15694. }
  15695. };
  15696. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  15697. /**
  15698. * Gets a value indicating if we are currently in VR mode.
  15699. */
  15700. get: function () {
  15701. return this._webVRpresenting || this._fullscreenVRpresenting;
  15702. },
  15703. enumerable: true,
  15704. configurable: true
  15705. });
  15706. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  15707. var vrDisplay = this._scene.getEngine().getVRDevice();
  15708. if (vrDisplay) {
  15709. var wasPresenting = this._webVRpresenting;
  15710. this._webVRpresenting = vrDisplay.isPresenting;
  15711. if (wasPresenting && !this._webVRpresenting) {
  15712. this.exitVR();
  15713. }
  15714. }
  15715. else {
  15716. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  15717. }
  15718. this.updateButtonVisibility();
  15719. };
  15720. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  15721. this._webVRsupported = eventArgs.vrSupported;
  15722. this._webVRready = !!eventArgs.vrDisplay;
  15723. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  15724. this.updateButtonVisibility();
  15725. };
  15726. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  15727. if (this._canvas && !this._useCustomVRButton) {
  15728. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  15729. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  15730. }
  15731. };
  15732. VRExperienceHelper.prototype.displayVRButton = function () {
  15733. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  15734. document.body.appendChild(this._btnVR);
  15735. this._btnVRDisplayed = true;
  15736. }
  15737. };
  15738. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  15739. if (!this._btnVR || this._useCustomVRButton) {
  15740. return;
  15741. }
  15742. this._btnVR.className = "babylonVRicon";
  15743. if (this.isInVRMode) {
  15744. this._btnVR.className += " vrdisplaypresenting";
  15745. }
  15746. else {
  15747. if (this._webVRready) {
  15748. this._btnVR.className += " vrdisplayready";
  15749. }
  15750. if (this._webVRsupported) {
  15751. this._btnVR.className += " vrdisplaysupported";
  15752. }
  15753. if (this._webVRrequesting) {
  15754. this._btnVR.className += " vrdisplayrequesting";
  15755. }
  15756. }
  15757. };
  15758. /**
  15759. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  15760. * Otherwise, will use the fullscreen API.
  15761. */
  15762. VRExperienceHelper.prototype.enterVR = function () {
  15763. if (this.onEnteringVRObservable) {
  15764. try {
  15765. this.onEnteringVRObservable.notifyObservers(this);
  15766. }
  15767. catch (err) {
  15768. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  15769. }
  15770. }
  15771. if (this._scene.activeCamera) {
  15772. this._position = this._scene.activeCamera.position.clone();
  15773. if (this.vrDeviceOrientationCamera) {
  15774. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  15775. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  15776. }
  15777. if (this.webVRCamera) {
  15778. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  15779. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  15780. var delta = desiredYRotation - currentYRotation;
  15781. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  15782. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  15783. }
  15784. // make sure that we return to the last active camera
  15785. this._existingCamera = this._scene.activeCamera;
  15786. // Remove and cache angular sensability to avoid camera rotation when in VR
  15787. if (this._existingCamera.angularSensibilityX) {
  15788. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  15789. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  15790. }
  15791. if (this._existingCamera.angularSensibilityY) {
  15792. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  15793. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  15794. }
  15795. if (this._existingCamera.angularSensibility) {
  15796. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  15797. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  15798. }
  15799. }
  15800. if (this._webVRrequesting) {
  15801. return;
  15802. }
  15803. // If WebVR is supported and a headset is connected
  15804. if (this._webVRready) {
  15805. if (!this._webVRpresenting) {
  15806. this._webVRCamera.position = this._position;
  15807. this._scene.activeCamera = this._webVRCamera;
  15808. }
  15809. }
  15810. else if (this._vrDeviceOrientationCamera) {
  15811. this._vrDeviceOrientationCamera.position = this._position;
  15812. if (this._scene.activeCamera) {
  15813. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  15814. }
  15815. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  15816. this._scene.getEngine().switchFullscreen(true);
  15817. this.updateButtonVisibility();
  15818. }
  15819. if (this._scene.activeCamera && this._canvas) {
  15820. this._scene.activeCamera.attachControl(this._canvas);
  15821. }
  15822. if (this._interactionsEnabled) {
  15823. this._scene.registerBeforeRender(this.beforeRender);
  15824. }
  15825. if (this._displayLaserPointer) {
  15826. [this._leftController, this._rightController].forEach(function (controller) {
  15827. if (controller) {
  15828. controller._activatePointer();
  15829. }
  15830. });
  15831. }
  15832. this._hasEnteredVR = true;
  15833. };
  15834. /**
  15835. * Attempt to exit VR, or fullscreen.
  15836. */
  15837. VRExperienceHelper.prototype.exitVR = function () {
  15838. if (this._hasEnteredVR) {
  15839. if (this.onExitingVRObservable) {
  15840. try {
  15841. this.onExitingVRObservable.notifyObservers(this);
  15842. }
  15843. catch (err) {
  15844. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  15845. }
  15846. }
  15847. if (this._webVRpresenting) {
  15848. this._scene.getEngine().disableVR();
  15849. }
  15850. if (this._scene.activeCamera) {
  15851. this._position = this._scene.activeCamera.position.clone();
  15852. }
  15853. if (this.vrDeviceOrientationCamera) {
  15854. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  15855. }
  15856. if (this._deviceOrientationCamera) {
  15857. this._deviceOrientationCamera.position = this._position;
  15858. this._scene.activeCamera = this._deviceOrientationCamera;
  15859. if (this._canvas) {
  15860. this._scene.activeCamera.attachControl(this._canvas);
  15861. }
  15862. // Restore angular sensibility
  15863. if (this._cachedAngularSensibility.angularSensibilityX) {
  15864. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  15865. this._cachedAngularSensibility.angularSensibilityX = null;
  15866. }
  15867. if (this._cachedAngularSensibility.angularSensibilityY) {
  15868. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  15869. this._cachedAngularSensibility.angularSensibilityY = null;
  15870. }
  15871. if (this._cachedAngularSensibility.angularSensibility) {
  15872. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  15873. this._cachedAngularSensibility.angularSensibility = null;
  15874. }
  15875. }
  15876. else if (this._existingCamera) {
  15877. this._existingCamera.position = this._position;
  15878. this._scene.activeCamera = this._existingCamera;
  15879. // Restore angular sensibility
  15880. if (this._cachedAngularSensibility.angularSensibilityX) {
  15881. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  15882. this._cachedAngularSensibility.angularSensibilityX = null;
  15883. }
  15884. if (this._cachedAngularSensibility.angularSensibilityY) {
  15885. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  15886. this._cachedAngularSensibility.angularSensibilityY = null;
  15887. }
  15888. if (this._cachedAngularSensibility.angularSensibility) {
  15889. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  15890. this._cachedAngularSensibility.angularSensibility = null;
  15891. }
  15892. }
  15893. this.updateButtonVisibility();
  15894. if (this._interactionsEnabled) {
  15895. this._scene.unregisterBeforeRender(this.beforeRender);
  15896. this._cameraGazer._gazeTracker.isVisible = false;
  15897. if (this._leftController) {
  15898. this._leftController._gazeTracker.isVisible = false;
  15899. }
  15900. if (this._rightController) {
  15901. this._rightController._gazeTracker.isVisible = false;
  15902. }
  15903. }
  15904. // resize to update width and height when exiting vr exits fullscreen
  15905. this._scene.getEngine().resize();
  15906. [this._leftController, this._rightController].forEach(function (controller) {
  15907. if (controller) {
  15908. controller._deactivatePointer();
  15909. }
  15910. });
  15911. this._hasEnteredVR = false;
  15912. }
  15913. };
  15914. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  15915. /**
  15916. * The position of the vr experience helper.
  15917. */
  15918. get: function () {
  15919. return this._position;
  15920. },
  15921. /**
  15922. * Sets the position of the vr experience helper.
  15923. */
  15924. set: function (value) {
  15925. this._position = value;
  15926. if (this._scene.activeCamera) {
  15927. this._scene.activeCamera.position = value;
  15928. }
  15929. },
  15930. enumerable: true,
  15931. configurable: true
  15932. });
  15933. /**
  15934. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  15935. */
  15936. VRExperienceHelper.prototype.enableInteractions = function () {
  15937. var _this = this;
  15938. if (!this._interactionsEnabled) {
  15939. this._interactionsRequested = true;
  15940. if (this._leftController) {
  15941. this._enableInteractionOnController(this._leftController);
  15942. }
  15943. if (this._rightController) {
  15944. this._enableInteractionOnController(this._rightController);
  15945. }
  15946. this.raySelectionPredicate = function (mesh) {
  15947. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  15948. };
  15949. this.meshSelectionPredicate = function () {
  15950. return true;
  15951. };
  15952. this._raySelectionPredicate = function (mesh) {
  15953. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  15954. && mesh.name.indexOf("teleportationTarget") === -1
  15955. && mesh.name.indexOf("torusTeleportation") === -1)) {
  15956. return _this.raySelectionPredicate(mesh);
  15957. }
  15958. return false;
  15959. };
  15960. this._interactionsEnabled = true;
  15961. }
  15962. };
  15963. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  15964. get: function () {
  15965. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  15966. },
  15967. enumerable: true,
  15968. configurable: true
  15969. });
  15970. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  15971. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  15972. if (this._floorMeshesCollection[i].id === mesh.id) {
  15973. return true;
  15974. }
  15975. }
  15976. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  15977. return true;
  15978. }
  15979. return false;
  15980. };
  15981. /**
  15982. * Adds a floor mesh to be used for teleportation.
  15983. * @param floorMesh the mesh to be used for teleportation.
  15984. */
  15985. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  15986. if (!this._floorMeshesCollection) {
  15987. return;
  15988. }
  15989. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  15990. return;
  15991. }
  15992. this._floorMeshesCollection.push(floorMesh);
  15993. };
  15994. /**
  15995. * Removes a floor mesh from being used for teleportation.
  15996. * @param floorMesh the mesh to be removed.
  15997. */
  15998. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  15999. if (!this._floorMeshesCollection) {
  16000. return;
  16001. }
  16002. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16003. if (meshIndex !== -1) {
  16004. this._floorMeshesCollection.splice(meshIndex, 1);
  16005. }
  16006. };
  16007. /**
  16008. * Enables interactions and teleportation using the VR controllers and gaze.
  16009. * @param vrTeleportationOptions options to modify teleportation behavior.
  16010. */
  16011. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16012. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16013. if (!this._teleportationInitialized) {
  16014. this._teleportationRequested = true;
  16015. this.enableInteractions();
  16016. if (vrTeleportationOptions.floorMeshName) {
  16017. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16018. }
  16019. if (vrTeleportationOptions.floorMeshes) {
  16020. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16021. }
  16022. if (this._leftController != null) {
  16023. this._enableTeleportationOnController(this._leftController);
  16024. }
  16025. if (this._rightController != null) {
  16026. this._enableTeleportationOnController(this._rightController);
  16027. }
  16028. // Creates an image processing post process for the vignette not relying
  16029. // on the main scene configuration for image processing to reduce setup and spaces
  16030. // (gamma/linear) conflicts.
  16031. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16032. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16033. imageProcessingConfiguration.vignetteEnabled = true;
  16034. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16035. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16036. this._teleportationInitialized = true;
  16037. if (this._isDefaultTeleportationTarget) {
  16038. this._createTeleportationCircles();
  16039. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16040. }
  16041. }
  16042. };
  16043. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16044. var _this = this;
  16045. var controllerMesh = controller.webVRController.mesh;
  16046. if (controllerMesh) {
  16047. controller._interactionsEnabled = true;
  16048. if (this.isInVRMode && this._displayLaserPointer) {
  16049. controller._activatePointer();
  16050. }
  16051. if (this.webVROptions.laserToggle) {
  16052. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16053. // Enabling / disabling laserPointer
  16054. if (_this._displayLaserPointer && stateObject.value === 1) {
  16055. if (controller._activePointer) {
  16056. controller._deactivatePointer();
  16057. }
  16058. else {
  16059. controller._activatePointer();
  16060. }
  16061. if (_this.displayGaze) {
  16062. controller._gazeTracker.isVisible = controller._activePointer;
  16063. }
  16064. }
  16065. });
  16066. }
  16067. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16068. var gazer = controller;
  16069. if (_this._noControllerIsActive) {
  16070. gazer = _this._cameraGazer;
  16071. }
  16072. if (!gazer._pointerDownOnMeshAsked) {
  16073. if (stateObject.value > _this._padSensibilityUp) {
  16074. gazer._selectionPointerDown();
  16075. }
  16076. }
  16077. else if (stateObject.value < _this._padSensibilityDown) {
  16078. gazer._selectionPointerUp();
  16079. }
  16080. });
  16081. }
  16082. };
  16083. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16084. // Dont teleport if another gaze already requested teleportation
  16085. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16086. return;
  16087. }
  16088. if (!gazer._teleportationRequestInitiated) {
  16089. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16090. gazer._activatePointer();
  16091. gazer._teleportationRequestInitiated = true;
  16092. }
  16093. }
  16094. else {
  16095. // Listening to the proper controller values changes to confirm teleportation
  16096. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16097. if (this._teleportActive) {
  16098. this.teleportCamera(this._haloCenter);
  16099. }
  16100. gazer._teleportationRequestInitiated = false;
  16101. }
  16102. }
  16103. };
  16104. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16105. // Only rotate when user is not currently selecting a teleportation location
  16106. if (gazer._teleportationRequestInitiated) {
  16107. return;
  16108. }
  16109. if (!gazer._rotationLeftAsked) {
  16110. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16111. gazer._rotationLeftAsked = true;
  16112. if (this._rotationAllowed) {
  16113. this._rotateCamera(false);
  16114. }
  16115. }
  16116. }
  16117. else {
  16118. if (stateObject.x > -this._padSensibilityDown) {
  16119. gazer._rotationLeftAsked = false;
  16120. }
  16121. }
  16122. if (!gazer._rotationRightAsked) {
  16123. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16124. gazer._rotationRightAsked = true;
  16125. if (this._rotationAllowed) {
  16126. this._rotateCamera(true);
  16127. }
  16128. }
  16129. }
  16130. else {
  16131. if (stateObject.x < this._padSensibilityDown) {
  16132. gazer._rotationRightAsked = false;
  16133. }
  16134. }
  16135. };
  16136. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16137. // Only teleport backwards when user is not currently selecting a teleportation location
  16138. if (gazer._teleportationRequestInitiated) {
  16139. return;
  16140. }
  16141. // Teleport backwards
  16142. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16143. if (!gazer._teleportationBackRequestInitiated) {
  16144. if (!this.currentVRCamera) {
  16145. return;
  16146. }
  16147. // Get rotation and position of the current camera
  16148. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16149. var position = this.currentVRCamera.position;
  16150. // If the camera has device position, use that instead
  16151. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16152. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16153. position = this.currentVRCamera.devicePosition;
  16154. }
  16155. // Get matrix with only the y rotation of the device rotation
  16156. rotation.toEulerAnglesToRef(this._workingVector);
  16157. this._workingVector.z = 0;
  16158. this._workingVector.x = 0;
  16159. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16160. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16161. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16162. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16163. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16164. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16165. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16166. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16167. this.teleportCamera(hit.pickedPoint);
  16168. }
  16169. gazer._teleportationBackRequestInitiated = true;
  16170. }
  16171. }
  16172. else {
  16173. gazer._teleportationBackRequestInitiated = false;
  16174. }
  16175. };
  16176. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16177. var _this = this;
  16178. var controllerMesh = controller.webVRController.mesh;
  16179. if (controllerMesh) {
  16180. if (!controller._interactionsEnabled) {
  16181. this._enableInteractionOnController(controller);
  16182. }
  16183. controller._interactionsEnabled = true;
  16184. controller._teleportationEnabled = true;
  16185. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16186. controller._dpadPressed = false;
  16187. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16188. controller._dpadPressed = stateObject.pressed;
  16189. if (!controller._dpadPressed) {
  16190. controller._rotationLeftAsked = false;
  16191. controller._rotationRightAsked = false;
  16192. controller._teleportationBackRequestInitiated = false;
  16193. }
  16194. });
  16195. }
  16196. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16197. if (_this.teleportationEnabled) {
  16198. _this._checkTeleportBackwards(stateObject, controller);
  16199. _this._checkTeleportWithRay(stateObject, controller);
  16200. }
  16201. _this._checkRotate(stateObject, controller);
  16202. });
  16203. }
  16204. };
  16205. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16206. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16207. this._teleportationTarget.isPickable = false;
  16208. var length = 512;
  16209. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16210. dynamicTexture.hasAlpha = true;
  16211. var context = dynamicTexture.getContext();
  16212. var centerX = length / 2;
  16213. var centerY = length / 2;
  16214. var radius = 200;
  16215. context.beginPath();
  16216. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16217. context.fillStyle = this._teleportationFillColor;
  16218. context.fill();
  16219. context.lineWidth = 10;
  16220. context.strokeStyle = this._teleportationBorderColor;
  16221. context.stroke();
  16222. context.closePath();
  16223. dynamicTexture.update();
  16224. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16225. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16226. this._teleportationTarget.material = teleportationCircleMaterial;
  16227. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16228. torus.isPickable = false;
  16229. torus.parent = this._teleportationTarget;
  16230. 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);
  16231. var keys = [];
  16232. keys.push({
  16233. frame: 0,
  16234. value: 0
  16235. });
  16236. keys.push({
  16237. frame: 30,
  16238. value: 0.4
  16239. });
  16240. keys.push({
  16241. frame: 60,
  16242. value: 0
  16243. });
  16244. animationInnerCircle.setKeys(keys);
  16245. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16246. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16247. animationInnerCircle.setEasingFunction(easingFunction);
  16248. torus.animations = [];
  16249. torus.animations.push(animationInnerCircle);
  16250. this._scene.beginAnimation(torus, 0, 60, true);
  16251. this._hideTeleportationTarget();
  16252. };
  16253. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16254. this._teleportActive = true;
  16255. if (this._teleportationInitialized) {
  16256. this._teleportationTarget.isVisible = true;
  16257. if (this._isDefaultTeleportationTarget) {
  16258. this._teleportationTarget.getChildren()[0].isVisible = true;
  16259. }
  16260. }
  16261. };
  16262. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16263. this._teleportActive = false;
  16264. if (this._teleportationInitialized) {
  16265. this._teleportationTarget.isVisible = false;
  16266. if (this._isDefaultTeleportationTarget) {
  16267. this._teleportationTarget.getChildren()[0].isVisible = false;
  16268. }
  16269. }
  16270. };
  16271. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16272. var _this = this;
  16273. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16274. return;
  16275. }
  16276. if (right) {
  16277. this._rotationAngle++;
  16278. }
  16279. else {
  16280. this._rotationAngle--;
  16281. }
  16282. this.currentVRCamera.animations = [];
  16283. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16284. 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);
  16285. var animationRotationKeys = [];
  16286. animationRotationKeys.push({
  16287. frame: 0,
  16288. value: this.currentVRCamera.rotationQuaternion
  16289. });
  16290. animationRotationKeys.push({
  16291. frame: 6,
  16292. value: target
  16293. });
  16294. animationRotation.setKeys(animationRotationKeys);
  16295. animationRotation.setEasingFunction(this._circleEase);
  16296. this.currentVRCamera.animations.push(animationRotation);
  16297. this._postProcessMove.animations = [];
  16298. 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);
  16299. var vignetteWeightKeys = [];
  16300. vignetteWeightKeys.push({
  16301. frame: 0,
  16302. value: 0
  16303. });
  16304. vignetteWeightKeys.push({
  16305. frame: 3,
  16306. value: 4
  16307. });
  16308. vignetteWeightKeys.push({
  16309. frame: 6,
  16310. value: 0
  16311. });
  16312. animationPP.setKeys(vignetteWeightKeys);
  16313. animationPP.setEasingFunction(this._circleEase);
  16314. this._postProcessMove.animations.push(animationPP);
  16315. 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);
  16316. var vignetteStretchKeys = [];
  16317. vignetteStretchKeys.push({
  16318. frame: 0,
  16319. value: 0
  16320. });
  16321. vignetteStretchKeys.push({
  16322. frame: 3,
  16323. value: 10
  16324. });
  16325. vignetteStretchKeys.push({
  16326. frame: 6,
  16327. value: 0
  16328. });
  16329. animationPP2.setKeys(vignetteStretchKeys);
  16330. animationPP2.setEasingFunction(this._circleEase);
  16331. this._postProcessMove.animations.push(animationPP2);
  16332. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16333. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16334. this._postProcessMove.samples = 4;
  16335. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16336. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  16337. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16338. });
  16339. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  16340. };
  16341. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  16342. if (hit.pickedPoint) {
  16343. if (gazer._teleportationRequestInitiated) {
  16344. this._displayTeleportationTarget();
  16345. this._haloCenter.copyFrom(hit.pickedPoint);
  16346. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  16347. }
  16348. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  16349. if (pickNormal) {
  16350. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16351. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16352. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  16353. }
  16354. this._teleportationTarget.position.y += 0.1;
  16355. }
  16356. };
  16357. /**
  16358. * Teleports the users feet to the desired location
  16359. * @param location The location where the user's feet should be placed
  16360. */
  16361. VRExperienceHelper.prototype.teleportCamera = function (location) {
  16362. var _this = this;
  16363. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16364. return;
  16365. }
  16366. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  16367. // offset of the headset from the anchor.
  16368. if (this.webVRCamera.leftCamera) {
  16369. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  16370. this._workingVector.subtractInPlace(this.webVRCamera.position);
  16371. location.subtractToRef(this._workingVector, this._workingVector);
  16372. }
  16373. else {
  16374. this._workingVector.copyFrom(location);
  16375. }
  16376. // Add height to account for user's height offset
  16377. if (this.isInVRMode) {
  16378. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  16379. }
  16380. else {
  16381. this._workingVector.y += this._defaultHeight;
  16382. }
  16383. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  16384. // Create animation from the camera's position to the new location
  16385. this.currentVRCamera.animations = [];
  16386. 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);
  16387. var animationCameraTeleportationKeys = [{
  16388. frame: 0,
  16389. value: this.currentVRCamera.position
  16390. },
  16391. {
  16392. frame: 11,
  16393. value: this._workingVector
  16394. }
  16395. ];
  16396. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  16397. animationCameraTeleportation.setEasingFunction(this._circleEase);
  16398. this.currentVRCamera.animations.push(animationCameraTeleportation);
  16399. this._postProcessMove.animations = [];
  16400. 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);
  16401. var vignetteWeightKeys = [];
  16402. vignetteWeightKeys.push({
  16403. frame: 0,
  16404. value: 0
  16405. });
  16406. vignetteWeightKeys.push({
  16407. frame: 5,
  16408. value: 8
  16409. });
  16410. vignetteWeightKeys.push({
  16411. frame: 11,
  16412. value: 0
  16413. });
  16414. animationPP.setKeys(vignetteWeightKeys);
  16415. this._postProcessMove.animations.push(animationPP);
  16416. 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);
  16417. var vignetteStretchKeys = [];
  16418. vignetteStretchKeys.push({
  16419. frame: 0,
  16420. value: 0
  16421. });
  16422. vignetteStretchKeys.push({
  16423. frame: 5,
  16424. value: 10
  16425. });
  16426. vignetteStretchKeys.push({
  16427. frame: 11,
  16428. value: 0
  16429. });
  16430. animationPP2.setKeys(vignetteStretchKeys);
  16431. this._postProcessMove.animations.push(animationPP2);
  16432. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16433. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16434. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16435. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  16436. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16437. });
  16438. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  16439. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  16440. });
  16441. this._hideTeleportationTarget();
  16442. };
  16443. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  16444. if (normal) {
  16445. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  16446. if (angle < Math.PI / 2) {
  16447. normal.scaleInPlace(-1);
  16448. }
  16449. }
  16450. return normal;
  16451. };
  16452. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  16453. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16454. return;
  16455. }
  16456. var ray = gazer._getForwardRay(this._rayLength);
  16457. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16458. if (hit) {
  16459. // Populate the contrllers mesh that can be used for drag/drop
  16460. if (gazer._laserPointer) {
  16461. hit.originMesh = gazer._laserPointer.parent;
  16462. }
  16463. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  16464. }
  16465. gazer._currentHit = hit;
  16466. // Moving the gazeTracker on the mesh face targetted
  16467. if (hit && hit.pickedPoint) {
  16468. if (this._displayGaze) {
  16469. var multiplier = 1;
  16470. gazer._gazeTracker.isVisible = true;
  16471. if (gazer._isActionableMesh) {
  16472. multiplier = 3;
  16473. }
  16474. if (this.updateGazeTrackerScale) {
  16475. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  16476. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  16477. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  16478. }
  16479. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  16480. // To avoid z-fighting
  16481. var deltaFighting = 0.002;
  16482. if (pickNormal) {
  16483. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16484. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16485. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  16486. }
  16487. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  16488. if (gazer._gazeTracker.position.x < 0) {
  16489. gazer._gazeTracker.position.x += deltaFighting;
  16490. }
  16491. else {
  16492. gazer._gazeTracker.position.x -= deltaFighting;
  16493. }
  16494. if (gazer._gazeTracker.position.y < 0) {
  16495. gazer._gazeTracker.position.y += deltaFighting;
  16496. }
  16497. else {
  16498. gazer._gazeTracker.position.y -= deltaFighting;
  16499. }
  16500. if (gazer._gazeTracker.position.z < 0) {
  16501. gazer._gazeTracker.position.z += deltaFighting;
  16502. }
  16503. else {
  16504. gazer._gazeTracker.position.z -= deltaFighting;
  16505. }
  16506. }
  16507. // Changing the size of the laser pointer based on the distance from the targetted point
  16508. gazer._updatePointerDistance();
  16509. }
  16510. else {
  16511. gazer._updatePointerDistance();
  16512. gazer._gazeTracker.isVisible = false;
  16513. }
  16514. if (hit && hit.pickedMesh) {
  16515. // The object selected is the floor, we're in a teleportation scenario
  16516. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  16517. // Moving the teleportation area to this targetted point
  16518. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  16519. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  16520. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16521. }
  16522. gazer._currentMeshSelected = null;
  16523. if (gazer._teleportationRequestInitiated) {
  16524. this._moveTeleportationSelectorTo(hit, gazer, ray);
  16525. }
  16526. return;
  16527. }
  16528. // If not, we're in a selection scenario
  16529. //this._teleportationAllowed = false;
  16530. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  16531. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  16532. this.onNewMeshPicked.notifyObservers(hit);
  16533. gazer._currentMeshSelected = hit.pickedMesh;
  16534. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  16535. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  16536. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  16537. gazer._isActionableMesh = true;
  16538. }
  16539. else {
  16540. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16541. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16542. gazer._isActionableMesh = false;
  16543. }
  16544. try {
  16545. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  16546. }
  16547. catch (err) {
  16548. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  16549. }
  16550. }
  16551. else {
  16552. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16553. gazer._currentMeshSelected = null;
  16554. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16555. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16556. }
  16557. }
  16558. }
  16559. else {
  16560. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16561. gazer._currentMeshSelected = null;
  16562. //this._teleportationAllowed = false;
  16563. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16564. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16565. }
  16566. };
  16567. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  16568. if (mesh) {
  16569. this.onSelectedMeshUnselected.notifyObservers(mesh);
  16570. }
  16571. };
  16572. /**
  16573. * Sets the color of the laser ray from the vr controllers.
  16574. * @param color new color for the ray.
  16575. */
  16576. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  16577. if (this._leftController) {
  16578. this._leftController._setLaserPointerColor(color);
  16579. }
  16580. if (this._rightController) {
  16581. this._rightController._setLaserPointerColor(color);
  16582. }
  16583. };
  16584. /**
  16585. * Sets the color of the ray from the vr headsets gaze.
  16586. * @param color new color for the ray.
  16587. */
  16588. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  16589. if (!this.updateGazeTrackerColor) {
  16590. return;
  16591. }
  16592. if (!this._cameraGazer._gazeTracker.material) {
  16593. return;
  16594. }
  16595. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  16596. if (this._leftController) {
  16597. this._leftController._gazeTracker.material.emissiveColor = color;
  16598. }
  16599. if (this._rightController) {
  16600. this._rightController._gazeTracker.material.emissiveColor = color;
  16601. }
  16602. };
  16603. /**
  16604. * Exits VR and disposes of the vr experience helper
  16605. */
  16606. VRExperienceHelper.prototype.dispose = function () {
  16607. if (this.isInVRMode) {
  16608. this.exitVR();
  16609. }
  16610. if (this._postProcessMove) {
  16611. this._postProcessMove.dispose();
  16612. }
  16613. if (this._webVRCamera) {
  16614. this._webVRCamera.dispose();
  16615. }
  16616. if (this._vrDeviceOrientationCamera) {
  16617. this._vrDeviceOrientationCamera.dispose();
  16618. }
  16619. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  16620. document.body.removeChild(this._btnVR);
  16621. }
  16622. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  16623. this._deviceOrientationCamera.dispose();
  16624. }
  16625. if (this._cameraGazer) {
  16626. this._cameraGazer.dispose();
  16627. }
  16628. if (this._leftController) {
  16629. this._leftController.dispose();
  16630. }
  16631. if (this._rightController) {
  16632. this._rightController.dispose();
  16633. }
  16634. if (this._teleportationTarget) {
  16635. this._teleportationTarget.dispose();
  16636. }
  16637. this._floorMeshesCollection = [];
  16638. document.removeEventListener("keydown", this._onKeyDown);
  16639. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16640. window.removeEventListener("resize", this._onResize);
  16641. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  16642. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  16643. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  16644. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  16645. document.onmsfullscreenchange = null;
  16646. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  16647. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  16648. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  16649. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16650. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  16651. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  16652. this._scene.unregisterBeforeRender(this.beforeRender);
  16653. };
  16654. /**
  16655. * Gets the name of the VRExperienceHelper class
  16656. * @returns "VRExperienceHelper"
  16657. */
  16658. VRExperienceHelper.prototype.getClassName = function () {
  16659. return "VRExperienceHelper";
  16660. };
  16661. return VRExperienceHelper;
  16662. }());
  16663. /***/ }),
  16664. /***/ "./Cameras/VR/webVRCamera.ts":
  16665. /*!***********************************!*\
  16666. !*** ./Cameras/VR/webVRCamera.ts ***!
  16667. \***********************************/
  16668. /*! exports provided: WebVRFreeCamera */
  16669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16670. "use strict";
  16671. __webpack_require__.r(__webpack_exports__);
  16672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  16673. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16674. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16675. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16676. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16677. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16678. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16679. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16680. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16681. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  16682. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  16683. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16684. });
  16685. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  16686. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16687. });
  16688. /**
  16689. * This represents a WebVR camera.
  16690. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  16691. * @example http://doc.babylonjs.com/how_to/webvr_camera
  16692. */
  16693. var WebVRFreeCamera = /** @class */ (function (_super) {
  16694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  16695. /**
  16696. * Instantiates a WebVRFreeCamera.
  16697. * @param name The name of the WebVRFreeCamera
  16698. * @param position The starting anchor position for the camera
  16699. * @param scene The scene the camera belongs to
  16700. * @param webVROptions a set of customizable options for the webVRCamera
  16701. */
  16702. function WebVRFreeCamera(name, position, scene, webVROptions) {
  16703. if (webVROptions === void 0) { webVROptions = {}; }
  16704. var _this = _super.call(this, name, position, scene) || this;
  16705. _this.webVROptions = webVROptions;
  16706. /**
  16707. * @hidden
  16708. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  16709. */
  16710. _this._vrDevice = null;
  16711. /**
  16712. * The rawPose of the vrDevice.
  16713. */
  16714. _this.rawPose = null;
  16715. _this._specsVersion = "1.1";
  16716. _this._attached = false;
  16717. _this._descendants = [];
  16718. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  16719. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16720. /** @hidden */
  16721. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  16722. _this._standingMatrix = null;
  16723. /**
  16724. * Represents device position in babylon space.
  16725. */
  16726. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16727. /**
  16728. * Represents device rotation in babylon space.
  16729. */
  16730. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  16731. /**
  16732. * The scale of the device to be used when translating from device space to babylon space.
  16733. */
  16734. _this.deviceScaleFactor = 1;
  16735. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16736. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16737. /**
  16738. * References to the webVR controllers for the vrDevice.
  16739. */
  16740. _this.controllers = [];
  16741. /**
  16742. * Emits an event when a controller is attached.
  16743. */
  16744. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16745. /**
  16746. * Emits an event when a controller's mesh has been loaded;
  16747. */
  16748. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16749. /**
  16750. * Emits an event when the HMD's pose has been updated.
  16751. */
  16752. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16753. _this._poseSet = false;
  16754. /**
  16755. * If the rig cameras be used as parent instead of this camera.
  16756. */
  16757. _this.rigParenting = true;
  16758. _this._defaultHeight = undefined;
  16759. _this._htmlElementAttached = null;
  16760. _this._detachIfAttached = function () {
  16761. var vrDisplay = _this.getEngine().getVRDevice();
  16762. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  16763. _this.detachControl(_this._htmlElementAttached);
  16764. }
  16765. };
  16766. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16767. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  16768. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16769. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  16770. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16771. if (webVROptions.defaultHeight) {
  16772. _this._defaultHeight = webVROptions.defaultHeight;
  16773. _this.position.y = _this._defaultHeight;
  16774. }
  16775. _this.minZ = 0.1;
  16776. //legacy support - the compensation boolean was removed.
  16777. if (arguments.length === 5) {
  16778. _this.webVROptions = arguments[4];
  16779. }
  16780. // default webVR options
  16781. if (_this.webVROptions.trackPosition == undefined) {
  16782. _this.webVROptions.trackPosition = true;
  16783. }
  16784. if (_this.webVROptions.controllerMeshes == undefined) {
  16785. _this.webVROptions.controllerMeshes = true;
  16786. }
  16787. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  16788. _this.webVROptions.defaultLightingOnControllers = true;
  16789. }
  16790. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  16791. if (_this.webVROptions && _this.webVROptions.positionScale) {
  16792. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  16793. }
  16794. //enable VR
  16795. var engine = _this.getEngine();
  16796. _this._onVREnabled = function (success) { if (success) {
  16797. _this.initControllers();
  16798. } };
  16799. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  16800. engine.initWebVR().add(function (event) {
  16801. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  16802. return;
  16803. }
  16804. _this._vrDevice = event.vrDisplay;
  16805. //reset the rig parameters.
  16806. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  16807. if (_this._attached) {
  16808. _this.getEngine().enableVR();
  16809. }
  16810. });
  16811. if (typeof (VRFrameData) !== "undefined") {
  16812. _this._frameData = new VRFrameData();
  16813. }
  16814. /**
  16815. * The idea behind the following lines:
  16816. * objects that have the camera as parent should actually have the rig cameras as a parent.
  16817. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  16818. * the second will not show it correctly.
  16819. *
  16820. * To solve this - each object that has the camera as parent will be added to a protected array.
  16821. * When the rig camera renders, it will take this array and set all of those to be its children.
  16822. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  16823. * Amazing!
  16824. */
  16825. scene.onBeforeCameraRenderObservable.add(function (camera) {
  16826. if (camera.parent === _this && _this.rigParenting) {
  16827. _this._descendants = _this.getDescendants(true, function (n) {
  16828. // don't take the cameras or the controllers!
  16829. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  16830. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  16831. return !isController && !isRigCamera;
  16832. });
  16833. _this._descendants.forEach(function (node) {
  16834. node.parent = camera;
  16835. });
  16836. }
  16837. });
  16838. scene.onAfterCameraRenderObservable.add(function (camera) {
  16839. if (camera.parent === _this && _this.rigParenting) {
  16840. _this._descendants.forEach(function (node) {
  16841. node.parent = _this;
  16842. });
  16843. }
  16844. });
  16845. return _this;
  16846. }
  16847. /**
  16848. * Gets the device distance from the ground in meters.
  16849. * @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.
  16850. */
  16851. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  16852. if (this._standingMatrix) {
  16853. // Add standing matrix offset to get real offset from ground in room
  16854. this._standingMatrix.getTranslationToRef(this._workingVector);
  16855. return this._deviceRoomPosition.y + this._workingVector.y;
  16856. }
  16857. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  16858. return this._defaultHeight || 0;
  16859. };
  16860. /**
  16861. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  16862. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  16863. */
  16864. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  16865. var _this = this;
  16866. if (callback === void 0) { callback = function (bool) { }; }
  16867. // Use standing matrix if available
  16868. this.getEngine().initWebVRAsync().then(function (result) {
  16869. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  16870. callback(false);
  16871. }
  16872. else {
  16873. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  16874. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  16875. if (!_this.getScene().useRightHandedSystem) {
  16876. if (_this._standingMatrix) {
  16877. _this._standingMatrix.toggleModelMatrixHandInPlace();
  16878. }
  16879. }
  16880. callback(true);
  16881. }
  16882. });
  16883. };
  16884. /**
  16885. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  16886. * @returns A promise with a boolean set to if the standing matrix is supported.
  16887. */
  16888. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  16889. var _this = this;
  16890. return new Promise(function (res) {
  16891. _this.useStandingMatrix(function (supported) {
  16892. res(supported);
  16893. });
  16894. });
  16895. };
  16896. /**
  16897. * Disposes the camera
  16898. */
  16899. WebVRFreeCamera.prototype.dispose = function () {
  16900. this._detachIfAttached();
  16901. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  16902. if (this._updateCacheWhenTrackingDisabledObserver) {
  16903. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  16904. }
  16905. _super.prototype.dispose.call(this);
  16906. };
  16907. /**
  16908. * Gets a vrController by name.
  16909. * @param name The name of the controller to retreive
  16910. * @returns the controller matching the name specified or null if not found
  16911. */
  16912. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  16913. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  16914. var gp = _a[_i];
  16915. if (gp.hand === name) {
  16916. return gp;
  16917. }
  16918. }
  16919. return null;
  16920. };
  16921. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  16922. /**
  16923. * The controller corrisponding to the users left hand.
  16924. */
  16925. get: function () {
  16926. if (!this._leftController) {
  16927. this._leftController = this.getControllerByName("left");
  16928. }
  16929. return this._leftController;
  16930. },
  16931. enumerable: true,
  16932. configurable: true
  16933. });
  16934. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  16935. /**
  16936. * The controller corrisponding to the users right hand.
  16937. */
  16938. get: function () {
  16939. if (!this._rightController) {
  16940. this._rightController = this.getControllerByName("right");
  16941. }
  16942. return this._rightController;
  16943. },
  16944. enumerable: true,
  16945. configurable: true
  16946. });
  16947. /**
  16948. * Casts a ray forward from the vrCamera's gaze.
  16949. * @param length Length of the ray (default: 100)
  16950. * @returns the ray corrisponding to the gaze
  16951. */
  16952. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  16953. if (length === void 0) { length = 100; }
  16954. if (this.leftCamera) {
  16955. // Use left eye to avoid computation to compute center on every call
  16956. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  16957. }
  16958. else {
  16959. return _super.prototype.getForwardRay.call(this, length);
  16960. }
  16961. };
  16962. /**
  16963. * @hidden
  16964. * Updates the camera based on device's frame data
  16965. */
  16966. WebVRFreeCamera.prototype._checkInputs = function () {
  16967. if (this._vrDevice && this._vrDevice.isPresenting) {
  16968. this._vrDevice.getFrameData(this._frameData);
  16969. this.updateFromDevice(this._frameData.pose);
  16970. }
  16971. _super.prototype._checkInputs.call(this);
  16972. };
  16973. /**
  16974. * Updates the poseControlled values based on the input device pose.
  16975. * @param poseData Pose coming from the device
  16976. */
  16977. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  16978. if (poseData && poseData.orientation) {
  16979. this.rawPose = poseData;
  16980. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  16981. if (this.getScene().useRightHandedSystem) {
  16982. this._deviceRoomRotationQuaternion.z *= -1;
  16983. this._deviceRoomRotationQuaternion.w *= -1;
  16984. }
  16985. if (this.webVROptions.trackPosition && this.rawPose.position) {
  16986. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  16987. if (this.getScene().useRightHandedSystem) {
  16988. this._deviceRoomPosition.z *= -1;
  16989. }
  16990. }
  16991. this._poseSet = true;
  16992. }
  16993. };
  16994. /**
  16995. * WebVR's attach control will start broadcasting frames to the device.
  16996. * Note that in certain browsers (chrome for example) this function must be called
  16997. * within a user-interaction callback. Example:
  16998. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  16999. *
  17000. * @param element html element to attach the vrDevice to
  17001. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17002. */
  17003. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17004. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17005. this._attached = true;
  17006. this._htmlElementAttached = element;
  17007. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17008. if (this._vrDevice) {
  17009. this.getEngine().enableVR();
  17010. }
  17011. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17012. };
  17013. /**
  17014. * Detaches the camera from the html element and disables VR
  17015. *
  17016. * @param element html element to detach from
  17017. */
  17018. WebVRFreeCamera.prototype.detachControl = function (element) {
  17019. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17020. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17021. _super.prototype.detachControl.call(this, element);
  17022. this._attached = false;
  17023. this.getEngine().disableVR();
  17024. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17025. };
  17026. /**
  17027. * @returns the name of this class
  17028. */
  17029. WebVRFreeCamera.prototype.getClassName = function () {
  17030. return "WebVRFreeCamera";
  17031. };
  17032. /**
  17033. * Calls resetPose on the vrDisplay
  17034. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17035. */
  17036. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17037. //uses the vrDisplay's "resetPose()".
  17038. //pitch and roll won't be affected.
  17039. this._vrDevice.resetPose();
  17040. };
  17041. /**
  17042. * @hidden
  17043. * Updates the rig cameras (left and right eye)
  17044. */
  17045. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17046. var camLeft = this._rigCameras[0];
  17047. var camRight = this._rigCameras[1];
  17048. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17049. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17050. camLeft.position.copyFrom(this._deviceRoomPosition);
  17051. camRight.position.copyFrom(this._deviceRoomPosition);
  17052. };
  17053. // Remove translation from 6dof headset if trackposition is set to false
  17054. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17055. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17056. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17057. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17058. if (!isViewMatrix) {
  17059. this._tmpMatrix.invert();
  17060. }
  17061. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17062. }
  17063. };
  17064. /**
  17065. * @hidden
  17066. * Updates the cached values of the camera
  17067. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17068. */
  17069. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17070. var _this = this;
  17071. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17072. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17073. if (!this.updateCacheCalled) {
  17074. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17075. this.updateCacheCalled = true;
  17076. this.update();
  17077. }
  17078. // Set working vector to the device position in room space rotated by the new rotation
  17079. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17080. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17081. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17082. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17083. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17084. // Add translation from anchor position
  17085. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17086. this._workingVector.addInPlace(this.position);
  17087. this._workingVector.subtractInPlace(this._cache.position);
  17088. this._deviceToWorld.setTranslation(this._workingVector);
  17089. // Set an inverted matrix to be used when updating the camera
  17090. this._deviceToWorld.invertToRef(this._worldToDevice);
  17091. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17092. this.controllers.forEach(function (controller) {
  17093. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17094. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17095. controller.update();
  17096. });
  17097. }
  17098. if (!ignoreParentClass) {
  17099. _super.prototype._updateCache.call(this);
  17100. }
  17101. this.updateCacheCalled = false;
  17102. };
  17103. /**
  17104. * @hidden
  17105. * Get current device position in babylon world
  17106. */
  17107. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17108. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17109. };
  17110. /**
  17111. * Updates the current device position and rotation in the babylon world
  17112. */
  17113. WebVRFreeCamera.prototype.update = function () {
  17114. this._computeDevicePosition();
  17115. // Get current device rotation in babylon world
  17116. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17117. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17118. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17119. if (this._poseSet) {
  17120. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17121. }
  17122. _super.prototype.update.call(this);
  17123. };
  17124. /**
  17125. * @hidden
  17126. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17127. * @returns an identity matrix
  17128. */
  17129. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17130. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17131. };
  17132. /**
  17133. * This function is called by the two RIG cameras.
  17134. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17135. */
  17136. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17137. // Update the parent camera prior to using a child camera to avoid desynchronization
  17138. var parentCamera = this._cameraRigParams["parentCamera"];
  17139. parentCamera._updateCache();
  17140. //WebVR 1.1
  17141. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17142. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17143. if (!this.getScene().useRightHandedSystem) {
  17144. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17145. }
  17146. // update the camera rotation matrix
  17147. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17148. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17149. // Computing target and final matrix
  17150. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17151. // should the view matrix be updated with scale and position offset?
  17152. if (parentCamera.deviceScaleFactor !== 1) {
  17153. this._webvrViewMatrix.invert();
  17154. // scale the position, if set
  17155. if (parentCamera.deviceScaleFactor) {
  17156. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17157. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17158. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17159. }
  17160. this._webvrViewMatrix.invert();
  17161. }
  17162. // Remove translation from 6dof headset if trackposition is set to false
  17163. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17164. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17165. // Compute global position
  17166. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17167. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17168. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17169. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17170. this._markSyncedWithParent();
  17171. return this._webvrViewMatrix;
  17172. };
  17173. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17174. var parentCamera = this.parent;
  17175. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17176. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17177. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17178. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17179. //babylon compatible matrix
  17180. if (!this.getScene().useRightHandedSystem) {
  17181. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17182. }
  17183. return this._projectionMatrix;
  17184. };
  17185. /**
  17186. * Initializes the controllers and their meshes
  17187. */
  17188. WebVRFreeCamera.prototype.initControllers = function () {
  17189. var _this = this;
  17190. this.controllers = [];
  17191. var manager = this.getScene().gamepadManager;
  17192. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17193. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17194. var webVrController = gamepad;
  17195. if (webVrController.defaultModel) {
  17196. webVrController.defaultModel.setEnabled(false);
  17197. }
  17198. if (webVrController.hand === "right") {
  17199. _this._rightController = null;
  17200. }
  17201. if (webVrController.hand === "left") {
  17202. _this._leftController = null;
  17203. }
  17204. var controllerIndex = _this.controllers.indexOf(webVrController);
  17205. if (controllerIndex !== -1) {
  17206. _this.controllers.splice(controllerIndex, 1);
  17207. }
  17208. }
  17209. });
  17210. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17211. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17212. var webVrController_1 = gamepad;
  17213. if (!_this.webVROptions.trackPosition) {
  17214. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17215. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17216. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17217. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17218. _this._updateCache();
  17219. });
  17220. }
  17221. }
  17222. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17223. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17224. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17225. if (_this.webVROptions.controllerMeshes) {
  17226. if (webVrController_1.defaultModel) {
  17227. webVrController_1.defaultModel.setEnabled(true);
  17228. }
  17229. else {
  17230. // Load the meshes
  17231. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17232. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17233. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17234. if (_this.webVROptions.defaultLightingOnControllers) {
  17235. if (!_this._lightOnControllers) {
  17236. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17237. }
  17238. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17239. var children = mesh.getChildren();
  17240. if (children && children.length !== 0) {
  17241. children.forEach(function (mesh) {
  17242. light.includedOnlyMeshes.push(mesh);
  17243. activateLightOnSubMeshes_1(mesh, light);
  17244. });
  17245. }
  17246. };
  17247. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17248. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17249. }
  17250. });
  17251. }
  17252. }
  17253. webVrController_1.attachToPoseControlledCamera(_this);
  17254. // since this is async - sanity check. Is the controller already stored?
  17255. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17256. //add to the controllers array
  17257. _this.controllers.push(webVrController_1);
  17258. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17259. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17260. // So we're overriding setting left & right manually to be sure
  17261. var firstViveWandDetected = false;
  17262. for (var i = 0; i < _this.controllers.length; i++) {
  17263. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17264. if (!firstViveWandDetected) {
  17265. firstViveWandDetected = true;
  17266. _this.controllers[i].hand = "left";
  17267. }
  17268. else {
  17269. _this.controllers[i].hand = "right";
  17270. }
  17271. }
  17272. }
  17273. //did we find enough controllers? Great! let the developer know.
  17274. if (_this.controllers.length >= 2) {
  17275. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17276. }
  17277. }
  17278. }
  17279. });
  17280. };
  17281. return WebVRFreeCamera;
  17282. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17283. /***/ }),
  17284. /***/ "./Cameras/XR/index.ts":
  17285. /*!*****************************!*\
  17286. !*** ./Cameras/XR/index.ts ***!
  17287. \*****************************/
  17288. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17290. "use strict";
  17291. __webpack_require__.r(__webpack_exports__);
  17292. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17294. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  17296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  17297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  17298. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  17300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  17301. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  17302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  17303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  17304. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  17305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  17306. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  17308. /***/ }),
  17309. /***/ "./Cameras/XR/webXRCamera.ts":
  17310. /*!***********************************!*\
  17311. !*** ./Cameras/XR/webXRCamera.ts ***!
  17312. \***********************************/
  17313. /*! exports provided: WebXRCamera */
  17314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17315. "use strict";
  17316. __webpack_require__.r(__webpack_exports__);
  17317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  17318. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17319. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17320. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17321. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17322. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  17323. /**
  17324. * WebXR Camera which holds the views for the xrSession
  17325. * @see https://doc.babylonjs.com/how_to/webxr
  17326. */
  17327. var WebXRCamera = /** @class */ (function (_super) {
  17328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  17329. /**
  17330. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  17331. * @param name the name of the camera
  17332. * @param scene the scene to add the camera to
  17333. */
  17334. function WebXRCamera(name, scene) {
  17335. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  17336. // Initial camera configuration
  17337. _this.minZ = 0;
  17338. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17339. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  17340. _this.updateUpVectorFromRotation = true;
  17341. _this._updateNumberOfRigCameras(1);
  17342. return _this;
  17343. }
  17344. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  17345. if (viewCount === void 0) { viewCount = 1; }
  17346. while (this.rigCameras.length < viewCount) {
  17347. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  17348. newCamera.minZ = 0;
  17349. newCamera.parent = this;
  17350. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17351. newCamera.updateUpVectorFromRotation = true;
  17352. this.rigCameras.push(newCamera);
  17353. }
  17354. while (this.rigCameras.length > viewCount) {
  17355. var removedCamera = this.rigCameras.pop();
  17356. if (removedCamera) {
  17357. removedCamera.dispose();
  17358. }
  17359. }
  17360. };
  17361. /** @hidden */
  17362. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  17363. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  17364. // Create initial camera rigs
  17365. this._updateNumberOfRigCameras(2);
  17366. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  17367. this.rigCameras[0].position.x = -pupilDistance / 2;
  17368. this.rigCameras[0].outputRenderTarget = null;
  17369. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  17370. this.rigCameras[1].position.x = pupilDistance / 2;
  17371. this.rigCameras[1].outputRenderTarget = null;
  17372. };
  17373. /**
  17374. * Updates the cameras position from the current pose information of the XR session
  17375. * @param xrSessionManager the session containing pose information
  17376. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  17377. */
  17378. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  17379. var _this = this;
  17380. // Ensure all frame data is available
  17381. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  17382. return false;
  17383. }
  17384. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  17385. if (!pose || !pose.poseModelMatrix) {
  17386. return false;
  17387. }
  17388. // Update the parent cameras matrix
  17389. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  17390. if (!this._scene.useRightHandedSystem) {
  17391. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  17392. }
  17393. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  17394. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  17395. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  17396. this.computeWorldMatrix();
  17397. // Update camera rigs
  17398. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  17399. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  17400. // Update view/projection matrix
  17401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  17402. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  17403. if (!_this._scene.useRightHandedSystem) {
  17404. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  17405. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17406. }
  17407. // Update viewport
  17408. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  17409. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  17410. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  17411. _this.rigCameras[i].viewport.width = viewport.width / width;
  17412. _this.rigCameras[i].viewport.height = viewport.height / height;
  17413. _this.rigCameras[i].viewport.x = viewport.x / width;
  17414. _this.rigCameras[i].viewport.y = viewport.y / height;
  17415. // Set cameras to render to the session's render target
  17416. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  17417. });
  17418. return true;
  17419. };
  17420. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  17421. return WebXRCamera;
  17422. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  17423. /***/ }),
  17424. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  17425. /*!****************************************!*\
  17426. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  17427. \****************************************/
  17428. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  17429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17430. "use strict";
  17431. __webpack_require__.r(__webpack_exports__);
  17432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  17433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  17434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  17435. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17436. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17437. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17438. /**
  17439. * Button which can be used to enter a different mode of XR
  17440. */
  17441. var WebXREnterExitUIButton = /** @class */ (function () {
  17442. /**
  17443. * Creates a WebXREnterExitUIButton
  17444. * @param element button element
  17445. * @param initializationOptions XR initialization options for the button
  17446. */
  17447. function WebXREnterExitUIButton(
  17448. /** button element */
  17449. element,
  17450. /** XR initialization options for the button */
  17451. initializationOptions) {
  17452. this.element = element;
  17453. this.initializationOptions = initializationOptions;
  17454. }
  17455. /**
  17456. * Overwritable function which can be used to update the button's visuals when the state changes
  17457. * @param activeButton the current active button in the UI
  17458. */
  17459. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  17460. };
  17461. return WebXREnterExitUIButton;
  17462. }());
  17463. /**
  17464. * Options to create the webXR UI
  17465. */
  17466. var WebXREnterExitUIOptions = /** @class */ (function () {
  17467. function WebXREnterExitUIOptions() {
  17468. }
  17469. return WebXREnterExitUIOptions;
  17470. }());
  17471. /**
  17472. * UI to allow the user to enter/exit XR mode
  17473. */
  17474. var WebXREnterExitUI = /** @class */ (function () {
  17475. function WebXREnterExitUI(scene, options) {
  17476. var _this = this;
  17477. this.scene = scene;
  17478. this._buttons = [];
  17479. this._activeButton = null;
  17480. /**
  17481. * Fired every time the active button is changed.
  17482. *
  17483. * When xr is entered via a button that launches xr that button will be the callback parameter
  17484. *
  17485. * When exiting xr the callback parameter will be null)
  17486. */
  17487. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17488. this._overlay = document.createElement("div");
  17489. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  17490. if (options.customButtons) {
  17491. this._buttons = options.customButtons;
  17492. }
  17493. else {
  17494. var hmdBtn = document.createElement("button");
  17495. 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;";
  17496. hmdBtn.innerText = "HMD";
  17497. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  17498. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17499. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17500. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  17501. };
  17502. var windowBtn = document.createElement("button");
  17503. windowBtn.style.cssText = hmdBtn.style.cssText;
  17504. windowBtn.innerText = "Window";
  17505. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  17506. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17507. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17508. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  17509. };
  17510. this._updateButtons(null);
  17511. }
  17512. var renderCanvas = scene.getEngine().getRenderingCanvas();
  17513. if (renderCanvas && renderCanvas.parentNode) {
  17514. renderCanvas.parentNode.appendChild(this._overlay);
  17515. scene.onDisposeObservable.addOnce(function () {
  17516. _this.dispose();
  17517. });
  17518. }
  17519. }
  17520. /**
  17521. * Creates UI to allow the user to enter/exit XR mode
  17522. * @param scene the scene to add the ui to
  17523. * @param helper the xr experience helper to enter/exit xr with
  17524. * @param options options to configure the UI
  17525. * @returns the created ui
  17526. */
  17527. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  17528. var _this = this;
  17529. var ui = new WebXREnterExitUI(scene, options);
  17530. var supportedPromises = ui._buttons.map(function (btn) {
  17531. return helper.supportsSessionAsync(btn.initializationOptions);
  17532. });
  17533. helper.onStateChangedObservable.add(function (state) {
  17534. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  17535. ui._updateButtons(null);
  17536. }
  17537. });
  17538. return Promise.all(supportedPromises).then(function (results) {
  17539. results.forEach(function (supported, i) {
  17540. if (supported) {
  17541. ui._overlay.appendChild(ui._buttons[i].element);
  17542. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  17543. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  17544. switch (_a.label) {
  17545. case 0:
  17546. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  17547. ui._updateButtons(null);
  17548. return [4 /*yield*/, helper.exitXRAsync()];
  17549. case 1:
  17550. _a.sent();
  17551. return [2 /*return*/];
  17552. case 2:
  17553. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  17554. ui._updateButtons(ui._buttons[i]);
  17555. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  17556. case 3:
  17557. _a.sent();
  17558. _a.label = 4;
  17559. case 4: return [2 /*return*/];
  17560. }
  17561. });
  17562. }); };
  17563. }
  17564. });
  17565. return ui;
  17566. });
  17567. };
  17568. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  17569. var _this = this;
  17570. this._activeButton = activeButton;
  17571. this._buttons.forEach(function (b) {
  17572. b.update(_this._activeButton);
  17573. });
  17574. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  17575. };
  17576. /**
  17577. * Disposes of the object
  17578. */
  17579. WebXREnterExitUI.prototype.dispose = function () {
  17580. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  17581. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  17582. renderCanvas.parentNode.removeChild(this._overlay);
  17583. }
  17584. this.activeButtonChangedObservable.clear();
  17585. };
  17586. return WebXREnterExitUI;
  17587. }());
  17588. /***/ }),
  17589. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  17590. /*!*********************************************!*\
  17591. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  17592. \*********************************************/
  17593. /*! exports provided: WebXRState, WebXRExperienceHelper */
  17594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17595. "use strict";
  17596. __webpack_require__.r(__webpack_exports__);
  17597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  17598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  17599. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17600. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17601. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  17602. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17603. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17604. /**
  17605. * States of the webXR experience
  17606. */
  17607. var WebXRState;
  17608. (function (WebXRState) {
  17609. /**
  17610. * Transitioning to being in XR mode
  17611. */
  17612. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  17613. /**
  17614. * Transitioning to non XR mode
  17615. */
  17616. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  17617. /**
  17618. * In XR mode and presenting
  17619. */
  17620. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  17621. /**
  17622. * Not entered XR mode
  17623. */
  17624. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  17625. })(WebXRState || (WebXRState = {}));
  17626. /**
  17627. * Helper class used to enable XR
  17628. * @see https://doc.babylonjs.com/how_to/webxr
  17629. */
  17630. var WebXRExperienceHelper = /** @class */ (function () {
  17631. /**
  17632. * Creates a WebXRExperienceHelper
  17633. * @param scene The scene the helper should be created in
  17634. */
  17635. function WebXRExperienceHelper(scene) {
  17636. this.scene = scene;
  17637. /**
  17638. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  17639. */
  17640. this.state = WebXRState.NOT_IN_XR;
  17641. /**
  17642. * Fires when the state of the experience helper has changed
  17643. */
  17644. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  17645. this._nonVRCamera = null;
  17646. this._originalSceneAutoClear = true;
  17647. this._supported = false;
  17648. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  17649. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  17650. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  17651. this.camera.parent = this.container;
  17652. }
  17653. WebXRExperienceHelper.prototype._setState = function (val) {
  17654. this.state = val;
  17655. this.onStateChangedObservable.notifyObservers(this.state);
  17656. };
  17657. /**
  17658. * Creates the experience helper
  17659. * @param scene the scene to attach the experience helper to
  17660. * @returns a promise for the experience helper
  17661. */
  17662. WebXRExperienceHelper.CreateAsync = function (scene) {
  17663. var helper = new WebXRExperienceHelper(scene);
  17664. return helper._sessionManager.initializeAsync().then(function () {
  17665. helper._supported = true;
  17666. return helper;
  17667. }).catch(function () {
  17668. return helper;
  17669. });
  17670. };
  17671. /**
  17672. * Exits XR mode and returns the scene to its original state
  17673. * @returns promise that resolves after xr mode has exited
  17674. */
  17675. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  17676. this._setState(WebXRState.EXITING_XR);
  17677. return this._sessionManager.exitXRAsync();
  17678. };
  17679. /**
  17680. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  17681. * @param sessionCreationOptions options for the XR session
  17682. * @param frameOfReference frame of reference of the XR session
  17683. * @returns promise that resolves after xr mode has entered
  17684. */
  17685. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  17686. var _this = this;
  17687. if (!this._supported) {
  17688. throw "XR session not supported by this browser";
  17689. }
  17690. this._setState(WebXRState.ENTERING_XR);
  17691. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  17692. // Cache pre xr scene settings
  17693. _this._originalSceneAutoClear = _this.scene.autoClear;
  17694. _this._nonVRCamera = _this.scene.activeCamera;
  17695. // Overwrite current scene settings
  17696. _this.scene.autoClear = false;
  17697. _this.scene.activeCamera = _this.camera;
  17698. _this._sessionManager.onXRFrameObservable.add(function () {
  17699. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  17700. });
  17701. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  17702. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  17703. _this.camera.rigCameras.forEach(function (c) {
  17704. c.outputRenderTarget = null;
  17705. });
  17706. // Restore scene settings
  17707. _this.scene.autoClear = _this._originalSceneAutoClear;
  17708. _this.scene.activeCamera = _this._nonVRCamera;
  17709. _this._sessionManager.onXRFrameObservable.clear();
  17710. _this._setState(WebXRState.NOT_IN_XR);
  17711. });
  17712. _this._setState(WebXRState.IN_XR);
  17713. });
  17714. };
  17715. /**
  17716. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  17717. * @param ray ray to cast into the environment
  17718. * @returns Promise which resolves with a collision point in the environment if it exists
  17719. */
  17720. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  17721. return this._sessionManager.environmentPointHitTestAsync(ray);
  17722. };
  17723. /**
  17724. * Updates the global position of the camera by moving the camera's container
  17725. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  17726. * @param position The desired global position of the camera
  17727. */
  17728. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  17729. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  17730. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  17731. };
  17732. /**
  17733. * Rotates the xr camera by rotating the camera's container around the camera's position
  17734. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  17735. * @param rotation the desired quaternion rotation to apply to the camera
  17736. */
  17737. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  17738. if (!this.container.rotationQuaternion) {
  17739. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  17740. }
  17741. this.container.rotationQuaternion.multiplyInPlace(rotation);
  17742. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  17743. };
  17744. /**
  17745. * Checks if the creation options are supported by the xr session
  17746. * @param options creation options
  17747. * @returns true if supported
  17748. */
  17749. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  17750. if (!this._supported) {
  17751. return Promise.resolve(false);
  17752. }
  17753. return this._sessionManager.supportsSessionAsync(options);
  17754. };
  17755. /**
  17756. * Disposes of the experience helper
  17757. */
  17758. WebXRExperienceHelper.prototype.dispose = function () {
  17759. this.camera.dispose();
  17760. this.container.dispose();
  17761. this.onStateChangedObservable.clear();
  17762. this._sessionManager.dispose();
  17763. };
  17764. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  17765. return WebXRExperienceHelper;
  17766. }());
  17767. /***/ }),
  17768. /***/ "./Cameras/XR/webXRInput.ts":
  17769. /*!**********************************!*\
  17770. !*** ./Cameras/XR/webXRInput.ts ***!
  17771. \**********************************/
  17772. /*! exports provided: WebXRController, WebXRInput */
  17773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17774. "use strict";
  17775. __webpack_require__.r(__webpack_exports__);
  17776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  17777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  17778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17779. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  17780. /**
  17781. * Represents an XR input
  17782. */
  17783. var WebXRController = /** @class */ (function () {
  17784. /**
  17785. * Creates the controller
  17786. * @see https://doc.babylonjs.com/how_to/webxr
  17787. * @param scene the scene which the controller should be associated to
  17788. */
  17789. function WebXRController(scene) {
  17790. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  17791. }
  17792. /**
  17793. * Disposes of the object
  17794. */
  17795. WebXRController.prototype.dispose = function () {
  17796. if (this.grip) {
  17797. this.grip.dispose();
  17798. }
  17799. this.pointer.dispose();
  17800. };
  17801. return WebXRController;
  17802. }());
  17803. /**
  17804. * XR input used to track XR inputs such as controllers/rays
  17805. */
  17806. var WebXRInput = /** @class */ (function () {
  17807. /**
  17808. * Initializes the WebXRInput
  17809. * @param helper experience helper which the input should be created for
  17810. */
  17811. function WebXRInput(helper) {
  17812. var _this = this;
  17813. this.helper = helper;
  17814. /**
  17815. * XR controllers being tracked
  17816. */
  17817. this.controllers = [];
  17818. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  17819. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  17820. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  17821. return;
  17822. }
  17823. var xrFrame = helper._sessionManager._currentXRFrame;
  17824. var inputSources = helper._sessionManager._xrSession.getInputSources();
  17825. inputSources.forEach(function (input, i) {
  17826. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  17827. if (inputPose) {
  17828. if (_this.controllers.length <= i) {
  17829. _this.controllers.push(new WebXRController(helper.container.getScene()));
  17830. }
  17831. var controller = _this.controllers[i];
  17832. // Manage the grip if it exists
  17833. if (inputPose.gripMatrix) {
  17834. if (!controller.grip) {
  17835. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  17836. }
  17837. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  17838. if (!controller.grip.getScene().useRightHandedSystem) {
  17839. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  17840. }
  17841. if (!controller.grip.rotationQuaternion) {
  17842. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  17843. }
  17844. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  17845. }
  17846. // Manager pointer of controller
  17847. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  17848. if (!controller.pointer.getScene().useRightHandedSystem) {
  17849. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  17850. }
  17851. if (!controller.pointer.rotationQuaternion) {
  17852. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  17853. }
  17854. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  17855. }
  17856. });
  17857. });
  17858. }
  17859. /**
  17860. * Disposes of the object
  17861. */
  17862. WebXRInput.prototype.dispose = function () {
  17863. this.controllers.forEach(function (c) {
  17864. c.dispose();
  17865. });
  17866. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  17867. };
  17868. return WebXRInput;
  17869. }());
  17870. /***/ }),
  17871. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  17872. /*!************************************************!*\
  17873. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  17874. \************************************************/
  17875. /*! exports provided: WebXRManagedOutputCanvas */
  17876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17877. "use strict";
  17878. __webpack_require__.r(__webpack_exports__);
  17879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  17880. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17881. /**
  17882. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  17883. */
  17884. var WebXRManagedOutputCanvas = /** @class */ (function () {
  17885. /**
  17886. * Initializes the canvas to be added/removed upon entering/exiting xr
  17887. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  17888. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  17889. */
  17890. function WebXRManagedOutputCanvas(helper, canvas) {
  17891. var _this = this;
  17892. this._canvas = null;
  17893. /**
  17894. * xrpresent context of the canvas which can be used to display/mirror xr content
  17895. */
  17896. this.canvasContext = null;
  17897. if (!canvas) {
  17898. canvas = document.createElement('canvas');
  17899. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  17900. }
  17901. this._setManagedOutputCanvas(canvas);
  17902. helper.onStateChangedObservable.add(function (stateInfo) {
  17903. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  17904. // 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
  17905. _this._addCanvas();
  17906. }
  17907. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  17908. _this._removeCanvas();
  17909. }
  17910. });
  17911. }
  17912. /**
  17913. * Disposes of the object
  17914. */
  17915. WebXRManagedOutputCanvas.prototype.dispose = function () {
  17916. this._removeCanvas();
  17917. this._setManagedOutputCanvas(null);
  17918. };
  17919. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  17920. this._removeCanvas();
  17921. if (!canvas) {
  17922. this._canvas = null;
  17923. this.canvasContext = null;
  17924. }
  17925. else {
  17926. this._canvas = canvas;
  17927. this.canvasContext = this._canvas.getContext('xrpresent');
  17928. }
  17929. };
  17930. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  17931. if (this._canvas) {
  17932. document.body.appendChild(this._canvas);
  17933. }
  17934. };
  17935. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  17936. if (this._canvas && document.body.contains(this._canvas)) {
  17937. document.body.removeChild(this._canvas);
  17938. }
  17939. };
  17940. return WebXRManagedOutputCanvas;
  17941. }());
  17942. /***/ }),
  17943. /***/ "./Cameras/XR/webXRSessionManager.ts":
  17944. /*!*******************************************!*\
  17945. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  17946. \*******************************************/
  17947. /*! exports provided: WebXRSessionManager */
  17948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17949. "use strict";
  17950. __webpack_require__.r(__webpack_exports__);
  17951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  17952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17953. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17954. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17955. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  17956. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  17957. /**
  17958. * Manages an XRSession
  17959. * @see https://doc.babylonjs.com/how_to/webxr
  17960. */
  17961. var WebXRSessionManager = /** @class */ (function () {
  17962. /**
  17963. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  17964. * @param scene The scene which the session should be created for
  17965. */
  17966. function WebXRSessionManager(scene) {
  17967. this.scene = scene;
  17968. /**
  17969. * Fires every time a new xrFrame arrives which can be used to update the camera
  17970. */
  17971. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17972. /**
  17973. * Fires when the xr session is ended either by the device or manually done
  17974. */
  17975. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17976. /** @hidden */
  17977. this._sessionRenderTargetTexture = null;
  17978. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  17979. }
  17980. /**
  17981. * Initializes the manager
  17982. * After initialization enterXR can be called to start an XR session
  17983. * @returns Promise which resolves after it is initialized
  17984. */
  17985. WebXRSessionManager.prototype.initializeAsync = function () {
  17986. var _this = this;
  17987. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  17988. // Check if the browser supports webXR
  17989. this._xrNavigator = navigator;
  17990. if (!this._xrNavigator.xr) {
  17991. return Promise.reject("webXR not supported by this browser");
  17992. }
  17993. // Request the webXR device
  17994. return this._xrNavigator.xr.requestDevice().then(function (device) {
  17995. _this._xrDevice = device;
  17996. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  17997. });
  17998. };
  17999. /**
  18000. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18001. * @param sessionCreationOptions xr options to create the session with
  18002. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18003. * @returns Promise which resolves after it enters XR
  18004. */
  18005. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18006. var _this = this;
  18007. // initialize session
  18008. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18009. _this._xrSession = session;
  18010. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18011. _this._xrSession.addEventListener("end", function () {
  18012. // Remove render target texture and notify frame obervers
  18013. _this._sessionRenderTargetTexture = null;
  18014. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18015. _this.scene.getEngine().restoreDefaultFramebuffer();
  18016. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18017. _this.scene.getEngine().customAnimationFrameRequester = null;
  18018. _this.onXRSessionEnded.notifyObservers(null);
  18019. _this.scene.getEngine()._renderLoop();
  18020. }, { once: true });
  18021. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18022. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18023. }).then(function (frameOfRef) {
  18024. _this._frameOfReference = frameOfRef;
  18025. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18026. _this.scene.getEngine().customAnimationFrameRequester = {
  18027. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18028. renderFunction: function (timestamp, xrFrame) {
  18029. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18030. _this._currentXRFrame = xrFrame;
  18031. _this.onXRFrameObservable.notifyObservers(null);
  18032. _this.scene.getEngine()._renderLoop();
  18033. }
  18034. };
  18035. // Create render target texture from xr's webgl render target
  18036. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18037. // Stop window's animation frame and trigger sessions animation frame
  18038. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18039. _this.scene.getEngine()._renderLoop();
  18040. });
  18041. };
  18042. /**
  18043. * Stops the xrSession and restores the renderloop
  18044. * @returns Promise which resolves after it exits XR
  18045. */
  18046. WebXRSessionManager.prototype.exitXRAsync = function () {
  18047. return this._xrSession.end();
  18048. };
  18049. /**
  18050. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18051. * @param ray ray to cast into the environment
  18052. * @returns Promise which resolves with a collision point in the environment if it exists
  18053. */
  18054. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18055. var _this = this;
  18056. return new Promise(function (res) {
  18057. // Compute left handed inputs to request hit test
  18058. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18059. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18060. if (!_this.scene.useRightHandedSystem) {
  18061. origin[2] *= -1;
  18062. direction[2] *= -1;
  18063. }
  18064. // Fire hittest
  18065. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18066. .then(function (hits) {
  18067. if (hits.length > 0) {
  18068. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18069. var hitPoint = _this._tmpMatrix.getTranslation();
  18070. if (!_this.scene.useRightHandedSystem) {
  18071. hitPoint.z *= -1;
  18072. }
  18073. res(hitPoint);
  18074. }
  18075. else {
  18076. res(null);
  18077. }
  18078. }).catch(function () {
  18079. res(null);
  18080. });
  18081. });
  18082. };
  18083. /**
  18084. * Checks if a session would be supported for the creation options specified
  18085. * @param options creation options to check if they are supported
  18086. * @returns true if supported
  18087. */
  18088. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18089. return this._xrDevice.supportsSession(options).then(function () {
  18090. return true;
  18091. }).catch(function () {
  18092. return false;
  18093. });
  18094. };
  18095. /**
  18096. * @hidden
  18097. * Converts the render layer of xrSession to a render target
  18098. * @param session session to create render target for
  18099. * @param scene scene the new render target should be created for
  18100. */
  18101. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18102. // Create internal texture
  18103. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18104. internalTexture.width = session.baseLayer.framebufferWidth;
  18105. internalTexture.height = session.baseLayer.framebufferHeight;
  18106. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18107. // Create render target texture from the internal texture
  18108. 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);
  18109. renderTargetTexture._texture = internalTexture;
  18110. return renderTargetTexture;
  18111. };
  18112. /**
  18113. * Disposes of the session manager
  18114. */
  18115. WebXRSessionManager.prototype.dispose = function () {
  18116. this.onXRFrameObservable.clear();
  18117. this.onXRSessionEnded.clear();
  18118. };
  18119. return WebXRSessionManager;
  18120. }());
  18121. /***/ }),
  18122. /***/ "./Cameras/arcRotateCamera.ts":
  18123. /*!************************************!*\
  18124. !*** ./Cameras/arcRotateCamera.ts ***!
  18125. \************************************/
  18126. /*! exports provided: ArcRotateCamera */
  18127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18128. "use strict";
  18129. __webpack_require__.r(__webpack_exports__);
  18130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18132. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18133. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18135. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18136. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18137. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18138. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18139. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18140. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  18141. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18142. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18143. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18144. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18145. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18146. });
  18147. /**
  18148. * This represents an orbital type of camera.
  18149. *
  18150. * 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.
  18151. * 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.
  18152. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18153. */
  18154. var ArcRotateCamera = /** @class */ (function (_super) {
  18155. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18156. /**
  18157. * Instantiates a new ArcRotateCamera in a given scene
  18158. * @param name Defines the name of the camera
  18159. * @param alpha Defines the camera rotation along the logitudinal axis
  18160. * @param beta Defines the camera rotation along the latitudinal axis
  18161. * @param radius Defines the camera distance from its target
  18162. * @param target Defines the camera target
  18163. * @param scene Defines the scene the camera belongs to
  18164. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18165. */
  18166. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18167. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18168. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18169. /**
  18170. * Current inertia value on the longitudinal axis.
  18171. * The bigger this number the longer it will take for the camera to stop.
  18172. */
  18173. _this.inertialAlphaOffset = 0;
  18174. /**
  18175. * Current inertia value on the latitudinal axis.
  18176. * The bigger this number the longer it will take for the camera to stop.
  18177. */
  18178. _this.inertialBetaOffset = 0;
  18179. /**
  18180. * Current inertia value on the radius axis.
  18181. * The bigger this number the longer it will take for the camera to stop.
  18182. */
  18183. _this.inertialRadiusOffset = 0;
  18184. /**
  18185. * Minimum allowed angle on the longitudinal axis.
  18186. * This can help limiting how the Camera is able to move in the scene.
  18187. */
  18188. _this.lowerAlphaLimit = null;
  18189. /**
  18190. * Maximum allowed angle on the longitudinal axis.
  18191. * This can help limiting how the Camera is able to move in the scene.
  18192. */
  18193. _this.upperAlphaLimit = null;
  18194. /**
  18195. * Minimum allowed angle on the latitudinal axis.
  18196. * This can help limiting how the Camera is able to move in the scene.
  18197. */
  18198. _this.lowerBetaLimit = 0.01;
  18199. /**
  18200. * Maximum allowed angle on the latitudinal axis.
  18201. * This can help limiting how the Camera is able to move in the scene.
  18202. */
  18203. _this.upperBetaLimit = Math.PI - 0.01;
  18204. /**
  18205. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18206. * This can help limiting how the Camera is able to move in the scene.
  18207. */
  18208. _this.lowerRadiusLimit = null;
  18209. /**
  18210. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18211. * This can help limiting how the Camera is able to move in the scene.
  18212. */
  18213. _this.upperRadiusLimit = null;
  18214. /**
  18215. * Defines the current inertia value used during panning of the camera along the X axis.
  18216. */
  18217. _this.inertialPanningX = 0;
  18218. /**
  18219. * Defines the current inertia value used during panning of the camera along the Y axis.
  18220. */
  18221. _this.inertialPanningY = 0;
  18222. /**
  18223. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18224. * Basically if your fingers moves away from more than this distance you will be considered
  18225. * in pinch mode.
  18226. */
  18227. _this.pinchToPanMaxDistance = 20;
  18228. /**
  18229. * Defines the maximum distance the camera can pan.
  18230. * This could help keeping the cammera always in your scene.
  18231. */
  18232. _this.panningDistanceLimit = null;
  18233. /**
  18234. * Defines the target of the camera before paning.
  18235. */
  18236. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18237. /**
  18238. * Defines the value of the inertia used during panning.
  18239. * 0 would mean stop inertia and one would mean no decelleration at all.
  18240. */
  18241. _this.panningInertia = 0.9;
  18242. //-- end properties for backward compatibility for inputs
  18243. /**
  18244. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18245. */
  18246. _this.zoomOnFactor = 1;
  18247. /**
  18248. * Defines a screen offset for the camera position.
  18249. */
  18250. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18251. /**
  18252. * Allows the camera to be completely reversed.
  18253. * If false the camera can not arrive upside down.
  18254. */
  18255. _this.allowUpsideDown = true;
  18256. /**
  18257. * Define if double tap/click is used to restore the previously saved state of the camera.
  18258. */
  18259. _this.useInputToRestoreState = true;
  18260. /** @hidden */
  18261. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18262. /**
  18263. * Defines the allowed panning axis.
  18264. */
  18265. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18266. /**
  18267. * Observable triggered when the mesh target has been changed on the camera.
  18268. */
  18269. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18270. /**
  18271. * Defines whether the camera should check collision with the objects oh the scene.
  18272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18273. */
  18274. _this.checkCollisions = false;
  18275. /**
  18276. * Defines the collision radius of the camera.
  18277. * This simulates a sphere around the camera.
  18278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18279. */
  18280. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18281. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18282. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18283. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18284. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18285. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18286. if (collidedMesh === void 0) { collidedMesh = null; }
  18287. if (!collidedMesh) {
  18288. _this._previousPosition.copyFrom(_this.position);
  18289. }
  18290. else {
  18291. _this.setPosition(newPosition);
  18292. if (_this.onCollide) {
  18293. _this.onCollide(collidedMesh);
  18294. }
  18295. }
  18296. // Recompute because of constraints
  18297. var cosa = Math.cos(_this.alpha);
  18298. var sina = Math.sin(_this.alpha);
  18299. var cosb = Math.cos(_this.beta);
  18300. var sinb = Math.sin(_this.beta);
  18301. if (sinb === 0) {
  18302. sinb = 0.0001;
  18303. }
  18304. var target = _this._getTargetPosition();
  18305. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  18306. target.addToRef(_this._computationVector, _this._newPosition);
  18307. _this.position.copyFrom(_this._newPosition);
  18308. var up = _this.upVector;
  18309. if (_this.allowUpsideDown && _this.beta < 0) {
  18310. up = up.clone();
  18311. up = up.negate();
  18312. }
  18313. _this._computeViewMatrix(_this.position, target, up);
  18314. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  18315. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  18316. _this._collisionTriggered = false;
  18317. };
  18318. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18319. if (target) {
  18320. _this.setTarget(target);
  18321. }
  18322. _this.alpha = alpha;
  18323. _this.beta = beta;
  18324. _this.radius = radius;
  18325. _this.getViewMatrix();
  18326. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__["ArcRotateCameraInputsManager"](_this);
  18327. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  18328. return _this;
  18329. }
  18330. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  18331. /**
  18332. * Defines the target point of the camera.
  18333. * The camera looks towards it form the radius distance.
  18334. */
  18335. get: function () {
  18336. return this._target;
  18337. },
  18338. set: function (value) {
  18339. this.setTarget(value);
  18340. },
  18341. enumerable: true,
  18342. configurable: true
  18343. });
  18344. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  18345. //-- begin properties for backward compatibility for inputs
  18346. /**
  18347. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  18348. */
  18349. get: function () {
  18350. var pointers = this.inputs.attached["pointers"];
  18351. if (pointers) {
  18352. return pointers.angularSensibilityX;
  18353. }
  18354. return 0;
  18355. },
  18356. set: function (value) {
  18357. var pointers = this.inputs.attached["pointers"];
  18358. if (pointers) {
  18359. pointers.angularSensibilityX = value;
  18360. }
  18361. },
  18362. enumerable: true,
  18363. configurable: true
  18364. });
  18365. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  18366. /**
  18367. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  18368. */
  18369. get: function () {
  18370. var pointers = this.inputs.attached["pointers"];
  18371. if (pointers) {
  18372. return pointers.angularSensibilityY;
  18373. }
  18374. return 0;
  18375. },
  18376. set: function (value) {
  18377. var pointers = this.inputs.attached["pointers"];
  18378. if (pointers) {
  18379. pointers.angularSensibilityY = value;
  18380. }
  18381. },
  18382. enumerable: true,
  18383. configurable: true
  18384. });
  18385. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  18386. /**
  18387. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  18388. */
  18389. get: function () {
  18390. var pointers = this.inputs.attached["pointers"];
  18391. if (pointers) {
  18392. return pointers.pinchPrecision;
  18393. }
  18394. return 0;
  18395. },
  18396. set: function (value) {
  18397. var pointers = this.inputs.attached["pointers"];
  18398. if (pointers) {
  18399. pointers.pinchPrecision = value;
  18400. }
  18401. },
  18402. enumerable: true,
  18403. configurable: true
  18404. });
  18405. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  18406. /**
  18407. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  18408. * It will be used instead of pinchDeltaPrecision if different from 0.
  18409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18410. */
  18411. get: function () {
  18412. var pointers = this.inputs.attached["pointers"];
  18413. if (pointers) {
  18414. return pointers.pinchDeltaPercentage;
  18415. }
  18416. return 0;
  18417. },
  18418. set: function (value) {
  18419. var pointers = this.inputs.attached["pointers"];
  18420. if (pointers) {
  18421. pointers.pinchDeltaPercentage = value;
  18422. }
  18423. },
  18424. enumerable: true,
  18425. configurable: true
  18426. });
  18427. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  18428. /**
  18429. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  18430. */
  18431. get: function () {
  18432. var pointers = this.inputs.attached["pointers"];
  18433. if (pointers) {
  18434. return pointers.panningSensibility;
  18435. }
  18436. return 0;
  18437. },
  18438. set: function (value) {
  18439. var pointers = this.inputs.attached["pointers"];
  18440. if (pointers) {
  18441. pointers.panningSensibility = value;
  18442. }
  18443. },
  18444. enumerable: true,
  18445. configurable: true
  18446. });
  18447. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  18448. /**
  18449. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  18450. */
  18451. get: function () {
  18452. var keyboard = this.inputs.attached["keyboard"];
  18453. if (keyboard) {
  18454. return keyboard.keysUp;
  18455. }
  18456. return [];
  18457. },
  18458. set: function (value) {
  18459. var keyboard = this.inputs.attached["keyboard"];
  18460. if (keyboard) {
  18461. keyboard.keysUp = value;
  18462. }
  18463. },
  18464. enumerable: true,
  18465. configurable: true
  18466. });
  18467. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  18468. /**
  18469. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  18470. */
  18471. get: function () {
  18472. var keyboard = this.inputs.attached["keyboard"];
  18473. if (keyboard) {
  18474. return keyboard.keysDown;
  18475. }
  18476. return [];
  18477. },
  18478. set: function (value) {
  18479. var keyboard = this.inputs.attached["keyboard"];
  18480. if (keyboard) {
  18481. keyboard.keysDown = value;
  18482. }
  18483. },
  18484. enumerable: true,
  18485. configurable: true
  18486. });
  18487. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  18488. /**
  18489. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  18490. */
  18491. get: function () {
  18492. var keyboard = this.inputs.attached["keyboard"];
  18493. if (keyboard) {
  18494. return keyboard.keysLeft;
  18495. }
  18496. return [];
  18497. },
  18498. set: function (value) {
  18499. var keyboard = this.inputs.attached["keyboard"];
  18500. if (keyboard) {
  18501. keyboard.keysLeft = value;
  18502. }
  18503. },
  18504. enumerable: true,
  18505. configurable: true
  18506. });
  18507. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  18508. /**
  18509. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  18510. */
  18511. get: function () {
  18512. var keyboard = this.inputs.attached["keyboard"];
  18513. if (keyboard) {
  18514. return keyboard.keysRight;
  18515. }
  18516. return [];
  18517. },
  18518. set: function (value) {
  18519. var keyboard = this.inputs.attached["keyboard"];
  18520. if (keyboard) {
  18521. keyboard.keysRight = value;
  18522. }
  18523. },
  18524. enumerable: true,
  18525. configurable: true
  18526. });
  18527. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  18528. /**
  18529. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  18530. */
  18531. get: function () {
  18532. var mousewheel = this.inputs.attached["mousewheel"];
  18533. if (mousewheel) {
  18534. return mousewheel.wheelPrecision;
  18535. }
  18536. return 0;
  18537. },
  18538. set: function (value) {
  18539. var mousewheel = this.inputs.attached["mousewheel"];
  18540. if (mousewheel) {
  18541. mousewheel.wheelPrecision = value;
  18542. }
  18543. },
  18544. enumerable: true,
  18545. configurable: true
  18546. });
  18547. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  18548. /**
  18549. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  18550. * It will be used instead of pinchDeltaPrecision if different from 0.
  18551. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18552. */
  18553. get: function () {
  18554. var mousewheel = this.inputs.attached["mousewheel"];
  18555. if (mousewheel) {
  18556. return mousewheel.wheelDeltaPercentage;
  18557. }
  18558. return 0;
  18559. },
  18560. set: function (value) {
  18561. var mousewheel = this.inputs.attached["mousewheel"];
  18562. if (mousewheel) {
  18563. mousewheel.wheelDeltaPercentage = value;
  18564. }
  18565. },
  18566. enumerable: true,
  18567. configurable: true
  18568. });
  18569. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  18570. /**
  18571. * Gets the bouncing behavior of the camera if it has been enabled.
  18572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18573. */
  18574. get: function () {
  18575. return this._bouncingBehavior;
  18576. },
  18577. enumerable: true,
  18578. configurable: true
  18579. });
  18580. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  18581. /**
  18582. * Defines if the bouncing behavior of the camera is enabled on the camera.
  18583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18584. */
  18585. get: function () {
  18586. return this._bouncingBehavior != null;
  18587. },
  18588. set: function (value) {
  18589. if (value === this.useBouncingBehavior) {
  18590. return;
  18591. }
  18592. if (value) {
  18593. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  18594. this.addBehavior(this._bouncingBehavior);
  18595. }
  18596. else if (this._bouncingBehavior) {
  18597. this.removeBehavior(this._bouncingBehavior);
  18598. this._bouncingBehavior = null;
  18599. }
  18600. },
  18601. enumerable: true,
  18602. configurable: true
  18603. });
  18604. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  18605. /**
  18606. * Gets the framing behavior of the camera if it has been enabled.
  18607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18608. */
  18609. get: function () {
  18610. return this._framingBehavior;
  18611. },
  18612. enumerable: true,
  18613. configurable: true
  18614. });
  18615. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  18616. /**
  18617. * Defines if the framing behavior of the camera is enabled on the camera.
  18618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18619. */
  18620. get: function () {
  18621. return this._framingBehavior != null;
  18622. },
  18623. set: function (value) {
  18624. if (value === this.useFramingBehavior) {
  18625. return;
  18626. }
  18627. if (value) {
  18628. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  18629. this.addBehavior(this._framingBehavior);
  18630. }
  18631. else if (this._framingBehavior) {
  18632. this.removeBehavior(this._framingBehavior);
  18633. this._framingBehavior = null;
  18634. }
  18635. },
  18636. enumerable: true,
  18637. configurable: true
  18638. });
  18639. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  18640. /**
  18641. * Gets the auto rotation behavior of the camera if it has been enabled.
  18642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18643. */
  18644. get: function () {
  18645. return this._autoRotationBehavior;
  18646. },
  18647. enumerable: true,
  18648. configurable: true
  18649. });
  18650. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  18651. /**
  18652. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  18653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18654. */
  18655. get: function () {
  18656. return this._autoRotationBehavior != null;
  18657. },
  18658. set: function (value) {
  18659. if (value === this.useAutoRotationBehavior) {
  18660. return;
  18661. }
  18662. if (value) {
  18663. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  18664. this.addBehavior(this._autoRotationBehavior);
  18665. }
  18666. else if (this._autoRotationBehavior) {
  18667. this.removeBehavior(this._autoRotationBehavior);
  18668. this._autoRotationBehavior = null;
  18669. }
  18670. },
  18671. enumerable: true,
  18672. configurable: true
  18673. });
  18674. // Cache
  18675. /** @hidden */
  18676. ArcRotateCamera.prototype._initCache = function () {
  18677. _super.prototype._initCache.call(this);
  18678. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  18679. this._cache.alpha = undefined;
  18680. this._cache.beta = undefined;
  18681. this._cache.radius = undefined;
  18682. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18683. };
  18684. /** @hidden */
  18685. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  18686. if (!ignoreParentClass) {
  18687. _super.prototype._updateCache.call(this);
  18688. }
  18689. this._cache._target.copyFrom(this._getTargetPosition());
  18690. this._cache.alpha = this.alpha;
  18691. this._cache.beta = this.beta;
  18692. this._cache.radius = this.radius;
  18693. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  18694. };
  18695. ArcRotateCamera.prototype._getTargetPosition = function () {
  18696. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  18697. var pos = this._targetHost.absolutePosition;
  18698. if (this._targetBoundingCenter) {
  18699. pos.addToRef(this._targetBoundingCenter, this._target);
  18700. }
  18701. else {
  18702. this._target.copyFrom(pos);
  18703. }
  18704. }
  18705. var lockedTargetPosition = this._getLockedTargetPosition();
  18706. if (lockedTargetPosition) {
  18707. return lockedTargetPosition;
  18708. }
  18709. return this._target;
  18710. };
  18711. /**
  18712. * Stores the current state of the camera (alpha, beta, radius and target)
  18713. * @returns the camera itself
  18714. */
  18715. ArcRotateCamera.prototype.storeState = function () {
  18716. this._storedAlpha = this.alpha;
  18717. this._storedBeta = this.beta;
  18718. this._storedRadius = this.radius;
  18719. this._storedTarget = this._getTargetPosition().clone();
  18720. return _super.prototype.storeState.call(this);
  18721. };
  18722. /**
  18723. * @hidden
  18724. * Restored camera state. You must call storeState() first
  18725. */
  18726. ArcRotateCamera.prototype._restoreStateValues = function () {
  18727. if (!_super.prototype._restoreStateValues.call(this)) {
  18728. return false;
  18729. }
  18730. this.alpha = this._storedAlpha;
  18731. this.beta = this._storedBeta;
  18732. this.radius = this._storedRadius;
  18733. this.setTarget(this._storedTarget.clone());
  18734. this.inertialAlphaOffset = 0;
  18735. this.inertialBetaOffset = 0;
  18736. this.inertialRadiusOffset = 0;
  18737. this.inertialPanningX = 0;
  18738. this.inertialPanningY = 0;
  18739. return true;
  18740. };
  18741. // Synchronized
  18742. /** @hidden */
  18743. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  18744. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  18745. return false;
  18746. }
  18747. return this._cache._target.equals(this._getTargetPosition())
  18748. && this._cache.alpha === this.alpha
  18749. && this._cache.beta === this.beta
  18750. && this._cache.radius === this.radius
  18751. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  18752. };
  18753. /**
  18754. * Attached controls to the current camera.
  18755. * @param element Defines the element the controls should be listened from
  18756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18757. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  18758. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  18759. */
  18760. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  18761. var _this = this;
  18762. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  18763. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  18764. this._useCtrlForPanning = useCtrlForPanning;
  18765. this._panningMouseButton = panningMouseButton;
  18766. this.inputs.attachElement(element, noPreventDefault);
  18767. this._reset = function () {
  18768. _this.inertialAlphaOffset = 0;
  18769. _this.inertialBetaOffset = 0;
  18770. _this.inertialRadiusOffset = 0;
  18771. _this.inertialPanningX = 0;
  18772. _this.inertialPanningY = 0;
  18773. };
  18774. };
  18775. /**
  18776. * Detach the current controls from the camera.
  18777. * The camera will stop reacting to inputs.
  18778. * @param element Defines the element to stop listening the inputs from
  18779. */
  18780. ArcRotateCamera.prototype.detachControl = function (element) {
  18781. this.inputs.detachElement(element);
  18782. if (this._reset) {
  18783. this._reset();
  18784. }
  18785. };
  18786. /** @hidden */
  18787. ArcRotateCamera.prototype._checkInputs = function () {
  18788. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  18789. if (this._collisionTriggered) {
  18790. return;
  18791. }
  18792. this.inputs.checkInputs();
  18793. // Inertia
  18794. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  18795. var inertialAlphaOffset = this.inertialAlphaOffset;
  18796. if (this.beta <= 0) {
  18797. inertialAlphaOffset *= -1;
  18798. }
  18799. if (this.getScene().useRightHandedSystem) {
  18800. inertialAlphaOffset *= -1;
  18801. }
  18802. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  18803. inertialAlphaOffset *= -1;
  18804. }
  18805. this.alpha += inertialAlphaOffset;
  18806. this.beta += this.inertialBetaOffset;
  18807. this.radius -= this.inertialRadiusOffset;
  18808. this.inertialAlphaOffset *= this.inertia;
  18809. this.inertialBetaOffset *= this.inertia;
  18810. this.inertialRadiusOffset *= this.inertia;
  18811. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18812. this.inertialAlphaOffset = 0;
  18813. }
  18814. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18815. this.inertialBetaOffset = 0;
  18816. }
  18817. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18818. this.inertialRadiusOffset = 0;
  18819. }
  18820. }
  18821. // Panning inertia
  18822. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  18823. if (!this._localDirection) {
  18824. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18825. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18826. }
  18827. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  18828. this._localDirection.multiplyInPlace(this.panningAxis);
  18829. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  18830. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  18831. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  18832. if (!this.panningAxis.y) {
  18833. this._transformedDirection.y = 0;
  18834. }
  18835. if (!this._targetHost) {
  18836. if (this.panningDistanceLimit) {
  18837. this._transformedDirection.addInPlace(this._target);
  18838. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  18839. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  18840. this._target.copyFrom(this._transformedDirection);
  18841. }
  18842. }
  18843. else {
  18844. this._target.addInPlace(this._transformedDirection);
  18845. }
  18846. }
  18847. this.inertialPanningX *= this.panningInertia;
  18848. this.inertialPanningY *= this.panningInertia;
  18849. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18850. this.inertialPanningX = 0;
  18851. }
  18852. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18853. this.inertialPanningY = 0;
  18854. }
  18855. }
  18856. // Limits
  18857. this._checkLimits();
  18858. _super.prototype._checkInputs.call(this);
  18859. };
  18860. ArcRotateCamera.prototype._checkLimits = function () {
  18861. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  18862. if (this.allowUpsideDown && this.beta > Math.PI) {
  18863. this.beta = this.beta - (2 * Math.PI);
  18864. }
  18865. }
  18866. else {
  18867. if (this.beta < this.lowerBetaLimit) {
  18868. this.beta = this.lowerBetaLimit;
  18869. }
  18870. }
  18871. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  18872. if (this.allowUpsideDown && this.beta < -Math.PI) {
  18873. this.beta = this.beta + (2 * Math.PI);
  18874. }
  18875. }
  18876. else {
  18877. if (this.beta > this.upperBetaLimit) {
  18878. this.beta = this.upperBetaLimit;
  18879. }
  18880. }
  18881. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  18882. this.alpha = this.lowerAlphaLimit;
  18883. }
  18884. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  18885. this.alpha = this.upperAlphaLimit;
  18886. }
  18887. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  18888. this.radius = this.lowerRadiusLimit;
  18889. this.inertialRadiusOffset = 0;
  18890. }
  18891. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  18892. this.radius = this.upperRadiusLimit;
  18893. this.inertialRadiusOffset = 0;
  18894. }
  18895. };
  18896. /**
  18897. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  18898. */
  18899. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  18900. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  18901. this.radius = this._computationVector.length();
  18902. if (this.radius === 0) {
  18903. this.radius = 0.0001; // Just to avoid division by zero
  18904. }
  18905. // Alpha
  18906. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  18907. if (this._computationVector.z < 0) {
  18908. this.alpha = 2 * Math.PI - this.alpha;
  18909. }
  18910. // Beta
  18911. this.beta = Math.acos(this._computationVector.y / this.radius);
  18912. this._checkLimits();
  18913. };
  18914. /**
  18915. * Use a position to define the current camera related information like aplha, beta and radius
  18916. * @param position Defines the position to set the camera at
  18917. */
  18918. ArcRotateCamera.prototype.setPosition = function (position) {
  18919. if (this.position.equals(position)) {
  18920. return;
  18921. }
  18922. this.position.copyFrom(position);
  18923. this.rebuildAnglesAndRadius();
  18924. };
  18925. /**
  18926. * Defines the target the camera should look at.
  18927. * This will automatically adapt alpha beta and radius to fit within the new target.
  18928. * @param target Defines the new target as a Vector or a mesh
  18929. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  18930. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  18931. */
  18932. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  18933. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  18934. if (allowSamePosition === void 0) { allowSamePosition = false; }
  18935. if (target.getBoundingInfo) {
  18936. if (toBoundingCenter) {
  18937. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  18938. }
  18939. else {
  18940. this._targetBoundingCenter = null;
  18941. }
  18942. this._targetHost = target;
  18943. this._target = this._getTargetPosition();
  18944. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  18945. }
  18946. else {
  18947. var newTarget = target;
  18948. var currentTarget = this._getTargetPosition();
  18949. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  18950. return;
  18951. }
  18952. this._targetHost = null;
  18953. this._target = newTarget;
  18954. this._targetBoundingCenter = null;
  18955. this.onMeshTargetChangedObservable.notifyObservers(null);
  18956. }
  18957. this.rebuildAnglesAndRadius();
  18958. };
  18959. /** @hidden */
  18960. ArcRotateCamera.prototype._getViewMatrix = function () {
  18961. // Compute
  18962. var cosa = Math.cos(this.alpha);
  18963. var sina = Math.sin(this.alpha);
  18964. var cosb = Math.cos(this.beta);
  18965. var sinb = Math.sin(this.beta);
  18966. if (sinb === 0) {
  18967. sinb = 0.0001;
  18968. }
  18969. var target = this._getTargetPosition();
  18970. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  18971. // Rotate according to up vector
  18972. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  18973. if (!this._tempAxisVector) {
  18974. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  18975. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18976. }
  18977. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  18978. this._tempAxisVector.normalize();
  18979. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  18980. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  18981. this._tempAxisVector.copyFrom(this._computationVector);
  18982. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  18983. }
  18984. target.addToRef(this._computationVector, this._newPosition);
  18985. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  18986. if (!this._collider) {
  18987. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  18988. }
  18989. this._collider._radius = this.collisionRadius;
  18990. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  18991. this._collisionTriggered = true;
  18992. this.getScene().collisionCoordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  18993. }
  18994. else {
  18995. this.position.copyFrom(this._newPosition);
  18996. var up = this.upVector;
  18997. if (this.allowUpsideDown && sinb < 0) {
  18998. up = up.clone();
  18999. up = up.negate();
  19000. }
  19001. this._computeViewMatrix(this.position, target, up);
  19002. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19003. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19004. }
  19005. this._currentTarget = target;
  19006. return this._viewMatrix;
  19007. };
  19008. /**
  19009. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19010. * @param meshes Defines the mesh to zoom on
  19011. * @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)
  19012. */
  19013. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19014. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19015. meshes = meshes || this.getScene().meshes;
  19016. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19017. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19018. this.radius = distance * this.zoomOnFactor;
  19019. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19020. };
  19021. /**
  19022. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19023. * The target will be changed but the radius
  19024. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19025. * @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)
  19026. */
  19027. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19028. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19029. var meshesOrMinMaxVector;
  19030. var distance;
  19031. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19032. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19033. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19034. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19035. }
  19036. else { //minMaxVector and distance
  19037. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19038. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19039. distance = minMaxVectorAndDistance.distance;
  19040. }
  19041. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19042. if (!doNotUpdateMaxZ) {
  19043. this.maxZ = distance * 2;
  19044. }
  19045. };
  19046. /**
  19047. * @override
  19048. * Override Camera.createRigCamera
  19049. */
  19050. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19051. var alphaShift = 0;
  19052. switch (this.cameraRigMode) {
  19053. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19054. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19055. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19056. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19057. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19058. break;
  19059. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19060. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19061. break;
  19062. }
  19063. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19064. rigCam._cameraRigParams = {};
  19065. return rigCam;
  19066. };
  19067. /**
  19068. * @hidden
  19069. * @override
  19070. * Override Camera._updateRigCameras
  19071. */
  19072. ArcRotateCamera.prototype._updateRigCameras = function () {
  19073. var camLeft = this._rigCameras[0];
  19074. var camRight = this._rigCameras[1];
  19075. camLeft.beta = camRight.beta = this.beta;
  19076. switch (this.cameraRigMode) {
  19077. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19078. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19079. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19080. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19081. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19082. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19083. break;
  19084. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19085. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19086. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19087. break;
  19088. }
  19089. _super.prototype._updateRigCameras.call(this);
  19090. };
  19091. /**
  19092. * Destroy the camera and release the current resources hold by it.
  19093. */
  19094. ArcRotateCamera.prototype.dispose = function () {
  19095. this.inputs.clear();
  19096. _super.prototype.dispose.call(this);
  19097. };
  19098. /**
  19099. * Gets the current object class name.
  19100. * @return the class name
  19101. */
  19102. ArcRotateCamera.prototype.getClassName = function () {
  19103. return "ArcRotateCamera";
  19104. };
  19105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19107. ], ArcRotateCamera.prototype, "alpha", void 0);
  19108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19110. ], ArcRotateCamera.prototype, "beta", void 0);
  19111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19113. ], ArcRotateCamera.prototype, "radius", void 0);
  19114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19116. ], ArcRotateCamera.prototype, "_target", void 0);
  19117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19119. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19122. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19125. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19128. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19131. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19134. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19137. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19140. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19143. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19146. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19149. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19152. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19155. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19158. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19161. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19162. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19164. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19165. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19166. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19167. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19168. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19169. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19170. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19173. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19174. return ArcRotateCamera;
  19175. }(_targetCamera__WEBPACK_IMPORTED_MODULE_11__["TargetCamera"]));
  19176. /***/ }),
  19177. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19178. /*!*************************************************!*\
  19179. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19180. \*************************************************/
  19181. /*! exports provided: ArcRotateCameraInputsManager */
  19182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19183. "use strict";
  19184. __webpack_require__.r(__webpack_exports__);
  19185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19187. /* harmony import */ var _Cameras_Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  19188. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19189. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19190. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19191. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19192. /**
  19193. * Default Inputs manager for the ArcRotateCamera.
  19194. * It groups all the default supported inputs for ease of use.
  19195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19196. */
  19197. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19199. /**
  19200. * Instantiates a new ArcRotateCameraInputsManager.
  19201. * @param camera Defines the camera the inputs belong to
  19202. */
  19203. function ArcRotateCameraInputsManager(camera) {
  19204. return _super.call(this, camera) || this;
  19205. }
  19206. /**
  19207. * Add mouse wheel input support to the input manager.
  19208. * @returns the current input manager
  19209. */
  19210. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19211. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraMouseWheelInput"]());
  19212. return this;
  19213. };
  19214. /**
  19215. * Add pointers input support to the input manager.
  19216. * @returns the current input manager
  19217. */
  19218. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19219. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraPointersInput"]());
  19220. return this;
  19221. };
  19222. /**
  19223. * Add keyboard input support to the input manager.
  19224. * @returns the current input manager
  19225. */
  19226. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19227. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraKeyboardMoveInput"]());
  19228. return this;
  19229. };
  19230. /**
  19231. * Add orientation input support to the input manager.
  19232. * @returns the current input manager
  19233. */
  19234. ArcRotateCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  19235. this.add(new _Cameras_Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraVRDeviceOrientationInput"]());
  19236. return this;
  19237. };
  19238. return ArcRotateCameraInputsManager;
  19239. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["CameraInputsManager"]));
  19240. /***/ }),
  19241. /***/ "./Cameras/camera.ts":
  19242. /*!***************************!*\
  19243. !*** ./Cameras/camera.ts ***!
  19244. \***************************/
  19245. /*! exports provided: Camera */
  19246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19247. "use strict";
  19248. __webpack_require__.r(__webpack_exports__);
  19249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19251. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19252. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19253. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19254. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19255. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19256. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19257. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  19258. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  19259. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  19260. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  19261. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  19262. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  19263. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  19264. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19265. /**
  19266. * This is the base class of all the camera used in the application.
  19267. * @see http://doc.babylonjs.com/features/cameras
  19268. */
  19269. var Camera = /** @class */ (function (_super) {
  19270. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19271. /**
  19272. * Instantiates a new camera object.
  19273. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19274. * @see http://doc.babylonjs.com/features/cameras
  19275. * @param name Defines the name of the camera in the scene
  19276. * @param position Defines the position of the camera
  19277. * @param scene Defines the scene the camera belongs too
  19278. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19279. */
  19280. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19281. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19282. var _this = _super.call(this, name, scene) || this;
  19283. /**
  19284. * The vector the camera should consider as up.
  19285. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19286. */
  19287. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19288. /**
  19289. * Define the current limit on the left side for an orthographic camera
  19290. * In scene unit
  19291. */
  19292. _this.orthoLeft = null;
  19293. /**
  19294. * Define the current limit on the right side for an orthographic camera
  19295. * In scene unit
  19296. */
  19297. _this.orthoRight = null;
  19298. /**
  19299. * Define the current limit on the bottom side for an orthographic camera
  19300. * In scene unit
  19301. */
  19302. _this.orthoBottom = null;
  19303. /**
  19304. * Define the current limit on the top side for an orthographic camera
  19305. * In scene unit
  19306. */
  19307. _this.orthoTop = null;
  19308. /**
  19309. * Field Of View is set in Radians. (default is 0.8)
  19310. */
  19311. _this.fov = 0.8;
  19312. /**
  19313. * Define the minimum distance the camera can see from.
  19314. * This is important to note that the depth buffer are not infinite and the closer it starts
  19315. * the more your scene might encounter depth fighting issue.
  19316. */
  19317. _this.minZ = 1;
  19318. /**
  19319. * Define the maximum distance the camera can see to.
  19320. * This is important to note that the depth buffer are not infinite and the further it end
  19321. * the more your scene might encounter depth fighting issue.
  19322. */
  19323. _this.maxZ = 10000.0;
  19324. /**
  19325. * Define the default inertia of the camera.
  19326. * This helps giving a smooth feeling to the camera movement.
  19327. */
  19328. _this.inertia = 0.9;
  19329. /**
  19330. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  19331. */
  19332. _this.mode = Camera.PERSPECTIVE_CAMERA;
  19333. /**
  19334. * Define wether the camera is intermediate.
  19335. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  19336. */
  19337. _this.isIntermediate = false;
  19338. /**
  19339. * Define the viewport of the camera.
  19340. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  19341. */
  19342. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  19343. /**
  19344. * Restricts the camera to viewing objects with the same layerMask.
  19345. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  19346. */
  19347. _this.layerMask = 0x0FFFFFFF;
  19348. /**
  19349. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  19350. */
  19351. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  19352. /**
  19353. * Rig mode of the camera.
  19354. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  19355. * This is normally controlled byt the camera themselves as internal use.
  19356. */
  19357. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  19358. /**
  19359. * 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
  19360. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  19361. * else in the scene.
  19362. */
  19363. _this.customRenderTargets = new Array();
  19364. /**
  19365. * When set, the camera will render to this render target instead of the default canvas
  19366. */
  19367. _this.outputRenderTarget = null;
  19368. /**
  19369. * Observable triggered when the camera view matrix has changed.
  19370. */
  19371. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19372. /**
  19373. * Observable triggered when the camera Projection matrix has changed.
  19374. */
  19375. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19376. /**
  19377. * Observable triggered when the inputs have been processed.
  19378. */
  19379. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19380. /**
  19381. * Observable triggered when reset has been called and applied to the camera.
  19382. */
  19383. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19384. /** @hidden */
  19385. _this._rigCameras = new Array();
  19386. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19387. /** @hidden */
  19388. _this._skipRendering = false;
  19389. /** @hidden */
  19390. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  19391. /** @hidden */
  19392. _this._postProcesses = new Array();
  19393. /** @hidden */
  19394. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  19395. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  19396. /** hidden */
  19397. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19398. _this._doNotComputeProjectionMatrix = false;
  19399. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  19400. _this._refreshFrustumPlanes = true;
  19401. /** @hidden */
  19402. _this._isCamera = true;
  19403. _this.getScene().addCamera(_this);
  19404. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  19405. _this.getScene().activeCamera = _this;
  19406. }
  19407. _this.position = position;
  19408. return _this;
  19409. }
  19410. /**
  19411. * Store current camera state (fov, position, etc..)
  19412. * @returns the camera
  19413. */
  19414. Camera.prototype.storeState = function () {
  19415. this._stateStored = true;
  19416. this._storedFov = this.fov;
  19417. return this;
  19418. };
  19419. /**
  19420. * Restores the camera state values if it has been stored. You must call storeState() first
  19421. */
  19422. Camera.prototype._restoreStateValues = function () {
  19423. if (!this._stateStored) {
  19424. return false;
  19425. }
  19426. this.fov = this._storedFov;
  19427. return true;
  19428. };
  19429. /**
  19430. * Restored camera state. You must call storeState() first.
  19431. * @returns true if restored and false otherwise
  19432. */
  19433. Camera.prototype.restoreState = function () {
  19434. if (this._restoreStateValues()) {
  19435. this.onRestoreStateObservable.notifyObservers(this);
  19436. return true;
  19437. }
  19438. return false;
  19439. };
  19440. /**
  19441. * Gets the class name of the camera.
  19442. * @returns the class name
  19443. */
  19444. Camera.prototype.getClassName = function () {
  19445. return "Camera";
  19446. };
  19447. /**
  19448. * Gets a string representation of the camera useful for debug purpose.
  19449. * @param fullDetails Defines that a more verboe level of logging is required
  19450. * @returns the string representation
  19451. */
  19452. Camera.prototype.toString = function (fullDetails) {
  19453. var ret = "Name: " + this.name;
  19454. ret += ", type: " + this.getClassName();
  19455. if (this.animations) {
  19456. for (var i = 0; i < this.animations.length; i++) {
  19457. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  19458. }
  19459. }
  19460. if (fullDetails) {
  19461. }
  19462. return ret;
  19463. };
  19464. Object.defineProperty(Camera.prototype, "globalPosition", {
  19465. /**
  19466. * Gets the current world space position of the camera.
  19467. */
  19468. get: function () {
  19469. return this._globalPosition;
  19470. },
  19471. enumerable: true,
  19472. configurable: true
  19473. });
  19474. /**
  19475. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  19476. * @returns the active meshe list
  19477. */
  19478. Camera.prototype.getActiveMeshes = function () {
  19479. return this._activeMeshes;
  19480. };
  19481. /**
  19482. * Check wether a mesh is part of the current active mesh list of the camera
  19483. * @param mesh Defines the mesh to check
  19484. * @returns true if active, false otherwise
  19485. */
  19486. Camera.prototype.isActiveMesh = function (mesh) {
  19487. return (this._activeMeshes.indexOf(mesh) !== -1);
  19488. };
  19489. /**
  19490. * Is this camera ready to be used/rendered
  19491. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  19492. * @return true if the camera is ready
  19493. */
  19494. Camera.prototype.isReady = function (completeCheck) {
  19495. if (completeCheck === void 0) { completeCheck = false; }
  19496. if (completeCheck) {
  19497. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  19498. var pp = _a[_i];
  19499. if (pp && !pp.isReady()) {
  19500. return false;
  19501. }
  19502. }
  19503. }
  19504. return _super.prototype.isReady.call(this, completeCheck);
  19505. };
  19506. /** @hidden */
  19507. Camera.prototype._initCache = function () {
  19508. _super.prototype._initCache.call(this);
  19509. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19510. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19511. this._cache.mode = undefined;
  19512. this._cache.minZ = undefined;
  19513. this._cache.maxZ = undefined;
  19514. this._cache.fov = undefined;
  19515. this._cache.fovMode = undefined;
  19516. this._cache.aspectRatio = undefined;
  19517. this._cache.orthoLeft = undefined;
  19518. this._cache.orthoRight = undefined;
  19519. this._cache.orthoBottom = undefined;
  19520. this._cache.orthoTop = undefined;
  19521. this._cache.renderWidth = undefined;
  19522. this._cache.renderHeight = undefined;
  19523. };
  19524. /** @hidden */
  19525. Camera.prototype._updateCache = function (ignoreParentClass) {
  19526. if (!ignoreParentClass) {
  19527. _super.prototype._updateCache.call(this);
  19528. }
  19529. this._cache.position.copyFrom(this.position);
  19530. this._cache.upVector.copyFrom(this.upVector);
  19531. };
  19532. /** @hidden */
  19533. Camera.prototype._isSynchronized = function () {
  19534. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  19535. };
  19536. /** @hidden */
  19537. Camera.prototype._isSynchronizedViewMatrix = function () {
  19538. if (!_super.prototype._isSynchronized.call(this)) {
  19539. return false;
  19540. }
  19541. return this._cache.position.equals(this.position)
  19542. && this._cache.upVector.equals(this.upVector)
  19543. && this.isSynchronizedWithParent();
  19544. };
  19545. /** @hidden */
  19546. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  19547. var check = this._cache.mode === this.mode
  19548. && this._cache.minZ === this.minZ
  19549. && this._cache.maxZ === this.maxZ;
  19550. if (!check) {
  19551. return false;
  19552. }
  19553. var engine = this.getEngine();
  19554. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  19555. check = this._cache.fov === this.fov
  19556. && this._cache.fovMode === this.fovMode
  19557. && this._cache.aspectRatio === engine.getAspectRatio(this);
  19558. }
  19559. else {
  19560. check = this._cache.orthoLeft === this.orthoLeft
  19561. && this._cache.orthoRight === this.orthoRight
  19562. && this._cache.orthoBottom === this.orthoBottom
  19563. && this._cache.orthoTop === this.orthoTop
  19564. && this._cache.renderWidth === engine.getRenderWidth()
  19565. && this._cache.renderHeight === engine.getRenderHeight();
  19566. }
  19567. return check;
  19568. };
  19569. /**
  19570. * Attach the input controls to a specific dom element to get the input from.
  19571. * @param element Defines the element the controls should be listened from
  19572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19573. */
  19574. Camera.prototype.attachControl = function (element, noPreventDefault) {
  19575. };
  19576. /**
  19577. * Detach the current controls from the specified dom element.
  19578. * @param element Defines the element to stop listening the inputs from
  19579. */
  19580. Camera.prototype.detachControl = function (element) {
  19581. };
  19582. /**
  19583. * Update the camera state according to the different inputs gathered during the frame.
  19584. */
  19585. Camera.prototype.update = function () {
  19586. this._checkInputs();
  19587. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  19588. this._updateRigCameras();
  19589. }
  19590. };
  19591. /** @hidden */
  19592. Camera.prototype._checkInputs = function () {
  19593. this.onAfterCheckInputsObservable.notifyObservers(this);
  19594. };
  19595. Object.defineProperty(Camera.prototype, "rigCameras", {
  19596. /** @hidden */
  19597. get: function () {
  19598. return this._rigCameras;
  19599. },
  19600. enumerable: true,
  19601. configurable: true
  19602. });
  19603. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  19604. /**
  19605. * Gets the post process used by the rig cameras
  19606. */
  19607. get: function () {
  19608. return this._rigPostProcess;
  19609. },
  19610. enumerable: true,
  19611. configurable: true
  19612. });
  19613. /**
  19614. * Internal, gets the first post proces.
  19615. * @returns the first post process to be run on this camera.
  19616. */
  19617. Camera.prototype._getFirstPostProcess = function () {
  19618. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  19619. if (this._postProcesses[ppIndex] !== null) {
  19620. return this._postProcesses[ppIndex];
  19621. }
  19622. }
  19623. return null;
  19624. };
  19625. Camera.prototype._cascadePostProcessesToRigCams = function () {
  19626. // invalidate framebuffer
  19627. var firstPostProcess = this._getFirstPostProcess();
  19628. if (firstPostProcess) {
  19629. firstPostProcess.markTextureDirty();
  19630. }
  19631. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  19632. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  19633. var cam = this._rigCameras[i];
  19634. var rigPostProcess = cam._rigPostProcess;
  19635. // for VR rig, there does not have to be a post process
  19636. if (rigPostProcess) {
  19637. var isPass = rigPostProcess instanceof _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_8__["PassPostProcess"];
  19638. if (isPass) {
  19639. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  19640. cam.isIntermediate = this._postProcesses.length === 0;
  19641. }
  19642. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  19643. rigPostProcess.markTextureDirty();
  19644. }
  19645. else {
  19646. cam._postProcesses = this._postProcesses.slice(0);
  19647. }
  19648. }
  19649. };
  19650. /**
  19651. * Attach a post process to the camera.
  19652. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19653. * @param postProcess The post process to attach to the camera
  19654. * @param insertAt The position of the post process in case several of them are in use in the scene
  19655. * @returns the position the post process has been inserted at
  19656. */
  19657. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  19658. if (insertAt === void 0) { insertAt = null; }
  19659. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  19660. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  19661. return 0;
  19662. }
  19663. if (insertAt == null || insertAt < 0) {
  19664. this._postProcesses.push(postProcess);
  19665. }
  19666. else if (this._postProcesses[insertAt] === null) {
  19667. this._postProcesses[insertAt] = postProcess;
  19668. }
  19669. else {
  19670. this._postProcesses.splice(insertAt, 0, postProcess);
  19671. }
  19672. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19673. return this._postProcesses.indexOf(postProcess);
  19674. };
  19675. /**
  19676. * Detach a post process to the camera.
  19677. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19678. * @param postProcess The post process to detach from the camera
  19679. */
  19680. Camera.prototype.detachPostProcess = function (postProcess) {
  19681. var idx = this._postProcesses.indexOf(postProcess);
  19682. if (idx !== -1) {
  19683. this._postProcesses[idx] = null;
  19684. }
  19685. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19686. };
  19687. /**
  19688. * Gets the current world matrix of the camera
  19689. */
  19690. Camera.prototype.getWorldMatrix = function () {
  19691. if (this._isSynchronizedViewMatrix()) {
  19692. return this._worldMatrix;
  19693. }
  19694. // Getting the the view matrix will also compute the world matrix.
  19695. this.getViewMatrix();
  19696. return this._worldMatrix;
  19697. };
  19698. /** @hidden */
  19699. Camera.prototype._getViewMatrix = function () {
  19700. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19701. };
  19702. /**
  19703. * Gets the current view matrix of the camera.
  19704. * @param force forces the camera to recompute the matrix without looking at the cached state
  19705. * @returns the view matrix
  19706. */
  19707. Camera.prototype.getViewMatrix = function (force) {
  19708. if (!force && this._isSynchronizedViewMatrix()) {
  19709. return this._computedViewMatrix;
  19710. }
  19711. this.updateCache();
  19712. this._computedViewMatrix = this._getViewMatrix();
  19713. this._currentRenderId = this.getScene().getRenderId();
  19714. this._childRenderId = this._currentRenderId;
  19715. this._refreshFrustumPlanes = true;
  19716. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  19717. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  19718. }
  19719. this.onViewMatrixChangedObservable.notifyObservers(this);
  19720. this._computedViewMatrix.invertToRef(this._worldMatrix);
  19721. return this._computedViewMatrix;
  19722. };
  19723. /**
  19724. * Freeze the projection matrix.
  19725. * It will prevent the cache check of the camera projection compute and can speed up perf
  19726. * if no parameter of the camera are meant to change
  19727. * @param projection Defines manually a projection if necessary
  19728. */
  19729. Camera.prototype.freezeProjectionMatrix = function (projection) {
  19730. this._doNotComputeProjectionMatrix = true;
  19731. if (projection !== undefined) {
  19732. this._projectionMatrix = projection;
  19733. }
  19734. };
  19735. /**
  19736. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  19737. */
  19738. Camera.prototype.unfreezeProjectionMatrix = function () {
  19739. this._doNotComputeProjectionMatrix = false;
  19740. };
  19741. /**
  19742. * Gets the current projection matrix of the camera.
  19743. * @param force forces the camera to recompute the matrix without looking at the cached state
  19744. * @returns the projection matrix
  19745. */
  19746. Camera.prototype.getProjectionMatrix = function (force) {
  19747. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  19748. return this._projectionMatrix;
  19749. }
  19750. // Cache
  19751. this._cache.mode = this.mode;
  19752. this._cache.minZ = this.minZ;
  19753. this._cache.maxZ = this.maxZ;
  19754. // Matrix
  19755. this._refreshFrustumPlanes = true;
  19756. var engine = this.getEngine();
  19757. var scene = this.getScene();
  19758. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  19759. this._cache.fov = this.fov;
  19760. this._cache.fovMode = this.fovMode;
  19761. this._cache.aspectRatio = engine.getAspectRatio(this);
  19762. if (this.minZ <= 0) {
  19763. this.minZ = 0.1;
  19764. }
  19765. if (scene.useRightHandedSystem) {
  19766. _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);
  19767. }
  19768. else {
  19769. _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);
  19770. }
  19771. }
  19772. else {
  19773. var halfWidth = engine.getRenderWidth() / 2.0;
  19774. var halfHeight = engine.getRenderHeight() / 2.0;
  19775. if (scene.useRightHandedSystem) {
  19776. _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);
  19777. }
  19778. else {
  19779. _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);
  19780. }
  19781. this._cache.orthoLeft = this.orthoLeft;
  19782. this._cache.orthoRight = this.orthoRight;
  19783. this._cache.orthoBottom = this.orthoBottom;
  19784. this._cache.orthoTop = this.orthoTop;
  19785. this._cache.renderWidth = engine.getRenderWidth();
  19786. this._cache.renderHeight = engine.getRenderHeight();
  19787. }
  19788. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  19789. return this._projectionMatrix;
  19790. };
  19791. /**
  19792. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  19793. * @returns a Matrix
  19794. */
  19795. Camera.prototype.getTransformationMatrix = function () {
  19796. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  19797. return this._transformMatrix;
  19798. };
  19799. Camera.prototype._updateFrustumPlanes = function () {
  19800. if (!this._refreshFrustumPlanes) {
  19801. return;
  19802. }
  19803. this.getTransformationMatrix();
  19804. if (!this._frustumPlanes) {
  19805. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  19806. }
  19807. else {
  19808. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  19809. }
  19810. this._refreshFrustumPlanes = false;
  19811. };
  19812. /**
  19813. * Checks if a cullable object (mesh...) is in the camera frustum
  19814. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  19815. * @param target The object to check
  19816. * @returns true if the object is in frustum otherwise false
  19817. */
  19818. Camera.prototype.isInFrustum = function (target) {
  19819. this._updateFrustumPlanes();
  19820. return target.isInFrustum(this._frustumPlanes);
  19821. };
  19822. /**
  19823. * Checks if a cullable object (mesh...) is in the camera frustum
  19824. * Unlike isInFrustum this cheks the full bounding box
  19825. * @param target The object to check
  19826. * @returns true if the object is in frustum otherwise false
  19827. */
  19828. Camera.prototype.isCompletelyInFrustum = function (target) {
  19829. this._updateFrustumPlanes();
  19830. return target.isCompletelyInFrustum(this._frustumPlanes);
  19831. };
  19832. /**
  19833. * Gets a ray in the forward direction from the camera.
  19834. * @param length Defines the length of the ray to create
  19835. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  19836. * @param origin Defines the start point of the ray which defaults to the camera position
  19837. * @returns the forward ray
  19838. */
  19839. Camera.prototype.getForwardRay = function (length, transform, origin) {
  19840. if (length === void 0) { length = 100; }
  19841. if (!transform) {
  19842. transform = this.getWorldMatrix();
  19843. }
  19844. if (!origin) {
  19845. origin = this.position;
  19846. }
  19847. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 1);
  19848. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(forward, transform);
  19849. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(forwardWorld);
  19850. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_7__["Ray"](origin, direction, length);
  19851. };
  19852. /**
  19853. * Releases resources associated with this node.
  19854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19856. */
  19857. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  19858. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  19859. // Observables
  19860. this.onViewMatrixChangedObservable.clear();
  19861. this.onProjectionMatrixChangedObservable.clear();
  19862. this.onAfterCheckInputsObservable.clear();
  19863. this.onRestoreStateObservable.clear();
  19864. // Inputs
  19865. if (this.inputs) {
  19866. this.inputs.clear();
  19867. }
  19868. // Animations
  19869. this.getScene().stopAnimation(this);
  19870. // Remove from scene
  19871. this.getScene().removeCamera(this);
  19872. while (this._rigCameras.length > 0) {
  19873. var camera = this._rigCameras.pop();
  19874. if (camera) {
  19875. camera.dispose();
  19876. }
  19877. }
  19878. // Postprocesses
  19879. if (this._rigPostProcess) {
  19880. this._rigPostProcess.dispose(this);
  19881. this._rigPostProcess = null;
  19882. this._postProcesses = [];
  19883. }
  19884. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  19885. this._rigPostProcess = null;
  19886. this._postProcesses = [];
  19887. }
  19888. else {
  19889. var i = this._postProcesses.length;
  19890. while (--i >= 0) {
  19891. var postProcess = this._postProcesses[i];
  19892. if (postProcess) {
  19893. postProcess.dispose(this);
  19894. }
  19895. }
  19896. }
  19897. // Render targets
  19898. var i = this.customRenderTargets.length;
  19899. while (--i >= 0) {
  19900. this.customRenderTargets[i].dispose();
  19901. }
  19902. this.customRenderTargets = [];
  19903. // Active Meshes
  19904. this._activeMeshes.dispose();
  19905. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  19906. };
  19907. Object.defineProperty(Camera.prototype, "leftCamera", {
  19908. /**
  19909. * Gets the left camera of a rig setup in case of Rigged Camera
  19910. */
  19911. get: function () {
  19912. if (this._rigCameras.length < 1) {
  19913. return null;
  19914. }
  19915. return this._rigCameras[0];
  19916. },
  19917. enumerable: true,
  19918. configurable: true
  19919. });
  19920. Object.defineProperty(Camera.prototype, "rightCamera", {
  19921. /**
  19922. * Gets the right camera of a rig setup in case of Rigged Camera
  19923. */
  19924. get: function () {
  19925. if (this._rigCameras.length < 2) {
  19926. return null;
  19927. }
  19928. return this._rigCameras[1];
  19929. },
  19930. enumerable: true,
  19931. configurable: true
  19932. });
  19933. /**
  19934. * Gets the left camera target of a rig setup in case of Rigged Camera
  19935. * @returns the target position
  19936. */
  19937. Camera.prototype.getLeftTarget = function () {
  19938. if (this._rigCameras.length < 1) {
  19939. return null;
  19940. }
  19941. return this._rigCameras[0].getTarget();
  19942. };
  19943. /**
  19944. * Gets the right camera target of a rig setup in case of Rigged Camera
  19945. * @returns the target position
  19946. */
  19947. Camera.prototype.getRightTarget = function () {
  19948. if (this._rigCameras.length < 2) {
  19949. return null;
  19950. }
  19951. return this._rigCameras[1].getTarget();
  19952. };
  19953. /**
  19954. * @hidden
  19955. */
  19956. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  19957. if (this.cameraRigMode === mode) {
  19958. return;
  19959. }
  19960. while (this._rigCameras.length > 0) {
  19961. var camera = this._rigCameras.pop();
  19962. if (camera) {
  19963. camera.dispose();
  19964. }
  19965. }
  19966. this.cameraRigMode = mode;
  19967. this._cameraRigParams = {};
  19968. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  19969. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  19970. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  19971. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  19972. // create the rig cameras, unless none
  19973. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  19974. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  19975. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  19976. if (leftCamera && rightCamera) {
  19977. this._rigCameras.push(leftCamera);
  19978. this._rigCameras.push(rightCamera);
  19979. }
  19980. }
  19981. switch (this.cameraRigMode) {
  19982. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19983. this._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_8__["PassPostProcess"](this.name + "_passthru", 1.0, this._rigCameras[0]);
  19984. this._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_9__["AnaglyphPostProcess"](this.name + "_anaglyph", 1.0, this._rigCameras);
  19985. break;
  19986. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19987. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19988. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19989. var isStereoscopicHoriz = this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  19990. this._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_8__["PassPostProcess"](this.name + "_passthru", 1.0, this._rigCameras[0]);
  19991. this._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_10__["StereoscopicInterlacePostProcess"](this.name + "_stereoInterlace", this._rigCameras, isStereoscopicHoriz);
  19992. break;
  19993. case Camera.RIG_MODE_VR:
  19994. var metrics = rigParams.vrCameraMetrics || _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_13__["VRCameraMetrics"].GetDefault();
  19995. this._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  19996. this._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 0.5, 1.0);
  19997. this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  19998. this._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  19999. this._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  20000. this._rigCameras[0].getProjectionMatrix = this._rigCameras[0]._getVRProjectionMatrix;
  20001. this._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  20002. this._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0.5, 0, 0.5, 1.0);
  20003. this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20004. this._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  20005. this._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  20006. this._rigCameras[1].getProjectionMatrix = this._rigCameras[1]._getVRProjectionMatrix;
  20007. if (metrics.compensateDistortion) {
  20008. this._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_11__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", this._rigCameras[0], false, metrics);
  20009. this._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_11__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", this._rigCameras[1], true, metrics);
  20010. }
  20011. break;
  20012. case Camera.RIG_MODE_WEBVR:
  20013. if (rigParams.vrDisplay) {
  20014. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  20015. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  20016. //Left eye
  20017. this._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 0.5, 1.0);
  20018. this._rigCameras[0].setCameraRigParameter("left", true);
  20019. //leaving this for future reference
  20020. this._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  20021. this._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  20022. this._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  20023. this._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  20024. this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20025. this._rigCameras[0].getProjectionMatrix = this._getWebVRProjectionMatrix;
  20026. this._rigCameras[0].parent = this;
  20027. this._rigCameras[0]._getViewMatrix = this._getWebVRViewMatrix;
  20028. //Right eye
  20029. this._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0.5, 0, 0.5, 1.0);
  20030. this._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  20031. this._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  20032. this._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  20033. this._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  20034. this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20035. this._rigCameras[1].getProjectionMatrix = this._getWebVRProjectionMatrix;
  20036. this._rigCameras[1].parent = this;
  20037. this._rigCameras[1]._getViewMatrix = this._getWebVRViewMatrix;
  20038. if (Camera.UseAlternateWebVRRendering) {
  20039. this._rigCameras[1]._skipRendering = true;
  20040. this._rigCameras[0]._alternateCamera = this._rigCameras[1];
  20041. }
  20042. }
  20043. break;
  20044. }
  20045. this._cascadePostProcessesToRigCams();
  20046. this.update();
  20047. };
  20048. Camera.prototype._getVRProjectionMatrix = function () {
  20049. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20050. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20051. return this._projectionMatrix;
  20052. };
  20053. Camera.prototype._updateCameraRotationMatrix = function () {
  20054. //Here for WebVR
  20055. };
  20056. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20057. //Here for WebVR
  20058. };
  20059. /**
  20060. * This function MUST be overwritten by the different WebVR cameras available.
  20061. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20062. */
  20063. Camera.prototype._getWebVRProjectionMatrix = function () {
  20064. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20065. };
  20066. /**
  20067. * This function MUST be overwritten by the different WebVR cameras available.
  20068. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20069. */
  20070. Camera.prototype._getWebVRViewMatrix = function () {
  20071. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20072. };
  20073. /** @hidden */
  20074. Camera.prototype.setCameraRigParameter = function (name, value) {
  20075. if (!this._cameraRigParams) {
  20076. this._cameraRigParams = {};
  20077. }
  20078. this._cameraRigParams[name] = value;
  20079. //provisionnally:
  20080. if (name === "interaxialDistance") {
  20081. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20082. }
  20083. };
  20084. /**
  20085. * needs to be overridden by children so sub has required properties to be copied
  20086. * @hidden
  20087. */
  20088. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20089. return null;
  20090. };
  20091. /**
  20092. * May need to be overridden by children
  20093. * @hidden
  20094. */
  20095. Camera.prototype._updateRigCameras = function () {
  20096. for (var i = 0; i < this._rigCameras.length; i++) {
  20097. this._rigCameras[i].minZ = this.minZ;
  20098. this._rigCameras[i].maxZ = this.maxZ;
  20099. this._rigCameras[i].fov = this.fov;
  20100. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20101. }
  20102. // only update viewport when ANAGLYPH
  20103. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20104. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20105. }
  20106. };
  20107. /** @hidden */
  20108. Camera.prototype._setupInputs = function () {
  20109. };
  20110. /**
  20111. * Serialiaze the camera setup to a json represention
  20112. * @returns the JSON representation
  20113. */
  20114. Camera.prototype.serialize = function () {
  20115. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20116. // Type
  20117. serializationObject.type = this.getClassName();
  20118. // Parent
  20119. if (this.parent) {
  20120. serializationObject.parentId = this.parent.id;
  20121. }
  20122. if (this.inputs) {
  20123. this.inputs.serialize(serializationObject);
  20124. }
  20125. // Animations
  20126. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20127. serializationObject.ranges = this.serializeAnimationRanges();
  20128. return serializationObject;
  20129. };
  20130. /**
  20131. * Clones the current camera.
  20132. * @param name The cloned camera name
  20133. * @returns the cloned camera
  20134. */
  20135. Camera.prototype.clone = function (name) {
  20136. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20137. };
  20138. /**
  20139. * Gets the direction of the camera relative to a given local axis.
  20140. * @param localAxis Defines the reference axis to provide a relative direction.
  20141. * @return the direction
  20142. */
  20143. Camera.prototype.getDirection = function (localAxis) {
  20144. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20145. this.getDirectionToRef(localAxis, result);
  20146. return result;
  20147. };
  20148. /**
  20149. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20150. * @param localAxis Defines the reference axis to provide a relative direction.
  20151. * @param result Defines the vector to store the result in
  20152. */
  20153. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20154. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20155. };
  20156. /**
  20157. * Gets a camera constructor for a given camera type
  20158. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20159. * @param name The name of the camera the result will be able to instantiate
  20160. * @param scene The scene the result will construct the camera in
  20161. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20162. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20163. * @returns a factory method to construc the camera
  20164. */
  20165. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20166. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20167. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20168. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20169. interaxial_distance: interaxial_distance,
  20170. isStereoscopicSideBySide: isStereoscopicSideBySide
  20171. });
  20172. if (constructorFunc) {
  20173. return constructorFunc;
  20174. }
  20175. // Default to universal camera
  20176. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20177. };
  20178. /**
  20179. * Compute the world matrix of the camera.
  20180. * @returns the camera workd matrix
  20181. */
  20182. Camera.prototype.computeWorldMatrix = function () {
  20183. return this.getWorldMatrix();
  20184. };
  20185. /**
  20186. * Parse a JSON and creates the camera from the parsed information
  20187. * @param parsedCamera The JSON to parse
  20188. * @param scene The scene to instantiate the camera in
  20189. * @returns the newly constructed camera
  20190. */
  20191. Camera.Parse = function (parsedCamera, scene) {
  20192. var type = parsedCamera.type;
  20193. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20194. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20195. // Parent
  20196. if (parsedCamera.parentId) {
  20197. camera._waitingParentId = parsedCamera.parentId;
  20198. }
  20199. //If camera has an input manager, let it parse inputs settings
  20200. if (camera.inputs) {
  20201. camera.inputs.parse(parsedCamera);
  20202. camera._setupInputs();
  20203. }
  20204. if (camera.setPosition) { // need to force position
  20205. camera.position.copyFromFloats(0, 0, 0);
  20206. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20207. }
  20208. // Target
  20209. if (parsedCamera.target) {
  20210. if (camera.setTarget) {
  20211. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20212. }
  20213. }
  20214. // Apply 3d rig, when found
  20215. if (parsedCamera.cameraRigMode) {
  20216. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20217. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20218. }
  20219. // Animations
  20220. if (parsedCamera.animations) {
  20221. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20222. var parsedAnimation = parsedCamera.animations[animationIndex];
  20223. camera.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_12__["Animation"].Parse(parsedAnimation));
  20224. }
  20225. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20226. }
  20227. if (parsedCamera.autoAnimate) {
  20228. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20229. }
  20230. return camera;
  20231. };
  20232. /** @hidden */
  20233. Camera._createDefaultParsedCamera = function (name, scene) {
  20234. throw "UniversalCamera needs to be imported before deserialization can create a default camera.";
  20235. };
  20236. /**
  20237. * This is the default projection mode used by the cameras.
  20238. * It helps recreating a feeling of perspective and better appreciate depth.
  20239. * This is the best way to simulate real life cameras.
  20240. */
  20241. Camera.PERSPECTIVE_CAMERA = 0;
  20242. /**
  20243. * This helps creating camera with an orthographic mode.
  20244. * 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.
  20245. */
  20246. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20247. /**
  20248. * This is the default FOV mode for perspective cameras.
  20249. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20250. */
  20251. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20252. /**
  20253. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20254. */
  20255. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20256. /**
  20257. * This specifies ther is no need for a camera rig.
  20258. * Basically only one eye is rendered corresponding to the camera.
  20259. */
  20260. Camera.RIG_MODE_NONE = 0;
  20261. /**
  20262. * Simulates a camera Rig with one blue eye and one red eye.
  20263. * This can be use with 3d blue and red glasses.
  20264. */
  20265. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20266. /**
  20267. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20268. */
  20269. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20270. /**
  20271. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20272. */
  20273. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20274. /**
  20275. * Defines that both eyes of the camera will be rendered over under each other.
  20276. */
  20277. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20278. /**
  20279. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20280. */
  20281. Camera.RIG_MODE_VR = 20;
  20282. /**
  20283. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20284. */
  20285. Camera.RIG_MODE_WEBVR = 21;
  20286. /**
  20287. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20288. */
  20289. Camera.RIG_MODE_CUSTOM = 22;
  20290. /**
  20291. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20292. */
  20293. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20294. /**
  20295. * @hidden
  20296. * Might be removed once multiview will be a thing
  20297. */
  20298. Camera.UseAlternateWebVRRendering = false;
  20299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20301. ], Camera.prototype, "position", void 0);
  20302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20304. ], Camera.prototype, "upVector", void 0);
  20305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20307. ], Camera.prototype, "orthoLeft", void 0);
  20308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20310. ], Camera.prototype, "orthoRight", void 0);
  20311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20313. ], Camera.prototype, "orthoBottom", void 0);
  20314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20316. ], Camera.prototype, "orthoTop", void 0);
  20317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20319. ], Camera.prototype, "fov", void 0);
  20320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20322. ], Camera.prototype, "minZ", void 0);
  20323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20325. ], Camera.prototype, "maxZ", void 0);
  20326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20328. ], Camera.prototype, "inertia", void 0);
  20329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20331. ], Camera.prototype, "mode", void 0);
  20332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20334. ], Camera.prototype, "layerMask", void 0);
  20335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20337. ], Camera.prototype, "fovMode", void 0);
  20338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20340. ], Camera.prototype, "cameraRigMode", void 0);
  20341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20343. ], Camera.prototype, "interaxialDistance", void 0);
  20344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20346. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  20347. return Camera;
  20348. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  20349. /***/ }),
  20350. /***/ "./Cameras/cameraInputsManager.ts":
  20351. /*!****************************************!*\
  20352. !*** ./Cameras/cameraInputsManager.ts ***!
  20353. \****************************************/
  20354. /*! exports provided: CameraInputTypes, CameraInputsManager */
  20355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20356. "use strict";
  20357. __webpack_require__.r(__webpack_exports__);
  20358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  20359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  20360. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20361. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20362. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  20363. /**
  20364. * @ignore
  20365. * This is a list of all the different input types that are available in the application.
  20366. * Fo instance: ArcRotateCameraGamepadInput...
  20367. */
  20368. var CameraInputTypes = {};
  20369. /**
  20370. * This represents the input manager used within a camera.
  20371. * It helps dealing with all the different kind of input attached to a camera.
  20372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20373. */
  20374. var CameraInputsManager = /** @class */ (function () {
  20375. /**
  20376. * Instantiate a new Camera Input Manager.
  20377. * @param camera Defines the camera the input manager blongs to
  20378. */
  20379. function CameraInputsManager(camera) {
  20380. this.attached = {};
  20381. this.camera = camera;
  20382. this.checkInputs = function () { };
  20383. }
  20384. /**
  20385. * Add an input method to a camera
  20386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20387. * @param input camera input method
  20388. */
  20389. CameraInputsManager.prototype.add = function (input) {
  20390. var type = input.getSimpleName();
  20391. if (this.attached[type]) {
  20392. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  20393. return;
  20394. }
  20395. this.attached[type] = input;
  20396. input.camera = this.camera;
  20397. //for checkInputs, we are dynamically creating a function
  20398. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  20399. if (input.checkInputs) {
  20400. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20401. }
  20402. if (this.attachedElement) {
  20403. input.attachControl(this.attachedElement);
  20404. }
  20405. };
  20406. /**
  20407. * Remove a specific input method from a camera
  20408. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  20409. * @param inputToRemove camera input method
  20410. */
  20411. CameraInputsManager.prototype.remove = function (inputToRemove) {
  20412. for (var cam in this.attached) {
  20413. var input = this.attached[cam];
  20414. if (input === inputToRemove) {
  20415. input.detachControl(this.attachedElement);
  20416. input.camera = null;
  20417. delete this.attached[cam];
  20418. this.rebuildInputCheck();
  20419. }
  20420. }
  20421. };
  20422. /**
  20423. * Remove a specific input type from a camera
  20424. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  20425. * @param inputType the type of the input to remove
  20426. */
  20427. CameraInputsManager.prototype.removeByType = function (inputType) {
  20428. for (var cam in this.attached) {
  20429. var input = this.attached[cam];
  20430. if (input.getClassName() === inputType) {
  20431. input.detachControl(this.attachedElement);
  20432. input.camera = null;
  20433. delete this.attached[cam];
  20434. this.rebuildInputCheck();
  20435. }
  20436. }
  20437. };
  20438. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  20439. var current = this.checkInputs;
  20440. return function () {
  20441. current();
  20442. fn();
  20443. };
  20444. };
  20445. /**
  20446. * Attach the input controls to the currently attached dom element to listen the events from.
  20447. * @param input Defines the input to attach
  20448. */
  20449. CameraInputsManager.prototype.attachInput = function (input) {
  20450. if (this.attachedElement) {
  20451. input.attachControl(this.attachedElement, this.noPreventDefault);
  20452. }
  20453. };
  20454. /**
  20455. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  20456. * @param element Defines the dom element to collect the events from
  20457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20458. */
  20459. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  20460. if (noPreventDefault === void 0) { noPreventDefault = false; }
  20461. if (this.attachedElement) {
  20462. return;
  20463. }
  20464. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  20465. this.attachedElement = element;
  20466. this.noPreventDefault = noPreventDefault;
  20467. for (var cam in this.attached) {
  20468. this.attached[cam].attachControl(element, noPreventDefault);
  20469. }
  20470. };
  20471. /**
  20472. * Detach the current manager inputs controls from a specific dom element.
  20473. * @param element Defines the dom element to collect the events from
  20474. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  20475. */
  20476. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  20477. if (disconnect === void 0) { disconnect = false; }
  20478. if (this.attachedElement !== element) {
  20479. return;
  20480. }
  20481. for (var cam in this.attached) {
  20482. this.attached[cam].detachControl(element);
  20483. if (disconnect) {
  20484. this.attached[cam].camera = null;
  20485. }
  20486. }
  20487. this.attachedElement = null;
  20488. };
  20489. /**
  20490. * Rebuild the dynamic inputCheck function from the current list of
  20491. * defined inputs in the manager.
  20492. */
  20493. CameraInputsManager.prototype.rebuildInputCheck = function () {
  20494. this.checkInputs = function () { };
  20495. for (var cam in this.attached) {
  20496. var input = this.attached[cam];
  20497. if (input.checkInputs) {
  20498. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20499. }
  20500. }
  20501. };
  20502. /**
  20503. * Remove all attached input methods from a camera
  20504. */
  20505. CameraInputsManager.prototype.clear = function () {
  20506. if (this.attachedElement) {
  20507. this.detachElement(this.attachedElement, true);
  20508. }
  20509. this.attached = {};
  20510. this.attachedElement = null;
  20511. this.checkInputs = function () { };
  20512. };
  20513. /**
  20514. * Serialize the current input manager attached to a camera.
  20515. * This ensures than once parsed,
  20516. * the input associated to the camera will be identical to the current ones
  20517. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  20518. */
  20519. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  20520. var inputs = {};
  20521. for (var cam in this.attached) {
  20522. var input = this.attached[cam];
  20523. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  20524. inputs[input.getClassName()] = res;
  20525. }
  20526. serializedCamera.inputsmgr = inputs;
  20527. };
  20528. /**
  20529. * Parses an input manager serialized JSON to restore the previous list of inputs
  20530. * and states associated to a camera.
  20531. * @param parsedCamera Defines the JSON to parse
  20532. */
  20533. CameraInputsManager.prototype.parse = function (parsedCamera) {
  20534. var parsedInputs = parsedCamera.inputsmgr;
  20535. if (parsedInputs) {
  20536. this.clear();
  20537. for (var n in parsedInputs) {
  20538. var construct = CameraInputTypes[n];
  20539. if (construct) {
  20540. var parsedinput = parsedInputs[n];
  20541. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  20542. this.add(input);
  20543. }
  20544. }
  20545. }
  20546. else {
  20547. //2016-03-08 this part is for managing backward compatibility
  20548. for (var n in this.attached) {
  20549. var construct = CameraInputTypes[this.attached[n].getClassName()];
  20550. if (construct) {
  20551. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  20552. this.remove(this.attached[n]);
  20553. this.add(input);
  20554. }
  20555. }
  20556. }
  20557. };
  20558. return CameraInputsManager;
  20559. }());
  20560. /***/ }),
  20561. /***/ "./Cameras/deviceOrientationCamera.ts":
  20562. /*!********************************************!*\
  20563. !*** ./Cameras/deviceOrientationCamera.ts ***!
  20564. \********************************************/
  20565. /*! exports provided: DeviceOrientationCamera */
  20566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20567. "use strict";
  20568. __webpack_require__.r(__webpack_exports__);
  20569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  20570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20571. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  20572. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20573. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  20574. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  20575. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  20576. });
  20577. // We're mainly based on the logic defined into the FreeCamera code
  20578. /**
  20579. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  20580. * being tilted forward or back and left or right.
  20581. */
  20582. var DeviceOrientationCamera = /** @class */ (function (_super) {
  20583. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  20584. /**
  20585. * Creates a new device orientation camera
  20586. * @param name The name of the camera
  20587. * @param position The start position camera
  20588. * @param scene The scene the camera belongs to
  20589. */
  20590. function DeviceOrientationCamera(name, position, scene) {
  20591. var _this = _super.call(this, name, position, scene) || this;
  20592. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20593. _this.inputs.addDeviceOrientation();
  20594. return _this;
  20595. }
  20596. /**
  20597. * Gets the current instance class name ("DeviceOrientationCamera").
  20598. * This helps avoiding instanceof at run time.
  20599. * @returns the class name
  20600. */
  20601. DeviceOrientationCamera.prototype.getClassName = function () {
  20602. return "DeviceOrientationCamera";
  20603. };
  20604. /**
  20605. * @hidden
  20606. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  20607. */
  20608. DeviceOrientationCamera.prototype._checkInputs = function () {
  20609. _super.prototype._checkInputs.call(this);
  20610. this._quaternionCache.copyFrom(this.rotationQuaternion);
  20611. if (this._initialQuaternion) {
  20612. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20613. }
  20614. };
  20615. /**
  20616. * Reset the camera to its default orientation on the specified axis only.
  20617. * @param axis The axis to reset
  20618. */
  20619. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  20620. var _this = this;
  20621. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  20622. //can only work if this camera has a rotation quaternion already.
  20623. if (!this.rotationQuaternion) {
  20624. return;
  20625. }
  20626. if (!this._initialQuaternion) {
  20627. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20628. }
  20629. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  20630. ['x', 'y', 'z'].forEach(function (axisName) {
  20631. if (!axis[axisName]) {
  20632. _this._initialQuaternion[axisName] = 0;
  20633. }
  20634. else {
  20635. _this._initialQuaternion[axisName] *= -1;
  20636. }
  20637. });
  20638. this._initialQuaternion.normalize();
  20639. //force rotation update
  20640. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20641. };
  20642. return DeviceOrientationCamera;
  20643. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  20644. /***/ }),
  20645. /***/ "./Cameras/flyCamera.ts":
  20646. /*!******************************!*\
  20647. !*** ./Cameras/flyCamera.ts ***!
  20648. \******************************/
  20649. /*! exports provided: FlyCamera */
  20650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20651. "use strict";
  20652. __webpack_require__.r(__webpack_exports__);
  20653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  20654. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20655. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20656. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20657. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  20658. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  20659. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  20660. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  20661. /**
  20662. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20663. * such as in a 3D Space Shooter or a Flight Simulator.
  20664. */
  20665. var FlyCamera = /** @class */ (function (_super) {
  20666. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  20667. /**
  20668. * Instantiates a FlyCamera.
  20669. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20670. * such as in a 3D Space Shooter or a Flight Simulator.
  20671. * @param name Define the name of the camera in the scene.
  20672. * @param position Define the starting position of the camera in the scene.
  20673. * @param scene Define the scene the camera belongs to.
  20674. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  20675. */
  20676. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20677. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20678. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  20679. /**
  20680. * Define the collision ellipsoid of the camera.
  20681. * This is helpful for simulating a camera body, like a player's body.
  20682. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  20683. */
  20684. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  20685. /**
  20686. * Define an offset for the position of the ellipsoid around the camera.
  20687. * This can be helpful if the camera is attached away from the player's body center,
  20688. * such as at its head.
  20689. */
  20690. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  20691. /**
  20692. * Enable or disable collisions of the camera with the rest of the scene objects.
  20693. */
  20694. _this.checkCollisions = false;
  20695. /**
  20696. * Enable or disable gravity on the camera.
  20697. */
  20698. _this.applyGravity = false;
  20699. /**
  20700. * Define the current direction the camera is moving to.
  20701. */
  20702. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20703. /**
  20704. * Track Roll to maintain the wanted Rolling when looking around.
  20705. */
  20706. _this._trackRoll = 0;
  20707. /**
  20708. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  20709. */
  20710. _this.rollCorrect = 100;
  20711. /**
  20712. * Mimic a banked turn, Rolling the camera when Yawing.
  20713. * It's recommended to use rollCorrect = 10 for faster banking correction.
  20714. */
  20715. _this.bankedTurn = false;
  20716. /**
  20717. * Limit in radians for how much Roll banking will add. (Default: 90°)
  20718. */
  20719. _this.bankedTurnLimit = Math.PI / 2;
  20720. /**
  20721. * Value of 0 disables the banked Roll.
  20722. * Value of 1 is equal to the Yaw angle in radians.
  20723. */
  20724. _this.bankedTurnMultiplier = 1;
  20725. _this._needMoveForGravity = false;
  20726. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20727. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20728. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20729. // Collisions.
  20730. _this._collisionMask = -1;
  20731. /** @hidden */
  20732. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  20733. if (collidedMesh === void 0) { collidedMesh = null; }
  20734. var updatePosition = function (newPos) {
  20735. _this._newPosition.copyFrom(newPos);
  20736. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  20737. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  20738. _this.position.addInPlace(_this._diffPosition);
  20739. if (_this.onCollide && collidedMesh) {
  20740. _this.onCollide(collidedMesh);
  20741. }
  20742. }
  20743. };
  20744. updatePosition(newPosition);
  20745. };
  20746. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FlyCameraInputsManager"](_this);
  20747. _this.inputs.addKeyboard().addMouse();
  20748. return _this;
  20749. }
  20750. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  20751. /**
  20752. * Gets the input sensibility for mouse input.
  20753. * Higher values reduce sensitivity.
  20754. */
  20755. get: function () {
  20756. var mouse = this.inputs.attached["mouse"];
  20757. if (mouse) {
  20758. return mouse.angularSensibility;
  20759. }
  20760. return 0;
  20761. },
  20762. /**
  20763. * Sets the input sensibility for a mouse input.
  20764. * Higher values reduce sensitivity.
  20765. */
  20766. set: function (value) {
  20767. var mouse = this.inputs.attached["mouse"];
  20768. if (mouse) {
  20769. mouse.angularSensibility = value;
  20770. }
  20771. },
  20772. enumerable: true,
  20773. configurable: true
  20774. });
  20775. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  20776. /**
  20777. * Get the keys for camera movement forward.
  20778. */
  20779. get: function () {
  20780. var keyboard = this.inputs.attached["keyboard"];
  20781. if (keyboard) {
  20782. return keyboard.keysForward;
  20783. }
  20784. return [];
  20785. },
  20786. /**
  20787. * Set the keys for camera movement forward.
  20788. */
  20789. set: function (value) {
  20790. var keyboard = this.inputs.attached["keyboard"];
  20791. if (keyboard) {
  20792. keyboard.keysForward = value;
  20793. }
  20794. },
  20795. enumerable: true,
  20796. configurable: true
  20797. });
  20798. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  20799. /**
  20800. * Get the keys for camera movement backward.
  20801. */
  20802. get: function () {
  20803. var keyboard = this.inputs.attached["keyboard"];
  20804. if (keyboard) {
  20805. return keyboard.keysBackward;
  20806. }
  20807. return [];
  20808. },
  20809. set: function (value) {
  20810. var keyboard = this.inputs.attached["keyboard"];
  20811. if (keyboard) {
  20812. keyboard.keysBackward = value;
  20813. }
  20814. },
  20815. enumerable: true,
  20816. configurable: true
  20817. });
  20818. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  20819. /**
  20820. * Get the keys for camera movement up.
  20821. */
  20822. get: function () {
  20823. var keyboard = this.inputs.attached["keyboard"];
  20824. if (keyboard) {
  20825. return keyboard.keysUp;
  20826. }
  20827. return [];
  20828. },
  20829. /**
  20830. * Set the keys for camera movement up.
  20831. */
  20832. set: function (value) {
  20833. var keyboard = this.inputs.attached["keyboard"];
  20834. if (keyboard) {
  20835. keyboard.keysUp = value;
  20836. }
  20837. },
  20838. enumerable: true,
  20839. configurable: true
  20840. });
  20841. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  20842. /**
  20843. * Get the keys for camera movement down.
  20844. */
  20845. get: function () {
  20846. var keyboard = this.inputs.attached["keyboard"];
  20847. if (keyboard) {
  20848. return keyboard.keysDown;
  20849. }
  20850. return [];
  20851. },
  20852. /**
  20853. * Set the keys for camera movement down.
  20854. */
  20855. set: function (value) {
  20856. var keyboard = this.inputs.attached["keyboard"];
  20857. if (keyboard) {
  20858. keyboard.keysDown = value;
  20859. }
  20860. },
  20861. enumerable: true,
  20862. configurable: true
  20863. });
  20864. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  20865. /**
  20866. * Get the keys for camera movement left.
  20867. */
  20868. get: function () {
  20869. var keyboard = this.inputs.attached["keyboard"];
  20870. if (keyboard) {
  20871. return keyboard.keysLeft;
  20872. }
  20873. return [];
  20874. },
  20875. /**
  20876. * Set the keys for camera movement left.
  20877. */
  20878. set: function (value) {
  20879. var keyboard = this.inputs.attached["keyboard"];
  20880. if (keyboard) {
  20881. keyboard.keysLeft = value;
  20882. }
  20883. },
  20884. enumerable: true,
  20885. configurable: true
  20886. });
  20887. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  20888. /**
  20889. * Set the keys for camera movement right.
  20890. */
  20891. get: function () {
  20892. var keyboard = this.inputs.attached["keyboard"];
  20893. if (keyboard) {
  20894. return keyboard.keysRight;
  20895. }
  20896. return [];
  20897. },
  20898. /**
  20899. * Set the keys for camera movement right.
  20900. */
  20901. set: function (value) {
  20902. var keyboard = this.inputs.attached["keyboard"];
  20903. if (keyboard) {
  20904. keyboard.keysRight = value;
  20905. }
  20906. },
  20907. enumerable: true,
  20908. configurable: true
  20909. });
  20910. /**
  20911. * Attach a control to the HTML DOM element.
  20912. * @param element Defines the element that listens to the input events.
  20913. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  20914. */
  20915. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  20916. this.inputs.attachElement(element, noPreventDefault);
  20917. };
  20918. /**
  20919. * Detach a control from the HTML DOM element.
  20920. * The camera will stop reacting to that input.
  20921. * @param element Defines the element that listens to the input events.
  20922. */
  20923. FlyCamera.prototype.detachControl = function (element) {
  20924. this.inputs.detachElement(element);
  20925. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  20926. };
  20927. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  20928. /**
  20929. * Get the mask that the camera ignores in collision events.
  20930. */
  20931. get: function () {
  20932. return this._collisionMask;
  20933. },
  20934. /**
  20935. * Set the mask that the camera ignores in collision events.
  20936. */
  20937. set: function (mask) {
  20938. this._collisionMask = !isNaN(mask) ? mask : -1;
  20939. },
  20940. enumerable: true,
  20941. configurable: true
  20942. });
  20943. /** @hidden */
  20944. FlyCamera.prototype._collideWithWorld = function (displacement) {
  20945. var globalPosition;
  20946. if (this.parent) {
  20947. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  20948. }
  20949. else {
  20950. globalPosition = this.position;
  20951. }
  20952. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  20953. this._oldPosition.addInPlace(this.ellipsoidOffset);
  20954. if (!this._collider) {
  20955. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__["Collider"]();
  20956. }
  20957. this._collider._radius = this.ellipsoid;
  20958. this._collider.collisionMask = this._collisionMask;
  20959. // No need for clone, as long as gravity is not on.
  20960. var actualDisplacement = displacement;
  20961. // Add gravity to direction to prevent dual-collision checking.
  20962. if (this.applyGravity) {
  20963. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  20964. actualDisplacement = displacement.add(this.getScene().gravity);
  20965. }
  20966. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20967. };
  20968. /** @hidden */
  20969. FlyCamera.prototype._checkInputs = function () {
  20970. if (!this._localDirection) {
  20971. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20972. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20973. }
  20974. this.inputs.checkInputs();
  20975. _super.prototype._checkInputs.call(this);
  20976. };
  20977. /** @hidden */
  20978. FlyCamera.prototype._decideIfNeedsToMove = function () {
  20979. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  20980. };
  20981. /** @hidden */
  20982. FlyCamera.prototype._updatePosition = function () {
  20983. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  20984. this._collideWithWorld(this.cameraDirection);
  20985. }
  20986. else {
  20987. _super.prototype._updatePosition.call(this);
  20988. }
  20989. };
  20990. /**
  20991. * Restore the Roll to its target value at the rate specified.
  20992. * @param rate - Higher means slower restoring.
  20993. * @hidden
  20994. */
  20995. FlyCamera.prototype.restoreRoll = function (rate) {
  20996. var limit = this._trackRoll; // Target Roll.
  20997. var z = this.rotation.z; // Current Roll.
  20998. var delta = limit - z; // Difference in Roll.
  20999. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21000. // If the difference is noticable, restore the Roll.
  21001. if (Math.abs(delta) >= minRad) {
  21002. // Change Z rotation towards the target Roll.
  21003. this.rotation.z += delta / rate;
  21004. // Match when near enough.
  21005. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21006. this.rotation.z = limit;
  21007. }
  21008. }
  21009. };
  21010. /**
  21011. * Destroy the camera and release the current resources held by it.
  21012. */
  21013. FlyCamera.prototype.dispose = function () {
  21014. this.inputs.clear();
  21015. _super.prototype.dispose.call(this);
  21016. };
  21017. /**
  21018. * Get the current object class name.
  21019. * @returns the class name.
  21020. */
  21021. FlyCamera.prototype.getClassName = function () {
  21022. return "FlyCamera";
  21023. };
  21024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21026. ], FlyCamera.prototype, "ellipsoid", void 0);
  21027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21029. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21032. ], FlyCamera.prototype, "checkCollisions", void 0);
  21033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21035. ], FlyCamera.prototype, "applyGravity", void 0);
  21036. return FlyCamera;
  21037. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21038. /***/ }),
  21039. /***/ "./Cameras/flyCameraInputsManager.ts":
  21040. /*!*******************************************!*\
  21041. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21042. \*******************************************/
  21043. /*! exports provided: FlyCameraInputsManager */
  21044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21045. "use strict";
  21046. __webpack_require__.r(__webpack_exports__);
  21047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21049. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21050. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21051. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21052. /**
  21053. * Default Inputs manager for the FlyCamera.
  21054. * It groups all the default supported inputs for ease of use.
  21055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21056. */
  21057. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21059. /**
  21060. * Instantiates a new FlyCameraInputsManager.
  21061. * @param camera Defines the camera the inputs belong to.
  21062. */
  21063. function FlyCameraInputsManager(camera) {
  21064. return _super.call(this, camera) || this;
  21065. }
  21066. /**
  21067. * Add keyboard input support to the input manager.
  21068. * @returns the new FlyCameraKeyboardMoveInput().
  21069. */
  21070. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21071. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21072. return this;
  21073. };
  21074. /**
  21075. * Add mouse input support to the input manager.
  21076. * @param touchEnabled Enable touch screen support.
  21077. * @returns the new FlyCameraMouseInput().
  21078. */
  21079. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21080. if (touchEnabled === void 0) { touchEnabled = true; }
  21081. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21082. return this;
  21083. };
  21084. return FlyCameraInputsManager;
  21085. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21086. /***/ }),
  21087. /***/ "./Cameras/followCamera.ts":
  21088. /*!*********************************!*\
  21089. !*** ./Cameras/followCamera.ts ***!
  21090. \*********************************/
  21091. /*! exports provided: FollowCamera, ArcFollowCamera */
  21092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21093. "use strict";
  21094. __webpack_require__.r(__webpack_exports__);
  21095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21097. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21098. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21099. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21100. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21102. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21103. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21104. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21105. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21106. });
  21107. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21108. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21109. });
  21110. /**
  21111. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21112. * an arc rotate version arcFollowCamera are available.
  21113. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21114. */
  21115. var FollowCamera = /** @class */ (function (_super) {
  21116. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21117. /**
  21118. * Instantiates the follow camera.
  21119. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21120. * @param name Define the name of the camera in the scene
  21121. * @param position Define the position of the camera
  21122. * @param scene Define the scene the camera belong to
  21123. * @param lockedTarget Define the target of the camera
  21124. */
  21125. function FollowCamera(name, position, scene, lockedTarget) {
  21126. if (lockedTarget === void 0) { lockedTarget = null; }
  21127. var _this = _super.call(this, name, position, scene) || this;
  21128. /**
  21129. * Distance the follow camera should follow an object at
  21130. */
  21131. _this.radius = 12;
  21132. /**
  21133. * Define a rotation offset between the camera and the object it follows
  21134. */
  21135. _this.rotationOffset = 0;
  21136. /**
  21137. * Define a height offset between the camera and the object it follows.
  21138. * It can help following an object from the top (like a car chaing a plane)
  21139. */
  21140. _this.heightOffset = 4;
  21141. /**
  21142. * Define how fast the camera can accelerate to follow it s target.
  21143. */
  21144. _this.cameraAcceleration = 0.05;
  21145. /**
  21146. * Define the speed limit of the camera following an object.
  21147. */
  21148. _this.maxCameraSpeed = 20;
  21149. _this.lockedTarget = lockedTarget;
  21150. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21151. _this.inputs.addKeyboard();
  21152. return _this;
  21153. // Uncomment the following line when the relevant handlers have been implemented.
  21154. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21155. }
  21156. FollowCamera.prototype._follow = function (cameraTarget) {
  21157. if (!cameraTarget) {
  21158. return;
  21159. }
  21160. var yRotation;
  21161. if (cameraTarget.rotationQuaternion) {
  21162. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21163. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21164. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21165. }
  21166. else {
  21167. yRotation = cameraTarget.rotation.y;
  21168. }
  21169. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21170. var targetPosition = cameraTarget.getAbsolutePosition();
  21171. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21172. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21173. var dx = targetX - this.position.x;
  21174. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21175. var dz = (targetZ) - this.position.z;
  21176. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21177. var vy = dy * this.cameraAcceleration;
  21178. var vz = dz * this.cameraAcceleration * 2;
  21179. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21180. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21181. }
  21182. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21183. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21184. }
  21185. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21186. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21187. }
  21188. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21189. this.setTarget(targetPosition);
  21190. };
  21191. /**
  21192. * Attached controls to the current camera.
  21193. * @param element Defines the element the controls should be listened from
  21194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21195. */
  21196. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21197. this.inputs.attachElement(element, noPreventDefault);
  21198. this._reset = function () {
  21199. };
  21200. };
  21201. /**
  21202. * Detach the current controls from the camera.
  21203. * The camera will stop reacting to inputs.
  21204. * @param element Defines the element to stop listening the inputs from
  21205. */
  21206. FollowCamera.prototype.detachControl = function (element) {
  21207. this.inputs.detachElement(element);
  21208. if (this._reset) {
  21209. this._reset();
  21210. }
  21211. };
  21212. /** @hidden */
  21213. FollowCamera.prototype._checkInputs = function () {
  21214. this.inputs.checkInputs();
  21215. _super.prototype._checkInputs.call(this);
  21216. if (this.lockedTarget) {
  21217. this._follow(this.lockedTarget);
  21218. }
  21219. };
  21220. /**
  21221. * Gets the camera class name.
  21222. * @returns the class name
  21223. */
  21224. FollowCamera.prototype.getClassName = function () {
  21225. return "FollowCamera";
  21226. };
  21227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21229. ], FollowCamera.prototype, "radius", void 0);
  21230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21232. ], FollowCamera.prototype, "rotationOffset", void 0);
  21233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21235. ], FollowCamera.prototype, "heightOffset", void 0);
  21236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21238. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21241. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21244. ], FollowCamera.prototype, "lockedTarget", void 0);
  21245. return FollowCamera;
  21246. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21247. /**
  21248. * Arc Rotate version of the follow camera.
  21249. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21250. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21251. */
  21252. var ArcFollowCamera = /** @class */ (function (_super) {
  21253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21254. /**
  21255. * Instantiates a new ArcFollowCamera
  21256. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21257. * @param name Define the name of the camera
  21258. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21259. * @param beta Define the rotation angle of the camera around the elevation axis
  21260. * @param radius Define the radius of the camera from its target point
  21261. * @param target Define the target of the camera
  21262. * @param scene Define the scene the camera belongs to
  21263. */
  21264. function ArcFollowCamera(name,
  21265. /** The longitudinal angle of the camera */
  21266. alpha,
  21267. /** The latitudinal angle of the camera */
  21268. beta,
  21269. /** The radius of the camera from its target */
  21270. radius,
  21271. /** Define the camera target (the messh it should follow) */
  21272. target, scene) {
  21273. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  21274. _this.alpha = alpha;
  21275. _this.beta = beta;
  21276. _this.radius = radius;
  21277. _this.target = target;
  21278. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  21279. _this._follow();
  21280. return _this;
  21281. }
  21282. ArcFollowCamera.prototype._follow = function () {
  21283. if (!this.target) {
  21284. return;
  21285. }
  21286. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  21287. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  21288. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  21289. var targetPosition = this.target.getAbsolutePosition();
  21290. this.position = targetPosition.add(this._cartesianCoordinates);
  21291. this.setTarget(targetPosition);
  21292. };
  21293. /** @hidden */
  21294. ArcFollowCamera.prototype._checkInputs = function () {
  21295. _super.prototype._checkInputs.call(this);
  21296. this._follow();
  21297. };
  21298. /**
  21299. * Returns the class name of the object.
  21300. * It is mostly used internally for serialization purposes.
  21301. */
  21302. ArcFollowCamera.prototype.getClassName = function () {
  21303. return "ArcFollowCamera";
  21304. };
  21305. return ArcFollowCamera;
  21306. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21307. /***/ }),
  21308. /***/ "./Cameras/followCameraInputsManager.ts":
  21309. /*!**********************************************!*\
  21310. !*** ./Cameras/followCameraInputsManager.ts ***!
  21311. \**********************************************/
  21312. /*! exports provided: FollowCameraInputsManager */
  21313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21314. "use strict";
  21315. __webpack_require__.r(__webpack_exports__);
  21316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  21317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21318. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21319. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  21320. /**
  21321. * Default Inputs manager for the FollowCamera.
  21322. * It groups all the default supported inputs for ease of use.
  21323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21324. */
  21325. var FollowCameraInputsManager = /** @class */ (function (_super) {
  21326. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  21327. /**
  21328. * Instantiates a new FollowCameraInputsManager.
  21329. * @param camera Defines the camera the inputs belong to
  21330. */
  21331. function FollowCameraInputsManager(camera) {
  21332. return _super.call(this, camera) || this;
  21333. }
  21334. /**
  21335. * Add keyboard input support to the input manager.
  21336. * @returns the current input manager
  21337. */
  21338. FollowCameraInputsManager.prototype.addKeyboard = function () {
  21339. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  21340. return this;
  21341. };
  21342. /**
  21343. * Add mouse wheel input support to the input manager.
  21344. * @returns the current input manager
  21345. */
  21346. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  21347. console.warn("MouseWheel support not yet implemented for FollowCamera.");
  21348. return this;
  21349. };
  21350. /**
  21351. * Add pointers input support to the input manager.
  21352. * @returns the current input manager
  21353. */
  21354. FollowCameraInputsManager.prototype.addPointers = function () {
  21355. console.warn("Pointer support not yet implemented for FollowCamera.");
  21356. return this;
  21357. };
  21358. /**
  21359. * Add orientation input support to the input manager.
  21360. * @returns the current input manager
  21361. */
  21362. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  21363. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  21364. return this;
  21365. };
  21366. return FollowCameraInputsManager;
  21367. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21368. /***/ }),
  21369. /***/ "./Cameras/freeCamera.ts":
  21370. /*!*******************************!*\
  21371. !*** ./Cameras/freeCamera.ts ***!
  21372. \*******************************/
  21373. /*! exports provided: FreeCamera */
  21374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21375. "use strict";
  21376. __webpack_require__.r(__webpack_exports__);
  21377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  21378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21379. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21381. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  21382. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21383. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21384. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  21385. /**
  21386. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21387. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  21388. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21389. */
  21390. var FreeCamera = /** @class */ (function (_super) {
  21391. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  21392. /**
  21393. * Instantiates a Free Camera.
  21394. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21395. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  21396. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21397. * @param name Define the name of the camera in the scene
  21398. * @param position Define the start position of the camera in the scene
  21399. * @param scene Define the scene the camera belongs to
  21400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  21401. */
  21402. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21403. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21404. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21405. /**
  21406. * Define the collision ellipsoid of the camera.
  21407. * This is helpful to simulate a camera body like the player body around the camera
  21408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21409. */
  21410. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  21411. /**
  21412. * Define an offset for the position of the ellipsoid around the camera.
  21413. * This can be helpful to determine the center of the body near the gravity center of the body
  21414. * instead of its head.
  21415. */
  21416. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21417. /**
  21418. * Enable or disable collisions of the camera with the rest of the scene objects.
  21419. */
  21420. _this.checkCollisions = false;
  21421. /**
  21422. * Enable or disable gravity on the camera.
  21423. */
  21424. _this.applyGravity = false;
  21425. _this._needMoveForGravity = false;
  21426. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21427. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21428. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21429. // Collisions
  21430. _this._collisionMask = -1;
  21431. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21432. if (collidedMesh === void 0) { collidedMesh = null; }
  21433. var updatePosition = function (newPos) {
  21434. _this._newPosition.copyFrom(newPos);
  21435. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21436. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  21437. _this.position.addInPlace(_this._diffPosition);
  21438. if (_this.onCollide && collidedMesh) {
  21439. _this.onCollide(collidedMesh);
  21440. }
  21441. }
  21442. };
  21443. updatePosition(newPosition);
  21444. };
  21445. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FreeCameraInputsManager"](_this);
  21446. _this.inputs.addKeyboard().addMouse();
  21447. return _this;
  21448. }
  21449. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  21450. /**
  21451. * Gets the input sensibility for a mouse input. (default is 2000.0)
  21452. * Higher values reduce sensitivity.
  21453. */
  21454. get: function () {
  21455. var mouse = this.inputs.attached["mouse"];
  21456. if (mouse) {
  21457. return mouse.angularSensibility;
  21458. }
  21459. return 0;
  21460. },
  21461. /**
  21462. * Sets the input sensibility for a mouse input. (default is 2000.0)
  21463. * Higher values reduce sensitivity.
  21464. */
  21465. set: function (value) {
  21466. var mouse = this.inputs.attached["mouse"];
  21467. if (mouse) {
  21468. mouse.angularSensibility = value;
  21469. }
  21470. },
  21471. enumerable: true,
  21472. configurable: true
  21473. });
  21474. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  21475. /**
  21476. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  21477. */
  21478. get: function () {
  21479. var keyboard = this.inputs.attached["keyboard"];
  21480. if (keyboard) {
  21481. return keyboard.keysUp;
  21482. }
  21483. return [];
  21484. },
  21485. set: function (value) {
  21486. var keyboard = this.inputs.attached["keyboard"];
  21487. if (keyboard) {
  21488. keyboard.keysUp = value;
  21489. }
  21490. },
  21491. enumerable: true,
  21492. configurable: true
  21493. });
  21494. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  21495. /**
  21496. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  21497. */
  21498. get: function () {
  21499. var keyboard = this.inputs.attached["keyboard"];
  21500. if (keyboard) {
  21501. return keyboard.keysDown;
  21502. }
  21503. return [];
  21504. },
  21505. set: function (value) {
  21506. var keyboard = this.inputs.attached["keyboard"];
  21507. if (keyboard) {
  21508. keyboard.keysDown = value;
  21509. }
  21510. },
  21511. enumerable: true,
  21512. configurable: true
  21513. });
  21514. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  21515. /**
  21516. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  21517. */
  21518. get: function () {
  21519. var keyboard = this.inputs.attached["keyboard"];
  21520. if (keyboard) {
  21521. return keyboard.keysLeft;
  21522. }
  21523. return [];
  21524. },
  21525. set: function (value) {
  21526. var keyboard = this.inputs.attached["keyboard"];
  21527. if (keyboard) {
  21528. keyboard.keysLeft = value;
  21529. }
  21530. },
  21531. enumerable: true,
  21532. configurable: true
  21533. });
  21534. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  21535. /**
  21536. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  21537. */
  21538. get: function () {
  21539. var keyboard = this.inputs.attached["keyboard"];
  21540. if (keyboard) {
  21541. return keyboard.keysRight;
  21542. }
  21543. return [];
  21544. },
  21545. set: function (value) {
  21546. var keyboard = this.inputs.attached["keyboard"];
  21547. if (keyboard) {
  21548. keyboard.keysRight = value;
  21549. }
  21550. },
  21551. enumerable: true,
  21552. configurable: true
  21553. });
  21554. /**
  21555. * Attached controls to the current camera.
  21556. * @param element Defines the element the controls should be listened from
  21557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21558. */
  21559. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  21560. this.inputs.attachElement(element, noPreventDefault);
  21561. };
  21562. /**
  21563. * Detach the current controls from the camera.
  21564. * The camera will stop reacting to inputs.
  21565. * @param element Defines the element to stop listening the inputs from
  21566. */
  21567. FreeCamera.prototype.detachControl = function (element) {
  21568. this.inputs.detachElement(element);
  21569. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21570. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  21571. };
  21572. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  21573. /**
  21574. * Define a collision mask to limit the list of object the camera can collide with
  21575. */
  21576. get: function () {
  21577. return this._collisionMask;
  21578. },
  21579. set: function (mask) {
  21580. this._collisionMask = !isNaN(mask) ? mask : -1;
  21581. },
  21582. enumerable: true,
  21583. configurable: true
  21584. });
  21585. /** @hidden */
  21586. FreeCamera.prototype._collideWithWorld = function (displacement) {
  21587. var globalPosition;
  21588. if (this.parent) {
  21589. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21590. }
  21591. else {
  21592. globalPosition = this.position;
  21593. }
  21594. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21595. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21596. if (!this._collider) {
  21597. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  21598. }
  21599. this._collider._radius = this.ellipsoid;
  21600. this._collider.collisionMask = this._collisionMask;
  21601. //no need for clone, as long as gravity is not on.
  21602. var actualDisplacement = displacement;
  21603. //add gravity to the direction to prevent the dual-collision checking
  21604. if (this.applyGravity) {
  21605. //this prevents mending with cameraDirection, a global variable of the free camera class.
  21606. actualDisplacement = displacement.add(this.getScene().gravity);
  21607. }
  21608. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21609. };
  21610. /** @hidden */
  21611. FreeCamera.prototype._checkInputs = function () {
  21612. if (!this._localDirection) {
  21613. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21614. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21615. }
  21616. this.inputs.checkInputs();
  21617. _super.prototype._checkInputs.call(this);
  21618. };
  21619. /** @hidden */
  21620. FreeCamera.prototype._decideIfNeedsToMove = function () {
  21621. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21622. };
  21623. /** @hidden */
  21624. FreeCamera.prototype._updatePosition = function () {
  21625. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21626. this._collideWithWorld(this.cameraDirection);
  21627. }
  21628. else {
  21629. _super.prototype._updatePosition.call(this);
  21630. }
  21631. };
  21632. /**
  21633. * Destroy the camera and release the current resources hold by it.
  21634. */
  21635. FreeCamera.prototype.dispose = function () {
  21636. this.inputs.clear();
  21637. _super.prototype.dispose.call(this);
  21638. };
  21639. /**
  21640. * Gets the current object class name.
  21641. * @return the class name
  21642. */
  21643. FreeCamera.prototype.getClassName = function () {
  21644. return "FreeCamera";
  21645. };
  21646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21648. ], FreeCamera.prototype, "ellipsoid", void 0);
  21649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21651. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  21652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21654. ], FreeCamera.prototype, "checkCollisions", void 0);
  21655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21657. ], FreeCamera.prototype, "applyGravity", void 0);
  21658. return FreeCamera;
  21659. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21660. /***/ }),
  21661. /***/ "./Cameras/freeCameraInputsManager.ts":
  21662. /*!********************************************!*\
  21663. !*** ./Cameras/freeCameraInputsManager.ts ***!
  21664. \********************************************/
  21665. /*! exports provided: FreeCameraInputsManager */
  21666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21667. "use strict";
  21668. __webpack_require__.r(__webpack_exports__);
  21669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  21670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21671. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21672. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  21673. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  21674. /* harmony import */ var _Cameras_Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21675. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  21676. /* harmony import */ var _Cameras_Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  21677. /**
  21678. * Default Inputs manager for the FreeCamera.
  21679. * It groups all the default supported inputs for ease of use.
  21680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21681. */
  21682. var FreeCameraInputsManager = /** @class */ (function (_super) {
  21683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  21684. /**
  21685. * Instantiates a new FreeCameraInputsManager.
  21686. * @param camera Defines the camera the inputs belong to
  21687. */
  21688. function FreeCameraInputsManager(camera) {
  21689. return _super.call(this, camera) || this;
  21690. }
  21691. /**
  21692. * Add keyboard input support to the input manager.
  21693. * @returns the current input manager
  21694. */
  21695. FreeCameraInputsManager.prototype.addKeyboard = function () {
  21696. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  21697. return this;
  21698. };
  21699. /**
  21700. * Add mouse input support to the input manager.
  21701. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  21702. * @returns the current input manager
  21703. */
  21704. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21705. if (touchEnabled === void 0) { touchEnabled = true; }
  21706. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  21707. return this;
  21708. };
  21709. /**
  21710. * Add orientation input support to the input manager.
  21711. * @returns the current input manager
  21712. */
  21713. FreeCameraInputsManager.prototype.addDeviceOrientation = function () {
  21714. this.add(new _Cameras_Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraDeviceOrientationInput"]());
  21715. return this;
  21716. };
  21717. /**
  21718. * Add touch input support to the input manager.
  21719. * @returns the current input manager
  21720. */
  21721. FreeCameraInputsManager.prototype.addTouch = function () {
  21722. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_5__["FreeCameraTouchInput"]());
  21723. return this;
  21724. };
  21725. /**
  21726. * Add virtual joystick input support to the input manager.
  21727. * @returns the current input manager
  21728. */
  21729. FreeCameraInputsManager.prototype.addVirtualJoystick = function () {
  21730. this.add(new _Cameras_Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_6__["FreeCameraVirtualJoystickInput"]());
  21731. return this;
  21732. };
  21733. return FreeCameraInputsManager;
  21734. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21735. /***/ }),
  21736. /***/ "./Cameras/gamepadCamera.ts":
  21737. /*!**********************************!*\
  21738. !*** ./Cameras/gamepadCamera.ts ***!
  21739. \**********************************/
  21740. /*! exports provided: GamepadCamera */
  21741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21742. "use strict";
  21743. __webpack_require__.r(__webpack_exports__);
  21744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  21745. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21746. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  21747. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21748. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21749. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  21750. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21751. });
  21752. /**
  21753. * This represents a FPS type of camera. This is only here for back compat purpose.
  21754. * Please use the UniversalCamera instead as both are identical.
  21755. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21756. */
  21757. var GamepadCamera = /** @class */ (function (_super) {
  21758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  21759. /**
  21760. * Instantiates a new Gamepad Camera
  21761. * This represents a FPS type of camera. This is only here for back compat purpose.
  21762. * Please use the UniversalCamera instead as both are identical.
  21763. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21764. * @param name Define the name of the camera in the scene
  21765. * @param position Define the start position of the camera in the scene
  21766. * @param scene Define the scene the camera belongs to
  21767. */
  21768. function GamepadCamera(name, position, scene) {
  21769. return _super.call(this, name, position, scene) || this;
  21770. }
  21771. /**
  21772. * Gets the current object class name.
  21773. * @return the class name
  21774. */
  21775. GamepadCamera.prototype.getClassName = function () {
  21776. return "GamepadCamera";
  21777. };
  21778. return GamepadCamera;
  21779. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  21780. /***/ }),
  21781. /***/ "./Cameras/index.ts":
  21782. /*!**************************!*\
  21783. !*** ./Cameras/index.ts ***!
  21784. \**************************/
  21785. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, VRCameraMetrics, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  21786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21787. "use strict";
  21788. __webpack_require__.r(__webpack_exports__);
  21789. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  21790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  21791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  21792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  21793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  21794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  21795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  21796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  21797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  21798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  21799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  21800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  21801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  21802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  21803. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  21805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  21806. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  21808. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  21810. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  21812. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  21813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  21814. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  21815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  21816. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  21817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  21818. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  21819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  21820. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  21821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  21822. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  21823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  21824. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  21826. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  21827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  21828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  21829. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  21830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  21831. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  21832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  21833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  21834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  21835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  21836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  21837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  21838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  21839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  21840. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  21841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  21842. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  21843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  21844. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  21845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  21846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  21847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  21848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  21849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  21850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  21851. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  21852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  21853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  21854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  21855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  21856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  21857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  21858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  21859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  21860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  21861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  21862. /***/ }),
  21863. /***/ "./Cameras/targetCamera.ts":
  21864. /*!*********************************!*\
  21865. !*** ./Cameras/targetCamera.ts ***!
  21866. \*********************************/
  21867. /*! exports provided: TargetCamera */
  21868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21869. "use strict";
  21870. __webpack_require__.r(__webpack_exports__);
  21871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  21872. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21873. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21874. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21876. /**
  21877. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  21878. * This is the base of the follow, arc rotate cameras and Free camera
  21879. * @see http://doc.babylonjs.com/features/cameras
  21880. */
  21881. var TargetCamera = /** @class */ (function (_super) {
  21882. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  21883. /**
  21884. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  21885. * This is the base of the follow, arc rotate cameras and Free camera
  21886. * @see http://doc.babylonjs.com/features/cameras
  21887. * @param name Defines the name of the camera in the scene
  21888. * @param position Defines the start position of the camera in the scene
  21889. * @param scene Defines the scene the camera belongs to
  21890. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  21891. */
  21892. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21893. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21894. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21895. /**
  21896. * Define the current direction the camera is moving to
  21897. */
  21898. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  21899. /**
  21900. * Define the current rotation the camera is rotating to
  21901. */
  21902. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  21903. /**
  21904. * When set, the up vector of the camera will be updated by the rotation of the camera
  21905. */
  21906. _this.updateUpVectorFromRotation = false;
  21907. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  21908. /**
  21909. * Define the current rotation of the camera
  21910. */
  21911. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  21912. /**
  21913. * Define the current speed of the camera
  21914. */
  21915. _this.speed = 2.0;
  21916. /**
  21917. * Add cconstraint to the camera to prevent it to move freely in all directions and
  21918. * around all axis.
  21919. */
  21920. _this.noRotationConstraint = false;
  21921. /**
  21922. * Define the current target of the camera as an object or a position.
  21923. */
  21924. _this.lockedTarget = null;
  21925. /** @hidden */
  21926. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  21927. /** @hidden */
  21928. _this._initialFocalDistance = 1;
  21929. /** @hidden */
  21930. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  21931. /** @hidden */
  21932. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  21933. /** @hidden */
  21934. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  21935. /** @hidden */
  21936. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  21937. /** @hidden */
  21938. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  21939. /** @hidden */
  21940. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  21941. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  21942. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  21943. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  21944. _this._cachedRotationZ = 0;
  21945. _this._cachedQuaternionRotationZ = 0;
  21946. return _this;
  21947. }
  21948. /**
  21949. * Gets the position in front of the camera at a given distance.
  21950. * @param distance The distance from the camera we want the position to be
  21951. * @returns the position
  21952. */
  21953. TargetCamera.prototype.getFrontPosition = function (distance) {
  21954. this.getWorldMatrix();
  21955. var direction = this.getTarget().subtract(this.position);
  21956. direction.normalize();
  21957. direction.scaleInPlace(distance);
  21958. return this.globalPosition.add(direction);
  21959. };
  21960. /** @hidden */
  21961. TargetCamera.prototype._getLockedTargetPosition = function () {
  21962. if (!this.lockedTarget) {
  21963. return null;
  21964. }
  21965. if (this.lockedTarget.absolutePosition) {
  21966. this.lockedTarget.computeWorldMatrix();
  21967. }
  21968. return this.lockedTarget.absolutePosition || this.lockedTarget;
  21969. };
  21970. /**
  21971. * Store current camera state of the camera (fov, position, rotation, etc..)
  21972. * @returns the camera
  21973. */
  21974. TargetCamera.prototype.storeState = function () {
  21975. this._storedPosition = this.position.clone();
  21976. this._storedRotation = this.rotation.clone();
  21977. if (this.rotationQuaternion) {
  21978. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  21979. }
  21980. return _super.prototype.storeState.call(this);
  21981. };
  21982. /**
  21983. * Restored camera state. You must call storeState() first
  21984. * @returns whether it was successful or not
  21985. * @hidden
  21986. */
  21987. TargetCamera.prototype._restoreStateValues = function () {
  21988. if (!_super.prototype._restoreStateValues.call(this)) {
  21989. return false;
  21990. }
  21991. this.position = this._storedPosition.clone();
  21992. this.rotation = this._storedRotation.clone();
  21993. if (this.rotationQuaternion) {
  21994. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  21995. }
  21996. this.cameraDirection.copyFromFloats(0, 0, 0);
  21997. this.cameraRotation.copyFromFloats(0, 0);
  21998. return true;
  21999. };
  22000. /** @hidden */
  22001. TargetCamera.prototype._initCache = function () {
  22002. _super.prototype._initCache.call(this);
  22003. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22004. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22005. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22006. };
  22007. /** @hidden */
  22008. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22009. if (!ignoreParentClass) {
  22010. _super.prototype._updateCache.call(this);
  22011. }
  22012. var lockedTargetPosition = this._getLockedTargetPosition();
  22013. if (!lockedTargetPosition) {
  22014. this._cache.lockedTarget = null;
  22015. }
  22016. else {
  22017. if (!this._cache.lockedTarget) {
  22018. this._cache.lockedTarget = lockedTargetPosition.clone();
  22019. }
  22020. else {
  22021. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22022. }
  22023. }
  22024. this._cache.rotation.copyFrom(this.rotation);
  22025. if (this.rotationQuaternion) {
  22026. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22027. }
  22028. };
  22029. // Synchronized
  22030. /** @hidden */
  22031. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22032. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22033. return false;
  22034. }
  22035. var lockedTargetPosition = this._getLockedTargetPosition();
  22036. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22037. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22038. };
  22039. // Methods
  22040. /** @hidden */
  22041. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22042. var engine = this.getEngine();
  22043. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22044. };
  22045. // Target
  22046. /** @hidden */
  22047. TargetCamera.prototype.setTarget = function (target) {
  22048. this.upVector.normalize();
  22049. this._initialFocalDistance = target.subtract(this.position).length();
  22050. if (this.position.z === target.z) {
  22051. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22052. }
  22053. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22054. this._camMatrix.invert();
  22055. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22056. var vDir = target.subtract(this.position);
  22057. if (vDir.x >= 0.0) {
  22058. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22059. }
  22060. else {
  22061. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22062. }
  22063. this.rotation.z = 0;
  22064. if (isNaN(this.rotation.x)) {
  22065. this.rotation.x = 0;
  22066. }
  22067. if (isNaN(this.rotation.y)) {
  22068. this.rotation.y = 0;
  22069. }
  22070. if (isNaN(this.rotation.z)) {
  22071. this.rotation.z = 0;
  22072. }
  22073. if (this.rotationQuaternion) {
  22074. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22075. }
  22076. };
  22077. /**
  22078. * Return the current target position of the camera. This value is expressed in local space.
  22079. * @returns the target position
  22080. */
  22081. TargetCamera.prototype.getTarget = function () {
  22082. return this._currentTarget;
  22083. };
  22084. /** @hidden */
  22085. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22086. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22087. };
  22088. /** @hidden */
  22089. TargetCamera.prototype._updatePosition = function () {
  22090. if (this.parent) {
  22091. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22092. _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]);
  22093. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22094. return;
  22095. }
  22096. this.position.addInPlace(this.cameraDirection);
  22097. };
  22098. /** @hidden */
  22099. TargetCamera.prototype._checkInputs = function () {
  22100. var needToMove = this._decideIfNeedsToMove();
  22101. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22102. // Move
  22103. if (needToMove) {
  22104. this._updatePosition();
  22105. }
  22106. // Rotate
  22107. if (needToRotate) {
  22108. this.rotation.x += this.cameraRotation.x;
  22109. this.rotation.y += this.cameraRotation.y;
  22110. //rotate, if quaternion is set and rotation was used
  22111. if (this.rotationQuaternion) {
  22112. var len = this.rotation.lengthSquared();
  22113. if (len) {
  22114. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22115. }
  22116. }
  22117. if (!this.noRotationConstraint) {
  22118. var limit = (Math.PI / 2) * 0.95;
  22119. if (this.rotation.x > limit) {
  22120. this.rotation.x = limit;
  22121. }
  22122. if (this.rotation.x < -limit) {
  22123. this.rotation.x = -limit;
  22124. }
  22125. }
  22126. }
  22127. // Inertia
  22128. if (needToMove) {
  22129. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22130. this.cameraDirection.x = 0;
  22131. }
  22132. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22133. this.cameraDirection.y = 0;
  22134. }
  22135. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22136. this.cameraDirection.z = 0;
  22137. }
  22138. this.cameraDirection.scaleInPlace(this.inertia);
  22139. }
  22140. if (needToRotate) {
  22141. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22142. this.cameraRotation.x = 0;
  22143. }
  22144. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22145. this.cameraRotation.y = 0;
  22146. }
  22147. this.cameraRotation.scaleInPlace(this.inertia);
  22148. }
  22149. _super.prototype._checkInputs.call(this);
  22150. };
  22151. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22152. if (this.rotationQuaternion) {
  22153. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22154. }
  22155. else {
  22156. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22157. }
  22158. };
  22159. /**
  22160. * 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)
  22161. * @returns the current camera
  22162. */
  22163. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22164. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22165. return this;
  22166. };
  22167. /** @hidden */
  22168. TargetCamera.prototype._getViewMatrix = function () {
  22169. if (this.lockedTarget) {
  22170. this.setTarget(this._getLockedTargetPosition());
  22171. }
  22172. // Compute
  22173. this._updateCameraRotationMatrix();
  22174. // Apply the changed rotation to the upVector
  22175. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22176. this._rotateUpVectorWithCameraRotationMatrix();
  22177. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22178. }
  22179. else if (this._cachedRotationZ != this.rotation.z) {
  22180. this._rotateUpVectorWithCameraRotationMatrix();
  22181. this._cachedRotationZ = this.rotation.z;
  22182. }
  22183. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22184. // Computing target and final matrix
  22185. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22186. if (this.updateUpVectorFromRotation) {
  22187. if (this.rotationQuaternion) {
  22188. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22189. }
  22190. else {
  22191. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22192. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22193. }
  22194. }
  22195. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22196. return this._viewMatrix;
  22197. };
  22198. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22199. if (this.parent) {
  22200. var parentWorldMatrix = this.parent.getWorldMatrix();
  22201. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22202. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22203. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22204. this._markSyncedWithParent();
  22205. }
  22206. else {
  22207. this._globalPosition.copyFrom(position);
  22208. this._globalCurrentTarget.copyFrom(target);
  22209. this._globalCurrentUpVector.copyFrom(up);
  22210. }
  22211. if (this.getScene().useRightHandedSystem) {
  22212. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22213. }
  22214. else {
  22215. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22216. }
  22217. };
  22218. /**
  22219. * @hidden
  22220. */
  22221. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22222. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22223. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22224. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22225. if (!this.rotationQuaternion) {
  22226. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22227. }
  22228. rigCamera._cameraRigParams = {};
  22229. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22230. }
  22231. return rigCamera;
  22232. }
  22233. return null;
  22234. };
  22235. /**
  22236. * @hidden
  22237. */
  22238. TargetCamera.prototype._updateRigCameras = function () {
  22239. var camLeft = this._rigCameras[0];
  22240. var camRight = this._rigCameras[1];
  22241. this.computeWorldMatrix();
  22242. switch (this.cameraRigMode) {
  22243. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22244. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22245. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22246. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22247. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22248. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22249. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22250. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22251. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22252. break;
  22253. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22254. if (camLeft.rotationQuaternion) {
  22255. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22256. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22257. }
  22258. else {
  22259. camLeft.rotation.copyFrom(this.rotation);
  22260. camRight.rotation.copyFrom(this.rotation);
  22261. }
  22262. camLeft.position.copyFrom(this.position);
  22263. camRight.position.copyFrom(this.position);
  22264. break;
  22265. }
  22266. _super.prototype._updateRigCameras.call(this);
  22267. };
  22268. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22269. var target = this.getTarget();
  22270. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22271. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22272. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22273. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22274. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22275. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22276. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22277. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22278. rigCamera.setTarget(newFocalTarget);
  22279. };
  22280. /**
  22281. * Gets the current object class name.
  22282. * @return the class name
  22283. */
  22284. TargetCamera.prototype.getClassName = function () {
  22285. return "TargetCamera";
  22286. };
  22287. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22288. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22289. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  22290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22292. ], TargetCamera.prototype, "rotation", void 0);
  22293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22295. ], TargetCamera.prototype, "speed", void 0);
  22296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22298. ], TargetCamera.prototype, "lockedTarget", void 0);
  22299. return TargetCamera;
  22300. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  22301. /***/ }),
  22302. /***/ "./Cameras/touchCamera.ts":
  22303. /*!********************************!*\
  22304. !*** ./Cameras/touchCamera.ts ***!
  22305. \********************************/
  22306. /*! exports provided: TouchCamera */
  22307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22308. "use strict";
  22309. __webpack_require__.r(__webpack_exports__);
  22310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  22311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22312. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22314. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22315. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  22316. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22317. });
  22318. /**
  22319. * This represents a FPS type of camera controlled by touch.
  22320. * This is like a universal camera minus the Gamepad controls.
  22321. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22322. */
  22323. var TouchCamera = /** @class */ (function (_super) {
  22324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  22325. /**
  22326. * Instantiates a new touch camera.
  22327. * This represents a FPS type of camera controlled by touch.
  22328. * This is like a universal camera minus the Gamepad controls.
  22329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22330. * @param name Define the name of the camera in the scene
  22331. * @param position Define the start position of the camera in the scene
  22332. * @param scene Define the scene the camera belongs to
  22333. */
  22334. function TouchCamera(name, position, scene) {
  22335. var _this = _super.call(this, name, position, scene) || this;
  22336. _this.inputs.addTouch();
  22337. _this._setupInputs();
  22338. return _this;
  22339. }
  22340. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  22341. /**
  22342. * Defines the touch sensibility for rotation.
  22343. * The higher the faster.
  22344. */
  22345. get: function () {
  22346. var touch = this.inputs.attached["touch"];
  22347. if (touch) {
  22348. return touch.touchAngularSensibility;
  22349. }
  22350. return 0;
  22351. },
  22352. set: function (value) {
  22353. var touch = this.inputs.attached["touch"];
  22354. if (touch) {
  22355. touch.touchAngularSensibility = value;
  22356. }
  22357. },
  22358. enumerable: true,
  22359. configurable: true
  22360. });
  22361. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  22362. /**
  22363. * Defines the touch sensibility for move.
  22364. * The higher the faster.
  22365. */
  22366. get: function () {
  22367. var touch = this.inputs.attached["touch"];
  22368. if (touch) {
  22369. return touch.touchMoveSensibility;
  22370. }
  22371. return 0;
  22372. },
  22373. set: function (value) {
  22374. var touch = this.inputs.attached["touch"];
  22375. if (touch) {
  22376. touch.touchMoveSensibility = value;
  22377. }
  22378. },
  22379. enumerable: true,
  22380. configurable: true
  22381. });
  22382. /**
  22383. * Gets the current object class name.
  22384. * @return the class name
  22385. */
  22386. TouchCamera.prototype.getClassName = function () {
  22387. return "TouchCamera";
  22388. };
  22389. /** @hidden */
  22390. TouchCamera.prototype._setupInputs = function () {
  22391. var mouse = this.inputs.attached["mouse"];
  22392. if (mouse) {
  22393. mouse.touchEnabled = false;
  22394. }
  22395. };
  22396. return TouchCamera;
  22397. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22398. /***/ }),
  22399. /***/ "./Cameras/universalCamera.ts":
  22400. /*!************************************!*\
  22401. !*** ./Cameras/universalCamera.ts ***!
  22402. \************************************/
  22403. /*! exports provided: UniversalCamera */
  22404. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22405. "use strict";
  22406. __webpack_require__.r(__webpack_exports__);
  22407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  22408. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22409. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22410. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  22411. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22412. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22413. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  22414. // Forcing to use the Universal camera
  22415. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  22416. });
  22417. /**
  22418. * 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,
  22419. * which still works and will still be found in many Playgrounds.
  22420. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22421. */
  22422. var UniversalCamera = /** @class */ (function (_super) {
  22423. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  22424. /**
  22425. * 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,
  22426. * which still works and will still be found in many Playgrounds.
  22427. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22428. * @param name Define the name of the camera in the scene
  22429. * @param position Define the start position of the camera in the scene
  22430. * @param scene Define the scene the camera belongs to
  22431. */
  22432. function UniversalCamera(name, position, scene) {
  22433. var _this = _super.call(this, name, position, scene) || this;
  22434. _this.inputs.addGamepad();
  22435. return _this;
  22436. }
  22437. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  22438. /**
  22439. * Defines the gamepad rotation sensiblity.
  22440. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  22441. */
  22442. get: function () {
  22443. var gamepad = this.inputs.attached["gamepad"];
  22444. if (gamepad) {
  22445. return gamepad.gamepadAngularSensibility;
  22446. }
  22447. return 0;
  22448. },
  22449. set: function (value) {
  22450. var gamepad = this.inputs.attached["gamepad"];
  22451. if (gamepad) {
  22452. gamepad.gamepadAngularSensibility = value;
  22453. }
  22454. },
  22455. enumerable: true,
  22456. configurable: true
  22457. });
  22458. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  22459. /**
  22460. * Defines the gamepad move sensiblity.
  22461. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  22462. */
  22463. get: function () {
  22464. var gamepad = this.inputs.attached["gamepad"];
  22465. if (gamepad) {
  22466. return gamepad.gamepadMoveSensibility;
  22467. }
  22468. return 0;
  22469. },
  22470. set: function (value) {
  22471. var gamepad = this.inputs.attached["gamepad"];
  22472. if (gamepad) {
  22473. gamepad.gamepadMoveSensibility = value;
  22474. }
  22475. },
  22476. enumerable: true,
  22477. configurable: true
  22478. });
  22479. /**
  22480. * Gets the current object class name.
  22481. * @return the class name
  22482. */
  22483. UniversalCamera.prototype.getClassName = function () {
  22484. return "UniversalCamera";
  22485. };
  22486. return UniversalCamera;
  22487. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  22488. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  22489. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  22490. };
  22491. /***/ }),
  22492. /***/ "./Cameras/virtualJoysticksCamera.ts":
  22493. /*!*******************************************!*\
  22494. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  22495. \*******************************************/
  22496. /*! exports provided: VirtualJoysticksCamera */
  22497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22498. "use strict";
  22499. __webpack_require__.r(__webpack_exports__);
  22500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  22501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22502. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22503. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22504. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22505. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  22506. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22507. });
  22508. /**
  22509. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22510. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22511. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22512. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22513. */
  22514. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  22515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  22516. /**
  22517. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  22518. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22519. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22520. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22521. * @param name Define the name of the camera in the scene
  22522. * @param position Define the start position of the camera in the scene
  22523. * @param scene Define the scene the camera belongs to
  22524. */
  22525. function VirtualJoysticksCamera(name, position, scene) {
  22526. var _this = _super.call(this, name, position, scene) || this;
  22527. _this.inputs.addVirtualJoystick();
  22528. return _this;
  22529. }
  22530. /**
  22531. * Gets the current object class name.
  22532. * @return the class name
  22533. */
  22534. VirtualJoysticksCamera.prototype.getClassName = function () {
  22535. return "VirtualJoysticksCamera";
  22536. };
  22537. return VirtualJoysticksCamera;
  22538. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22539. /***/ }),
  22540. /***/ "./Collisions/collider.ts":
  22541. /*!********************************!*\
  22542. !*** ./Collisions/collider.ts ***!
  22543. \********************************/
  22544. /*! exports provided: Collider */
  22545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22546. "use strict";
  22547. __webpack_require__.r(__webpack_exports__);
  22548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  22549. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22550. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  22551. if (boxMin.x > sphereCenter.x + sphereRadius) {
  22552. return false;
  22553. }
  22554. if (sphereCenter.x - sphereRadius > boxMax.x) {
  22555. return false;
  22556. }
  22557. if (boxMin.y > sphereCenter.y + sphereRadius) {
  22558. return false;
  22559. }
  22560. if (sphereCenter.y - sphereRadius > boxMax.y) {
  22561. return false;
  22562. }
  22563. if (boxMin.z > sphereCenter.z + sphereRadius) {
  22564. return false;
  22565. }
  22566. if (sphereCenter.z - sphereRadius > boxMax.z) {
  22567. return false;
  22568. }
  22569. return true;
  22570. };
  22571. var getLowestRoot = (function () {
  22572. var result = { root: 0, found: false };
  22573. return function (a, b, c, maxR) {
  22574. result.root = 0;
  22575. result.found = false;
  22576. var determinant = b * b - 4.0 * a * c;
  22577. if (determinant < 0) {
  22578. return result;
  22579. }
  22580. var sqrtD = Math.sqrt(determinant);
  22581. var r1 = (-b - sqrtD) / (2.0 * a);
  22582. var r2 = (-b + sqrtD) / (2.0 * a);
  22583. if (r1 > r2) {
  22584. var temp = r2;
  22585. r2 = r1;
  22586. r1 = temp;
  22587. }
  22588. if (r1 > 0 && r1 < maxR) {
  22589. result.root = r1;
  22590. result.found = true;
  22591. return result;
  22592. }
  22593. if (r2 > 0 && r2 < maxR) {
  22594. result.root = r2;
  22595. result.found = true;
  22596. return result;
  22597. }
  22598. return result;
  22599. };
  22600. })();
  22601. /** @hidden */
  22602. var Collider = /** @class */ (function () {
  22603. function Collider() {
  22604. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22605. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22606. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22607. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22608. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22609. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22610. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22611. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22612. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22613. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22614. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22615. /** @hidden */
  22616. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  22617. /** @hidden */
  22618. this._retry = 0;
  22619. /** @hidden */
  22620. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22621. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22622. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22623. this._collisionMask = -1;
  22624. }
  22625. Object.defineProperty(Collider.prototype, "collisionMask", {
  22626. get: function () {
  22627. return this._collisionMask;
  22628. },
  22629. set: function (mask) {
  22630. this._collisionMask = !isNaN(mask) ? mask : -1;
  22631. },
  22632. enumerable: true,
  22633. configurable: true
  22634. });
  22635. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  22636. /**
  22637. * Gets the plane normal used to compute the sliding response (in local space)
  22638. */
  22639. get: function () {
  22640. return this._slidePlaneNormal;
  22641. },
  22642. enumerable: true,
  22643. configurable: true
  22644. });
  22645. // Methods
  22646. /** @hidden */
  22647. Collider.prototype._initialize = function (source, dir, e) {
  22648. this._velocity = dir;
  22649. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  22650. this._basePoint = source;
  22651. source.multiplyToRef(this._radius, this._basePointWorld);
  22652. dir.multiplyToRef(this._radius, this._velocityWorld);
  22653. this._velocityWorldLength = this._velocityWorld.length();
  22654. this._epsilon = e;
  22655. this.collisionFound = false;
  22656. };
  22657. /** @hidden */
  22658. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  22659. pa.subtractToRef(point, this._tempVector);
  22660. pb.subtractToRef(point, this._tempVector2);
  22661. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  22662. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22663. if (d < 0) {
  22664. return false;
  22665. }
  22666. pc.subtractToRef(point, this._tempVector3);
  22667. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  22668. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22669. if (d < 0) {
  22670. return false;
  22671. }
  22672. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  22673. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22674. return d >= 0;
  22675. };
  22676. /** @hidden */
  22677. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  22678. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  22679. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  22680. if (distance > this._velocityWorldLength + max + sphereRadius) {
  22681. return false;
  22682. }
  22683. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  22684. return false;
  22685. }
  22686. return true;
  22687. };
  22688. /** @hidden */
  22689. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  22690. var t0;
  22691. var embeddedInPlane = false;
  22692. //defensive programming, actually not needed.
  22693. if (!trianglePlaneArray) {
  22694. trianglePlaneArray = [];
  22695. }
  22696. if (!trianglePlaneArray[faceIndex]) {
  22697. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  22698. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  22699. }
  22700. var trianglePlane = trianglePlaneArray[faceIndex];
  22701. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  22702. return;
  22703. }
  22704. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  22705. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  22706. if (normalDotVelocity == 0) {
  22707. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  22708. return;
  22709. }
  22710. embeddedInPlane = true;
  22711. t0 = 0;
  22712. }
  22713. else {
  22714. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22715. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22716. if (t0 > t1) {
  22717. var temp = t1;
  22718. t1 = t0;
  22719. t0 = temp;
  22720. }
  22721. if (t0 > 1.0 || t1 < 0.0) {
  22722. return;
  22723. }
  22724. if (t0 < 0) {
  22725. t0 = 0;
  22726. }
  22727. if (t0 > 1.0) {
  22728. t0 = 1.0;
  22729. }
  22730. }
  22731. this._collisionPoint.copyFromFloats(0, 0, 0);
  22732. var found = false;
  22733. var t = 1.0;
  22734. if (!embeddedInPlane) {
  22735. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  22736. this._velocity.scaleToRef(t0, this._tempVector);
  22737. this._planeIntersectionPoint.addInPlace(this._tempVector);
  22738. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  22739. found = true;
  22740. t = t0;
  22741. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  22742. }
  22743. }
  22744. if (!found) {
  22745. var velocitySquaredLength = this._velocity.lengthSquared();
  22746. var a = velocitySquaredLength;
  22747. this._basePoint.subtractToRef(p1, this._tempVector);
  22748. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22749. var c = this._tempVector.lengthSquared() - 1.0;
  22750. var lowestRoot = getLowestRoot(a, b, c, t);
  22751. if (lowestRoot.found) {
  22752. t = lowestRoot.root;
  22753. found = true;
  22754. this._collisionPoint.copyFrom(p1);
  22755. }
  22756. this._basePoint.subtractToRef(p2, this._tempVector);
  22757. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22758. c = this._tempVector.lengthSquared() - 1.0;
  22759. lowestRoot = getLowestRoot(a, b, c, t);
  22760. if (lowestRoot.found) {
  22761. t = lowestRoot.root;
  22762. found = true;
  22763. this._collisionPoint.copyFrom(p2);
  22764. }
  22765. this._basePoint.subtractToRef(p3, this._tempVector);
  22766. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22767. c = this._tempVector.lengthSquared() - 1.0;
  22768. lowestRoot = getLowestRoot(a, b, c, t);
  22769. if (lowestRoot.found) {
  22770. t = lowestRoot.root;
  22771. found = true;
  22772. this._collisionPoint.copyFrom(p3);
  22773. }
  22774. p2.subtractToRef(p1, this._edge);
  22775. p1.subtractToRef(this._basePoint, this._baseToVertex);
  22776. var edgeSquaredLength = this._edge.lengthSquared();
  22777. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22778. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22779. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22780. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22781. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22782. lowestRoot = getLowestRoot(a, b, c, t);
  22783. if (lowestRoot.found) {
  22784. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22785. if (f >= 0.0 && f <= 1.0) {
  22786. t = lowestRoot.root;
  22787. found = true;
  22788. this._edge.scaleInPlace(f);
  22789. p1.addToRef(this._edge, this._collisionPoint);
  22790. }
  22791. }
  22792. p3.subtractToRef(p2, this._edge);
  22793. p2.subtractToRef(this._basePoint, this._baseToVertex);
  22794. edgeSquaredLength = this._edge.lengthSquared();
  22795. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22796. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22797. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22798. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22799. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22800. lowestRoot = getLowestRoot(a, b, c, t);
  22801. if (lowestRoot.found) {
  22802. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22803. if (f >= 0.0 && f <= 1.0) {
  22804. t = lowestRoot.root;
  22805. found = true;
  22806. this._edge.scaleInPlace(f);
  22807. p2.addToRef(this._edge, this._collisionPoint);
  22808. }
  22809. }
  22810. p1.subtractToRef(p3, this._edge);
  22811. p3.subtractToRef(this._basePoint, this._baseToVertex);
  22812. edgeSquaredLength = this._edge.lengthSquared();
  22813. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22814. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22815. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22816. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22817. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22818. lowestRoot = getLowestRoot(a, b, c, t);
  22819. if (lowestRoot.found) {
  22820. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22821. if (f >= 0.0 && f <= 1.0) {
  22822. t = lowestRoot.root;
  22823. found = true;
  22824. this._edge.scaleInPlace(f);
  22825. p3.addToRef(this._edge, this._collisionPoint);
  22826. }
  22827. }
  22828. }
  22829. if (found) {
  22830. var distToCollision = t * this._velocity.length();
  22831. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  22832. if (!this.intersectionPoint) {
  22833. this.intersectionPoint = this._collisionPoint.clone();
  22834. }
  22835. else {
  22836. this.intersectionPoint.copyFrom(this._collisionPoint);
  22837. }
  22838. this._nearestDistance = distToCollision;
  22839. this.collisionFound = true;
  22840. }
  22841. }
  22842. };
  22843. /** @hidden */
  22844. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  22845. for (var i = indexStart; i < indexEnd; i += 3) {
  22846. var p1 = pts[indices[i] - decal];
  22847. var p2 = pts[indices[i + 1] - decal];
  22848. var p3 = pts[indices[i + 2] - decal];
  22849. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  22850. }
  22851. };
  22852. /** @hidden */
  22853. Collider.prototype._getResponse = function (pos, vel) {
  22854. pos.addToRef(vel, this._destinationPoint);
  22855. vel.scaleInPlace((this._nearestDistance / vel.length()));
  22856. this._basePoint.addToRef(vel, pos);
  22857. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  22858. this._slidePlaneNormal.normalize();
  22859. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  22860. pos.addInPlace(this._displacementVector);
  22861. this.intersectionPoint.addInPlace(this._displacementVector);
  22862. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  22863. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  22864. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  22865. };
  22866. return Collider;
  22867. }());
  22868. /***/ }),
  22869. /***/ "./Collisions/collisionCoordinator.ts":
  22870. /*!********************************************!*\
  22871. !*** ./Collisions/collisionCoordinator.ts ***!
  22872. \********************************************/
  22873. /*! exports provided: CollisionCoordinatorLegacy */
  22874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22875. "use strict";
  22876. __webpack_require__.r(__webpack_exports__);
  22877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return CollisionCoordinatorLegacy; });
  22878. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22879. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22880. /** @hidden */
  22881. var CollisionCoordinatorLegacy = /** @class */ (function () {
  22882. function CollisionCoordinatorLegacy() {
  22883. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22884. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22885. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22886. }
  22887. CollisionCoordinatorLegacy.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  22888. position.divideToRef(collider._radius, this._scaledPosition);
  22889. displacement.divideToRef(collider._radius, this._scaledVelocity);
  22890. collider.collidedMesh = null;
  22891. collider._retry = 0;
  22892. collider._initialVelocity = this._scaledVelocity;
  22893. collider._initialPosition = this._scaledPosition;
  22894. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  22895. this._finalPosition.multiplyInPlace(collider._radius);
  22896. //run the callback
  22897. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  22898. };
  22899. CollisionCoordinatorLegacy.prototype.init = function (scene) {
  22900. this._scene = scene;
  22901. };
  22902. CollisionCoordinatorLegacy.prototype.destroy = function () {
  22903. //Legacy need no destruction method.
  22904. };
  22905. //No update in legacy mode
  22906. CollisionCoordinatorLegacy.prototype.onMeshAdded = function (mesh) { };
  22907. CollisionCoordinatorLegacy.prototype.onMeshUpdated = function (mesh) { };
  22908. CollisionCoordinatorLegacy.prototype.onMeshRemoved = function (mesh) { };
  22909. CollisionCoordinatorLegacy.prototype.onGeometryAdded = function (geometry) { };
  22910. CollisionCoordinatorLegacy.prototype.onGeometryUpdated = function (geometry) { };
  22911. CollisionCoordinatorLegacy.prototype.onGeometryDeleted = function (geometry) { };
  22912. CollisionCoordinatorLegacy.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  22913. if (excludedMesh === void 0) { excludedMesh = null; }
  22914. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].CollisionsEpsilon * 10.0;
  22915. if (collider._retry >= maximumRetry) {
  22916. finalPosition.copyFrom(position);
  22917. return;
  22918. }
  22919. // Check if this is a mesh else camera or -1
  22920. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  22921. collider._initialize(position, velocity, closeDistance);
  22922. // Check all meshes
  22923. for (var index = 0; index < this._scene.meshes.length; index++) {
  22924. var mesh = this._scene.meshes[index];
  22925. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  22926. mesh._checkCollision(collider);
  22927. }
  22928. }
  22929. if (!collider.collisionFound) {
  22930. position.addToRef(velocity, finalPosition);
  22931. return;
  22932. }
  22933. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  22934. collider._getResponse(position, velocity);
  22935. }
  22936. if (velocity.length() <= closeDistance) {
  22937. finalPosition.copyFrom(position);
  22938. return;
  22939. }
  22940. collider._retry++;
  22941. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  22942. };
  22943. return CollisionCoordinatorLegacy;
  22944. }());
  22945. /***/ }),
  22946. /***/ "./Collisions/index.ts":
  22947. /*!*****************************!*\
  22948. !*** ./Collisions/index.ts ***!
  22949. \*****************************/
  22950. /*! exports provided: Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo */
  22951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22952. "use strict";
  22953. __webpack_require__.r(__webpack_exports__);
  22954. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  22955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  22956. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  22957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["CollisionCoordinatorLegacy"]; });
  22958. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  22959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  22960. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  22961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  22962. /***/ }),
  22963. /***/ "./Collisions/intersectionInfo.ts":
  22964. /*!****************************************!*\
  22965. !*** ./Collisions/intersectionInfo.ts ***!
  22966. \****************************************/
  22967. /*! exports provided: IntersectionInfo */
  22968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22969. "use strict";
  22970. __webpack_require__.r(__webpack_exports__);
  22971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  22972. /**
  22973. * @hidden
  22974. */
  22975. var IntersectionInfo = /** @class */ (function () {
  22976. function IntersectionInfo(bu, bv, distance) {
  22977. this.bu = bu;
  22978. this.bv = bv;
  22979. this.distance = distance;
  22980. this.faceId = 0;
  22981. this.subMeshId = 0;
  22982. }
  22983. return IntersectionInfo;
  22984. }());
  22985. /***/ }),
  22986. /***/ "./Collisions/pickingInfo.ts":
  22987. /*!***********************************!*\
  22988. !*** ./Collisions/pickingInfo.ts ***!
  22989. \***********************************/
  22990. /*! exports provided: PickingInfo */
  22991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22992. "use strict";
  22993. __webpack_require__.r(__webpack_exports__);
  22994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  22995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22996. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  22997. /**
  22998. * Information about the result of picking within a scene
  22999. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23000. */
  23001. var PickingInfo = /** @class */ (function () {
  23002. function PickingInfo() {
  23003. /**
  23004. * If the pick collided with an object
  23005. */
  23006. this.hit = false;
  23007. /**
  23008. * Distance away where the pick collided
  23009. */
  23010. this.distance = 0;
  23011. /**
  23012. * The location of pick collision
  23013. */
  23014. this.pickedPoint = null;
  23015. /**
  23016. * The mesh corresponding the the pick collision
  23017. */
  23018. this.pickedMesh = null;
  23019. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23020. this.bu = 0;
  23021. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23022. this.bv = 0;
  23023. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23024. this.faceId = -1;
  23025. /** Id of the the submesh that was picked */
  23026. this.subMeshId = 0;
  23027. /** If a sprite was picked, this will be the sprite the pick collided with */
  23028. this.pickedSprite = null;
  23029. /**
  23030. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23031. */
  23032. this.originMesh = null;
  23033. /**
  23034. * The ray that was used to perform the picking.
  23035. */
  23036. this.ray = null;
  23037. }
  23038. /**
  23039. * Gets the normal correspodning to the face the pick collided with
  23040. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23041. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23042. * @returns The normal correspodning to the face the pick collided with
  23043. */
  23044. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23045. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23046. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23047. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23048. return null;
  23049. }
  23050. var indices = this.pickedMesh.getIndices();
  23051. if (!indices) {
  23052. return null;
  23053. }
  23054. var result;
  23055. if (useVerticesNormals) {
  23056. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23057. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23058. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23059. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23060. normal0 = normal0.scale(this.bu);
  23061. normal1 = normal1.scale(this.bv);
  23062. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23063. 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);
  23064. }
  23065. else {
  23066. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23067. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23068. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23069. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23070. var p1p2 = vertex1.subtract(vertex2);
  23071. var p3p2 = vertex3.subtract(vertex2);
  23072. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23073. }
  23074. if (useWorldCoordinates) {
  23075. var wm = this.pickedMesh.getWorldMatrix();
  23076. if (this.pickedMesh.nonUniformScaling) {
  23077. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23078. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23079. wm.setTranslationFromFloats(0, 0, 0);
  23080. wm.invert();
  23081. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23082. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23083. }
  23084. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23085. }
  23086. result.normalize();
  23087. return result;
  23088. };
  23089. /**
  23090. * Gets the texture coordinates of where the pick occured
  23091. * @returns the vector containing the coordnates of the texture
  23092. */
  23093. PickingInfo.prototype.getTextureCoordinates = function () {
  23094. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23095. return null;
  23096. }
  23097. var indices = this.pickedMesh.getIndices();
  23098. if (!indices) {
  23099. return null;
  23100. }
  23101. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23102. if (!uvs) {
  23103. return null;
  23104. }
  23105. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23106. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23107. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23108. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23109. uv1 = uv1.scale(this.bu);
  23110. uv2 = uv2.scale(this.bv);
  23111. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23112. };
  23113. return PickingInfo;
  23114. }());
  23115. /***/ }),
  23116. /***/ "./Culling/Octrees/index.ts":
  23117. /*!**********************************!*\
  23118. !*** ./Culling/Octrees/index.ts ***!
  23119. \**********************************/
  23120. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23122. "use strict";
  23123. __webpack_require__.r(__webpack_exports__);
  23124. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23126. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23128. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23130. /***/ }),
  23131. /***/ "./Culling/Octrees/octree.ts":
  23132. /*!***********************************!*\
  23133. !*** ./Culling/Octrees/octree.ts ***!
  23134. \***********************************/
  23135. /*! exports provided: Octree */
  23136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23137. "use strict";
  23138. __webpack_require__.r(__webpack_exports__);
  23139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23140. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23141. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23142. /**
  23143. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23144. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23145. */
  23146. var Octree = /** @class */ (function () {
  23147. /**
  23148. * Creates a octree
  23149. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23150. * @param creationFunc function to be used to instatiate the octree
  23151. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23152. * @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.)
  23153. */
  23154. function Octree(creationFunc, maxBlockCapacity,
  23155. /** 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.) */
  23156. maxDepth) {
  23157. if (maxDepth === void 0) { maxDepth = 2; }
  23158. this.maxDepth = maxDepth;
  23159. /**
  23160. * Content stored in the octree
  23161. */
  23162. this.dynamicContent = new Array();
  23163. this._maxBlockCapacity = maxBlockCapacity || 64;
  23164. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23165. this._creationFunc = creationFunc;
  23166. }
  23167. // Methods
  23168. /**
  23169. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23170. * @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);
  23171. * @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);
  23172. * @param entries meshes to be added to the octree blocks
  23173. */
  23174. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23175. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23176. };
  23177. /**
  23178. * Adds a mesh to the octree
  23179. * @param entry Mesh to add to the octree
  23180. */
  23181. Octree.prototype.addMesh = function (entry) {
  23182. for (var index = 0; index < this.blocks.length; index++) {
  23183. var block = this.blocks[index];
  23184. block.addEntry(entry);
  23185. }
  23186. };
  23187. /**
  23188. * Remove an element from the octree
  23189. * @param entry defines the element to remove
  23190. */
  23191. Octree.prototype.removeMesh = function (entry) {
  23192. for (var index = 0; index < this.blocks.length; index++) {
  23193. var block = this.blocks[index];
  23194. block.removeEntry(entry);
  23195. }
  23196. };
  23197. /**
  23198. * Selects an array of meshes within the frustum
  23199. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23200. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23201. * @returns array of meshes within the frustum
  23202. */
  23203. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23204. this._selectionContent.reset();
  23205. for (var index = 0; index < this.blocks.length; index++) {
  23206. var block = this.blocks[index];
  23207. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23208. }
  23209. if (allowDuplicate) {
  23210. this._selectionContent.concat(this.dynamicContent);
  23211. }
  23212. else {
  23213. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23214. }
  23215. return this._selectionContent;
  23216. };
  23217. /**
  23218. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23219. * @param sphereCenter defines the bounding sphere center
  23220. * @param sphereRadius defines the bounding sphere radius
  23221. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23222. * @returns an array of objects that intersect the sphere
  23223. */
  23224. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23225. this._selectionContent.reset();
  23226. for (var index = 0; index < this.blocks.length; index++) {
  23227. var block = this.blocks[index];
  23228. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23229. }
  23230. if (allowDuplicate) {
  23231. this._selectionContent.concat(this.dynamicContent);
  23232. }
  23233. else {
  23234. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23235. }
  23236. return this._selectionContent;
  23237. };
  23238. /**
  23239. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23240. * @param ray defines the ray to test with
  23241. * @returns array of intersected objects
  23242. */
  23243. Octree.prototype.intersectsRay = function (ray) {
  23244. this._selectionContent.reset();
  23245. for (var index = 0; index < this.blocks.length; index++) {
  23246. var block = this.blocks[index];
  23247. block.intersectsRay(ray, this._selectionContent);
  23248. }
  23249. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23250. return this._selectionContent;
  23251. };
  23252. /**
  23253. * Adds a mesh into the octree block if it intersects the block
  23254. */
  23255. Octree.CreationFuncForMeshes = function (entry, block) {
  23256. var boundingInfo = entry.getBoundingInfo();
  23257. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23258. block.entries.push(entry);
  23259. }
  23260. };
  23261. /**
  23262. * Adds a submesh into the octree block if it intersects the block
  23263. */
  23264. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23265. var boundingInfo = entry.getBoundingInfo();
  23266. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23267. block.entries.push(entry);
  23268. }
  23269. };
  23270. return Octree;
  23271. }());
  23272. /***/ }),
  23273. /***/ "./Culling/Octrees/octreeBlock.ts":
  23274. /*!****************************************!*\
  23275. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23276. \****************************************/
  23277. /*! exports provided: OctreeBlock */
  23278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23279. "use strict";
  23280. __webpack_require__.r(__webpack_exports__);
  23281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23282. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23283. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23284. /**
  23285. * Class used to store a cell in an octree
  23286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23287. */
  23288. var OctreeBlock = /** @class */ (function () {
  23289. /**
  23290. * Creates a new block
  23291. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  23292. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  23293. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23294. * @param depth defines the current depth of this block in the octree
  23295. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  23296. * @param creationFunc defines a callback to call when an element is added to the block
  23297. */
  23298. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  23299. /**
  23300. * Gets the content of the current block
  23301. */
  23302. this.entries = new Array();
  23303. this._boundingVectors = new Array();
  23304. this._capacity = capacity;
  23305. this._depth = depth;
  23306. this._maxDepth = maxDepth;
  23307. this._creationFunc = creationFunc;
  23308. this._minPoint = minPoint;
  23309. this._maxPoint = maxPoint;
  23310. this._boundingVectors.push(minPoint.clone());
  23311. this._boundingVectors.push(maxPoint.clone());
  23312. this._boundingVectors.push(minPoint.clone());
  23313. this._boundingVectors[2].x = maxPoint.x;
  23314. this._boundingVectors.push(minPoint.clone());
  23315. this._boundingVectors[3].y = maxPoint.y;
  23316. this._boundingVectors.push(minPoint.clone());
  23317. this._boundingVectors[4].z = maxPoint.z;
  23318. this._boundingVectors.push(maxPoint.clone());
  23319. this._boundingVectors[5].z = minPoint.z;
  23320. this._boundingVectors.push(maxPoint.clone());
  23321. this._boundingVectors[6].x = minPoint.x;
  23322. this._boundingVectors.push(maxPoint.clone());
  23323. this._boundingVectors[7].y = minPoint.y;
  23324. }
  23325. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  23326. // Property
  23327. /**
  23328. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23329. */
  23330. get: function () {
  23331. return this._capacity;
  23332. },
  23333. enumerable: true,
  23334. configurable: true
  23335. });
  23336. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  23337. /**
  23338. * Gets the minimum vector (in world space) of the block's bounding box
  23339. */
  23340. get: function () {
  23341. return this._minPoint;
  23342. },
  23343. enumerable: true,
  23344. configurable: true
  23345. });
  23346. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  23347. /**
  23348. * Gets the maximum vector (in world space) of the block's bounding box
  23349. */
  23350. get: function () {
  23351. return this._maxPoint;
  23352. },
  23353. enumerable: true,
  23354. configurable: true
  23355. });
  23356. // Methods
  23357. /**
  23358. * Add a new element to this block
  23359. * @param entry defines the element to add
  23360. */
  23361. OctreeBlock.prototype.addEntry = function (entry) {
  23362. if (this.blocks) {
  23363. for (var index = 0; index < this.blocks.length; index++) {
  23364. var block = this.blocks[index];
  23365. block.addEntry(entry);
  23366. }
  23367. return;
  23368. }
  23369. this._creationFunc(entry, this);
  23370. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  23371. this.createInnerBlocks();
  23372. }
  23373. };
  23374. /**
  23375. * Remove an element from this block
  23376. * @param entry defines the element to remove
  23377. */
  23378. OctreeBlock.prototype.removeEntry = function (entry) {
  23379. if (this.blocks) {
  23380. for (var index = 0; index < this.blocks.length; index++) {
  23381. var block = this.blocks[index];
  23382. block.removeEntry(entry);
  23383. }
  23384. return;
  23385. }
  23386. var entryIndex = this.entries.indexOf(entry);
  23387. if (entryIndex > -1) {
  23388. this.entries.splice(entryIndex, 1);
  23389. }
  23390. };
  23391. /**
  23392. * Add an array of elements to this block
  23393. * @param entries defines the array of elements to add
  23394. */
  23395. OctreeBlock.prototype.addEntries = function (entries) {
  23396. for (var index = 0; index < entries.length; index++) {
  23397. var mesh = entries[index];
  23398. this.addEntry(mesh);
  23399. }
  23400. };
  23401. /**
  23402. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  23403. * @param frustumPlanes defines the frustum planes to test
  23404. * @param selection defines the array to store current content if selection is positive
  23405. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23406. */
  23407. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  23408. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  23409. if (this.blocks) {
  23410. for (var index = 0; index < this.blocks.length; index++) {
  23411. var block = this.blocks[index];
  23412. block.select(frustumPlanes, selection, allowDuplicate);
  23413. }
  23414. return;
  23415. }
  23416. if (allowDuplicate) {
  23417. selection.concat(this.entries);
  23418. }
  23419. else {
  23420. selection.concatWithNoDuplicate(this.entries);
  23421. }
  23422. }
  23423. };
  23424. /**
  23425. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  23426. * @param sphereCenter defines the bounding sphere center
  23427. * @param sphereRadius defines the bounding sphere radius
  23428. * @param selection defines the array to store current content if selection is positive
  23429. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23430. */
  23431. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  23432. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  23433. if (this.blocks) {
  23434. for (var index = 0; index < this.blocks.length; index++) {
  23435. var block = this.blocks[index];
  23436. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  23437. }
  23438. return;
  23439. }
  23440. if (allowDuplicate) {
  23441. selection.concat(this.entries);
  23442. }
  23443. else {
  23444. selection.concatWithNoDuplicate(this.entries);
  23445. }
  23446. }
  23447. };
  23448. /**
  23449. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  23450. * @param ray defines the ray to test with
  23451. * @param selection defines the array to store current content if selection is positive
  23452. */
  23453. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  23454. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  23455. if (this.blocks) {
  23456. for (var index = 0; index < this.blocks.length; index++) {
  23457. var block = this.blocks[index];
  23458. block.intersectsRay(ray, selection);
  23459. }
  23460. return;
  23461. }
  23462. selection.concatWithNoDuplicate(this.entries);
  23463. }
  23464. };
  23465. /**
  23466. * Subdivide the content into child blocks (this block will then be empty)
  23467. */
  23468. OctreeBlock.prototype.createInnerBlocks = function () {
  23469. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  23470. };
  23471. /**
  23472. * @hidden
  23473. */
  23474. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  23475. target.blocks = new Array();
  23476. 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);
  23477. // Segmenting space
  23478. for (var x = 0; x < 2; x++) {
  23479. for (var y = 0; y < 2; y++) {
  23480. for (var z = 0; z < 2; z++) {
  23481. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  23482. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  23483. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  23484. block.addEntries(entries);
  23485. target.blocks.push(block);
  23486. }
  23487. }
  23488. }
  23489. };
  23490. return OctreeBlock;
  23491. }());
  23492. /***/ }),
  23493. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  23494. /*!*************************************************!*\
  23495. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  23496. \*************************************************/
  23497. /*! exports provided: OctreeSceneComponent */
  23498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23499. "use strict";
  23500. __webpack_require__.r(__webpack_exports__);
  23501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  23502. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  23503. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23504. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  23505. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  23506. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  23507. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23508. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  23509. if (maxCapacity === void 0) { maxCapacity = 64; }
  23510. if (maxDepth === void 0) { maxDepth = 2; }
  23511. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23512. if (!component) {
  23513. component = new OctreeSceneComponent(this);
  23514. this._addComponent(component);
  23515. }
  23516. if (!this._selectionOctree) {
  23517. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  23518. }
  23519. var worldExtends = this.getWorldExtends();
  23520. // Update octree
  23521. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  23522. return this._selectionOctree;
  23523. };
  23524. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  23525. get: function () {
  23526. return this._selectionOctree;
  23527. },
  23528. enumerable: true,
  23529. configurable: true
  23530. });
  23531. /**
  23532. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  23533. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23534. * @param maxCapacity defines the maximum size of each block (64 by default)
  23535. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  23536. * @returns the new octree
  23537. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  23538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23539. */
  23540. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  23541. if (maxCapacity === void 0) { maxCapacity = 64; }
  23542. if (maxDepth === void 0) { maxDepth = 2; }
  23543. var scene = this.getScene();
  23544. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23545. if (!component) {
  23546. component = new OctreeSceneComponent(scene);
  23547. scene._addComponent(component);
  23548. }
  23549. if (!this._submeshesOctree) {
  23550. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  23551. }
  23552. this.computeWorldMatrix(true);
  23553. var boundingInfo = this.getBoundingInfo();
  23554. // Update octree
  23555. var bbox = boundingInfo.boundingBox;
  23556. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  23557. return this._submeshesOctree;
  23558. };
  23559. /**
  23560. * Defines the octree scene component responsible to manage any octrees
  23561. * in a given scene.
  23562. */
  23563. var OctreeSceneComponent = /** @class */ (function () {
  23564. /**
  23565. * Creates a new instance of the component for the given scene
  23566. * @param scene Defines the scene to register the component in
  23567. */
  23568. function OctreeSceneComponent(scene) {
  23569. /**
  23570. * The component name helpfull to identify the component in the list of scene components.
  23571. */
  23572. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  23573. /**
  23574. * Indicates if the meshes have been checked to make sure they are isEnabled()
  23575. */
  23576. this.checksIsEnabled = true;
  23577. 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));
  23578. this.scene = scene;
  23579. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  23580. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  23581. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  23582. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  23583. }
  23584. /**
  23585. * Registers the component in a given scene
  23586. */
  23587. OctreeSceneComponent.prototype.register = function () {
  23588. var _this = this;
  23589. this.scene.onMeshRemovedObservable.add(function (mesh) {
  23590. var sceneOctree = _this.scene.selectionOctree;
  23591. if (sceneOctree !== undefined && sceneOctree !== null) {
  23592. var index = sceneOctree.dynamicContent.indexOf(mesh);
  23593. if (index !== -1) {
  23594. sceneOctree.dynamicContent.splice(index, 1);
  23595. }
  23596. }
  23597. });
  23598. this.scene.onMeshImportedObservable.add(function (mesh) {
  23599. var sceneOctree = _this.scene.selectionOctree;
  23600. if (sceneOctree !== undefined && sceneOctree !== null) {
  23601. sceneOctree.addMesh(mesh);
  23602. }
  23603. });
  23604. };
  23605. /**
  23606. * Return the list of active meshes
  23607. * @returns the list of active meshes
  23608. */
  23609. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  23610. if (this.scene._selectionOctree) {
  23611. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  23612. return selection;
  23613. }
  23614. return this.scene._getDefaultMeshCandidates();
  23615. };
  23616. /**
  23617. * Return the list of active sub meshes
  23618. * @param mesh The mesh to get the candidates sub meshes from
  23619. * @returns the list of active sub meshes
  23620. */
  23621. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  23622. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  23623. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  23624. return intersections;
  23625. }
  23626. return this.scene._getDefaultSubMeshCandidates(mesh);
  23627. };
  23628. /**
  23629. * Return the list of sub meshes intersecting with a given local ray
  23630. * @param mesh defines the mesh to find the submesh for
  23631. * @param localRay defines the ray in local space
  23632. * @returns the list of intersecting sub meshes
  23633. */
  23634. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  23635. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  23636. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  23637. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  23638. return intersections;
  23639. }
  23640. return this.scene._getDefaultSubMeshCandidates(mesh);
  23641. };
  23642. /**
  23643. * Return the list of sub meshes colliding with a collider
  23644. * @param mesh defines the mesh to find the submesh for
  23645. * @param collider defines the collider to evaluate the collision against
  23646. * @returns the list of colliding sub meshes
  23647. */
  23648. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  23649. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  23650. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  23651. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  23652. return intersections;
  23653. }
  23654. return this.scene._getDefaultSubMeshCandidates(mesh);
  23655. };
  23656. /**
  23657. * Rebuilds the elements related to this component in case of
  23658. * context lost for instance.
  23659. */
  23660. OctreeSceneComponent.prototype.rebuild = function () {
  23661. // Nothing to do here.
  23662. };
  23663. /**
  23664. * Disposes the component and the associated ressources.
  23665. */
  23666. OctreeSceneComponent.prototype.dispose = function () {
  23667. // Nothing to do here.
  23668. };
  23669. return OctreeSceneComponent;
  23670. }());
  23671. /***/ }),
  23672. /***/ "./Culling/boundingBox.ts":
  23673. /*!********************************!*\
  23674. !*** ./Culling/boundingBox.ts ***!
  23675. \********************************/
  23676. /*! exports provided: BoundingBox */
  23677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23678. "use strict";
  23679. __webpack_require__.r(__webpack_exports__);
  23680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  23681. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  23682. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23683. /**
  23684. * Class used to store bounding box information
  23685. */
  23686. var BoundingBox = /** @class */ (function () {
  23687. /**
  23688. * Creates a new bounding box
  23689. * @param min defines the minimum vector (in local space)
  23690. * @param max defines the maximum vector (in local space)
  23691. * @param worldMatrix defines the new world matrix
  23692. */
  23693. function BoundingBox(min, max, worldMatrix) {
  23694. /**
  23695. * Gets the 8 vectors representing the bounding box in local space
  23696. */
  23697. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23698. /**
  23699. * Gets the center of the bounding box in local space
  23700. */
  23701. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23702. /**
  23703. * Gets the center of the bounding box in world space
  23704. */
  23705. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23706. /**
  23707. * Gets the extend size in local space
  23708. */
  23709. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23710. /**
  23711. * Gets the extend size in world space
  23712. */
  23713. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23714. /**
  23715. * Gets the OBB (object bounding box) directions
  23716. */
  23717. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23718. /**
  23719. * Gets the 8 vectors representing the bounding box in world space
  23720. */
  23721. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23722. /**
  23723. * Gets the minimum vector in world space
  23724. */
  23725. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23726. /**
  23727. * Gets the maximum vector in world space
  23728. */
  23729. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23730. /**
  23731. * Gets the minimum vector in local space
  23732. */
  23733. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23734. /**
  23735. * Gets the maximum vector in local space
  23736. */
  23737. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23738. this.reConstruct(min, max, worldMatrix);
  23739. }
  23740. // Methods
  23741. /**
  23742. * Recreates the entire bounding box from scratch as if we call the constructor in place
  23743. * @param min defines the new minimum vector (in local space)
  23744. * @param max defines the new maximum vector (in local space)
  23745. * @param worldMatrix defines the new world matrix
  23746. */
  23747. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  23748. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23749. var vectors = this.vectors;
  23750. this.minimum.copyFromFloats(minX, minY, minZ);
  23751. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  23752. vectors[0].copyFromFloats(minX, minY, minZ);
  23753. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  23754. vectors[2].copyFromFloats(maxX, minY, minZ);
  23755. vectors[3].copyFromFloats(minX, maxY, minZ);
  23756. vectors[4].copyFromFloats(minX, minY, maxZ);
  23757. vectors[5].copyFromFloats(maxX, maxY, minZ);
  23758. vectors[6].copyFromFloats(minX, maxY, maxZ);
  23759. vectors[7].copyFromFloats(maxX, minY, maxZ);
  23760. // OBB
  23761. max.addToRef(min, this.center).scaleInPlace(0.5);
  23762. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  23763. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  23764. };
  23765. /**
  23766. * Scale the current bounding box by applying a scale factor
  23767. * @param factor defines the scale factor to apply
  23768. * @returns the current bounding box
  23769. */
  23770. BoundingBox.prototype.scale = function (factor) {
  23771. var tmpVectors = BoundingBox.TmpVector3;
  23772. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  23773. var len = diff.length();
  23774. diff.normalizeFromLength(len);
  23775. var distance = len * factor;
  23776. var newRadius = diff.scaleInPlace(distance * 0.5);
  23777. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  23778. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  23779. this.reConstruct(min, max, this._worldMatrix);
  23780. return this;
  23781. };
  23782. /**
  23783. * Gets the world matrix of the bounding box
  23784. * @returns a matrix
  23785. */
  23786. BoundingBox.prototype.getWorldMatrix = function () {
  23787. return this._worldMatrix;
  23788. };
  23789. /** @hidden */
  23790. BoundingBox.prototype._update = function (world) {
  23791. var minWorld = this.minimumWorld;
  23792. var maxWorld = this.maximumWorld;
  23793. var directions = this.directions;
  23794. var vectorsWorld = this.vectorsWorld;
  23795. var vectors = this.vectors;
  23796. if (!world.isIdentity()) {
  23797. minWorld.setAll(Number.MAX_VALUE);
  23798. maxWorld.setAll(-Number.MAX_VALUE);
  23799. for (var index = 0; index < 8; ++index) {
  23800. var v = vectorsWorld[index];
  23801. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  23802. minWorld.minimizeInPlace(v);
  23803. maxWorld.maximizeInPlace(v);
  23804. }
  23805. // Extend
  23806. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  23807. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  23808. }
  23809. else {
  23810. minWorld.copyFrom(this.minimum);
  23811. maxWorld.copyFrom(this.maximum);
  23812. for (var index = 0; index < 8; ++index) {
  23813. vectorsWorld[index].copyFrom(vectors[index]);
  23814. }
  23815. // Extend
  23816. this.extendSizeWorld.copyFrom(this.extendSize);
  23817. this.centerWorld.copyFrom(this.center);
  23818. }
  23819. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  23820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  23821. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  23822. this._worldMatrix = world;
  23823. };
  23824. /**
  23825. * Tests if the bounding box is intersecting the frustum planes
  23826. * @param frustumPlanes defines the frustum planes to test
  23827. * @returns true if there is an intersection
  23828. */
  23829. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  23830. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  23831. };
  23832. /**
  23833. * Tests if the bounding box is entirely inside the frustum planes
  23834. * @param frustumPlanes defines the frustum planes to test
  23835. * @returns true if there is an inclusion
  23836. */
  23837. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  23838. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  23839. };
  23840. /**
  23841. * Tests if a point is inside the bounding box
  23842. * @param point defines the point to test
  23843. * @returns true if the point is inside the bounding box
  23844. */
  23845. BoundingBox.prototype.intersectsPoint = function (point) {
  23846. var min = this.minimumWorld;
  23847. var max = this.maximumWorld;
  23848. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23849. var pointX = point.x, pointY = point.y, pointZ = point.z;
  23850. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  23851. if (maxX - pointX < delta || delta > pointX - minX) {
  23852. return false;
  23853. }
  23854. if (maxY - pointY < delta || delta > pointY - minY) {
  23855. return false;
  23856. }
  23857. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  23858. return false;
  23859. }
  23860. return true;
  23861. };
  23862. /**
  23863. * Tests if the bounding box intersects with a bounding sphere
  23864. * @param sphere defines the sphere to test
  23865. * @returns true if there is an intersection
  23866. */
  23867. BoundingBox.prototype.intersectsSphere = function (sphere) {
  23868. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  23869. };
  23870. /**
  23871. * Tests if the bounding box intersects with a box defined by a min and max vectors
  23872. * @param min defines the min vector to use
  23873. * @param max defines the max vector to use
  23874. * @returns true if there is an intersection
  23875. */
  23876. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  23877. var myMin = this.minimumWorld;
  23878. var myMax = this.maximumWorld;
  23879. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  23880. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23881. if (myMaxX < minX || myMinX > maxX) {
  23882. return false;
  23883. }
  23884. if (myMaxY < minY || myMinY > maxY) {
  23885. return false;
  23886. }
  23887. if (myMaxZ < minZ || myMinZ > maxZ) {
  23888. return false;
  23889. }
  23890. return true;
  23891. };
  23892. // Statics
  23893. /**
  23894. * Tests if two bounding boxes are intersections
  23895. * @param box0 defines the first box to test
  23896. * @param box1 defines the second box to test
  23897. * @returns true if there is an intersection
  23898. */
  23899. BoundingBox.Intersects = function (box0, box1) {
  23900. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  23901. };
  23902. /**
  23903. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  23904. * @param minPoint defines the minimum vector of the bounding box
  23905. * @param maxPoint defines the maximum vector of the bounding box
  23906. * @param sphereCenter defines the sphere center
  23907. * @param sphereRadius defines the sphere radius
  23908. * @returns true if there is an intersection
  23909. */
  23910. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  23911. var vector = BoundingBox.TmpVector3[0];
  23912. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  23913. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  23914. return (num <= (sphereRadius * sphereRadius));
  23915. };
  23916. /**
  23917. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  23918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  23919. * @param frustumPlanes defines the frustum planes to test
  23920. * @return true if there is an inclusion
  23921. */
  23922. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  23923. for (var p = 0; p < 6; ++p) {
  23924. var frustumPlane = frustumPlanes[p];
  23925. for (var i = 0; i < 8; ++i) {
  23926. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  23927. return false;
  23928. }
  23929. }
  23930. }
  23931. return true;
  23932. };
  23933. /**
  23934. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  23935. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  23936. * @param frustumPlanes defines the frustum planes to test
  23937. * @return true if there is an intersection
  23938. */
  23939. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  23940. for (var p = 0; p < 6; ++p) {
  23941. var canReturnFalse = true;
  23942. var frustumPlane = frustumPlanes[p];
  23943. for (var i = 0; i < 8; ++i) {
  23944. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  23945. canReturnFalse = false;
  23946. break;
  23947. }
  23948. }
  23949. if (canReturnFalse) {
  23950. return false;
  23951. }
  23952. }
  23953. return true;
  23954. };
  23955. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23956. return BoundingBox;
  23957. }());
  23958. /***/ }),
  23959. /***/ "./Culling/boundingInfo.ts":
  23960. /*!*********************************!*\
  23961. !*** ./Culling/boundingInfo.ts ***!
  23962. \*********************************/
  23963. /*! exports provided: BoundingInfo */
  23964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23965. "use strict";
  23966. __webpack_require__.r(__webpack_exports__);
  23967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  23968. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  23969. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23970. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  23971. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  23972. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  23973. var _result0 = { min: 0, max: 0 };
  23974. var _result1 = { min: 0, max: 0 };
  23975. var computeBoxExtents = function (axis, box, result) {
  23976. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  23977. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  23978. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  23979. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  23980. var r = r0 + r1 + r2;
  23981. result.min = p - r;
  23982. result.max = p + r;
  23983. };
  23984. var axisOverlap = function (axis, box0, box1) {
  23985. computeBoxExtents(axis, box0, _result0);
  23986. computeBoxExtents(axis, box1, _result1);
  23987. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  23988. };
  23989. /**
  23990. * Info for a bounding data of a mesh
  23991. */
  23992. var BoundingInfo = /** @class */ (function () {
  23993. /**
  23994. * Constructs bounding info
  23995. * @param minimum min vector of the bounding box/sphere
  23996. * @param maximum max vector of the bounding box/sphere
  23997. * @param worldMatrix defines the new world matrix
  23998. */
  23999. function BoundingInfo(minimum, maximum, worldMatrix) {
  24000. this._isLocked = false;
  24001. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24002. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24003. }
  24004. /**
  24005. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24006. * @param min defines the new minimum vector (in local space)
  24007. * @param max defines the new maximum vector (in local space)
  24008. * @param worldMatrix defines the new world matrix
  24009. */
  24010. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24011. this.boundingBox.reConstruct(min, max, worldMatrix);
  24012. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24013. };
  24014. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24015. /**
  24016. * min vector of the bounding box/sphere
  24017. */
  24018. get: function () {
  24019. return this.boundingBox.minimum;
  24020. },
  24021. enumerable: true,
  24022. configurable: true
  24023. });
  24024. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24025. /**
  24026. * max vector of the bounding box/sphere
  24027. */
  24028. get: function () {
  24029. return this.boundingBox.maximum;
  24030. },
  24031. enumerable: true,
  24032. configurable: true
  24033. });
  24034. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24035. /**
  24036. * If the info is locked and won't be updated to avoid perf overhead
  24037. */
  24038. get: function () {
  24039. return this._isLocked;
  24040. },
  24041. set: function (value) {
  24042. this._isLocked = value;
  24043. },
  24044. enumerable: true,
  24045. configurable: true
  24046. });
  24047. // Methods
  24048. /**
  24049. * Updates the bounding sphere and box
  24050. * @param world world matrix to be used to update
  24051. */
  24052. BoundingInfo.prototype.update = function (world) {
  24053. if (this._isLocked) {
  24054. return;
  24055. }
  24056. this.boundingBox._update(world);
  24057. this.boundingSphere._update(world);
  24058. };
  24059. /**
  24060. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24061. * @param center New center of the bounding info
  24062. * @param extend New extend of the bounding info
  24063. * @returns the current bounding info
  24064. */
  24065. BoundingInfo.prototype.centerOn = function (center, extend) {
  24066. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24067. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24068. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24069. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24070. return this;
  24071. };
  24072. /**
  24073. * Scale the current bounding info by applying a scale factor
  24074. * @param factor defines the scale factor to apply
  24075. * @returns the current bounding info
  24076. */
  24077. BoundingInfo.prototype.scale = function (factor) {
  24078. this.boundingBox.scale(factor);
  24079. this.boundingSphere.scale(factor);
  24080. return this;
  24081. };
  24082. /**
  24083. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24084. * @param frustumPlanes defines the frustum to test
  24085. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24086. * @returns true if the bounding info is in the frustum planes
  24087. */
  24088. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24089. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24090. 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);
  24091. if (inclusionTest) {
  24092. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24093. return true;
  24094. }
  24095. }
  24096. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24097. return false;
  24098. }
  24099. 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);
  24100. if (bSphereOnlyTest) {
  24101. return true;
  24102. }
  24103. return this.boundingBox.isInFrustum(frustumPlanes);
  24104. };
  24105. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24106. /**
  24107. * Gets the world distance between the min and max points of the bounding box
  24108. */
  24109. get: function () {
  24110. var boundingBox = this.boundingBox;
  24111. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24112. return diag.length();
  24113. },
  24114. enumerable: true,
  24115. configurable: true
  24116. });
  24117. /**
  24118. * Checks if a cullable object (mesh...) is in the camera frustum
  24119. * Unlike isInFrustum this cheks the full bounding box
  24120. * @param frustumPlanes Camera near/planes
  24121. * @returns true if the object is in frustum otherwise false
  24122. */
  24123. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24124. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24125. };
  24126. /** @hidden */
  24127. BoundingInfo.prototype._checkCollision = function (collider) {
  24128. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24129. };
  24130. /**
  24131. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24132. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24133. * @param point the point to check intersection with
  24134. * @returns if the point intersects
  24135. */
  24136. BoundingInfo.prototype.intersectsPoint = function (point) {
  24137. if (!this.boundingSphere.centerWorld) {
  24138. return false;
  24139. }
  24140. if (!this.boundingSphere.intersectsPoint(point)) {
  24141. return false;
  24142. }
  24143. if (!this.boundingBox.intersectsPoint(point)) {
  24144. return false;
  24145. }
  24146. return true;
  24147. };
  24148. /**
  24149. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24150. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24151. * @param boundingInfo the bounding info to check intersection with
  24152. * @param precise if the intersection should be done using OBB
  24153. * @returns if the bounding info intersects
  24154. */
  24155. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24156. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24157. return false;
  24158. }
  24159. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24160. return false;
  24161. }
  24162. if (!precise) {
  24163. return true;
  24164. }
  24165. var box0 = this.boundingBox;
  24166. var box1 = boundingInfo.boundingBox;
  24167. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24168. return false;
  24169. }
  24170. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24171. return false;
  24172. }
  24173. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24174. return false;
  24175. }
  24176. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24177. return false;
  24178. }
  24179. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24180. return false;
  24181. }
  24182. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24183. return false;
  24184. }
  24185. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24186. return false;
  24187. }
  24188. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24189. return false;
  24190. }
  24191. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24192. return false;
  24193. }
  24194. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24195. return false;
  24196. }
  24197. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24198. return false;
  24199. }
  24200. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24201. return false;
  24202. }
  24203. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24204. return false;
  24205. }
  24206. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24207. return false;
  24208. }
  24209. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24210. return false;
  24211. }
  24212. return true;
  24213. };
  24214. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24215. return BoundingInfo;
  24216. }());
  24217. /***/ }),
  24218. /***/ "./Culling/boundingSphere.ts":
  24219. /*!***********************************!*\
  24220. !*** ./Culling/boundingSphere.ts ***!
  24221. \***********************************/
  24222. /*! exports provided: BoundingSphere */
  24223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24224. "use strict";
  24225. __webpack_require__.r(__webpack_exports__);
  24226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24227. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24228. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24229. /**
  24230. * Class used to store bounding sphere information
  24231. */
  24232. var BoundingSphere = /** @class */ (function () {
  24233. /**
  24234. * Creates a new bounding sphere
  24235. * @param min defines the minimum vector (in local space)
  24236. * @param max defines the maximum vector (in local space)
  24237. * @param worldMatrix defines the new world matrix
  24238. */
  24239. function BoundingSphere(min, max, worldMatrix) {
  24240. /**
  24241. * Gets the center of the bounding sphere in local space
  24242. */
  24243. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24244. /**
  24245. * Gets the center of the bounding sphere in world space
  24246. */
  24247. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24248. /**
  24249. * Gets the minimum vector in local space
  24250. */
  24251. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24252. /**
  24253. * Gets the maximum vector in local space
  24254. */
  24255. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24256. this.reConstruct(min, max, worldMatrix);
  24257. }
  24258. /**
  24259. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24260. * @param min defines the new minimum vector (in local space)
  24261. * @param max defines the new maximum vector (in local space)
  24262. * @param worldMatrix defines the new world matrix
  24263. */
  24264. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24265. this.minimum.copyFrom(min);
  24266. this.maximum.copyFrom(max);
  24267. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24268. max.addToRef(min, this.center).scaleInPlace(0.5);
  24269. this.radius = distance * 0.5;
  24270. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24271. };
  24272. /**
  24273. * Scale the current bounding sphere by applying a scale factor
  24274. * @param factor defines the scale factor to apply
  24275. * @returns the current bounding box
  24276. */
  24277. BoundingSphere.prototype.scale = function (factor) {
  24278. var newRadius = this.radius * factor;
  24279. var tmpVectors = BoundingSphere.TmpVector3;
  24280. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24281. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24282. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24283. this.reConstruct(min, max, this._worldMatrix);
  24284. return this;
  24285. };
  24286. /**
  24287. * Gets the world matrix of the bounding box
  24288. * @returns a matrix
  24289. */
  24290. BoundingSphere.prototype.getWorldMatrix = function () {
  24291. return this._worldMatrix;
  24292. };
  24293. // Methods
  24294. /** @hidden */
  24295. BoundingSphere.prototype._update = function (worldMatrix) {
  24296. if (!worldMatrix.isIdentity()) {
  24297. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  24298. var tempVector = BoundingSphere.TmpVector3[0];
  24299. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  24300. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  24301. }
  24302. else {
  24303. this.centerWorld.copyFrom(this.center);
  24304. this.radiusWorld = this.radius;
  24305. }
  24306. };
  24307. /**
  24308. * Tests if the bounding sphere is intersecting the frustum planes
  24309. * @param frustumPlanes defines the frustum planes to test
  24310. * @returns true if there is an intersection
  24311. */
  24312. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  24313. var center = this.centerWorld;
  24314. var radius = this.radiusWorld;
  24315. for (var i = 0; i < 6; i++) {
  24316. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  24317. return false;
  24318. }
  24319. }
  24320. return true;
  24321. };
  24322. /**
  24323. * Tests if the bounding sphere center is in between the frustum planes.
  24324. * Used for optimistic fast inclusion.
  24325. * @param frustumPlanes defines the frustum planes to test
  24326. * @returns true if the sphere center is in between the frustum planes
  24327. */
  24328. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  24329. var center = this.centerWorld;
  24330. for (var i = 0; i < 6; i++) {
  24331. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  24332. return false;
  24333. }
  24334. }
  24335. return true;
  24336. };
  24337. /**
  24338. * Tests if a point is inside the bounding sphere
  24339. * @param point defines the point to test
  24340. * @returns true if the point is inside the bounding sphere
  24341. */
  24342. BoundingSphere.prototype.intersectsPoint = function (point) {
  24343. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  24344. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  24345. return false;
  24346. }
  24347. return true;
  24348. };
  24349. // Statics
  24350. /**
  24351. * Checks if two sphere intersct
  24352. * @param sphere0 sphere 0
  24353. * @param sphere1 sphere 1
  24354. * @returns true if the speres intersect
  24355. */
  24356. BoundingSphere.Intersects = function (sphere0, sphere1) {
  24357. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  24358. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  24359. if (radiusSum * radiusSum < squareDistance) {
  24360. return false;
  24361. }
  24362. return true;
  24363. };
  24364. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24365. return BoundingSphere;
  24366. }());
  24367. /***/ }),
  24368. /***/ "./Culling/index.ts":
  24369. /*!**************************!*\
  24370. !*** ./Culling/index.ts ***!
  24371. \**************************/
  24372. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  24373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24374. "use strict";
  24375. __webpack_require__.r(__webpack_exports__);
  24376. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  24378. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  24379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  24380. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  24382. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  24383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  24384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  24385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  24386. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  24387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  24388. /***/ }),
  24389. /***/ "./Culling/ray.ts":
  24390. /*!************************!*\
  24391. !*** ./Culling/ray.ts ***!
  24392. \************************/
  24393. /*! exports provided: Ray */
  24394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24395. "use strict";
  24396. __webpack_require__.r(__webpack_exports__);
  24397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  24398. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24400. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24401. /**
  24402. * Class representing a ray with position and direction
  24403. */
  24404. var Ray = /** @class */ (function () {
  24405. /**
  24406. * Creates a new ray
  24407. * @param origin origin point
  24408. * @param direction direction
  24409. * @param length length of the ray
  24410. */
  24411. function Ray(
  24412. /** origin point */
  24413. origin,
  24414. /** direction */
  24415. direction,
  24416. /** length of the ray */
  24417. length) {
  24418. if (length === void 0) { length = Number.MAX_VALUE; }
  24419. this.origin = origin;
  24420. this.direction = direction;
  24421. this.length = length;
  24422. }
  24423. // Methods
  24424. /**
  24425. * Checks if the ray intersects a box
  24426. * @param minimum bound of the box
  24427. * @param maximum bound of the box
  24428. * @param intersectionTreshold extra extend to be added to the box in all direction
  24429. * @returns if the box was hit
  24430. */
  24431. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  24432. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24433. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  24434. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  24435. var d = 0.0;
  24436. var maxValue = Number.MAX_VALUE;
  24437. var inv;
  24438. var min;
  24439. var max;
  24440. var temp;
  24441. if (Math.abs(this.direction.x) < 0.0000001) {
  24442. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  24443. return false;
  24444. }
  24445. }
  24446. else {
  24447. inv = 1.0 / this.direction.x;
  24448. min = (newMinimum.x - this.origin.x) * inv;
  24449. max = (newMaximum.x - this.origin.x) * inv;
  24450. if (max === -Infinity) {
  24451. max = Infinity;
  24452. }
  24453. if (min > max) {
  24454. temp = min;
  24455. min = max;
  24456. max = temp;
  24457. }
  24458. d = Math.max(min, d);
  24459. maxValue = Math.min(max, maxValue);
  24460. if (d > maxValue) {
  24461. return false;
  24462. }
  24463. }
  24464. if (Math.abs(this.direction.y) < 0.0000001) {
  24465. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  24466. return false;
  24467. }
  24468. }
  24469. else {
  24470. inv = 1.0 / this.direction.y;
  24471. min = (newMinimum.y - this.origin.y) * inv;
  24472. max = (newMaximum.y - this.origin.y) * inv;
  24473. if (max === -Infinity) {
  24474. max = Infinity;
  24475. }
  24476. if (min > max) {
  24477. temp = min;
  24478. min = max;
  24479. max = temp;
  24480. }
  24481. d = Math.max(min, d);
  24482. maxValue = Math.min(max, maxValue);
  24483. if (d > maxValue) {
  24484. return false;
  24485. }
  24486. }
  24487. if (Math.abs(this.direction.z) < 0.0000001) {
  24488. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  24489. return false;
  24490. }
  24491. }
  24492. else {
  24493. inv = 1.0 / this.direction.z;
  24494. min = (newMinimum.z - this.origin.z) * inv;
  24495. max = (newMaximum.z - this.origin.z) * inv;
  24496. if (max === -Infinity) {
  24497. max = Infinity;
  24498. }
  24499. if (min > max) {
  24500. temp = min;
  24501. min = max;
  24502. max = temp;
  24503. }
  24504. d = Math.max(min, d);
  24505. maxValue = Math.min(max, maxValue);
  24506. if (d > maxValue) {
  24507. return false;
  24508. }
  24509. }
  24510. return true;
  24511. };
  24512. /**
  24513. * Checks if the ray intersects a box
  24514. * @param box the bounding box to check
  24515. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  24516. * @returns if the box was hit
  24517. */
  24518. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  24519. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24520. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  24521. };
  24522. /**
  24523. * If the ray hits a sphere
  24524. * @param sphere the bounding sphere to check
  24525. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  24526. * @returns true if it hits the sphere
  24527. */
  24528. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  24529. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24530. var x = sphere.center.x - this.origin.x;
  24531. var y = sphere.center.y - this.origin.y;
  24532. var z = sphere.center.z - this.origin.z;
  24533. var pyth = (x * x) + (y * y) + (z * z);
  24534. var radius = sphere.radius + intersectionTreshold;
  24535. var rr = radius * radius;
  24536. if (pyth <= rr) {
  24537. return true;
  24538. }
  24539. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  24540. if (dot < 0.0) {
  24541. return false;
  24542. }
  24543. var temp = pyth - (dot * dot);
  24544. return temp <= rr;
  24545. };
  24546. /**
  24547. * If the ray hits a triange
  24548. * @param vertex0 triangle vertex
  24549. * @param vertex1 triangle vertex
  24550. * @param vertex2 triangle vertex
  24551. * @returns intersection information if hit
  24552. */
  24553. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  24554. var edge1 = Ray.TmpVector3[0];
  24555. var edge2 = Ray.TmpVector3[1];
  24556. var pvec = Ray.TmpVector3[2];
  24557. var tvec = Ray.TmpVector3[3];
  24558. var qvec = Ray.TmpVector3[4];
  24559. vertex1.subtractToRef(vertex0, edge1);
  24560. vertex2.subtractToRef(vertex0, edge2);
  24561. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  24562. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  24563. if (det === 0) {
  24564. return null;
  24565. }
  24566. var invdet = 1 / det;
  24567. this.origin.subtractToRef(vertex0, tvec);
  24568. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  24569. if (bu < 0 || bu > 1.0) {
  24570. return null;
  24571. }
  24572. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  24573. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  24574. if (bv < 0 || bu + bv > 1.0) {
  24575. return null;
  24576. }
  24577. //check if the distance is longer than the predefined length.
  24578. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  24579. if (distance > this.length) {
  24580. return null;
  24581. }
  24582. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](bu, bv, distance);
  24583. };
  24584. /**
  24585. * Checks if ray intersects a plane
  24586. * @param plane the plane to check
  24587. * @returns the distance away it was hit
  24588. */
  24589. Ray.prototype.intersectsPlane = function (plane) {
  24590. var distance;
  24591. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  24592. if (Math.abs(result1) < 9.99999997475243E-07) {
  24593. return null;
  24594. }
  24595. else {
  24596. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  24597. distance = (-plane.d - result2) / result1;
  24598. if (distance < 0.0) {
  24599. if (distance < -9.99999997475243E-07) {
  24600. return null;
  24601. }
  24602. else {
  24603. return 0;
  24604. }
  24605. }
  24606. return distance;
  24607. }
  24608. };
  24609. /**
  24610. * Checks if ray intersects a mesh
  24611. * @param mesh the mesh to check
  24612. * @param fastCheck if only the bounding box should checked
  24613. * @returns picking info of the intersecton
  24614. */
  24615. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  24616. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  24617. mesh.getWorldMatrix().invertToRef(tm);
  24618. if (this._tmpRay) {
  24619. Ray.TransformToRef(this, tm, this._tmpRay);
  24620. }
  24621. else {
  24622. this._tmpRay = Ray.Transform(this, tm);
  24623. }
  24624. return mesh.intersects(this._tmpRay, fastCheck);
  24625. };
  24626. /**
  24627. * Checks if ray intersects a mesh
  24628. * @param meshes the meshes to check
  24629. * @param fastCheck if only the bounding box should checked
  24630. * @param results array to store result in
  24631. * @returns Array of picking infos
  24632. */
  24633. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  24634. if (results) {
  24635. results.length = 0;
  24636. }
  24637. else {
  24638. results = [];
  24639. }
  24640. for (var i = 0; i < meshes.length; i++) {
  24641. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  24642. if (pickInfo.hit) {
  24643. results.push(pickInfo);
  24644. }
  24645. }
  24646. results.sort(this._comparePickingInfo);
  24647. return results;
  24648. };
  24649. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  24650. if (pickingInfoA.distance < pickingInfoB.distance) {
  24651. return -1;
  24652. }
  24653. else if (pickingInfoA.distance > pickingInfoB.distance) {
  24654. return 1;
  24655. }
  24656. else {
  24657. return 0;
  24658. }
  24659. };
  24660. /**
  24661. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  24662. * @param sega the first point of the segment to test the intersection against
  24663. * @param segb the second point of the segment to test the intersection against
  24664. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  24665. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  24666. */
  24667. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  24668. var o = this.origin;
  24669. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  24670. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  24671. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  24672. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  24673. segb.subtractToRef(sega, u);
  24674. this.direction.scaleToRef(Ray.rayl, v);
  24675. o.addToRef(v, rsegb);
  24676. sega.subtractToRef(o, w);
  24677. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  24678. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  24679. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  24680. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  24681. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  24682. var D = a * c - b * b; // always >= 0
  24683. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  24684. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  24685. // compute the line parameters of the two closest points
  24686. if (D < Ray.smallnum) { // the lines are almost parallel
  24687. sN = 0.0; // force using point P0 on segment S1
  24688. sD = 1.0; // to prevent possible division by 0.0 later
  24689. tN = e;
  24690. tD = c;
  24691. }
  24692. else { // get the closest points on the infinite lines
  24693. sN = (b * e - c * d);
  24694. tN = (a * e - b * d);
  24695. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  24696. sN = 0.0;
  24697. tN = e;
  24698. tD = c;
  24699. }
  24700. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  24701. sN = sD;
  24702. tN = e + b;
  24703. tD = c;
  24704. }
  24705. }
  24706. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  24707. tN = 0.0;
  24708. // recompute sc for this edge
  24709. if (-d < 0.0) {
  24710. sN = 0.0;
  24711. }
  24712. else if (-d > a) {
  24713. sN = sD;
  24714. }
  24715. else {
  24716. sN = -d;
  24717. sD = a;
  24718. }
  24719. }
  24720. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  24721. tN = tD;
  24722. // recompute sc for this edge
  24723. if ((-d + b) < 0.0) {
  24724. sN = 0;
  24725. }
  24726. else if ((-d + b) > a) {
  24727. sN = sD;
  24728. }
  24729. else {
  24730. sN = (-d + b);
  24731. sD = a;
  24732. }
  24733. }
  24734. // finally do the division to get sc and tc
  24735. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  24736. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  24737. // get the difference of the two closest points
  24738. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  24739. v.scaleToRef(tc, qtc);
  24740. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  24741. u.scaleToRef(sc, qsc);
  24742. qsc.addInPlace(w);
  24743. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  24744. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  24745. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  24746. if (isIntersected) {
  24747. return qsc.length();
  24748. }
  24749. return -1;
  24750. };
  24751. /**
  24752. * Update the ray from viewport position
  24753. * @param x position
  24754. * @param y y position
  24755. * @param viewportWidth viewport width
  24756. * @param viewportHeight viewport height
  24757. * @param world world matrix
  24758. * @param view view matrix
  24759. * @param projection projection matrix
  24760. * @returns this ray updated
  24761. */
  24762. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  24763. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  24764. return this;
  24765. };
  24766. // Statics
  24767. /**
  24768. * Creates a ray with origin and direction of 0,0,0
  24769. * @returns the new ray
  24770. */
  24771. Ray.Zero = function () {
  24772. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  24773. };
  24774. /**
  24775. * Creates a new ray from screen space and viewport
  24776. * @param x position
  24777. * @param y y position
  24778. * @param viewportWidth viewport width
  24779. * @param viewportHeight viewport height
  24780. * @param world world matrix
  24781. * @param view view matrix
  24782. * @param projection projection matrix
  24783. * @returns new ray
  24784. */
  24785. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  24786. var result = Ray.Zero();
  24787. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  24788. };
  24789. /**
  24790. * 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
  24791. * transformed to the given world matrix.
  24792. * @param origin The origin point
  24793. * @param end The end point
  24794. * @param world a matrix to transform the ray to. Default is the identity matrix.
  24795. * @returns the new ray
  24796. */
  24797. Ray.CreateNewFromTo = function (origin, end, world) {
  24798. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  24799. var direction = end.subtract(origin);
  24800. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  24801. direction.normalize();
  24802. return Ray.Transform(new Ray(origin, direction, length), world);
  24803. };
  24804. /**
  24805. * Transforms a ray by a matrix
  24806. * @param ray ray to transform
  24807. * @param matrix matrix to apply
  24808. * @returns the resulting new ray
  24809. */
  24810. Ray.Transform = function (ray, matrix) {
  24811. 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));
  24812. Ray.TransformToRef(ray, matrix, result);
  24813. return result;
  24814. };
  24815. /**
  24816. * Transforms a ray by a matrix
  24817. * @param ray ray to transform
  24818. * @param matrix matrix to apply
  24819. * @param result ray to store result in
  24820. */
  24821. Ray.TransformToRef = function (ray, matrix, result) {
  24822. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  24823. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  24824. result.length = ray.length;
  24825. var dir = result.direction;
  24826. var len = dir.length();
  24827. if (!(len === 0 || len === 1)) {
  24828. var num = 1.0 / len;
  24829. dir.x *= num;
  24830. dir.y *= num;
  24831. dir.z *= num;
  24832. result.length *= len;
  24833. }
  24834. };
  24835. /**
  24836. * Unproject a ray from screen space to object space
  24837. * @param sourceX defines the screen space x coordinate to use
  24838. * @param sourceY defines the screen space y coordinate to use
  24839. * @param viewportWidth defines the current width of the viewport
  24840. * @param viewportHeight defines the current height of the viewport
  24841. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  24842. * @param view defines the view matrix to use
  24843. * @param projection defines the projection matrix to use
  24844. */
  24845. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  24846. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  24847. world.multiplyToRef(view, matrix);
  24848. matrix.multiplyToRef(projection, matrix);
  24849. matrix.invert();
  24850. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  24851. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  24852. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  24853. nearScreenSource.z = -1.0;
  24854. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  24855. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  24856. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  24857. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  24858. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  24859. this.origin.copyFrom(nearVec3);
  24860. farVec3.subtractToRef(nearVec3, this.direction);
  24861. this.direction.normalize();
  24862. };
  24863. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24864. Ray.smallnum = 0.00000001;
  24865. Ray.rayl = 10e8;
  24866. return Ray;
  24867. }());
  24868. /***/ }),
  24869. /***/ "./Debug/axesViewer.ts":
  24870. /*!*****************************!*\
  24871. !*** ./Debug/axesViewer.ts ***!
  24872. \*****************************/
  24873. /*! exports provided: AxesViewer */
  24874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24875. "use strict";
  24876. __webpack_require__.r(__webpack_exports__);
  24877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  24878. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24879. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  24880. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  24881. /**
  24882. * The Axes viewer will show 3 axes in a specific point in space
  24883. */
  24884. var AxesViewer = /** @class */ (function () {
  24885. /**
  24886. * Creates a new AxesViewer
  24887. * @param scene defines the hosting scene
  24888. * @param scaleLines defines a number used to scale line length (1 by default)
  24889. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  24890. * @param xAxis defines the node hierarchy used to render the x-axis
  24891. * @param yAxis defines the node hierarchy used to render the y-axis
  24892. * @param zAxis defines the node hierarchy used to render the z-axis
  24893. */
  24894. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  24895. if (scaleLines === void 0) { scaleLines = 1; }
  24896. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  24897. this._scaleLinesFactor = 4;
  24898. this._instanced = false;
  24899. /**
  24900. * Gets or sets a number used to scale line length
  24901. */
  24902. this.scaleLines = 1;
  24903. this.scaleLines = scaleLines;
  24904. if (!xAxis) {
  24905. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  24906. redColoredMaterial.disableLighting = true;
  24907. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  24908. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  24909. }
  24910. if (!yAxis) {
  24911. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  24912. greenColoredMaterial.disableLighting = true;
  24913. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  24914. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  24915. }
  24916. if (!zAxis) {
  24917. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  24918. blueColoredMaterial.disableLighting = true;
  24919. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  24920. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  24921. }
  24922. this._xAxis = xAxis;
  24923. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24924. this._yAxis = yAxis;
  24925. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24926. this._zAxis = zAxis;
  24927. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24928. if (renderingGroupId != null) {
  24929. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  24930. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  24931. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  24932. }
  24933. this.scene = scene;
  24934. 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());
  24935. }
  24936. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  24937. /** Gets the node hierarchy used to render x-axis */
  24938. get: function () {
  24939. return this._xAxis;
  24940. },
  24941. enumerable: true,
  24942. configurable: true
  24943. });
  24944. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  24945. /** Gets the node hierarchy used to render y-axis */
  24946. get: function () {
  24947. return this._yAxis;
  24948. },
  24949. enumerable: true,
  24950. configurable: true
  24951. });
  24952. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  24953. /** Gets the node hierarchy used to render z-axis */
  24954. get: function () {
  24955. return this._zAxis;
  24956. },
  24957. enumerable: true,
  24958. configurable: true
  24959. });
  24960. /**
  24961. * Force the viewer to update
  24962. * @param position defines the position of the viewer
  24963. * @param xaxis defines the x axis of the viewer
  24964. * @param yaxis defines the y axis of the viewer
  24965. * @param zaxis defines the z axis of the viewer
  24966. */
  24967. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  24968. this._xAxis.position.copyFrom(position);
  24969. this._xAxis.setDirection(xaxis);
  24970. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24971. this._yAxis.position.copyFrom(position);
  24972. this._yAxis.setDirection(yaxis);
  24973. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24974. this._zAxis.position.copyFrom(position);
  24975. this._zAxis.setDirection(zaxis);
  24976. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  24977. };
  24978. /**
  24979. * Creates an instance of this axes viewer.
  24980. * @returns a new axes viewer with instanced meshes
  24981. */
  24982. AxesViewer.prototype.createInstance = function () {
  24983. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  24984. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  24985. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  24986. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  24987. axesViewer._instanced = true;
  24988. return axesViewer;
  24989. };
  24990. /** Releases resources */
  24991. AxesViewer.prototype.dispose = function () {
  24992. if (this._xAxis) {
  24993. this._xAxis.dispose(false, !this._instanced);
  24994. delete this._xAxis;
  24995. }
  24996. if (this._yAxis) {
  24997. this._yAxis.dispose(false, !this._instanced);
  24998. delete this._yAxis;
  24999. }
  25000. if (this._zAxis) {
  25001. this._zAxis.dispose(false, !this._instanced);
  25002. delete this._zAxis;
  25003. }
  25004. delete this.scene;
  25005. };
  25006. AxesViewer._SetRenderingGroupId = function (node, id) {
  25007. node.getChildMeshes().forEach(function (mesh) {
  25008. mesh.renderingGroupId = id;
  25009. });
  25010. };
  25011. return AxesViewer;
  25012. }());
  25013. /***/ }),
  25014. /***/ "./Debug/boneAxesViewer.ts":
  25015. /*!*********************************!*\
  25016. !*** ./Debug/boneAxesViewer.ts ***!
  25017. \*********************************/
  25018. /*! exports provided: BoneAxesViewer */
  25019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25020. "use strict";
  25021. __webpack_require__.r(__webpack_exports__);
  25022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25023. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25024. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25026. /**
  25027. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25028. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25029. */
  25030. var BoneAxesViewer = /** @class */ (function (_super) {
  25031. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25032. /**
  25033. * Creates a new BoneAxesViewer
  25034. * @param scene defines the hosting scene
  25035. * @param bone defines the target bone
  25036. * @param mesh defines the target mesh
  25037. * @param scaleLines defines a scaling factor for line length (1 by default)
  25038. */
  25039. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25040. if (scaleLines === void 0) { scaleLines = 1; }
  25041. var _this = _super.call(this, scene, scaleLines) || this;
  25042. /** Gets current position */
  25043. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25044. /** Gets direction of X axis */
  25045. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25046. /** Gets direction of Y axis */
  25047. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25048. /** Gets direction of Z axis */
  25049. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25050. _this.mesh = mesh;
  25051. _this.bone = bone;
  25052. return _this;
  25053. }
  25054. /**
  25055. * Force the viewer to update
  25056. */
  25057. BoneAxesViewer.prototype.update = function () {
  25058. if (!this.mesh || !this.bone) {
  25059. return;
  25060. }
  25061. var bone = this.bone;
  25062. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25063. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25064. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25065. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25066. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25067. };
  25068. /** Releases resources */
  25069. BoneAxesViewer.prototype.dispose = function () {
  25070. if (this.mesh) {
  25071. this.mesh = null;
  25072. this.bone = null;
  25073. _super.prototype.dispose.call(this);
  25074. }
  25075. };
  25076. return BoneAxesViewer;
  25077. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25078. /***/ }),
  25079. /***/ "./Debug/debugLayer.ts":
  25080. /*!*****************************!*\
  25081. !*** ./Debug/debugLayer.ts ***!
  25082. \*****************************/
  25083. /*! exports provided: DebugLayer */
  25084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25085. "use strict";
  25086. __webpack_require__.r(__webpack_exports__);
  25087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25088. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25089. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25090. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25091. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25092. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25093. get: function () {
  25094. if (!this._debugLayer) {
  25095. this._debugLayer = new DebugLayer(this);
  25096. }
  25097. return this._debugLayer;
  25098. },
  25099. enumerable: true,
  25100. configurable: true
  25101. });
  25102. /**
  25103. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25104. * what is happening in your scene
  25105. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25106. */
  25107. var DebugLayer = /** @class */ (function () {
  25108. /**
  25109. * Instantiates a new debug layer.
  25110. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25111. * what is happening in your scene
  25112. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25113. * @param scene Defines the scene to inspect
  25114. */
  25115. function DebugLayer(scene) {
  25116. var _this = this;
  25117. this.BJSINSPECTOR = this._getGlobalInspector();
  25118. /**
  25119. * Observable triggered when a property is changed through the inspector.
  25120. */
  25121. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  25122. this._scene = scene;
  25123. this._scene.onDisposeObservable.add(function () {
  25124. // Debug layer
  25125. if (_this._scene._debugLayer) {
  25126. _this._scene._debugLayer.hide();
  25127. }
  25128. });
  25129. }
  25130. /** Creates the inspector window. */
  25131. DebugLayer.prototype._createInspector = function (config) {
  25132. if (this.isVisible()) {
  25133. return;
  25134. }
  25135. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  25136. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  25137. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  25138. };
  25139. /** Get the inspector from bundle or global */
  25140. DebugLayer.prototype._getGlobalInspector = function () {
  25141. // UMD Global name detection from Webpack Bundle UMD Name.
  25142. if (typeof INSPECTOR !== 'undefined') {
  25143. return INSPECTOR;
  25144. }
  25145. // In case of module let s check the global emitted from the Inspector entry point.
  25146. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  25147. return BABYLON;
  25148. }
  25149. return undefined;
  25150. };
  25151. /**
  25152. * Get if the inspector is visible or not.
  25153. * @returns true if visible otherwise, false
  25154. */
  25155. DebugLayer.prototype.isVisible = function () {
  25156. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  25157. };
  25158. /**
  25159. * Hide the inspector and close its window.
  25160. */
  25161. DebugLayer.prototype.hide = function () {
  25162. if (this.BJSINSPECTOR) {
  25163. this.BJSINSPECTOR.Inspector.Hide();
  25164. }
  25165. };
  25166. /**
  25167. * Launch the debugLayer.
  25168. * @param config Define the configuration of the inspector
  25169. */
  25170. DebugLayer.prototype.show = function (config) {
  25171. if (typeof this.BJSINSPECTOR == 'undefined') {
  25172. // Load inspector and add it to the DOM
  25173. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  25174. }
  25175. else {
  25176. // Otherwise creates the inspector
  25177. this._createInspector(config);
  25178. }
  25179. };
  25180. /**
  25181. * Define the url to get the inspector script from.
  25182. * By default it uses the babylonjs CDN.
  25183. * @ignoreNaming
  25184. */
  25185. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  25186. return DebugLayer;
  25187. }());
  25188. /***/ }),
  25189. /***/ "./Debug/index.ts":
  25190. /*!************************!*\
  25191. !*** ./Debug/index.ts ***!
  25192. \************************/
  25193. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  25194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25195. "use strict";
  25196. __webpack_require__.r(__webpack_exports__);
  25197. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  25198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  25199. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  25200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  25201. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  25202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  25203. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  25204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  25205. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  25206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  25207. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  25208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  25209. /***/ }),
  25210. /***/ "./Debug/physicsViewer.ts":
  25211. /*!********************************!*\
  25212. !*** ./Debug/physicsViewer.ts ***!
  25213. \********************************/
  25214. /*! exports provided: PhysicsViewer */
  25215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25216. "use strict";
  25217. __webpack_require__.r(__webpack_exports__);
  25218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  25219. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25221. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  25222. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25223. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  25224. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25225. /**
  25226. * Used to show the physics impostor around the specific mesh
  25227. */
  25228. var PhysicsViewer = /** @class */ (function () {
  25229. /**
  25230. * Creates a new PhysicsViewer
  25231. * @param scene defines the hosting scene
  25232. */
  25233. function PhysicsViewer(scene) {
  25234. /** @hidden */
  25235. this._impostors = [];
  25236. /** @hidden */
  25237. this._meshes = [];
  25238. /** @hidden */
  25239. this._numMeshes = 0;
  25240. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  25241. var physicEngine = this._scene.getPhysicsEngine();
  25242. if (physicEngine) {
  25243. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  25244. }
  25245. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__["UtilityLayerRenderer"](this._scene, false);
  25246. this._utilityLayer.pickUtilitySceneFirst = false;
  25247. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25248. }
  25249. /** @hidden */
  25250. PhysicsViewer.prototype._updateDebugMeshes = function () {
  25251. var plugin = this._physicsEnginePlugin;
  25252. for (var i = 0; i < this._numMeshes; i++) {
  25253. var impostor = this._impostors[i];
  25254. if (!impostor) {
  25255. continue;
  25256. }
  25257. if (impostor.isDisposed) {
  25258. this.hideImpostor(this._impostors[i--]);
  25259. }
  25260. else {
  25261. var mesh = this._meshes[i];
  25262. if (mesh && plugin) {
  25263. plugin.syncMeshWithImpostor(mesh, impostor);
  25264. }
  25265. }
  25266. }
  25267. };
  25268. /**
  25269. * Renders a specified physic impostor
  25270. * @param impostor defines the impostor to render
  25271. * @returns the new debug mesh used to render the impostor
  25272. */
  25273. PhysicsViewer.prototype.showImpostor = function (impostor) {
  25274. if (!this._scene) {
  25275. return null;
  25276. }
  25277. for (var i = 0; i < this._numMeshes; i++) {
  25278. if (this._impostors[i] == impostor) {
  25279. return null;
  25280. }
  25281. }
  25282. var debugMesh = this._getDebugMesh(impostor);
  25283. if (debugMesh) {
  25284. this._impostors[this._numMeshes] = impostor;
  25285. this._meshes[this._numMeshes] = debugMesh;
  25286. if (this._numMeshes === 0) {
  25287. this._renderFunction = this._updateDebugMeshes.bind(this);
  25288. this._scene.registerBeforeRender(this._renderFunction);
  25289. }
  25290. this._numMeshes++;
  25291. }
  25292. return debugMesh;
  25293. };
  25294. /**
  25295. * Hides a specified physic impostor
  25296. * @param impostor defines the impostor to hide
  25297. */
  25298. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  25299. if (!impostor || !this._scene || !this._utilityLayer) {
  25300. return;
  25301. }
  25302. var removed = false;
  25303. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25304. for (var i = 0; i < this._numMeshes; i++) {
  25305. if (this._impostors[i] == impostor) {
  25306. var mesh = this._meshes[i];
  25307. if (!mesh) {
  25308. continue;
  25309. }
  25310. utilityLayerScene.removeMesh(mesh);
  25311. mesh.dispose();
  25312. this._numMeshes--;
  25313. if (this._numMeshes > 0) {
  25314. this._meshes[i] = this._meshes[this._numMeshes];
  25315. this._impostors[i] = this._impostors[this._numMeshes];
  25316. this._meshes[this._numMeshes] = null;
  25317. this._impostors[this._numMeshes] = null;
  25318. }
  25319. else {
  25320. this._meshes[0] = null;
  25321. this._impostors[0] = null;
  25322. }
  25323. removed = true;
  25324. break;
  25325. }
  25326. }
  25327. if (removed && this._numMeshes === 0) {
  25328. this._scene.unregisterBeforeRender(this._renderFunction);
  25329. }
  25330. };
  25331. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  25332. if (!this._debugMaterial) {
  25333. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]('', scene);
  25334. this._debugMaterial.wireframe = true;
  25335. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  25336. this._debugMaterial.disableLighting = true;
  25337. }
  25338. return this._debugMaterial;
  25339. };
  25340. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  25341. if (!this._debugBoxMesh) {
  25342. this._debugBoxMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  25343. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25344. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  25345. }
  25346. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  25347. };
  25348. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  25349. if (!this._debugSphereMesh) {
  25350. this._debugSphereMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  25351. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25352. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  25353. }
  25354. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  25355. };
  25356. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  25357. if (!this._utilityLayer) {
  25358. return null;
  25359. }
  25360. var mesh = null;
  25361. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25362. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].BoxImpostor) {
  25363. mesh = this._getDebugBoxMesh(utilityLayerScene);
  25364. impostor.getBoxSizeToRef(mesh.scaling);
  25365. }
  25366. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].SphereImpostor) {
  25367. mesh = this._getDebugSphereMesh(utilityLayerScene);
  25368. var radius = impostor.getRadius();
  25369. mesh.scaling.x = radius * 2;
  25370. mesh.scaling.y = radius * 2;
  25371. mesh.scaling.z = radius * 2;
  25372. }
  25373. return mesh;
  25374. };
  25375. /** Releases all resources */
  25376. PhysicsViewer.prototype.dispose = function () {
  25377. for (var i = 0; i < this._numMeshes; i++) {
  25378. this.hideImpostor(this._impostors[i]);
  25379. }
  25380. if (this._debugBoxMesh) {
  25381. this._debugBoxMesh.dispose();
  25382. }
  25383. if (this._debugSphereMesh) {
  25384. this._debugSphereMesh.dispose();
  25385. }
  25386. if (this._debugMaterial) {
  25387. this._debugMaterial.dispose();
  25388. }
  25389. this._impostors.length = 0;
  25390. this._scene = null;
  25391. this._physicsEnginePlugin = null;
  25392. if (this._utilityLayer) {
  25393. this._utilityLayer.dispose();
  25394. this._utilityLayer = null;
  25395. }
  25396. };
  25397. return PhysicsViewer;
  25398. }());
  25399. /***/ }),
  25400. /***/ "./Debug/rayHelper.ts":
  25401. /*!****************************!*\
  25402. !*** ./Debug/rayHelper.ts ***!
  25403. \****************************/
  25404. /*! exports provided: RayHelper */
  25405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25406. "use strict";
  25407. __webpack_require__.r(__webpack_exports__);
  25408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  25409. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25410. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  25411. /**
  25412. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25413. * in order to better appreciate the issue one might have.
  25414. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25415. */
  25416. var RayHelper = /** @class */ (function () {
  25417. /**
  25418. * Instantiate a new ray helper.
  25419. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25420. * in order to better appreciate the issue one might have.
  25421. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25422. * @param ray Defines the ray we are currently tryin to visualize
  25423. */
  25424. function RayHelper(ray) {
  25425. this.ray = ray;
  25426. }
  25427. /**
  25428. * Helper function to create a colored helper in a scene in one line.
  25429. * @param ray Defines the ray we are currently tryin to visualize
  25430. * @param scene Defines the scene the ray is used in
  25431. * @param color Defines the color we want to see the ray in
  25432. * @returns The newly created ray helper.
  25433. */
  25434. RayHelper.CreateAndShow = function (ray, scene, color) {
  25435. var helper = new RayHelper(ray);
  25436. helper.show(scene, color);
  25437. return helper;
  25438. };
  25439. /**
  25440. * Shows the ray we are willing to debug.
  25441. * @param scene Defines the scene the ray needs to be rendered in
  25442. * @param color Defines the color the ray needs to be rendered in
  25443. */
  25444. RayHelper.prototype.show = function (scene, color) {
  25445. if (!this._renderFunction && this.ray) {
  25446. var ray = this.ray;
  25447. this._renderFunction = this._render.bind(this);
  25448. this._scene = scene;
  25449. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  25450. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  25451. if (this._renderFunction) {
  25452. this._scene.registerBeforeRender(this._renderFunction);
  25453. }
  25454. }
  25455. if (color && this._renderLine) {
  25456. this._renderLine.color.copyFrom(color);
  25457. }
  25458. };
  25459. /**
  25460. * Hides the ray we are debugging.
  25461. */
  25462. RayHelper.prototype.hide = function () {
  25463. if (this._renderFunction && this._scene) {
  25464. this._scene.unregisterBeforeRender(this._renderFunction);
  25465. this._scene = null;
  25466. this._renderFunction = null;
  25467. if (this._renderLine) {
  25468. this._renderLine.dispose();
  25469. this._renderLine = null;
  25470. }
  25471. this._renderPoints = [];
  25472. }
  25473. };
  25474. RayHelper.prototype._render = function () {
  25475. var ray = this.ray;
  25476. if (!ray) {
  25477. return;
  25478. }
  25479. var point = this._renderPoints[1];
  25480. var len = Math.min(ray.length, 1000000);
  25481. point.copyFrom(ray.direction);
  25482. point.scaleInPlace(len);
  25483. point.addInPlace(ray.origin);
  25484. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  25485. };
  25486. /**
  25487. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  25488. * @param mesh Defines the mesh we want the helper attached to
  25489. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  25490. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  25491. * @param length Defines the length of the ray
  25492. */
  25493. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  25494. this._attachedToMesh = mesh;
  25495. var ray = this.ray;
  25496. if (!ray) {
  25497. return;
  25498. }
  25499. if (!ray.direction) {
  25500. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25501. }
  25502. if (!ray.origin) {
  25503. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25504. }
  25505. if (length) {
  25506. ray.length = length;
  25507. }
  25508. if (!meshSpaceOrigin) {
  25509. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25510. }
  25511. if (!meshSpaceDirection) {
  25512. // -1 so that this will work with Mesh.lookAt
  25513. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  25514. }
  25515. if (!this._meshSpaceDirection) {
  25516. this._meshSpaceDirection = meshSpaceDirection.clone();
  25517. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  25518. }
  25519. else {
  25520. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  25521. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  25522. }
  25523. if (!this._updateToMeshFunction) {
  25524. this._updateToMeshFunction = this._updateToMesh.bind(this);
  25525. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  25526. }
  25527. this._updateToMesh();
  25528. };
  25529. /**
  25530. * Detach the ray helper from the mesh it has previously been attached to.
  25531. */
  25532. RayHelper.prototype.detachFromMesh = function () {
  25533. if (this._attachedToMesh) {
  25534. if (this._updateToMeshFunction) {
  25535. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  25536. }
  25537. this._attachedToMesh = null;
  25538. this._updateToMeshFunction = null;
  25539. }
  25540. };
  25541. RayHelper.prototype._updateToMesh = function () {
  25542. var ray = this.ray;
  25543. if (!this._attachedToMesh || !ray) {
  25544. return;
  25545. }
  25546. if (this._attachedToMesh._isDisposed) {
  25547. this.detachFromMesh();
  25548. return;
  25549. }
  25550. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  25551. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  25552. };
  25553. /**
  25554. * Dispose the helper and release its associated resources.
  25555. */
  25556. RayHelper.prototype.dispose = function () {
  25557. this.hide();
  25558. this.detachFromMesh();
  25559. this.ray = null;
  25560. };
  25561. return RayHelper;
  25562. }());
  25563. /***/ }),
  25564. /***/ "./Debug/skeletonViewer.ts":
  25565. /*!*********************************!*\
  25566. !*** ./Debug/skeletonViewer.ts ***!
  25567. \*********************************/
  25568. /*! exports provided: SkeletonViewer */
  25569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25570. "use strict";
  25571. __webpack_require__.r(__webpack_exports__);
  25572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  25573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25574. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25575. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25576. /**
  25577. * Class used to render a debug view of a given skeleton
  25578. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  25579. */
  25580. var SkeletonViewer = /** @class */ (function () {
  25581. /**
  25582. * Creates a new SkeletonViewer
  25583. * @param skeleton defines the skeleton to render
  25584. * @param mesh defines the mesh attached to the skeleton
  25585. * @param scene defines the hosting scene
  25586. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  25587. * @param renderingGroupId defines the rendering group id to use with the viewer
  25588. */
  25589. function SkeletonViewer(
  25590. /** defines the skeleton to render */
  25591. skeleton,
  25592. /** defines the mesh attached to the skeleton */
  25593. mesh, scene,
  25594. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  25595. autoUpdateBonesMatrices,
  25596. /** defines the rendering group id to use with the viewer */
  25597. renderingGroupId) {
  25598. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  25599. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  25600. this.skeleton = skeleton;
  25601. this.mesh = mesh;
  25602. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  25603. this.renderingGroupId = renderingGroupId;
  25604. /** Gets or sets the color used to render the skeleton */
  25605. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  25606. this._debugLines = new Array();
  25607. this._isEnabled = false;
  25608. this._scene = scene;
  25609. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  25610. this._utilityLayer.pickUtilitySceneFirst = false;
  25611. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25612. this.update();
  25613. this._renderFunction = this.update.bind(this);
  25614. }
  25615. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  25616. /**
  25617. * Returns the mesh used to render the bones
  25618. */
  25619. get: function () {
  25620. return this._debugMesh;
  25621. },
  25622. enumerable: true,
  25623. configurable: true
  25624. });
  25625. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  25626. get: function () {
  25627. return this._isEnabled;
  25628. },
  25629. /** Gets or sets a boolean indicating if the viewer is enabled */
  25630. set: function (value) {
  25631. if (this._isEnabled === value) {
  25632. return;
  25633. }
  25634. this._isEnabled = value;
  25635. if (value) {
  25636. this._scene.registerBeforeRender(this._renderFunction);
  25637. }
  25638. else {
  25639. this._scene.unregisterBeforeRender(this._renderFunction);
  25640. }
  25641. },
  25642. enumerable: true,
  25643. configurable: true
  25644. });
  25645. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  25646. if (x === void 0) { x = 0; }
  25647. if (y === void 0) { y = 0; }
  25648. if (z === void 0) { z = 0; }
  25649. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  25650. var parentBone = bone.getParent();
  25651. tmat.copyFrom(bone.getLocalMatrix());
  25652. if (x !== 0 || y !== 0 || z !== 0) {
  25653. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  25654. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  25655. tmat2.setTranslationFromFloats(x, y, z);
  25656. tmat2.multiplyToRef(tmat, tmat);
  25657. }
  25658. if (parentBone) {
  25659. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  25660. }
  25661. tmat.multiplyToRef(meshMat, tmat);
  25662. position.x = tmat.m[12];
  25663. position.y = tmat.m[13];
  25664. position.z = tmat.m[14];
  25665. };
  25666. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  25667. var len = bones.length;
  25668. var meshPos = this.mesh.position;
  25669. for (var i = 0; i < len; i++) {
  25670. var bone = bones[i];
  25671. var points = this._debugLines[i];
  25672. if (!points) {
  25673. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25674. this._debugLines[i] = points;
  25675. }
  25676. this._getBonePosition(points[0], bone, meshMat);
  25677. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  25678. points[0].subtractInPlace(meshPos);
  25679. points[1].subtractInPlace(meshPos);
  25680. }
  25681. };
  25682. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  25683. var len = bones.length;
  25684. var boneNum = 0;
  25685. var meshPos = this.mesh.position;
  25686. for (var i = len - 1; i >= 0; i--) {
  25687. var childBone = bones[i];
  25688. var parentBone = childBone.getParent();
  25689. if (!parentBone) {
  25690. continue;
  25691. }
  25692. var points = this._debugLines[boneNum];
  25693. if (!points) {
  25694. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25695. this._debugLines[boneNum] = points;
  25696. }
  25697. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  25698. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  25699. points[0].subtractInPlace(meshPos);
  25700. points[1].subtractInPlace(meshPos);
  25701. boneNum++;
  25702. }
  25703. };
  25704. /** Update the viewer to sync with current skeleton state */
  25705. SkeletonViewer.prototype.update = function () {
  25706. if (!this._utilityLayer) {
  25707. return;
  25708. }
  25709. if (this.autoUpdateBonesMatrices) {
  25710. this.skeleton.computeAbsoluteTransforms();
  25711. }
  25712. if (this.skeleton.bones[0].length === undefined) {
  25713. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25714. }
  25715. else {
  25716. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25717. }
  25718. var targetScene = this._utilityLayer.utilityLayerScene;
  25719. if (!this._debugMesh) {
  25720. this._debugMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  25721. this._debugMesh.renderingGroupId = this.renderingGroupId;
  25722. }
  25723. else {
  25724. _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  25725. }
  25726. this._debugMesh.position.copyFrom(this.mesh.position);
  25727. this._debugMesh.color = this.color;
  25728. };
  25729. /** Release associated resources */
  25730. SkeletonViewer.prototype.dispose = function () {
  25731. this.isEnabled = false;
  25732. if (this._debugMesh) {
  25733. this.isEnabled = false;
  25734. this._debugMesh.dispose();
  25735. this._debugMesh = null;
  25736. }
  25737. if (this._utilityLayer) {
  25738. this._utilityLayer.dispose();
  25739. this._utilityLayer = null;
  25740. }
  25741. };
  25742. return SkeletonViewer;
  25743. }());
  25744. /***/ }),
  25745. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  25746. /*!*****************************************************!*\
  25747. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  25748. \*****************************************************/
  25749. /*! exports provided: _OcclusionDataStorage */
  25750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25751. "use strict";
  25752. __webpack_require__.r(__webpack_exports__);
  25753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  25754. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  25755. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  25756. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  25757. /** @hidden */
  25758. var _OcclusionDataStorage = /** @class */ (function () {
  25759. function _OcclusionDataStorage() {
  25760. /** @hidden */
  25761. this.occlusionInternalRetryCounter = 0;
  25762. /** @hidden */
  25763. this.isOcclusionQueryInProgress = false;
  25764. /** @hidden */
  25765. this.isOccluded = false;
  25766. /** @hidden */
  25767. this.occlusionRetryCount = -1;
  25768. /** @hidden */
  25769. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  25770. /** @hidden */
  25771. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  25772. }
  25773. return _OcclusionDataStorage;
  25774. }());
  25775. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  25776. return this._gl.createQuery();
  25777. };
  25778. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  25779. this._gl.deleteQuery(query);
  25780. return this;
  25781. };
  25782. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  25783. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  25784. };
  25785. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  25786. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  25787. };
  25788. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  25789. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  25790. this._gl.beginQuery(glAlgorithm, query);
  25791. return this;
  25792. };
  25793. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  25794. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  25795. this._gl.endQuery(glAlgorithm);
  25796. return this;
  25797. };
  25798. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  25799. var timerQuery = this.getCaps().timerQuery;
  25800. if (timerQuery.createQueryEXT) {
  25801. return timerQuery.createQueryEXT();
  25802. }
  25803. return this.createQuery();
  25804. };
  25805. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  25806. var timerQuery = this.getCaps().timerQuery;
  25807. if (timerQuery.deleteQueryEXT) {
  25808. timerQuery.deleteQueryEXT(query);
  25809. return;
  25810. }
  25811. this.deleteQuery(query);
  25812. };
  25813. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  25814. var timerQuery = this.getCaps().timerQuery;
  25815. if (timerQuery.getQueryObjectEXT) {
  25816. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  25817. }
  25818. return this.getQueryResult(query);
  25819. };
  25820. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  25821. var timerQuery = this.getCaps().timerQuery;
  25822. if (timerQuery.getQueryObjectEXT) {
  25823. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  25824. }
  25825. return this.isQueryResultAvailable(query);
  25826. };
  25827. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  25828. var caps = this.getCaps();
  25829. var timerQuery = caps.timerQuery;
  25830. if (!timerQuery) {
  25831. return null;
  25832. }
  25833. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  25834. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  25835. if (caps.canUseTimestampForTimerQuery) {
  25836. token._startTimeQuery = this._createTimeQuery();
  25837. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  25838. }
  25839. else {
  25840. if (this._currentNonTimestampToken) {
  25841. return this._currentNonTimestampToken;
  25842. }
  25843. token._timeElapsedQuery = this._createTimeQuery();
  25844. if (timerQuery.beginQueryEXT) {
  25845. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  25846. }
  25847. else {
  25848. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  25849. }
  25850. this._currentNonTimestampToken = token;
  25851. }
  25852. return token;
  25853. };
  25854. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  25855. var caps = this.getCaps();
  25856. var timerQuery = caps.timerQuery;
  25857. if (!timerQuery || !token) {
  25858. return -1;
  25859. }
  25860. if (caps.canUseTimestampForTimerQuery) {
  25861. if (!token._startTimeQuery) {
  25862. return -1;
  25863. }
  25864. if (!token._endTimeQuery) {
  25865. token._endTimeQuery = this._createTimeQuery();
  25866. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  25867. }
  25868. }
  25869. else if (!token._timeElapsedQueryEnded) {
  25870. if (!token._timeElapsedQuery) {
  25871. return -1;
  25872. }
  25873. if (timerQuery.endQueryEXT) {
  25874. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  25875. }
  25876. else {
  25877. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  25878. }
  25879. token._timeElapsedQueryEnded = true;
  25880. }
  25881. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  25882. var available = false;
  25883. if (token._endTimeQuery) {
  25884. available = this._getTimeQueryAvailability(token._endTimeQuery);
  25885. }
  25886. else if (token._timeElapsedQuery) {
  25887. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  25888. }
  25889. if (available && !disjoint) {
  25890. var result = 0;
  25891. if (caps.canUseTimestampForTimerQuery) {
  25892. if (!token._startTimeQuery || !token._endTimeQuery) {
  25893. return -1;
  25894. }
  25895. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  25896. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  25897. result = timeEnd - timeStart;
  25898. this._deleteTimeQuery(token._startTimeQuery);
  25899. this._deleteTimeQuery(token._endTimeQuery);
  25900. token._startTimeQuery = null;
  25901. token._endTimeQuery = null;
  25902. }
  25903. else {
  25904. if (!token._timeElapsedQuery) {
  25905. return -1;
  25906. }
  25907. result = this._getTimeQueryResult(token._timeElapsedQuery);
  25908. this._deleteTimeQuery(token._timeElapsedQuery);
  25909. token._timeElapsedQuery = null;
  25910. token._timeElapsedQueryEnded = false;
  25911. this._currentNonTimestampToken = null;
  25912. }
  25913. return result;
  25914. }
  25915. return -1;
  25916. };
  25917. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  25918. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  25919. };
  25920. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  25921. get: function () {
  25922. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  25923. },
  25924. enumerable: false,
  25925. configurable: true
  25926. });
  25927. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  25928. get: function () {
  25929. if (!this.__occlusionDataStorage) {
  25930. this.__occlusionDataStorage = new _OcclusionDataStorage();
  25931. }
  25932. return this.__occlusionDataStorage;
  25933. },
  25934. enumerable: false,
  25935. configurable: true
  25936. });
  25937. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  25938. get: function () {
  25939. return this._occlusionDataStorage.isOccluded;
  25940. },
  25941. set: function (value) {
  25942. this._occlusionDataStorage.isOccluded = value;
  25943. },
  25944. enumerable: true,
  25945. configurable: true
  25946. });
  25947. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  25948. get: function () {
  25949. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  25950. },
  25951. set: function (value) {
  25952. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  25953. },
  25954. enumerable: true,
  25955. configurable: true
  25956. });
  25957. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  25958. get: function () {
  25959. return this._occlusionDataStorage.occlusionType;
  25960. },
  25961. set: function (value) {
  25962. this._occlusionDataStorage.occlusionType = value;
  25963. },
  25964. enumerable: true,
  25965. configurable: true
  25966. });
  25967. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  25968. get: function () {
  25969. return this._occlusionDataStorage.occlusionRetryCount;
  25970. },
  25971. set: function (value) {
  25972. this._occlusionDataStorage.occlusionRetryCount = value;
  25973. },
  25974. enumerable: true,
  25975. configurable: true
  25976. });
  25977. // We also need to update AbstractMesh as there is a portion of the code there
  25978. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  25979. var dataStorage = this._occlusionDataStorage;
  25980. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  25981. dataStorage.isOccluded = false;
  25982. return false;
  25983. }
  25984. var engine = this.getEngine();
  25985. if (engine.webGLVersion < 2) {
  25986. dataStorage.isOccluded = false;
  25987. return false;
  25988. }
  25989. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  25990. dataStorage.isOccluded = false;
  25991. return false;
  25992. }
  25993. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  25994. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  25995. if (isOcclusionQueryAvailable) {
  25996. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  25997. dataStorage.isOcclusionQueryInProgress = false;
  25998. dataStorage.occlusionInternalRetryCounter = 0;
  25999. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26000. }
  26001. else {
  26002. dataStorage.occlusionInternalRetryCounter++;
  26003. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26004. dataStorage.isOcclusionQueryInProgress = false;
  26005. dataStorage.occlusionInternalRetryCounter = 0;
  26006. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26007. // if strict continue the last state of the object.
  26008. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26009. }
  26010. else {
  26011. return false;
  26012. }
  26013. }
  26014. }
  26015. var scene = this.getScene();
  26016. if (scene.getBoundingBoxRenderer) {
  26017. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26018. if (!this._occlusionQuery) {
  26019. this._occlusionQuery = engine.createQuery();
  26020. }
  26021. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26022. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26023. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26024. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26025. }
  26026. return dataStorage.isOccluded;
  26027. };
  26028. /***/ }),
  26029. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26030. /*!********************************************************!*\
  26031. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26032. \********************************************************/
  26033. /*! exports provided: _forceTransformFeedbackToBundle */
  26034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26035. "use strict";
  26036. __webpack_require__.r(__webpack_exports__);
  26037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26038. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26039. /** @hidden */
  26040. var _forceTransformFeedbackToBundle = true;
  26041. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26042. return this._gl.createTransformFeedback();
  26043. };
  26044. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26045. this._gl.deleteTransformFeedback(value);
  26046. };
  26047. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26048. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26049. };
  26050. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26051. if (usePoints === void 0) { usePoints = true; }
  26052. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26053. };
  26054. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26055. this._gl.endTransformFeedback();
  26056. };
  26057. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26058. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26059. };
  26060. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26061. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26062. };
  26063. /***/ }),
  26064. /***/ "./Engines/Extensions/index.ts":
  26065. /*!*************************************!*\
  26066. !*** ./Engines/Extensions/index.ts ***!
  26067. \*************************************/
  26068. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26070. "use strict";
  26071. __webpack_require__.r(__webpack_exports__);
  26072. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26074. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26076. /***/ }),
  26077. /***/ "./Engines/constants.ts":
  26078. /*!******************************!*\
  26079. !*** ./Engines/constants.ts ***!
  26080. \******************************/
  26081. /*! exports provided: Constants */
  26082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26083. "use strict";
  26084. __webpack_require__.r(__webpack_exports__);
  26085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26086. /** Defines the cross module used constants to avoid circular dependncies */
  26087. var Constants = /** @class */ (function () {
  26088. function Constants() {
  26089. }
  26090. /** Defines that alpha blending is disabled */
  26091. Constants.ALPHA_DISABLE = 0;
  26092. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26093. Constants.ALPHA_ADD = 1;
  26094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26095. Constants.ALPHA_COMBINE = 2;
  26096. /** Defines that alpha blending to DEST - SRC * DEST */
  26097. Constants.ALPHA_SUBTRACT = 3;
  26098. /** Defines that alpha blending to SRC * DEST */
  26099. Constants.ALPHA_MULTIPLY = 4;
  26100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26101. Constants.ALPHA_MAXIMIZED = 5;
  26102. /** Defines that alpha blending to SRC + DEST */
  26103. Constants.ALPHA_ONEONE = 6;
  26104. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26105. Constants.ALPHA_PREMULTIPLIED = 7;
  26106. /**
  26107. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26108. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26109. */
  26110. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  26111. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26112. Constants.ALPHA_INTERPOLATE = 9;
  26113. /**
  26114. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26115. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26116. */
  26117. Constants.ALPHA_SCREENMODE = 10;
  26118. /** Defines that the ressource is not delayed*/
  26119. Constants.DELAYLOADSTATE_NONE = 0;
  26120. /** Defines that the ressource was successfully delay loaded */
  26121. Constants.DELAYLOADSTATE_LOADED = 1;
  26122. /** Defines that the ressource is currently delay loading */
  26123. Constants.DELAYLOADSTATE_LOADING = 2;
  26124. /** Defines that the ressource is delayed and has not started loading */
  26125. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  26126. // Depht or Stencil test Constants.
  26127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26128. Constants.NEVER = 0x0200;
  26129. /** 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 */
  26130. Constants.ALWAYS = 0x0207;
  26131. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26132. Constants.LESS = 0x0201;
  26133. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26134. Constants.EQUAL = 0x0202;
  26135. /** 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 */
  26136. Constants.LEQUAL = 0x0203;
  26137. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26138. Constants.GREATER = 0x0204;
  26139. /** 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 */
  26140. Constants.GEQUAL = 0x0206;
  26141. /** 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 */
  26142. Constants.NOTEQUAL = 0x0205;
  26143. // Stencil Actions Constants.
  26144. /** Passed to stencilOperation to specify that stencil value must be kept */
  26145. Constants.KEEP = 0x1E00;
  26146. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26147. Constants.REPLACE = 0x1E01;
  26148. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26149. Constants.INCR = 0x1E02;
  26150. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26151. Constants.DECR = 0x1E03;
  26152. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26153. Constants.INVERT = 0x150A;
  26154. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26155. Constants.INCR_WRAP = 0x8507;
  26156. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26157. Constants.DECR_WRAP = 0x8508;
  26158. /** Texture is not repeating outside of 0..1 UVs */
  26159. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  26160. /** Texture is repeating outside of 0..1 UVs */
  26161. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  26162. /** Texture is repeating and mirrored */
  26163. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  26164. /** ALPHA */
  26165. Constants.TEXTUREFORMAT_ALPHA = 0;
  26166. /** LUMINANCE */
  26167. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  26168. /** LUMINANCE_ALPHA */
  26169. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  26170. /** RGB */
  26171. Constants.TEXTUREFORMAT_RGB = 4;
  26172. /** RGBA */
  26173. Constants.TEXTUREFORMAT_RGBA = 5;
  26174. /** RED */
  26175. Constants.TEXTUREFORMAT_RED = 6;
  26176. /** RED (2nd reference) */
  26177. Constants.TEXTUREFORMAT_R = 6;
  26178. /** RG */
  26179. Constants.TEXTUREFORMAT_RG = 7;
  26180. /** RED_INTEGER */
  26181. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  26182. /** RED_INTEGER (2nd reference) */
  26183. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  26184. /** RG_INTEGER */
  26185. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  26186. /** RGB_INTEGER */
  26187. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  26188. /** RGBA_INTEGER */
  26189. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  26190. /** UNSIGNED_BYTE */
  26191. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  26192. /** UNSIGNED_BYTE (2nd reference) */
  26193. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  26194. /** FLOAT */
  26195. Constants.TEXTURETYPE_FLOAT = 1;
  26196. /** HALF_FLOAT */
  26197. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  26198. /** BYTE */
  26199. Constants.TEXTURETYPE_BYTE = 3;
  26200. /** SHORT */
  26201. Constants.TEXTURETYPE_SHORT = 4;
  26202. /** UNSIGNED_SHORT */
  26203. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  26204. /** INT */
  26205. Constants.TEXTURETYPE_INT = 6;
  26206. /** UNSIGNED_INT */
  26207. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  26208. /** UNSIGNED_SHORT_4_4_4_4 */
  26209. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  26210. /** UNSIGNED_SHORT_5_5_5_1 */
  26211. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  26212. /** UNSIGNED_SHORT_5_6_5 */
  26213. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  26214. /** UNSIGNED_INT_2_10_10_10_REV */
  26215. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  26216. /** UNSIGNED_INT_24_8 */
  26217. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  26218. /** UNSIGNED_INT_10F_11F_11F_REV */
  26219. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  26220. /** UNSIGNED_INT_5_9_9_9_REV */
  26221. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  26222. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26223. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  26224. /** nearest is mag = nearest and min = nearest and mip = linear */
  26225. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  26226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26227. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  26228. /** Trilinear is mag = linear and min = linear and mip = linear */
  26229. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  26230. /** nearest is mag = nearest and min = nearest and mip = linear */
  26231. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  26232. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26233. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  26234. /** Trilinear is mag = linear and min = linear and mip = linear */
  26235. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  26236. /** mag = nearest and min = nearest and mip = nearest */
  26237. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  26238. /** mag = nearest and min = linear and mip = nearest */
  26239. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  26240. /** mag = nearest and min = linear and mip = linear */
  26241. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  26242. /** mag = nearest and min = linear and mip = none */
  26243. Constants.TEXTURE_NEAREST_LINEAR = 7;
  26244. /** mag = nearest and min = nearest and mip = none */
  26245. Constants.TEXTURE_NEAREST_NEAREST = 8;
  26246. /** mag = linear and min = nearest and mip = nearest */
  26247. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  26248. /** mag = linear and min = nearest and mip = linear */
  26249. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  26250. /** mag = linear and min = linear and mip = none */
  26251. Constants.TEXTURE_LINEAR_LINEAR = 11;
  26252. /** mag = linear and min = nearest and mip = none */
  26253. Constants.TEXTURE_LINEAR_NEAREST = 12;
  26254. /** Explicit coordinates mode */
  26255. Constants.TEXTURE_EXPLICIT_MODE = 0;
  26256. /** Spherical coordinates mode */
  26257. Constants.TEXTURE_SPHERICAL_MODE = 1;
  26258. /** Planar coordinates mode */
  26259. Constants.TEXTURE_PLANAR_MODE = 2;
  26260. /** Cubic coordinates mode */
  26261. Constants.TEXTURE_CUBIC_MODE = 3;
  26262. /** Projection coordinates mode */
  26263. Constants.TEXTURE_PROJECTION_MODE = 4;
  26264. /** Skybox coordinates mode */
  26265. Constants.TEXTURE_SKYBOX_MODE = 5;
  26266. /** Inverse Cubic coordinates mode */
  26267. Constants.TEXTURE_INVCUBIC_MODE = 6;
  26268. /** Equirectangular coordinates mode */
  26269. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  26270. /** Equirectangular Fixed coordinates mode */
  26271. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  26272. /** Equirectangular Fixed Mirrored coordinates mode */
  26273. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  26274. // Texture rescaling mode
  26275. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26276. Constants.SCALEMODE_FLOOR = 1;
  26277. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26278. Constants.SCALEMODE_NEAREST = 2;
  26279. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26280. Constants.SCALEMODE_CEILING = 3;
  26281. /**
  26282. * The dirty texture flag value
  26283. */
  26284. Constants.MATERIAL_TextureDirtyFlag = 1;
  26285. /**
  26286. * The dirty light flag value
  26287. */
  26288. Constants.MATERIAL_LightDirtyFlag = 2;
  26289. /**
  26290. * The dirty fresnel flag value
  26291. */
  26292. Constants.MATERIAL_FresnelDirtyFlag = 4;
  26293. /**
  26294. * The dirty attribute flag value
  26295. */
  26296. Constants.MATERIAL_AttributesDirtyFlag = 8;
  26297. /**
  26298. * The dirty misc flag value
  26299. */
  26300. Constants.MATERIAL_MiscDirtyFlag = 16;
  26301. /**
  26302. * The all dirty flag value
  26303. */
  26304. Constants.MATERIAL_AllDirtyFlag = 31;
  26305. /**
  26306. * Returns the triangle fill mode
  26307. */
  26308. Constants.MATERIAL_TriangleFillMode = 0;
  26309. /**
  26310. * Returns the wireframe mode
  26311. */
  26312. Constants.MATERIAL_WireFrameFillMode = 1;
  26313. /**
  26314. * Returns the point fill mode
  26315. */
  26316. Constants.MATERIAL_PointFillMode = 2;
  26317. /**
  26318. * Returns the point list draw mode
  26319. */
  26320. Constants.MATERIAL_PointListDrawMode = 3;
  26321. /**
  26322. * Returns the line list draw mode
  26323. */
  26324. Constants.MATERIAL_LineListDrawMode = 4;
  26325. /**
  26326. * Returns the line loop draw mode
  26327. */
  26328. Constants.MATERIAL_LineLoopDrawMode = 5;
  26329. /**
  26330. * Returns the line strip draw mode
  26331. */
  26332. Constants.MATERIAL_LineStripDrawMode = 6;
  26333. /**
  26334. * Returns the triangle strip draw mode
  26335. */
  26336. Constants.MATERIAL_TriangleStripDrawMode = 7;
  26337. /**
  26338. * Returns the triangle fan draw mode
  26339. */
  26340. Constants.MATERIAL_TriangleFanDrawMode = 8;
  26341. /**
  26342. * Stores the clock-wise side orientation
  26343. */
  26344. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  26345. /**
  26346. * Stores the counter clock-wise side orientation
  26347. */
  26348. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  26349. /**
  26350. * Nothing
  26351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26352. */
  26353. Constants.ACTION_NothingTrigger = 0;
  26354. /**
  26355. * On pick
  26356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26357. */
  26358. Constants.ACTION_OnPickTrigger = 1;
  26359. /**
  26360. * On left pick
  26361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26362. */
  26363. Constants.ACTION_OnLeftPickTrigger = 2;
  26364. /**
  26365. * On right pick
  26366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26367. */
  26368. Constants.ACTION_OnRightPickTrigger = 3;
  26369. /**
  26370. * On center pick
  26371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26372. */
  26373. Constants.ACTION_OnCenterPickTrigger = 4;
  26374. /**
  26375. * On pick down
  26376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26377. */
  26378. Constants.ACTION_OnPickDownTrigger = 5;
  26379. /**
  26380. * On double pick
  26381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26382. */
  26383. Constants.ACTION_OnDoublePickTrigger = 6;
  26384. /**
  26385. * On pick up
  26386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26387. */
  26388. Constants.ACTION_OnPickUpTrigger = 7;
  26389. /**
  26390. * On pick out.
  26391. * This trigger will only be raised if you also declared a OnPickDown
  26392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26393. */
  26394. Constants.ACTION_OnPickOutTrigger = 16;
  26395. /**
  26396. * On long press
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26398. */
  26399. Constants.ACTION_OnLongPressTrigger = 8;
  26400. /**
  26401. * On pointer over
  26402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26403. */
  26404. Constants.ACTION_OnPointerOverTrigger = 9;
  26405. /**
  26406. * On pointer out
  26407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26408. */
  26409. Constants.ACTION_OnPointerOutTrigger = 10;
  26410. /**
  26411. * On every frame
  26412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26413. */
  26414. Constants.ACTION_OnEveryFrameTrigger = 11;
  26415. /**
  26416. * On intersection enter
  26417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26418. */
  26419. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  26420. /**
  26421. * On intersection exit
  26422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26423. */
  26424. Constants.ACTION_OnIntersectionExitTrigger = 13;
  26425. /**
  26426. * On key down
  26427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26428. */
  26429. Constants.ACTION_OnKeyDownTrigger = 14;
  26430. /**
  26431. * On key up
  26432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26433. */
  26434. Constants.ACTION_OnKeyUpTrigger = 15;
  26435. /**
  26436. * Billboard mode will only apply to Y axis
  26437. */
  26438. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  26439. /**
  26440. * Billboard mode will apply to all axes
  26441. */
  26442. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  26443. /**
  26444. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  26445. */
  26446. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  26447. /**
  26448. * Gets or sets base Assets URL
  26449. */
  26450. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  26451. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26452. * Test order :
  26453. * Is the bounding sphere outside the frustum ?
  26454. * If not, are the bounding box vertices outside the frustum ?
  26455. * It not, then the cullable object is in the frustum.
  26456. */
  26457. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  26458. /** Culling strategy : Bounding Sphere Only.
  26459. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26460. * It's also less accurate than the standard because some not visible objects can still be selected.
  26461. * Test : is the bounding sphere outside the frustum ?
  26462. * If not, then the cullable object is in the frustum.
  26463. */
  26464. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  26465. /** Culling strategy : Optimistic Inclusion.
  26466. * This in an inclusion test first, then the standard exclusion test.
  26467. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26468. * 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.
  26469. * Anyway, it's as accurate as the standard strategy.
  26470. * Test :
  26471. * Is the cullable object bounding sphere center in the frustum ?
  26472. * If not, apply the default culling strategy.
  26473. */
  26474. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  26475. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26476. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26477. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26478. * 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.
  26479. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26480. * Test :
  26481. * Is the cullable object bounding sphere center in the frustum ?
  26482. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26483. */
  26484. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  26485. /**
  26486. * No logging while loading
  26487. */
  26488. Constants.SCENELOADER_NO_LOGGING = 0;
  26489. /**
  26490. * Minimal logging while loading
  26491. */
  26492. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  26493. /**
  26494. * Summary logging while loading
  26495. */
  26496. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  26497. /**
  26498. * Detailled logging while loading
  26499. */
  26500. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  26501. return Constants;
  26502. }());
  26503. /***/ }),
  26504. /***/ "./Engines/engine.ts":
  26505. /*!***************************!*\
  26506. !*** ./Engines/engine.ts ***!
  26507. \***************************/
  26508. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  26509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26510. "use strict";
  26511. __webpack_require__.r(__webpack_exports__);
  26512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  26513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  26514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  26515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  26516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26517. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26518. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  26519. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  26520. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  26521. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26522. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26523. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  26524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  26525. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  26526. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  26527. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  26528. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  26529. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  26530. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  26531. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  26532. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  26533. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  26534. /**
  26535. * Keeps track of all the buffer info used in engine.
  26536. */
  26537. var BufferPointer = /** @class */ (function () {
  26538. function BufferPointer() {
  26539. }
  26540. return BufferPointer;
  26541. }());
  26542. /**
  26543. * Interface for attribute information associated with buffer instanciation
  26544. */
  26545. var InstancingAttributeInfo = /** @class */ (function () {
  26546. function InstancingAttributeInfo() {
  26547. }
  26548. return InstancingAttributeInfo;
  26549. }());
  26550. /**
  26551. * Define options used to create a depth texture
  26552. */
  26553. var DepthTextureCreationOptions = /** @class */ (function () {
  26554. function DepthTextureCreationOptions() {
  26555. }
  26556. return DepthTextureCreationOptions;
  26557. }());
  26558. /**
  26559. * Class used to describe the capabilities of the engine relatively to the current browser
  26560. */
  26561. var EngineCapabilities = /** @class */ (function () {
  26562. function EngineCapabilities() {
  26563. }
  26564. return EngineCapabilities;
  26565. }());
  26566. /**
  26567. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26568. */
  26569. var Engine = /** @class */ (function () {
  26570. /**
  26571. * Creates a new engine
  26572. * @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
  26573. * @param antialias defines enable antialiasing (default: false)
  26574. * @param options defines further options to be sent to the getContext() function
  26575. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26576. */
  26577. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  26578. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  26579. var _this = this;
  26580. // Public members
  26581. /**
  26582. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26583. */
  26584. this.forcePOTTextures = false;
  26585. /**
  26586. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26587. */
  26588. this.isFullscreen = false;
  26589. /**
  26590. * Gets a boolean indicating if the pointer is currently locked
  26591. */
  26592. this.isPointerLock = false;
  26593. /**
  26594. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26595. */
  26596. this.cullBackFaces = true;
  26597. /**
  26598. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26599. */
  26600. this.renderEvenInBackground = true;
  26601. /**
  26602. * Gets or sets a boolean indicating that cache can be kept between frames
  26603. */
  26604. this.preventCacheWipeBetweenFrames = false;
  26605. /**
  26606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26607. **/
  26608. this.enableOfflineSupport = false;
  26609. /**
  26610. * 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)
  26611. **/
  26612. this.disableManifestCheck = false;
  26613. /**
  26614. * Gets the list of created scenes
  26615. */
  26616. this.scenes = new Array();
  26617. /**
  26618. * Event raised when a new scene is created
  26619. */
  26620. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26621. /**
  26622. * Gets the list of created postprocesses
  26623. */
  26624. this.postProcesses = new Array();
  26625. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26626. this.validateShaderPrograms = false;
  26627. // Observables
  26628. /**
  26629. * Observable event triggered each time the rendering canvas is resized
  26630. */
  26631. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26632. /**
  26633. * Observable event triggered each time the canvas loses focus
  26634. */
  26635. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26636. /**
  26637. * Observable event triggered each time the canvas gains focus
  26638. */
  26639. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26640. /**
  26641. * Observable event triggered each time the canvas receives pointerout event
  26642. */
  26643. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26644. /**
  26645. * Observable event triggered before each texture is initialized
  26646. */
  26647. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26648. //WebVR
  26649. this._vrDisplay = undefined;
  26650. this._vrSupported = false;
  26651. this._vrExclusivePointerMode = false;
  26652. // Uniform buffers list
  26653. /**
  26654. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26655. */
  26656. this.disableUniformBuffers = false;
  26657. /** @hidden */
  26658. this._uniformBuffers = new Array();
  26659. // Observables
  26660. /**
  26661. * Observable raised when the engine begins a new frame
  26662. */
  26663. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26664. /**
  26665. * If set, will be used to request the next animation frame for the render loop
  26666. */
  26667. this.customAnimationFrameRequester = null;
  26668. /**
  26669. * Observable raised when the engine ends the current frame
  26670. */
  26671. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26672. /**
  26673. * Observable raised when the engine is about to compile a shader
  26674. */
  26675. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26676. /**
  26677. * Observable raised when the engine has jsut compiled a shader
  26678. */
  26679. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26680. this._windowIsBackground = false;
  26681. this._webGLVersion = 1.0;
  26682. /** @hidden */
  26683. this._badOS = false;
  26684. /** @hidden */
  26685. this._badDesktopOS = false;
  26686. /**
  26687. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26688. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26689. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26690. */
  26691. this.disableTextureBindingOptimization = false;
  26692. /**
  26693. * Observable signaled when VR display mode changes
  26694. */
  26695. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26696. /**
  26697. * Observable signaled when VR request present is complete
  26698. */
  26699. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26700. /**
  26701. * Observable signaled when VR request present starts
  26702. */
  26703. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26704. this._colorWrite = true;
  26705. /** @hidden */
  26706. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26707. /** @hidden */
  26708. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26709. this._renderingQueueLaunched = false;
  26710. this._activeRenderLoops = new Array();
  26711. // Deterministic lockstepMaxSteps
  26712. this._deterministicLockstep = false;
  26713. this._lockstepMaxSteps = 4;
  26714. // Lost context
  26715. /**
  26716. * Observable signaled when a context lost event is raised
  26717. */
  26718. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26719. /**
  26720. * Observable signaled when a context restored event is raised
  26721. */
  26722. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26723. this._contextWasLost = false;
  26724. this._doNotHandleContextLost = false;
  26725. // FPS
  26726. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  26727. this._fps = 60;
  26728. this._deltaTime = 0;
  26729. /**
  26730. * Turn this value on if you want to pause FPS computation when in background
  26731. */
  26732. this.disablePerformanceMonitorInBackground = false;
  26733. // States
  26734. /** @hidden */
  26735. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  26736. /** @hidden */
  26737. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  26738. /** @hidden */
  26739. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  26740. /** @hidden */
  26741. this._alphaMode = Engine.ALPHA_DISABLE;
  26742. // Cache
  26743. this._internalTexturesCache = new Array();
  26744. /** @hidden */
  26745. this._activeChannel = 0;
  26746. this._currentTextureChannel = -1;
  26747. /** @hidden */
  26748. this._boundTexturesCache = {};
  26749. this._compiledEffects = {};
  26750. this._vertexAttribArraysEnabled = [];
  26751. this._uintIndicesCurrentlySet = false;
  26752. this._currentBoundBuffer = new Array();
  26753. /** @hidden */
  26754. this._currentFramebuffer = null;
  26755. this._currentBufferPointers = new Array();
  26756. this._currentInstanceLocations = new Array();
  26757. this._currentInstanceBuffers = new Array();
  26758. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  26759. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  26760. this._vaoRecordInProgress = false;
  26761. this._mustWipeVertexAttributes = false;
  26762. this._nextFreeTextureSlots = new Array();
  26763. this._maxSimultaneousTextures = 0;
  26764. this._activeRequests = new Array();
  26765. // Hardware supported Compressed Textures
  26766. this._texturesSupported = new Array();
  26767. /**
  26768. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26769. */
  26770. this.premultipliedAlpha = true;
  26771. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  26772. this._onVRFullScreenTriggered = function () {
  26773. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  26774. //get the old size before we change
  26775. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  26776. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  26777. //get the width and height, change the render size
  26778. var leftEye = _this._vrDisplay.getEyeParameters('left');
  26779. _this.setHardwareScalingLevel(1);
  26780. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  26781. }
  26782. else {
  26783. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  26784. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  26785. }
  26786. };
  26787. this._unpackFlipYCached = null;
  26788. /**
  26789. * In case you are sharing the context with other applications, it might
  26790. * be interested to not cache the unpack flip y state to ensure a consistent
  26791. * value would be set.
  26792. */
  26793. this.enableUnpackFlipYCached = true;
  26794. this._boundUniforms = {};
  26795. // Register promises
  26796. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  26797. var canvas = null;
  26798. Engine.Instances.push(this);
  26799. if (!canvasOrContext) {
  26800. return;
  26801. }
  26802. options = options || {};
  26803. if (canvasOrContext.getContext) {
  26804. canvas = canvasOrContext;
  26805. this._renderingCanvas = canvas;
  26806. if (antialias != null) {
  26807. options.antialias = antialias;
  26808. }
  26809. if (options.deterministicLockstep === undefined) {
  26810. options.deterministicLockstep = false;
  26811. }
  26812. if (options.lockstepMaxSteps === undefined) {
  26813. options.lockstepMaxSteps = 4;
  26814. }
  26815. if (options.preserveDrawingBuffer === undefined) {
  26816. options.preserveDrawingBuffer = false;
  26817. }
  26818. if (options.audioEngine === undefined) {
  26819. options.audioEngine = true;
  26820. }
  26821. if (options.stencil === undefined) {
  26822. options.stencil = true;
  26823. }
  26824. if (options.premultipliedAlpha === false) {
  26825. this.premultipliedAlpha = false;
  26826. }
  26827. this._deterministicLockstep = options.deterministicLockstep;
  26828. this._lockstepMaxSteps = options.lockstepMaxSteps;
  26829. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  26830. // Exceptions
  26831. if (navigator && navigator.userAgent) {
  26832. var ua = navigator.userAgent;
  26833. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  26834. var exception = _a[_i];
  26835. var key = exception.key;
  26836. var targets = exception.targets;
  26837. if (ua.indexOf(key) > -1) {
  26838. if (exception.capture && exception.captureConstraint) {
  26839. var capture = exception.capture;
  26840. var constraint = exception.captureConstraint;
  26841. var regex = new RegExp(capture);
  26842. var matches = regex.exec(ua);
  26843. if (matches && matches.length > 0) {
  26844. var capturedValue = parseInt(matches[matches.length - 1]);
  26845. if (capturedValue >= constraint) {
  26846. continue;
  26847. }
  26848. }
  26849. }
  26850. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  26851. var target = targets_1[_b];
  26852. switch (target) {
  26853. case "uniformBuffer":
  26854. this.disableUniformBuffers = true;
  26855. break;
  26856. case "textureBindingOptimization":
  26857. this.disableTextureBindingOptimization = true;
  26858. break;
  26859. }
  26860. }
  26861. }
  26862. }
  26863. }
  26864. // GL
  26865. if (!options.disableWebGL2Support) {
  26866. try {
  26867. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  26868. if (this._gl) {
  26869. this._webGLVersion = 2.0;
  26870. // Prevent weird browsers to lie :-)
  26871. if (!this._gl.deleteQuery) {
  26872. this._webGLVersion = 1.0;
  26873. }
  26874. }
  26875. }
  26876. catch (e) {
  26877. // Do nothing
  26878. }
  26879. }
  26880. if (!this._gl) {
  26881. if (!canvas) {
  26882. throw new Error("The provided canvas is null or undefined.");
  26883. }
  26884. try {
  26885. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  26886. }
  26887. catch (e) {
  26888. throw new Error("WebGL not supported");
  26889. }
  26890. }
  26891. if (!this._gl) {
  26892. throw new Error("WebGL not supported");
  26893. }
  26894. this._onCanvasFocus = function () {
  26895. _this.onCanvasFocusObservable.notifyObservers(_this);
  26896. };
  26897. this._onCanvasBlur = function () {
  26898. _this.onCanvasBlurObservable.notifyObservers(_this);
  26899. };
  26900. canvas.addEventListener("focus", this._onCanvasFocus);
  26901. canvas.addEventListener("blur", this._onCanvasBlur);
  26902. this._onBlur = function () {
  26903. if (_this.disablePerformanceMonitorInBackground) {
  26904. _this._performanceMonitor.disable();
  26905. }
  26906. _this._windowIsBackground = true;
  26907. };
  26908. this._onFocus = function () {
  26909. if (_this.disablePerformanceMonitorInBackground) {
  26910. _this._performanceMonitor.enable();
  26911. }
  26912. _this._windowIsBackground = false;
  26913. };
  26914. this._onCanvasPointerOut = function (ev) {
  26915. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  26916. };
  26917. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  26918. window.addEventListener("blur", this._onBlur);
  26919. window.addEventListener("focus", this._onFocus);
  26920. }
  26921. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  26922. // Context lost
  26923. if (!this._doNotHandleContextLost) {
  26924. this._onContextLost = function (evt) {
  26925. evt.preventDefault();
  26926. _this._contextWasLost = true;
  26927. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  26928. _this.onContextLostObservable.notifyObservers(_this);
  26929. };
  26930. this._onContextRestored = function () {
  26931. // Adding a timeout to avoid race condition at browser level
  26932. setTimeout(function () {
  26933. // Rebuild gl context
  26934. _this._initGLContext();
  26935. // Rebuild effects
  26936. _this._rebuildEffects();
  26937. // Rebuild textures
  26938. _this._rebuildInternalTextures();
  26939. // Rebuild buffers
  26940. _this._rebuildBuffers();
  26941. // Cache
  26942. _this.wipeCaches(true);
  26943. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  26944. _this.onContextRestoredObservable.notifyObservers(_this);
  26945. _this._contextWasLost = false;
  26946. }, 0);
  26947. };
  26948. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  26949. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  26950. }
  26951. if (!options.doNotHandleTouchAction) {
  26952. this._disableTouchAction();
  26953. }
  26954. }
  26955. else {
  26956. this._gl = canvasOrContext;
  26957. this._renderingCanvas = this._gl.canvas;
  26958. if (this._gl.renderbufferStorageMultisample) {
  26959. this._webGLVersion = 2.0;
  26960. }
  26961. var attributes = this._gl.getContextAttributes();
  26962. if (attributes) {
  26963. options.stencil = attributes.stencil;
  26964. }
  26965. }
  26966. // Viewport
  26967. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  26968. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  26969. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  26970. this.resize();
  26971. this._isStencilEnable = options.stencil ? true : false;
  26972. this._initGLContext();
  26973. if (canvas) {
  26974. // Fullscreen
  26975. this._onFullscreenChange = function () {
  26976. if (document.fullscreen !== undefined) {
  26977. _this.isFullscreen = document.fullscreen;
  26978. }
  26979. else if (document.mozFullScreen !== undefined) {
  26980. _this.isFullscreen = document.mozFullScreen;
  26981. }
  26982. else if (document.webkitIsFullScreen !== undefined) {
  26983. _this.isFullscreen = document.webkitIsFullScreen;
  26984. }
  26985. else if (document.msIsFullScreen !== undefined) {
  26986. _this.isFullscreen = document.msIsFullScreen;
  26987. }
  26988. // Pointer lock
  26989. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  26990. canvas.requestPointerLock = canvas.requestPointerLock ||
  26991. canvas.msRequestPointerLock ||
  26992. canvas.mozRequestPointerLock ||
  26993. canvas.webkitRequestPointerLock;
  26994. if (canvas.requestPointerLock) {
  26995. canvas.requestPointerLock();
  26996. }
  26997. }
  26998. };
  26999. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27000. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27001. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27002. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27003. // Pointer lock
  27004. this._onPointerLockChange = function () {
  27005. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27006. document.webkitPointerLockElement === canvas ||
  27007. document.msPointerLockElement === canvas ||
  27008. document.pointerLockElement === canvas);
  27009. };
  27010. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27011. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27012. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27013. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27014. this._onVRDisplayPointerRestricted = function () {
  27015. if (canvas) {
  27016. canvas.requestPointerLock();
  27017. }
  27018. };
  27019. this._onVRDisplayPointerUnrestricted = function () {
  27020. document.exitPointerLock();
  27021. };
  27022. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27023. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27024. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27025. }
  27026. }
  27027. // Create Audio Engine if needed.
  27028. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27029. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27030. }
  27031. // Prepare buffer pointers
  27032. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27033. this._currentBufferPointers[i] = new BufferPointer();
  27034. }
  27035. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27036. // Load WebVR Devices
  27037. if (options.autoEnableWebVR) {
  27038. this.initWebVR();
  27039. }
  27040. // Detect if we are running on a faulty buggy OS.
  27041. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27042. // Detect if we are running on a faulty buggy desktop OS.
  27043. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27044. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27045. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27046. }
  27047. Object.defineProperty(Engine, "Instances", {
  27048. /** Gets the list of created engines */
  27049. get: function () {
  27050. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27051. },
  27052. enumerable: true,
  27053. configurable: true
  27054. });
  27055. Object.defineProperty(Engine, "LastCreatedEngine", {
  27056. /**
  27057. * Gets the latest created engine
  27058. */
  27059. get: function () {
  27060. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27061. },
  27062. enumerable: true,
  27063. configurable: true
  27064. });
  27065. Object.defineProperty(Engine, "LastCreatedScene", {
  27066. /**
  27067. * Gets the latest created scene
  27068. */
  27069. get: function () {
  27070. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27071. },
  27072. enumerable: true,
  27073. configurable: true
  27074. });
  27075. /**
  27076. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27077. * @param flag defines which part of the materials must be marked as dirty
  27078. * @param predicate defines a predicate used to filter which materials should be affected
  27079. */
  27080. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27081. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27082. var engine = Engine.Instances[engineIndex];
  27083. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27084. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27085. }
  27086. }
  27087. };
  27088. Object.defineProperty(Engine, "Version", {
  27089. /**
  27090. * Returns the current version of the framework
  27091. */
  27092. get: function () {
  27093. return "4.0.0-alpha.17";
  27094. },
  27095. enumerable: true,
  27096. configurable: true
  27097. });
  27098. Object.defineProperty(Engine.prototype, "description", {
  27099. /**
  27100. * Returns a string describing the current engine
  27101. */
  27102. get: function () {
  27103. var description = "WebGL" + this.webGLVersion;
  27104. if (this._caps.parallelShaderCompile) {
  27105. description += " - Parallel shader compilation";
  27106. }
  27107. return description;
  27108. },
  27109. enumerable: true,
  27110. configurable: true
  27111. });
  27112. Object.defineProperty(Engine, "ShadersRepository", {
  27113. /**
  27114. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27115. */
  27116. get: function () {
  27117. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  27118. },
  27119. set: function (value) {
  27120. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  27121. },
  27122. enumerable: true,
  27123. configurable: true
  27124. });
  27125. /**
  27126. * Method called to create the default loading screen.
  27127. * This can be overriden in your own app.
  27128. * @param canvas The rendering canvas element
  27129. * @returns The loading screen
  27130. */
  27131. Engine.DefaultLoadingScreenFactory = function (canvas) {
  27132. throw "Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen";
  27133. };
  27134. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  27135. /**
  27136. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27137. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27138. */
  27139. get: function () {
  27140. return this._vrExclusivePointerMode;
  27141. },
  27142. enumerable: true,
  27143. configurable: true
  27144. });
  27145. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  27146. /**
  27147. * Gets a boolean indicating that the engine supports uniform buffers
  27148. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27149. */
  27150. get: function () {
  27151. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  27152. },
  27153. enumerable: true,
  27154. configurable: true
  27155. });
  27156. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  27157. /**
  27158. * Gets a boolean indicating that only power of 2 textures are supported
  27159. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27160. */
  27161. get: function () {
  27162. return this._webGLVersion < 2 || this.forcePOTTextures;
  27163. },
  27164. enumerable: true,
  27165. configurable: true
  27166. });
  27167. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  27168. /**
  27169. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27171. */
  27172. get: function () {
  27173. return this._doNotHandleContextLost;
  27174. },
  27175. set: function (value) {
  27176. this._doNotHandleContextLost = value;
  27177. },
  27178. enumerable: true,
  27179. configurable: true
  27180. });
  27181. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  27182. /**
  27183. * Gets the performance monitor attached to this engine
  27184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27185. */
  27186. get: function () {
  27187. return this._performanceMonitor;
  27188. },
  27189. enumerable: true,
  27190. configurable: true
  27191. });
  27192. Object.defineProperty(Engine.prototype, "texturesSupported", {
  27193. /**
  27194. * Gets the list of texture formats supported
  27195. */
  27196. get: function () {
  27197. return this._texturesSupported;
  27198. },
  27199. enumerable: true,
  27200. configurable: true
  27201. });
  27202. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  27203. /**
  27204. * Gets the list of texture formats in use
  27205. */
  27206. get: function () {
  27207. return this._textureFormatInUse;
  27208. },
  27209. enumerable: true,
  27210. configurable: true
  27211. });
  27212. Object.defineProperty(Engine.prototype, "currentViewport", {
  27213. /**
  27214. * Gets the current viewport
  27215. */
  27216. get: function () {
  27217. return this._cachedViewport;
  27218. },
  27219. enumerable: true,
  27220. configurable: true
  27221. });
  27222. Object.defineProperty(Engine.prototype, "emptyTexture", {
  27223. /**
  27224. * Gets the default empty texture
  27225. */
  27226. get: function () {
  27227. if (!this._emptyTexture) {
  27228. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27229. }
  27230. return this._emptyTexture;
  27231. },
  27232. enumerable: true,
  27233. configurable: true
  27234. });
  27235. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  27236. /**
  27237. * Gets the default empty 3D texture
  27238. */
  27239. get: function () {
  27240. if (!this._emptyTexture3D) {
  27241. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27242. }
  27243. return this._emptyTexture3D;
  27244. },
  27245. enumerable: true,
  27246. configurable: true
  27247. });
  27248. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  27249. /**
  27250. * Gets the default empty cube texture
  27251. */
  27252. get: function () {
  27253. if (!this._emptyCubeTexture) {
  27254. var faceData = new Uint8Array(4);
  27255. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  27256. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27257. }
  27258. return this._emptyCubeTexture;
  27259. },
  27260. enumerable: true,
  27261. configurable: true
  27262. });
  27263. Engine.prototype._disableTouchAction = function () {
  27264. if (!this._renderingCanvas) {
  27265. return;
  27266. }
  27267. this._renderingCanvas.setAttribute("touch-action", "none");
  27268. this._renderingCanvas.style.touchAction = "none";
  27269. this._renderingCanvas.style.msTouchAction = "none";
  27270. };
  27271. Engine.prototype._rebuildInternalTextures = function () {
  27272. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  27273. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  27274. var internalTexture = currentState_1[_i];
  27275. internalTexture._rebuild();
  27276. }
  27277. };
  27278. Engine.prototype._rebuildEffects = function () {
  27279. for (var key in this._compiledEffects) {
  27280. var effect = this._compiledEffects[key];
  27281. effect._prepareEffect();
  27282. }
  27283. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  27284. };
  27285. /**
  27286. * Gets a boolean indicating if all created effects are ready
  27287. * @returns true if all effects are ready
  27288. */
  27289. Engine.prototype.areAllEffectsReady = function () {
  27290. for (var key in this._compiledEffects) {
  27291. var effect = this._compiledEffects[key];
  27292. if (!effect.isReady()) {
  27293. return false;
  27294. }
  27295. }
  27296. return true;
  27297. };
  27298. Engine.prototype._rebuildBuffers = function () {
  27299. // Index / Vertex
  27300. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  27301. var scene = _a[_i];
  27302. scene.resetCachedMaterial();
  27303. scene._rebuildGeometries();
  27304. scene._rebuildTextures();
  27305. }
  27306. // Uniforms
  27307. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  27308. var uniformBuffer = _c[_b];
  27309. uniformBuffer._rebuild();
  27310. }
  27311. };
  27312. Engine.prototype._initGLContext = function () {
  27313. // Caps
  27314. this._caps = new EngineCapabilities();
  27315. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  27316. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  27317. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  27318. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  27319. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  27320. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  27321. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  27322. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  27323. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  27324. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  27325. // Infos
  27326. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  27327. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  27328. if (rendererInfo != null) {
  27329. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  27330. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  27331. }
  27332. if (!this._glVendor) {
  27333. this._glVendor = "Unknown vendor";
  27334. }
  27335. if (!this._glRenderer) {
  27336. this._glRenderer = "Unknown renderer";
  27337. }
  27338. // Constants
  27339. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  27340. if (this._gl.RGBA16F !== 0x881A) {
  27341. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  27342. }
  27343. if (this._gl.RGBA32F !== 0x8814) {
  27344. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  27345. }
  27346. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  27347. this._gl.DEPTH24_STENCIL8 = 35056;
  27348. }
  27349. // Extensions
  27350. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  27351. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  27352. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  27353. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  27354. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  27355. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  27356. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  27357. 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');
  27358. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  27359. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  27360. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  27361. this._caps.highPrecisionShaderSupported = false;
  27362. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  27363. if (this._caps.timerQuery) {
  27364. if (this._webGLVersion === 1) {
  27365. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  27366. }
  27367. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  27368. }
  27369. // Checks if some of the format renders first to allow the use of webgl inspector.
  27370. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  27371. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  27372. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  27373. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  27374. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  27375. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  27376. if (this._webGLVersion > 1) {
  27377. this._gl.HALF_FLOAT_OES = 0x140B;
  27378. }
  27379. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  27380. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  27381. // Draw buffers
  27382. if (this._webGLVersion > 1) {
  27383. this._caps.drawBuffersExtension = true;
  27384. }
  27385. else {
  27386. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  27387. if (drawBuffersExtension !== null) {
  27388. this._caps.drawBuffersExtension = true;
  27389. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  27390. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  27391. for (var i = 0; i < 16; i++) {
  27392. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  27393. }
  27394. }
  27395. else {
  27396. this._caps.drawBuffersExtension = false;
  27397. }
  27398. }
  27399. // Shader compiler threads
  27400. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  27401. if (this._caps.parallelShaderCompile) {
  27402. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  27403. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  27404. }
  27405. // Depth Texture
  27406. if (this._webGLVersion > 1) {
  27407. this._caps.depthTextureExtension = true;
  27408. }
  27409. else {
  27410. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  27411. if (depthTextureExtension != null) {
  27412. this._caps.depthTextureExtension = true;
  27413. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  27414. }
  27415. }
  27416. // Vertex array object
  27417. if (this._webGLVersion > 1) {
  27418. this._caps.vertexArrayObject = true;
  27419. }
  27420. else {
  27421. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  27422. if (vertexArrayObjectExtension != null) {
  27423. this._caps.vertexArrayObject = true;
  27424. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  27425. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  27426. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  27427. }
  27428. else {
  27429. this._caps.vertexArrayObject = false;
  27430. }
  27431. }
  27432. // Instances count
  27433. if (this._webGLVersion > 1) {
  27434. this._caps.instancedArrays = true;
  27435. }
  27436. else {
  27437. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  27438. if (instanceExtension != null) {
  27439. this._caps.instancedArrays = true;
  27440. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  27441. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  27442. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  27443. }
  27444. else {
  27445. this._caps.instancedArrays = false;
  27446. }
  27447. }
  27448. // Intelligently add supported compressed formats in order to check for.
  27449. // Check for ASTC support first as it is most powerful and to be very cross platform.
  27450. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  27451. // Likely no hardware which supports both PVR & DXT, so order matters little.
  27452. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  27453. if (this._caps.astc) {
  27454. this.texturesSupported.push('-astc.ktx');
  27455. }
  27456. if (this._caps.s3tc) {
  27457. this.texturesSupported.push('-dxt.ktx');
  27458. }
  27459. if (this._caps.pvrtc) {
  27460. this.texturesSupported.push('-pvrtc.ktx');
  27461. }
  27462. if (this._caps.etc2) {
  27463. this.texturesSupported.push('-etc2.ktx');
  27464. }
  27465. if (this._caps.etc1) {
  27466. this.texturesSupported.push('-etc1.ktx');
  27467. }
  27468. if (this._gl.getShaderPrecisionFormat) {
  27469. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  27470. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  27471. if (vertex_highp && fragment_highp) {
  27472. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  27473. }
  27474. }
  27475. // Depth buffer
  27476. this.setDepthBuffer(true);
  27477. this.setDepthFunctionToLessOrEqual();
  27478. this.setDepthWrite(true);
  27479. // Texture maps
  27480. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  27481. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27482. this._nextFreeTextureSlots.push(slot);
  27483. }
  27484. };
  27485. Object.defineProperty(Engine.prototype, "webGLVersion", {
  27486. /**
  27487. * Gets version of the current webGL context
  27488. */
  27489. get: function () {
  27490. return this._webGLVersion;
  27491. },
  27492. enumerable: true,
  27493. configurable: true
  27494. });
  27495. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  27496. /**
  27497. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27498. */
  27499. get: function () {
  27500. return this._isStencilEnable;
  27501. },
  27502. enumerable: true,
  27503. configurable: true
  27504. });
  27505. Engine.prototype._prepareWorkingCanvas = function () {
  27506. if (this._workingCanvas) {
  27507. return;
  27508. }
  27509. this._workingCanvas = document.createElement("canvas");
  27510. var context = this._workingCanvas.getContext("2d");
  27511. if (context) {
  27512. this._workingContext = context;
  27513. }
  27514. };
  27515. /**
  27516. * Reset the texture cache to empty state
  27517. */
  27518. Engine.prototype.resetTextureCache = function () {
  27519. for (var key in this._boundTexturesCache) {
  27520. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  27521. continue;
  27522. }
  27523. var boundTexture = this._boundTexturesCache[key];
  27524. if (boundTexture) {
  27525. this._removeDesignatedSlot(boundTexture);
  27526. }
  27527. this._boundTexturesCache[key] = null;
  27528. }
  27529. if (!this.disableTextureBindingOptimization) {
  27530. this._nextFreeTextureSlots = [];
  27531. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27532. this._nextFreeTextureSlots.push(slot);
  27533. }
  27534. }
  27535. this._currentTextureChannel = -1;
  27536. };
  27537. /**
  27538. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27540. * @returns true if engine is in deterministic lock step mode
  27541. */
  27542. Engine.prototype.isDeterministicLockStep = function () {
  27543. return this._deterministicLockstep;
  27544. };
  27545. /**
  27546. * Gets the max steps when engine is running in deterministic lock step
  27547. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27548. * @returns the max steps
  27549. */
  27550. Engine.prototype.getLockstepMaxSteps = function () {
  27551. return this._lockstepMaxSteps;
  27552. };
  27553. /**
  27554. * Gets an object containing information about the current webGL context
  27555. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27556. */
  27557. Engine.prototype.getGlInfo = function () {
  27558. return {
  27559. vendor: this._glVendor,
  27560. renderer: this._glRenderer,
  27561. version: this._glVersion
  27562. };
  27563. };
  27564. /**
  27565. * Gets current aspect ratio
  27566. * @param camera defines the camera to use to get the aspect ratio
  27567. * @param useScreen defines if screen size must be used (or the current render target if any)
  27568. * @returns a number defining the aspect ratio
  27569. */
  27570. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  27571. if (useScreen === void 0) { useScreen = false; }
  27572. var viewport = camera.viewport;
  27573. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  27574. };
  27575. /**
  27576. * Gets current screen aspect ratio
  27577. * @returns a number defining the aspect ratio
  27578. */
  27579. Engine.prototype.getScreenAspectRatio = function () {
  27580. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  27581. };
  27582. /**
  27583. * Gets the current render width
  27584. * @param useScreen defines if screen size must be used (or the current render target if any)
  27585. * @returns a number defining the current render width
  27586. */
  27587. Engine.prototype.getRenderWidth = function (useScreen) {
  27588. if (useScreen === void 0) { useScreen = false; }
  27589. if (!useScreen && this._currentRenderTarget) {
  27590. return this._currentRenderTarget.width;
  27591. }
  27592. return this._gl.drawingBufferWidth;
  27593. };
  27594. /**
  27595. * Gets the current render height
  27596. * @param useScreen defines if screen size must be used (or the current render target if any)
  27597. * @returns a number defining the current render height
  27598. */
  27599. Engine.prototype.getRenderHeight = function (useScreen) {
  27600. if (useScreen === void 0) { useScreen = false; }
  27601. if (!useScreen && this._currentRenderTarget) {
  27602. return this._currentRenderTarget.height;
  27603. }
  27604. return this._gl.drawingBufferHeight;
  27605. };
  27606. /**
  27607. * Gets the HTML canvas attached with the current webGL context
  27608. * @returns a HTML canvas
  27609. */
  27610. Engine.prototype.getRenderingCanvas = function () {
  27611. return this._renderingCanvas;
  27612. };
  27613. /**
  27614. * Gets the client rect of the HTML canvas attached with the current webGL context
  27615. * @returns a client rectanglee
  27616. */
  27617. Engine.prototype.getRenderingCanvasClientRect = function () {
  27618. if (!this._renderingCanvas) {
  27619. return null;
  27620. }
  27621. return this._renderingCanvas.getBoundingClientRect();
  27622. };
  27623. /**
  27624. * Defines the hardware scaling level.
  27625. * By default the hardware scaling level is computed from the window device ratio.
  27626. * 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.
  27627. * @param level defines the level to use
  27628. */
  27629. Engine.prototype.setHardwareScalingLevel = function (level) {
  27630. this._hardwareScalingLevel = level;
  27631. this.resize();
  27632. };
  27633. /**
  27634. * Gets the current hardware scaling level.
  27635. * By default the hardware scaling level is computed from the window device ratio.
  27636. * 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.
  27637. * @returns a number indicating the current hardware scaling level
  27638. */
  27639. Engine.prototype.getHardwareScalingLevel = function () {
  27640. return this._hardwareScalingLevel;
  27641. };
  27642. /**
  27643. * Gets the list of loaded textures
  27644. * @returns an array containing all loaded textures
  27645. */
  27646. Engine.prototype.getLoadedTexturesCache = function () {
  27647. return this._internalTexturesCache;
  27648. };
  27649. /**
  27650. * Gets the object containing all engine capabilities
  27651. * @returns the EngineCapabilities object
  27652. */
  27653. Engine.prototype.getCaps = function () {
  27654. return this._caps;
  27655. };
  27656. /**
  27657. * Gets the current depth function
  27658. * @returns a number defining the depth function
  27659. */
  27660. Engine.prototype.getDepthFunction = function () {
  27661. return this._depthCullingState.depthFunc;
  27662. };
  27663. /**
  27664. * Sets the current depth function
  27665. * @param depthFunc defines the function to use
  27666. */
  27667. Engine.prototype.setDepthFunction = function (depthFunc) {
  27668. this._depthCullingState.depthFunc = depthFunc;
  27669. };
  27670. /**
  27671. * Sets the current depth function to GREATER
  27672. */
  27673. Engine.prototype.setDepthFunctionToGreater = function () {
  27674. this._depthCullingState.depthFunc = this._gl.GREATER;
  27675. };
  27676. /**
  27677. * Sets the current depth function to GEQUAL
  27678. */
  27679. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  27680. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  27681. };
  27682. /**
  27683. * Sets the current depth function to LESS
  27684. */
  27685. Engine.prototype.setDepthFunctionToLess = function () {
  27686. this._depthCullingState.depthFunc = this._gl.LESS;
  27687. };
  27688. /**
  27689. * Sets the current depth function to LEQUAL
  27690. */
  27691. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  27692. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  27693. };
  27694. /**
  27695. * Gets a boolean indicating if stencil buffer is enabled
  27696. * @returns the current stencil buffer state
  27697. */
  27698. Engine.prototype.getStencilBuffer = function () {
  27699. return this._stencilState.stencilTest;
  27700. };
  27701. /**
  27702. * Enable or disable the stencil buffer
  27703. * @param enable defines if the stencil buffer must be enabled or disabled
  27704. */
  27705. Engine.prototype.setStencilBuffer = function (enable) {
  27706. this._stencilState.stencilTest = enable;
  27707. };
  27708. /**
  27709. * Gets the current stencil mask
  27710. * @returns a number defining the new stencil mask to use
  27711. */
  27712. Engine.prototype.getStencilMask = function () {
  27713. return this._stencilState.stencilMask;
  27714. };
  27715. /**
  27716. * Sets the current stencil mask
  27717. * @param mask defines the new stencil mask to use
  27718. */
  27719. Engine.prototype.setStencilMask = function (mask) {
  27720. this._stencilState.stencilMask = mask;
  27721. };
  27722. /**
  27723. * Gets the current stencil function
  27724. * @returns a number defining the stencil function to use
  27725. */
  27726. Engine.prototype.getStencilFunction = function () {
  27727. return this._stencilState.stencilFunc;
  27728. };
  27729. /**
  27730. * Gets the current stencil reference value
  27731. * @returns a number defining the stencil reference value to use
  27732. */
  27733. Engine.prototype.getStencilFunctionReference = function () {
  27734. return this._stencilState.stencilFuncRef;
  27735. };
  27736. /**
  27737. * Gets the current stencil mask
  27738. * @returns a number defining the stencil mask to use
  27739. */
  27740. Engine.prototype.getStencilFunctionMask = function () {
  27741. return this._stencilState.stencilFuncMask;
  27742. };
  27743. /**
  27744. * Sets the current stencil function
  27745. * @param stencilFunc defines the new stencil function to use
  27746. */
  27747. Engine.prototype.setStencilFunction = function (stencilFunc) {
  27748. this._stencilState.stencilFunc = stencilFunc;
  27749. };
  27750. /**
  27751. * Sets the current stencil reference
  27752. * @param reference defines the new stencil reference to use
  27753. */
  27754. Engine.prototype.setStencilFunctionReference = function (reference) {
  27755. this._stencilState.stencilFuncRef = reference;
  27756. };
  27757. /**
  27758. * Sets the current stencil mask
  27759. * @param mask defines the new stencil mask to use
  27760. */
  27761. Engine.prototype.setStencilFunctionMask = function (mask) {
  27762. this._stencilState.stencilFuncMask = mask;
  27763. };
  27764. /**
  27765. * Gets the current stencil operation when stencil fails
  27766. * @returns a number defining stencil operation to use when stencil fails
  27767. */
  27768. Engine.prototype.getStencilOperationFail = function () {
  27769. return this._stencilState.stencilOpStencilFail;
  27770. };
  27771. /**
  27772. * Gets the current stencil operation when depth fails
  27773. * @returns a number defining stencil operation to use when depth fails
  27774. */
  27775. Engine.prototype.getStencilOperationDepthFail = function () {
  27776. return this._stencilState.stencilOpDepthFail;
  27777. };
  27778. /**
  27779. * Gets the current stencil operation when stencil passes
  27780. * @returns a number defining stencil operation to use when stencil passes
  27781. */
  27782. Engine.prototype.getStencilOperationPass = function () {
  27783. return this._stencilState.stencilOpStencilDepthPass;
  27784. };
  27785. /**
  27786. * Sets the stencil operation to use when stencil fails
  27787. * @param operation defines the stencil operation to use when stencil fails
  27788. */
  27789. Engine.prototype.setStencilOperationFail = function (operation) {
  27790. this._stencilState.stencilOpStencilFail = operation;
  27791. };
  27792. /**
  27793. * Sets the stencil operation to use when depth fails
  27794. * @param operation defines the stencil operation to use when depth fails
  27795. */
  27796. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  27797. this._stencilState.stencilOpDepthFail = operation;
  27798. };
  27799. /**
  27800. * Sets the stencil operation to use when stencil passes
  27801. * @param operation defines the stencil operation to use when stencil passes
  27802. */
  27803. Engine.prototype.setStencilOperationPass = function (operation) {
  27804. this._stencilState.stencilOpStencilDepthPass = operation;
  27805. };
  27806. /**
  27807. * Sets a boolean indicating if the dithering state is enabled or disabled
  27808. * @param value defines the dithering state
  27809. */
  27810. Engine.prototype.setDitheringState = function (value) {
  27811. if (value) {
  27812. this._gl.enable(this._gl.DITHER);
  27813. }
  27814. else {
  27815. this._gl.disable(this._gl.DITHER);
  27816. }
  27817. };
  27818. /**
  27819. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27820. * @param value defines the rasterizer state
  27821. */
  27822. Engine.prototype.setRasterizerState = function (value) {
  27823. if (value) {
  27824. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  27825. }
  27826. else {
  27827. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  27828. }
  27829. };
  27830. /**
  27831. * stop executing a render loop function and remove it from the execution array
  27832. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27833. */
  27834. Engine.prototype.stopRenderLoop = function (renderFunction) {
  27835. if (!renderFunction) {
  27836. this._activeRenderLoops = [];
  27837. return;
  27838. }
  27839. var index = this._activeRenderLoops.indexOf(renderFunction);
  27840. if (index >= 0) {
  27841. this._activeRenderLoops.splice(index, 1);
  27842. }
  27843. };
  27844. /** @hidden */
  27845. Engine.prototype._renderLoop = function () {
  27846. if (!this._contextWasLost) {
  27847. var shouldRender = true;
  27848. if (!this.renderEvenInBackground && this._windowIsBackground) {
  27849. shouldRender = false;
  27850. }
  27851. if (shouldRender) {
  27852. // Start new frame
  27853. this.beginFrame();
  27854. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  27855. var renderFunction = this._activeRenderLoops[index];
  27856. renderFunction();
  27857. }
  27858. // Present
  27859. this.endFrame();
  27860. }
  27861. }
  27862. if (this._activeRenderLoops.length > 0) {
  27863. // Register new frame
  27864. if (this.customAnimationFrameRequester) {
  27865. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  27866. this._frameHandler = this.customAnimationFrameRequester.requestID;
  27867. }
  27868. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  27869. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  27870. }
  27871. else {
  27872. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  27873. }
  27874. }
  27875. else {
  27876. this._renderingQueueLaunched = false;
  27877. }
  27878. };
  27879. /**
  27880. * Register and execute a render loop. The engine can have more than one render function
  27881. * @param renderFunction defines the function to continuously execute
  27882. */
  27883. Engine.prototype.runRenderLoop = function (renderFunction) {
  27884. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  27885. return;
  27886. }
  27887. this._activeRenderLoops.push(renderFunction);
  27888. if (!this._renderingQueueLaunched) {
  27889. this._renderingQueueLaunched = true;
  27890. this._bindedRenderFunction = this._renderLoop.bind(this);
  27891. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  27892. }
  27893. };
  27894. /**
  27895. * Toggle full screen mode
  27896. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27897. */
  27898. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  27899. if (this.isFullscreen) {
  27900. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  27901. }
  27902. else {
  27903. this._pointerLockRequested = requestPointerLock;
  27904. if (this._renderingCanvas) {
  27905. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  27906. }
  27907. }
  27908. };
  27909. /**
  27910. * Clear the current render buffer or the current render target (if any is set up)
  27911. * @param color defines the color to use
  27912. * @param backBuffer defines if the back buffer must be cleared
  27913. * @param depth defines if the depth buffer must be cleared
  27914. * @param stencil defines if the stencil buffer must be cleared
  27915. */
  27916. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  27917. if (stencil === void 0) { stencil = false; }
  27918. this.applyStates();
  27919. var mode = 0;
  27920. if (backBuffer && color) {
  27921. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  27922. mode |= this._gl.COLOR_BUFFER_BIT;
  27923. }
  27924. if (depth) {
  27925. this._gl.clearDepth(1.0);
  27926. mode |= this._gl.DEPTH_BUFFER_BIT;
  27927. }
  27928. if (stencil) {
  27929. this._gl.clearStencil(0);
  27930. mode |= this._gl.STENCIL_BUFFER_BIT;
  27931. }
  27932. this._gl.clear(mode);
  27933. };
  27934. /**
  27935. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27936. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27937. * @param y defines the y-coordinate of the corner of the clear rectangle
  27938. * @param width defines the width of the clear rectangle
  27939. * @param height defines the height of the clear rectangle
  27940. * @param clearColor defines the clear color
  27941. */
  27942. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  27943. this.enableScissor(x, y, width, height);
  27944. this.clear(clearColor, true, true, true);
  27945. this.disableScissor();
  27946. };
  27947. /**
  27948. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27949. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27950. * @param y defines the y-coordinate of the corner of the clear rectangle
  27951. * @param width defines the width of the clear rectangle
  27952. * @param height defines the height of the clear rectangle
  27953. */
  27954. Engine.prototype.enableScissor = function (x, y, width, height) {
  27955. var gl = this._gl;
  27956. // Change state
  27957. gl.enable(gl.SCISSOR_TEST);
  27958. gl.scissor(x, y, width, height);
  27959. };
  27960. /**
  27961. * Disable previously set scissor test rectangle
  27962. */
  27963. Engine.prototype.disableScissor = function () {
  27964. var gl = this._gl;
  27965. gl.disable(gl.SCISSOR_TEST);
  27966. };
  27967. /** @hidden */
  27968. Engine.prototype._viewport = function (x, y, width, height) {
  27969. if (x !== this._viewportCached.x ||
  27970. y !== this._viewportCached.y ||
  27971. width !== this._viewportCached.z ||
  27972. height !== this._viewportCached.w) {
  27973. this._viewportCached.x = x;
  27974. this._viewportCached.y = y;
  27975. this._viewportCached.z = width;
  27976. this._viewportCached.w = height;
  27977. this._gl.viewport(x, y, width, height);
  27978. }
  27979. };
  27980. /**
  27981. * Set the WebGL's viewport
  27982. * @param viewport defines the viewport element to be used
  27983. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27984. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27985. */
  27986. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  27987. var width = requiredWidth || this.getRenderWidth();
  27988. var height = requiredHeight || this.getRenderHeight();
  27989. var x = viewport.x || 0;
  27990. var y = viewport.y || 0;
  27991. this._cachedViewport = viewport;
  27992. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  27993. };
  27994. /**
  27995. * Directly set the WebGL Viewport
  27996. * @param x defines the x coordinate of the viewport (in screen space)
  27997. * @param y defines the y coordinate of the viewport (in screen space)
  27998. * @param width defines the width of the viewport (in screen space)
  27999. * @param height defines the height of the viewport (in screen space)
  28000. * @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
  28001. */
  28002. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28003. var currentViewport = this._cachedViewport;
  28004. this._cachedViewport = null;
  28005. this._viewport(x, y, width, height);
  28006. return currentViewport;
  28007. };
  28008. /**
  28009. * Begin a new frame
  28010. */
  28011. Engine.prototype.beginFrame = function () {
  28012. this.onBeginFrameObservable.notifyObservers(this);
  28013. this._measureFps();
  28014. };
  28015. /**
  28016. * Enf the current frame
  28017. */
  28018. Engine.prototype.endFrame = function () {
  28019. // Force a flush in case we are using a bad OS.
  28020. if (this._badOS) {
  28021. this.flushFramebuffer();
  28022. }
  28023. // Submit frame to the vr device, if enabled
  28024. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28025. // TODO: We should only submit the frame if we read frameData successfully.
  28026. this._vrDisplay.submitFrame();
  28027. }
  28028. this.onEndFrameObservable.notifyObservers(this);
  28029. };
  28030. /**
  28031. * Resize the view according to the canvas' size
  28032. */
  28033. Engine.prototype.resize = function () {
  28034. // We're not resizing the size of the canvas while in VR mode & presenting
  28035. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28036. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28037. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28038. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28039. }
  28040. };
  28041. /**
  28042. * Force a specific size of the canvas
  28043. * @param width defines the new canvas' width
  28044. * @param height defines the new canvas' height
  28045. */
  28046. Engine.prototype.setSize = function (width, height) {
  28047. if (!this._renderingCanvas) {
  28048. return;
  28049. }
  28050. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28051. return;
  28052. }
  28053. this._renderingCanvas.width = width;
  28054. this._renderingCanvas.height = height;
  28055. for (var index = 0; index < this.scenes.length; index++) {
  28056. var scene = this.scenes[index];
  28057. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28058. var cam = scene.cameras[camIndex];
  28059. cam._currentRenderId = 0;
  28060. }
  28061. }
  28062. if (this.onResizeObservable.hasObservers) {
  28063. this.onResizeObservable.notifyObservers(this);
  28064. }
  28065. };
  28066. // WebVR functions
  28067. /**
  28068. * Gets a boolean indicating if a webVR device was detected
  28069. * @returns true if a webVR device was detected
  28070. */
  28071. Engine.prototype.isVRDevicePresent = function () {
  28072. return !!this._vrDisplay;
  28073. };
  28074. /**
  28075. * Gets the current webVR device
  28076. * @returns the current webVR device (or null)
  28077. */
  28078. Engine.prototype.getVRDevice = function () {
  28079. return this._vrDisplay;
  28080. };
  28081. /**
  28082. * Initializes a webVR display and starts listening to display change events
  28083. * The onVRDisplayChangedObservable will be notified upon these changes
  28084. * @returns The onVRDisplayChangedObservable
  28085. */
  28086. Engine.prototype.initWebVR = function () {
  28087. this.initWebVRAsync();
  28088. return this.onVRDisplayChangedObservable;
  28089. };
  28090. /**
  28091. * Initializes a webVR display and starts listening to display change events
  28092. * The onVRDisplayChangedObservable will be notified upon these changes
  28093. * @returns A promise containing a VRDisplay and if vr is supported
  28094. */
  28095. Engine.prototype.initWebVRAsync = function () {
  28096. var _this = this;
  28097. var notifyObservers = function () {
  28098. var eventArgs = {
  28099. vrDisplay: _this._vrDisplay,
  28100. vrSupported: _this._vrSupported
  28101. };
  28102. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28103. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28104. };
  28105. if (!this._onVrDisplayConnect) {
  28106. this._onVrDisplayConnect = function (event) {
  28107. _this._vrDisplay = event.display;
  28108. notifyObservers();
  28109. };
  28110. this._onVrDisplayDisconnect = function () {
  28111. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28112. _this._vrDisplay = undefined;
  28113. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28114. notifyObservers();
  28115. };
  28116. this._onVrDisplayPresentChange = function () {
  28117. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28118. };
  28119. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28120. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28121. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28122. }
  28123. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  28124. this._webVRInitPromise.then(notifyObservers);
  28125. return this._webVRInitPromise;
  28126. };
  28127. /**
  28128. * Call this function to switch to webVR mode
  28129. * Will do nothing if webVR is not supported or if there is no webVR device
  28130. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28131. */
  28132. Engine.prototype.enableVR = function () {
  28133. var _this = this;
  28134. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  28135. var onResolved = function () {
  28136. _this.onVRRequestPresentComplete.notifyObservers(true);
  28137. _this._onVRFullScreenTriggered();
  28138. };
  28139. var onRejected = function () {
  28140. _this.onVRRequestPresentComplete.notifyObservers(false);
  28141. };
  28142. this.onVRRequestPresentStart.notifyObservers(this);
  28143. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  28144. }
  28145. };
  28146. /**
  28147. * Call this function to leave webVR mode
  28148. * Will do nothing if webVR is not supported or if there is no webVR device
  28149. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28150. */
  28151. Engine.prototype.disableVR = function () {
  28152. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28153. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  28154. }
  28155. };
  28156. Engine.prototype._getVRDisplaysAsync = function () {
  28157. var _this = this;
  28158. return new Promise(function (res) {
  28159. if (navigator.getVRDisplays) {
  28160. navigator.getVRDisplays().then(function (devices) {
  28161. _this._vrSupported = true;
  28162. // note that devices may actually be an empty array. This is fine;
  28163. // we expect this._vrDisplay to be undefined in this case.
  28164. _this._vrDisplay = devices[0];
  28165. res({
  28166. vrDisplay: _this._vrDisplay,
  28167. vrSupported: _this._vrSupported
  28168. });
  28169. });
  28170. }
  28171. else {
  28172. _this._vrDisplay = undefined;
  28173. _this._vrSupported = false;
  28174. res({
  28175. vrDisplay: _this._vrDisplay,
  28176. vrSupported: _this._vrSupported
  28177. });
  28178. }
  28179. });
  28180. };
  28181. /**
  28182. * Binds the frame buffer to the specified texture.
  28183. * @param texture The texture to render to or null for the default canvas
  28184. * @param faceIndex The face of the texture to render to in case of cube texture
  28185. * @param requiredWidth The width of the target to render to
  28186. * @param requiredHeight The height of the target to render to
  28187. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28188. * @param depthStencilTexture The depth stencil texture to use to render
  28189. * @param lodLevel defines le lod level to bind to the frame buffer
  28190. */
  28191. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  28192. if (lodLevel === void 0) { lodLevel = 0; }
  28193. if (this._currentRenderTarget) {
  28194. this.unBindFramebuffer(this._currentRenderTarget);
  28195. }
  28196. this._currentRenderTarget = texture;
  28197. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  28198. var gl = this._gl;
  28199. if (texture.isCube) {
  28200. if (faceIndex === undefined) {
  28201. faceIndex = 0;
  28202. }
  28203. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  28204. if (depthStencilTexture) {
  28205. if (depthStencilTexture._generateStencilBuffer) {
  28206. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28207. }
  28208. else {
  28209. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28210. }
  28211. }
  28212. }
  28213. if (this._cachedViewport && !forceFullscreenViewport) {
  28214. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  28215. }
  28216. else {
  28217. if (!requiredWidth) {
  28218. requiredWidth = texture.width;
  28219. if (lodLevel) {
  28220. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  28221. }
  28222. }
  28223. if (!requiredHeight) {
  28224. requiredHeight = texture.height;
  28225. if (lodLevel) {
  28226. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  28227. }
  28228. }
  28229. this._viewport(0, 0, requiredWidth, requiredHeight);
  28230. }
  28231. this.wipeCaches();
  28232. };
  28233. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  28234. if (this._currentFramebuffer !== framebuffer) {
  28235. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  28236. this._currentFramebuffer = framebuffer;
  28237. }
  28238. };
  28239. /**
  28240. * Unbind the current render target texture from the webGL context
  28241. * @param texture defines the render target texture to unbind
  28242. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28243. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28244. */
  28245. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  28246. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28247. this._currentRenderTarget = null;
  28248. // If MSAA, we need to bitblt back to main texture
  28249. var gl = this._gl;
  28250. if (texture._MSAAFramebuffer) {
  28251. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  28252. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  28253. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28254. }
  28255. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28256. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  28257. gl.generateMipmap(gl.TEXTURE_2D);
  28258. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28259. }
  28260. if (onBeforeUnbind) {
  28261. if (texture._MSAAFramebuffer) {
  28262. // Bind the correct framebuffer
  28263. this.bindUnboundFramebuffer(texture._framebuffer);
  28264. }
  28265. onBeforeUnbind();
  28266. }
  28267. this.bindUnboundFramebuffer(null);
  28268. };
  28269. /**
  28270. * Unbind a list of render target textures from the webGL context
  28271. * This is used only when drawBuffer extension or webGL2 are active
  28272. * @param textures defines the render target textures to unbind
  28273. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28274. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28275. */
  28276. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  28277. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28278. this._currentRenderTarget = null;
  28279. // If MSAA, we need to bitblt back to main texture
  28280. var gl = this._gl;
  28281. if (textures[0]._MSAAFramebuffer) {
  28282. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  28283. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  28284. var attachments = textures[0]._attachments;
  28285. if (!attachments) {
  28286. attachments = new Array(textures.length);
  28287. textures[0]._attachments = attachments;
  28288. }
  28289. for (var i = 0; i < textures.length; i++) {
  28290. var texture = textures[i];
  28291. for (var j = 0; j < attachments.length; j++) {
  28292. attachments[j] = gl.NONE;
  28293. }
  28294. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28295. gl.readBuffer(attachments[i]);
  28296. gl.drawBuffers(attachments);
  28297. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28298. }
  28299. for (var i = 0; i < attachments.length; i++) {
  28300. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28301. }
  28302. gl.drawBuffers(attachments);
  28303. }
  28304. for (var i = 0; i < textures.length; i++) {
  28305. var texture = textures[i];
  28306. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28307. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  28308. gl.generateMipmap(gl.TEXTURE_2D);
  28309. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28310. }
  28311. }
  28312. if (onBeforeUnbind) {
  28313. if (textures[0]._MSAAFramebuffer) {
  28314. // Bind the correct framebuffer
  28315. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  28316. }
  28317. onBeforeUnbind();
  28318. }
  28319. this.bindUnboundFramebuffer(null);
  28320. };
  28321. /**
  28322. * Force the mipmap generation for the given render target texture
  28323. * @param texture defines the render target texture to use
  28324. */
  28325. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  28326. if (texture.generateMipMaps) {
  28327. var gl = this._gl;
  28328. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28329. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  28330. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28331. }
  28332. };
  28333. /**
  28334. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28335. */
  28336. Engine.prototype.flushFramebuffer = function () {
  28337. this._gl.flush();
  28338. };
  28339. /**
  28340. * Unbind the current render target and bind the default framebuffer
  28341. */
  28342. Engine.prototype.restoreDefaultFramebuffer = function () {
  28343. if (this._currentRenderTarget) {
  28344. this.unBindFramebuffer(this._currentRenderTarget);
  28345. }
  28346. else {
  28347. this.bindUnboundFramebuffer(null);
  28348. }
  28349. if (this._cachedViewport) {
  28350. this.setViewport(this._cachedViewport);
  28351. }
  28352. this.wipeCaches();
  28353. };
  28354. // UBOs
  28355. /**
  28356. * Create an uniform buffer
  28357. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28358. * @param elements defines the content of the uniform buffer
  28359. * @returns the webGL uniform buffer
  28360. */
  28361. Engine.prototype.createUniformBuffer = function (elements) {
  28362. var ubo = this._gl.createBuffer();
  28363. if (!ubo) {
  28364. throw new Error("Unable to create uniform buffer");
  28365. }
  28366. this.bindUniformBuffer(ubo);
  28367. if (elements instanceof Float32Array) {
  28368. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  28369. }
  28370. else {
  28371. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  28372. }
  28373. this.bindUniformBuffer(null);
  28374. ubo.references = 1;
  28375. return ubo;
  28376. };
  28377. /**
  28378. * Create a dynamic uniform buffer
  28379. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28380. * @param elements defines the content of the uniform buffer
  28381. * @returns the webGL uniform buffer
  28382. */
  28383. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  28384. var ubo = this._gl.createBuffer();
  28385. if (!ubo) {
  28386. throw new Error("Unable to create dynamic uniform buffer");
  28387. }
  28388. this.bindUniformBuffer(ubo);
  28389. if (elements instanceof Float32Array) {
  28390. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  28391. }
  28392. else {
  28393. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  28394. }
  28395. this.bindUniformBuffer(null);
  28396. ubo.references = 1;
  28397. return ubo;
  28398. };
  28399. /**
  28400. * Update an existing uniform buffer
  28401. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28402. * @param uniformBuffer defines the target uniform buffer
  28403. * @param elements defines the content to update
  28404. * @param offset defines the offset in the uniform buffer where update should start
  28405. * @param count defines the size of the data to update
  28406. */
  28407. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  28408. this.bindUniformBuffer(uniformBuffer);
  28409. if (offset === undefined) {
  28410. offset = 0;
  28411. }
  28412. if (count === undefined) {
  28413. if (elements instanceof Float32Array) {
  28414. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  28415. }
  28416. else {
  28417. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  28418. }
  28419. }
  28420. else {
  28421. if (elements instanceof Float32Array) {
  28422. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  28423. }
  28424. else {
  28425. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  28426. }
  28427. }
  28428. this.bindUniformBuffer(null);
  28429. };
  28430. // VBOs
  28431. Engine.prototype._resetVertexBufferBinding = function () {
  28432. this.bindArrayBuffer(null);
  28433. this._cachedVertexBuffers = null;
  28434. };
  28435. /**
  28436. * Creates a vertex buffer
  28437. * @param data the data for the vertex buffer
  28438. * @returns the new WebGL static buffer
  28439. */
  28440. Engine.prototype.createVertexBuffer = function (data) {
  28441. var vbo = this._gl.createBuffer();
  28442. if (!vbo) {
  28443. throw new Error("Unable to create vertex buffer");
  28444. }
  28445. this.bindArrayBuffer(vbo);
  28446. if (data instanceof Array) {
  28447. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  28448. }
  28449. else {
  28450. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  28451. }
  28452. this._resetVertexBufferBinding();
  28453. vbo.references = 1;
  28454. return vbo;
  28455. };
  28456. /**
  28457. * Creates a dynamic vertex buffer
  28458. * @param data the data for the dynamic vertex buffer
  28459. * @returns the new WebGL dynamic buffer
  28460. */
  28461. Engine.prototype.createDynamicVertexBuffer = function (data) {
  28462. var vbo = this._gl.createBuffer();
  28463. if (!vbo) {
  28464. throw new Error("Unable to create dynamic vertex buffer");
  28465. }
  28466. this.bindArrayBuffer(vbo);
  28467. if (data instanceof Array) {
  28468. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  28469. }
  28470. else {
  28471. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  28472. }
  28473. this._resetVertexBufferBinding();
  28474. vbo.references = 1;
  28475. return vbo;
  28476. };
  28477. /**
  28478. * Update a dynamic index buffer
  28479. * @param indexBuffer defines the target index buffer
  28480. * @param indices defines the data to update
  28481. * @param offset defines the offset in the target index buffer where update should start
  28482. */
  28483. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  28484. if (offset === void 0) { offset = 0; }
  28485. // Force cache update
  28486. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  28487. this.bindIndexBuffer(indexBuffer);
  28488. var arrayBuffer;
  28489. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  28490. arrayBuffer = indices;
  28491. }
  28492. else {
  28493. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28494. }
  28495. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  28496. this._resetIndexBufferBinding();
  28497. };
  28498. /**
  28499. * Updates a dynamic vertex buffer.
  28500. * @param vertexBuffer the vertex buffer to update
  28501. * @param data the data used to update the vertex buffer
  28502. * @param byteOffset the byte offset of the data
  28503. * @param byteLength the byte length of the data
  28504. */
  28505. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  28506. this.bindArrayBuffer(vertexBuffer);
  28507. if (byteOffset === undefined) {
  28508. byteOffset = 0;
  28509. }
  28510. if (byteLength === undefined) {
  28511. if (data instanceof Array) {
  28512. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  28513. }
  28514. else {
  28515. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  28516. }
  28517. }
  28518. else {
  28519. if (data instanceof Array) {
  28520. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  28521. }
  28522. else {
  28523. if (data instanceof ArrayBuffer) {
  28524. data = new Uint8Array(data, byteOffset, byteLength);
  28525. }
  28526. else {
  28527. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  28528. }
  28529. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28530. }
  28531. }
  28532. this._resetVertexBufferBinding();
  28533. };
  28534. Engine.prototype._resetIndexBufferBinding = function () {
  28535. this.bindIndexBuffer(null);
  28536. this._cachedIndexBuffer = null;
  28537. };
  28538. /**
  28539. * Creates a new index buffer
  28540. * @param indices defines the content of the index buffer
  28541. * @param updatable defines if the index buffer must be updatable
  28542. * @returns a new webGL buffer
  28543. */
  28544. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  28545. var vbo = this._gl.createBuffer();
  28546. if (!vbo) {
  28547. throw new Error("Unable to create index buffer");
  28548. }
  28549. this.bindIndexBuffer(vbo);
  28550. // Check for 32 bits indices
  28551. var arrayBuffer;
  28552. var need32Bits = false;
  28553. if (indices instanceof Uint16Array) {
  28554. arrayBuffer = indices;
  28555. }
  28556. else {
  28557. //check 32 bit support
  28558. if (this._caps.uintIndices) {
  28559. if (indices instanceof Uint32Array) {
  28560. arrayBuffer = indices;
  28561. need32Bits = true;
  28562. }
  28563. else {
  28564. //number[] or Int32Array, check if 32 bit is necessary
  28565. for (var index = 0; index < indices.length; index++) {
  28566. if (indices[index] > 65535) {
  28567. need32Bits = true;
  28568. break;
  28569. }
  28570. }
  28571. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28572. }
  28573. }
  28574. else {
  28575. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  28576. arrayBuffer = new Uint16Array(indices);
  28577. }
  28578. }
  28579. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  28580. this._resetIndexBufferBinding();
  28581. vbo.references = 1;
  28582. vbo.is32Bits = need32Bits;
  28583. return vbo;
  28584. };
  28585. /**
  28586. * Bind a webGL buffer to the webGL context
  28587. * @param buffer defines the buffer to bind
  28588. */
  28589. Engine.prototype.bindArrayBuffer = function (buffer) {
  28590. if (!this._vaoRecordInProgress) {
  28591. this._unbindVertexArrayObject();
  28592. }
  28593. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  28594. };
  28595. /**
  28596. * Bind an uniform buffer to the current webGL context
  28597. * @param buffer defines the buffer to bind
  28598. */
  28599. Engine.prototype.bindUniformBuffer = function (buffer) {
  28600. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  28601. };
  28602. /**
  28603. * Bind a buffer to the current webGL context at a given location
  28604. * @param buffer defines the buffer to bind
  28605. * @param location defines the index where to bind the buffer
  28606. */
  28607. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  28608. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  28609. };
  28610. /**
  28611. * Bind a specific block at a given index in a specific shader program
  28612. * @param shaderProgram defines the shader program
  28613. * @param blockName defines the block name
  28614. * @param index defines the index where to bind the block
  28615. */
  28616. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  28617. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  28618. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  28619. };
  28620. Engine.prototype.bindIndexBuffer = function (buffer) {
  28621. if (!this._vaoRecordInProgress) {
  28622. this._unbindVertexArrayObject();
  28623. }
  28624. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  28625. };
  28626. Engine.prototype.bindBuffer = function (buffer, target) {
  28627. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  28628. this._gl.bindBuffer(target, buffer);
  28629. this._currentBoundBuffer[target] = buffer;
  28630. }
  28631. };
  28632. /**
  28633. * update the bound buffer with the given data
  28634. * @param data defines the data to update
  28635. */
  28636. Engine.prototype.updateArrayBuffer = function (data) {
  28637. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28638. };
  28639. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  28640. var pointer = this._currentBufferPointers[indx];
  28641. var changed = false;
  28642. if (!pointer.active) {
  28643. changed = true;
  28644. pointer.active = true;
  28645. pointer.index = indx;
  28646. pointer.size = size;
  28647. pointer.type = type;
  28648. pointer.normalized = normalized;
  28649. pointer.stride = stride;
  28650. pointer.offset = offset;
  28651. pointer.buffer = buffer;
  28652. }
  28653. else {
  28654. if (pointer.buffer !== buffer) {
  28655. pointer.buffer = buffer;
  28656. changed = true;
  28657. }
  28658. if (pointer.size !== size) {
  28659. pointer.size = size;
  28660. changed = true;
  28661. }
  28662. if (pointer.type !== type) {
  28663. pointer.type = type;
  28664. changed = true;
  28665. }
  28666. if (pointer.normalized !== normalized) {
  28667. pointer.normalized = normalized;
  28668. changed = true;
  28669. }
  28670. if (pointer.stride !== stride) {
  28671. pointer.stride = stride;
  28672. changed = true;
  28673. }
  28674. if (pointer.offset !== offset) {
  28675. pointer.offset = offset;
  28676. changed = true;
  28677. }
  28678. }
  28679. if (changed || this._vaoRecordInProgress) {
  28680. this.bindArrayBuffer(buffer);
  28681. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  28682. }
  28683. };
  28684. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  28685. if (indexBuffer == null) {
  28686. return;
  28687. }
  28688. if (this._cachedIndexBuffer !== indexBuffer) {
  28689. this._cachedIndexBuffer = indexBuffer;
  28690. this.bindIndexBuffer(indexBuffer);
  28691. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  28692. }
  28693. };
  28694. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  28695. var attributes = effect.getAttributesNames();
  28696. if (!this._vaoRecordInProgress) {
  28697. this._unbindVertexArrayObject();
  28698. }
  28699. this.unbindAllAttributes();
  28700. for (var index = 0; index < attributes.length; index++) {
  28701. var order = effect.getAttributeLocation(index);
  28702. if (order >= 0) {
  28703. var vertexBuffer = vertexBuffers[attributes[index]];
  28704. if (!vertexBuffer) {
  28705. continue;
  28706. }
  28707. this._gl.enableVertexAttribArray(order);
  28708. if (!this._vaoRecordInProgress) {
  28709. this._vertexAttribArraysEnabled[order] = true;
  28710. }
  28711. var buffer = vertexBuffer.getBuffer();
  28712. if (buffer) {
  28713. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  28714. if (vertexBuffer.getIsInstanced()) {
  28715. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  28716. if (!this._vaoRecordInProgress) {
  28717. this._currentInstanceLocations.push(order);
  28718. this._currentInstanceBuffers.push(buffer);
  28719. }
  28720. }
  28721. }
  28722. }
  28723. }
  28724. };
  28725. /**
  28726. * Records a vertex array object
  28727. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28728. * @param vertexBuffers defines the list of vertex buffers to store
  28729. * @param indexBuffer defines the index buffer to store
  28730. * @param effect defines the effect to store
  28731. * @returns the new vertex array object
  28732. */
  28733. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  28734. var vao = this._gl.createVertexArray();
  28735. this._vaoRecordInProgress = true;
  28736. this._gl.bindVertexArray(vao);
  28737. this._mustWipeVertexAttributes = true;
  28738. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  28739. this.bindIndexBuffer(indexBuffer);
  28740. this._vaoRecordInProgress = false;
  28741. this._gl.bindVertexArray(null);
  28742. return vao;
  28743. };
  28744. /**
  28745. * Bind a specific vertex array object
  28746. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28747. * @param vertexArrayObject defines the vertex array object to bind
  28748. * @param indexBuffer defines the index buffer to bind
  28749. */
  28750. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  28751. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  28752. this._cachedVertexArrayObject = vertexArrayObject;
  28753. this._gl.bindVertexArray(vertexArrayObject);
  28754. this._cachedVertexBuffers = null;
  28755. this._cachedIndexBuffer = null;
  28756. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  28757. this._mustWipeVertexAttributes = true;
  28758. }
  28759. };
  28760. /**
  28761. * Bind webGl buffers directly to the webGL context
  28762. * @param vertexBuffer defines the vertex buffer to bind
  28763. * @param indexBuffer defines the index buffer to bind
  28764. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28765. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28766. * @param effect defines the effect associated with the vertex buffer
  28767. */
  28768. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  28769. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  28770. this._cachedVertexBuffers = vertexBuffer;
  28771. this._cachedEffectForVertexBuffers = effect;
  28772. var attributesCount = effect.getAttributesCount();
  28773. this._unbindVertexArrayObject();
  28774. this.unbindAllAttributes();
  28775. var offset = 0;
  28776. for (var index = 0; index < attributesCount; index++) {
  28777. if (index < vertexDeclaration.length) {
  28778. var order = effect.getAttributeLocation(index);
  28779. if (order >= 0) {
  28780. this._gl.enableVertexAttribArray(order);
  28781. this._vertexAttribArraysEnabled[order] = true;
  28782. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  28783. }
  28784. offset += vertexDeclaration[index] * 4;
  28785. }
  28786. }
  28787. }
  28788. this._bindIndexBufferWithCache(indexBuffer);
  28789. };
  28790. Engine.prototype._unbindVertexArrayObject = function () {
  28791. if (!this._cachedVertexArrayObject) {
  28792. return;
  28793. }
  28794. this._cachedVertexArrayObject = null;
  28795. this._gl.bindVertexArray(null);
  28796. };
  28797. /**
  28798. * Bind a list of vertex buffers to the webGL context
  28799. * @param vertexBuffers defines the list of vertex buffers to bind
  28800. * @param indexBuffer defines the index buffer to bind
  28801. * @param effect defines the effect associated with the vertex buffers
  28802. */
  28803. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  28804. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  28805. this._cachedVertexBuffers = vertexBuffers;
  28806. this._cachedEffectForVertexBuffers = effect;
  28807. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  28808. }
  28809. this._bindIndexBufferWithCache(indexBuffer);
  28810. };
  28811. /**
  28812. * Unbind all instance attributes
  28813. */
  28814. Engine.prototype.unbindInstanceAttributes = function () {
  28815. var boundBuffer;
  28816. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  28817. var instancesBuffer = this._currentInstanceBuffers[i];
  28818. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  28819. boundBuffer = instancesBuffer;
  28820. this.bindArrayBuffer(instancesBuffer);
  28821. }
  28822. var offsetLocation = this._currentInstanceLocations[i];
  28823. this._gl.vertexAttribDivisor(offsetLocation, 0);
  28824. }
  28825. this._currentInstanceBuffers.length = 0;
  28826. this._currentInstanceLocations.length = 0;
  28827. };
  28828. /**
  28829. * Release and free the memory of a vertex array object
  28830. * @param vao defines the vertex array object to delete
  28831. */
  28832. Engine.prototype.releaseVertexArrayObject = function (vao) {
  28833. this._gl.deleteVertexArray(vao);
  28834. };
  28835. /** @hidden */
  28836. Engine.prototype._releaseBuffer = function (buffer) {
  28837. buffer.references--;
  28838. if (buffer.references === 0) {
  28839. this._gl.deleteBuffer(buffer);
  28840. return true;
  28841. }
  28842. return false;
  28843. };
  28844. /**
  28845. * Creates a webGL buffer to use with instanciation
  28846. * @param capacity defines the size of the buffer
  28847. * @returns the webGL buffer
  28848. */
  28849. Engine.prototype.createInstancesBuffer = function (capacity) {
  28850. var buffer = this._gl.createBuffer();
  28851. if (!buffer) {
  28852. throw new Error("Unable to create instance buffer");
  28853. }
  28854. buffer.capacity = capacity;
  28855. this.bindArrayBuffer(buffer);
  28856. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  28857. return buffer;
  28858. };
  28859. /**
  28860. * Delete a webGL buffer used with instanciation
  28861. * @param buffer defines the webGL buffer to delete
  28862. */
  28863. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  28864. this._gl.deleteBuffer(buffer);
  28865. };
  28866. /**
  28867. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28868. * @param instancesBuffer defines the webGL buffer to update and bind
  28869. * @param data defines the data to store in the buffer
  28870. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28871. */
  28872. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  28873. this.bindArrayBuffer(instancesBuffer);
  28874. if (data) {
  28875. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28876. }
  28877. if (offsetLocations[0].index !== undefined) {
  28878. var stride = 0;
  28879. for (var i = 0; i < offsetLocations.length; i++) {
  28880. var ai = offsetLocations[i];
  28881. stride += ai.attributeSize * 4;
  28882. }
  28883. for (var i = 0; i < offsetLocations.length; i++) {
  28884. var ai = offsetLocations[i];
  28885. if (!this._vertexAttribArraysEnabled[ai.index]) {
  28886. this._gl.enableVertexAttribArray(ai.index);
  28887. this._vertexAttribArraysEnabled[ai.index] = true;
  28888. }
  28889. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  28890. this._gl.vertexAttribDivisor(ai.index, 1);
  28891. this._currentInstanceLocations.push(ai.index);
  28892. this._currentInstanceBuffers.push(instancesBuffer);
  28893. }
  28894. }
  28895. else {
  28896. for (var index = 0; index < 4; index++) {
  28897. var offsetLocation = offsetLocations[index];
  28898. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  28899. this._gl.enableVertexAttribArray(offsetLocation);
  28900. this._vertexAttribArraysEnabled[offsetLocation] = true;
  28901. }
  28902. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  28903. this._gl.vertexAttribDivisor(offsetLocation, 1);
  28904. this._currentInstanceLocations.push(offsetLocation);
  28905. this._currentInstanceBuffers.push(instancesBuffer);
  28906. }
  28907. }
  28908. };
  28909. /**
  28910. * Apply all cached states (depth, culling, stencil and alpha)
  28911. */
  28912. Engine.prototype.applyStates = function () {
  28913. this._depthCullingState.apply(this._gl);
  28914. this._stencilState.apply(this._gl);
  28915. this._alphaState.apply(this._gl);
  28916. };
  28917. /**
  28918. * Send a draw order
  28919. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28920. * @param indexStart defines the starting index
  28921. * @param indexCount defines the number of index to draw
  28922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28923. */
  28924. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  28925. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  28926. };
  28927. /**
  28928. * Draw a list of points
  28929. * @param verticesStart defines the index of first vertex to draw
  28930. * @param verticesCount defines the count of vertices to draw
  28931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28932. */
  28933. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  28934. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  28935. };
  28936. /**
  28937. * Draw a list of unindexed primitives
  28938. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28939. * @param verticesStart defines the index of first vertex to draw
  28940. * @param verticesCount defines the count of vertices to draw
  28941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28942. */
  28943. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  28944. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  28945. };
  28946. /**
  28947. * Draw a list of indexed primitives
  28948. * @param fillMode defines the primitive to use
  28949. * @param indexStart defines the starting index
  28950. * @param indexCount defines the number of index to draw
  28951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28952. */
  28953. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  28954. // Apply states
  28955. this.applyStates();
  28956. this._drawCalls.addCount(1, false);
  28957. // Render
  28958. var drawMode = this._drawMode(fillMode);
  28959. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  28960. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  28961. if (instancesCount) {
  28962. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  28963. }
  28964. else {
  28965. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  28966. }
  28967. };
  28968. /**
  28969. * Draw a list of unindexed primitives
  28970. * @param fillMode defines the primitive to use
  28971. * @param verticesStart defines the index of first vertex to draw
  28972. * @param verticesCount defines the count of vertices to draw
  28973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28974. */
  28975. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  28976. // Apply states
  28977. this.applyStates();
  28978. this._drawCalls.addCount(1, false);
  28979. var drawMode = this._drawMode(fillMode);
  28980. if (instancesCount) {
  28981. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  28982. }
  28983. else {
  28984. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  28985. }
  28986. };
  28987. Engine.prototype._drawMode = function (fillMode) {
  28988. switch (fillMode) {
  28989. // Triangle views
  28990. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  28991. return this._gl.TRIANGLES;
  28992. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  28993. return this._gl.POINTS;
  28994. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  28995. return this._gl.LINES;
  28996. // Draw modes
  28997. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  28998. return this._gl.POINTS;
  28999. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29000. return this._gl.LINES;
  29001. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29002. return this._gl.LINE_LOOP;
  29003. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29004. return this._gl.LINE_STRIP;
  29005. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29006. return this._gl.TRIANGLE_STRIP;
  29007. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29008. return this._gl.TRIANGLE_FAN;
  29009. default:
  29010. return this._gl.TRIANGLES;
  29011. }
  29012. };
  29013. // Shaders
  29014. /** @hidden */
  29015. Engine.prototype._releaseEffect = function (effect) {
  29016. if (this._compiledEffects[effect._key]) {
  29017. delete this._compiledEffects[effect._key];
  29018. this._deleteProgram(effect.getProgram());
  29019. }
  29020. };
  29021. /** @hidden */
  29022. Engine.prototype._deleteProgram = function (program) {
  29023. if (program) {
  29024. program.__SPECTOR_rebuildProgram = null;
  29025. if (program.transformFeedback) {
  29026. this.deleteTransformFeedback(program.transformFeedback);
  29027. program.transformFeedback = null;
  29028. }
  29029. this._gl.deleteProgram(program);
  29030. }
  29031. };
  29032. /**
  29033. * Create a new effect (used to store vertex/fragment shaders)
  29034. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29035. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29036. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29037. * @param samplers defines an array of string used to represent textures
  29038. * @param defines defines the string containing the defines to use to compile the shaders
  29039. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29040. * @param onCompiled defines a function to call when the effect creation is successful
  29041. * @param onError defines a function to call when the effect creation has failed
  29042. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29043. * @returns the new Effect
  29044. */
  29045. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29046. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29047. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29048. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29049. if (this._compiledEffects[name]) {
  29050. var compiledEffect = this._compiledEffects[name];
  29051. if (onCompiled && compiledEffect.isReady()) {
  29052. onCompiled(compiledEffect);
  29053. }
  29054. return compiledEffect;
  29055. }
  29056. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29057. effect._key = name;
  29058. this._compiledEffects[name] = effect;
  29059. return effect;
  29060. };
  29061. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29062. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29063. };
  29064. Engine.prototype._compileRawShader = function (source, type) {
  29065. var gl = this._gl;
  29066. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29067. if (!shader) {
  29068. throw new Error("Something went wrong while compile the shader.");
  29069. }
  29070. gl.shaderSource(shader, source);
  29071. gl.compileShader(shader);
  29072. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29073. var log = gl.getShaderInfoLog(shader);
  29074. if (log) {
  29075. throw new Error(log);
  29076. }
  29077. }
  29078. return shader;
  29079. };
  29080. /**
  29081. * Directly creates a webGL program
  29082. * @param vertexCode defines the vertex shader code to use
  29083. * @param fragmentCode defines the fragment shader code to use
  29084. * @param context defines the webGL context to use (if not set, the current one will be used)
  29085. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29086. * @returns the new webGL program
  29087. */
  29088. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  29089. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29090. context = context || this._gl;
  29091. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  29092. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  29093. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29094. };
  29095. /**
  29096. * Creates a webGL program
  29097. * @param vertexCode defines the vertex shader code to use
  29098. * @param fragmentCode defines the fragment shader code to use
  29099. * @param defines defines the string containing the defines to use to compile the shaders
  29100. * @param context defines the webGL context to use (if not set, the current one will be used)
  29101. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29102. * @returns the new webGL program
  29103. */
  29104. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  29105. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29106. context = context || this._gl;
  29107. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29108. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  29109. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  29110. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  29111. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29112. this.onAfterShaderCompilationObservable.notifyObservers(this);
  29113. return program;
  29114. };
  29115. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  29116. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29117. var shaderProgram = context.createProgram();
  29118. if (!shaderProgram) {
  29119. throw new Error("Unable to create program");
  29120. }
  29121. context.attachShader(shaderProgram, vertexShader);
  29122. context.attachShader(shaderProgram, fragmentShader);
  29123. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29124. var transformFeedback = this.createTransformFeedback();
  29125. this.bindTransformFeedback(transformFeedback);
  29126. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  29127. shaderProgram.transformFeedback = transformFeedback;
  29128. }
  29129. context.linkProgram(shaderProgram);
  29130. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29131. this.bindTransformFeedback(null);
  29132. }
  29133. shaderProgram.context = context;
  29134. shaderProgram.vertexShader = vertexShader;
  29135. shaderProgram.fragmentShader = fragmentShader;
  29136. if (!this._caps.parallelShaderCompile) {
  29137. this._finalizeProgram(shaderProgram);
  29138. }
  29139. else {
  29140. shaderProgram.isParallelCompiled = true;
  29141. }
  29142. return shaderProgram;
  29143. };
  29144. Engine.prototype._finalizeProgram = function (shaderProgram) {
  29145. var context = shaderProgram.context;
  29146. var vertexShader = shaderProgram.vertexShader;
  29147. var fragmentShader = shaderProgram.fragmentShader;
  29148. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  29149. if (!linked) {
  29150. var error = context.getProgramInfoLog(shaderProgram);
  29151. if (error) {
  29152. throw new Error(error);
  29153. }
  29154. }
  29155. if (this.validateShaderPrograms) {
  29156. context.validateProgram(shaderProgram);
  29157. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  29158. if (!validated) {
  29159. var error = context.getProgramInfoLog(shaderProgram);
  29160. if (error) {
  29161. throw new Error(error);
  29162. }
  29163. }
  29164. }
  29165. context.deleteShader(vertexShader);
  29166. context.deleteShader(fragmentShader);
  29167. shaderProgram.context = undefined;
  29168. shaderProgram.vertexShader = undefined;
  29169. shaderProgram.fragmentShader = undefined;
  29170. if (shaderProgram.onCompiled) {
  29171. shaderProgram.onCompiled();
  29172. shaderProgram.onCompiled = undefined;
  29173. }
  29174. };
  29175. /** @hidden */
  29176. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  29177. if (!shaderProgram.isParallelCompiled) {
  29178. return true;
  29179. }
  29180. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  29181. this._finalizeProgram(shaderProgram);
  29182. return true;
  29183. }
  29184. return false;
  29185. };
  29186. /** @hidden */
  29187. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  29188. if (!shaderProgram.isParallelCompiled) {
  29189. action();
  29190. return;
  29191. }
  29192. shaderProgram.onCompiled = action;
  29193. };
  29194. /**
  29195. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29196. * @param shaderProgram defines the webGL program to use
  29197. * @param uniformsNames defines the list of uniform names
  29198. * @returns an array of webGL uniform locations
  29199. */
  29200. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  29201. var results = new Array();
  29202. for (var index = 0; index < uniformsNames.length; index++) {
  29203. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  29204. }
  29205. return results;
  29206. };
  29207. /**
  29208. * Gets the lsit of active attributes for a given webGL program
  29209. * @param shaderProgram defines the webGL program to use
  29210. * @param attributesNames defines the list of attribute names to get
  29211. * @returns an array of indices indicating the offset of each attribute
  29212. */
  29213. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  29214. var results = [];
  29215. for (var index = 0; index < attributesNames.length; index++) {
  29216. try {
  29217. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  29218. }
  29219. catch (e) {
  29220. results.push(-1);
  29221. }
  29222. }
  29223. return results;
  29224. };
  29225. /**
  29226. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29227. * @param effect defines the effect to activate
  29228. */
  29229. Engine.prototype.enableEffect = function (effect) {
  29230. if (!effect || effect === this._currentEffect) {
  29231. return;
  29232. }
  29233. // Use program
  29234. this.bindSamplers(effect);
  29235. this._currentEffect = effect;
  29236. if (effect.onBind) {
  29237. effect.onBind(effect);
  29238. }
  29239. if (effect._onBindObservable) {
  29240. effect._onBindObservable.notifyObservers(effect);
  29241. }
  29242. };
  29243. /**
  29244. * Set the value of an uniform to an array of int32
  29245. * @param uniform defines the webGL uniform location where to store the value
  29246. * @param array defines the array of int32 to store
  29247. */
  29248. Engine.prototype.setIntArray = function (uniform, array) {
  29249. if (!uniform) {
  29250. return;
  29251. }
  29252. this._gl.uniform1iv(uniform, array);
  29253. };
  29254. /**
  29255. * Set the value of an uniform to an array of int32 (stored as vec2)
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param array defines the array of int32 to store
  29258. */
  29259. Engine.prototype.setIntArray2 = function (uniform, array) {
  29260. if (!uniform || array.length % 2 !== 0) {
  29261. return;
  29262. }
  29263. this._gl.uniform2iv(uniform, array);
  29264. };
  29265. /**
  29266. * Set the value of an uniform to an array of int32 (stored as vec3)
  29267. * @param uniform defines the webGL uniform location where to store the value
  29268. * @param array defines the array of int32 to store
  29269. */
  29270. Engine.prototype.setIntArray3 = function (uniform, array) {
  29271. if (!uniform || array.length % 3 !== 0) {
  29272. return;
  29273. }
  29274. this._gl.uniform3iv(uniform, array);
  29275. };
  29276. /**
  29277. * Set the value of an uniform to an array of int32 (stored as vec4)
  29278. * @param uniform defines the webGL uniform location where to store the value
  29279. * @param array defines the array of int32 to store
  29280. */
  29281. Engine.prototype.setIntArray4 = function (uniform, array) {
  29282. if (!uniform || array.length % 4 !== 0) {
  29283. return;
  29284. }
  29285. this._gl.uniform4iv(uniform, array);
  29286. };
  29287. /**
  29288. * Set the value of an uniform to an array of float32
  29289. * @param uniform defines the webGL uniform location where to store the value
  29290. * @param array defines the array of float32 to store
  29291. */
  29292. Engine.prototype.setFloatArray = function (uniform, array) {
  29293. if (!uniform) {
  29294. return;
  29295. }
  29296. this._gl.uniform1fv(uniform, array);
  29297. };
  29298. /**
  29299. * Set the value of an uniform to an array of float32 (stored as vec2)
  29300. * @param uniform defines the webGL uniform location where to store the value
  29301. * @param array defines the array of float32 to store
  29302. */
  29303. Engine.prototype.setFloatArray2 = function (uniform, array) {
  29304. if (!uniform || array.length % 2 !== 0) {
  29305. return;
  29306. }
  29307. this._gl.uniform2fv(uniform, array);
  29308. };
  29309. /**
  29310. * Set the value of an uniform to an array of float32 (stored as vec3)
  29311. * @param uniform defines the webGL uniform location where to store the value
  29312. * @param array defines the array of float32 to store
  29313. */
  29314. Engine.prototype.setFloatArray3 = function (uniform, array) {
  29315. if (!uniform || array.length % 3 !== 0) {
  29316. return;
  29317. }
  29318. this._gl.uniform3fv(uniform, array);
  29319. };
  29320. /**
  29321. * Set the value of an uniform to an array of float32 (stored as vec4)
  29322. * @param uniform defines the webGL uniform location where to store the value
  29323. * @param array defines the array of float32 to store
  29324. */
  29325. Engine.prototype.setFloatArray4 = function (uniform, array) {
  29326. if (!uniform || array.length % 4 !== 0) {
  29327. return;
  29328. }
  29329. this._gl.uniform4fv(uniform, array);
  29330. };
  29331. /**
  29332. * Set the value of an uniform to an array of number
  29333. * @param uniform defines the webGL uniform location where to store the value
  29334. * @param array defines the array of number to store
  29335. */
  29336. Engine.prototype.setArray = function (uniform, array) {
  29337. if (!uniform) {
  29338. return;
  29339. }
  29340. this._gl.uniform1fv(uniform, array);
  29341. };
  29342. /**
  29343. * Set the value of an uniform to an array of number (stored as vec2)
  29344. * @param uniform defines the webGL uniform location where to store the value
  29345. * @param array defines the array of number to store
  29346. */
  29347. Engine.prototype.setArray2 = function (uniform, array) {
  29348. if (!uniform || array.length % 2 !== 0) {
  29349. return;
  29350. }
  29351. this._gl.uniform2fv(uniform, array);
  29352. };
  29353. /**
  29354. * Set the value of an uniform to an array of number (stored as vec3)
  29355. * @param uniform defines the webGL uniform location where to store the value
  29356. * @param array defines the array of number to store
  29357. */
  29358. Engine.prototype.setArray3 = function (uniform, array) {
  29359. if (!uniform || array.length % 3 !== 0) {
  29360. return;
  29361. }
  29362. this._gl.uniform3fv(uniform, array);
  29363. };
  29364. /**
  29365. * Set the value of an uniform to an array of number (stored as vec4)
  29366. * @param uniform defines the webGL uniform location where to store the value
  29367. * @param array defines the array of number to store
  29368. */
  29369. Engine.prototype.setArray4 = function (uniform, array) {
  29370. if (!uniform || array.length % 4 !== 0) {
  29371. return;
  29372. }
  29373. this._gl.uniform4fv(uniform, array);
  29374. };
  29375. /**
  29376. * Set the value of an uniform to an array of float32 (stored as matrices)
  29377. * @param uniform defines the webGL uniform location where to store the value
  29378. * @param matrices defines the array of float32 to store
  29379. */
  29380. Engine.prototype.setMatrices = function (uniform, matrices) {
  29381. if (!uniform) {
  29382. return;
  29383. }
  29384. this._gl.uniformMatrix4fv(uniform, false, matrices);
  29385. };
  29386. /**
  29387. * Set the value of an uniform to a matrix
  29388. * @param uniform defines the webGL uniform location where to store the value
  29389. * @param matrix defines the matrix to store
  29390. */
  29391. Engine.prototype.setMatrix = function (uniform, matrix) {
  29392. if (!uniform) {
  29393. return;
  29394. }
  29395. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  29396. };
  29397. /**
  29398. * Set the value of an uniform to a matrix (3x3)
  29399. * @param uniform defines the webGL uniform location where to store the value
  29400. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29401. */
  29402. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  29403. if (!uniform) {
  29404. return;
  29405. }
  29406. this._gl.uniformMatrix3fv(uniform, false, matrix);
  29407. };
  29408. /**
  29409. * Set the value of an uniform to a matrix (2x2)
  29410. * @param uniform defines the webGL uniform location where to store the value
  29411. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29412. */
  29413. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  29414. if (!uniform) {
  29415. return;
  29416. }
  29417. this._gl.uniformMatrix2fv(uniform, false, matrix);
  29418. };
  29419. /**
  29420. * Set the value of an uniform to a number (int)
  29421. * @param uniform defines the webGL uniform location where to store the value
  29422. * @param value defines the int number to store
  29423. */
  29424. Engine.prototype.setInt = function (uniform, value) {
  29425. if (!uniform) {
  29426. return;
  29427. }
  29428. this._gl.uniform1i(uniform, value);
  29429. };
  29430. /**
  29431. * Set the value of an uniform to a number (float)
  29432. * @param uniform defines the webGL uniform location where to store the value
  29433. * @param value defines the float number to store
  29434. */
  29435. Engine.prototype.setFloat = function (uniform, value) {
  29436. if (!uniform) {
  29437. return;
  29438. }
  29439. this._gl.uniform1f(uniform, value);
  29440. };
  29441. /**
  29442. * Set the value of an uniform to a vec2
  29443. * @param uniform defines the webGL uniform location where to store the value
  29444. * @param x defines the 1st component of the value
  29445. * @param y defines the 2nd component of the value
  29446. */
  29447. Engine.prototype.setFloat2 = function (uniform, x, y) {
  29448. if (!uniform) {
  29449. return;
  29450. }
  29451. this._gl.uniform2f(uniform, x, y);
  29452. };
  29453. /**
  29454. * Set the value of an uniform to a vec3
  29455. * @param uniform defines the webGL uniform location where to store the value
  29456. * @param x defines the 1st component of the value
  29457. * @param y defines the 2nd component of the value
  29458. * @param z defines the 3rd component of the value
  29459. */
  29460. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  29461. if (!uniform) {
  29462. return;
  29463. }
  29464. this._gl.uniform3f(uniform, x, y, z);
  29465. };
  29466. /**
  29467. * Set the value of an uniform to a boolean
  29468. * @param uniform defines the webGL uniform location where to store the value
  29469. * @param bool defines the boolean to store
  29470. */
  29471. Engine.prototype.setBool = function (uniform, bool) {
  29472. if (!uniform) {
  29473. return;
  29474. }
  29475. this._gl.uniform1i(uniform, bool);
  29476. };
  29477. /**
  29478. * Set the value of an uniform to a vec4
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param x defines the 1st component of the value
  29481. * @param y defines the 2nd component of the value
  29482. * @param z defines the 3rd component of the value
  29483. * @param w defines the 4th component of the value
  29484. */
  29485. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  29486. if (!uniform) {
  29487. return;
  29488. }
  29489. this._gl.uniform4f(uniform, x, y, z, w);
  29490. };
  29491. /**
  29492. * Set the value of an uniform to a Color3
  29493. * @param uniform defines the webGL uniform location where to store the value
  29494. * @param color3 defines the color to store
  29495. */
  29496. Engine.prototype.setColor3 = function (uniform, color3) {
  29497. if (!uniform) {
  29498. return;
  29499. }
  29500. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  29501. };
  29502. /**
  29503. * Set the value of an uniform to a Color3 and an alpha value
  29504. * @param uniform defines the webGL uniform location where to store the value
  29505. * @param color3 defines the color to store
  29506. * @param alpha defines the alpha component to store
  29507. */
  29508. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  29509. if (!uniform) {
  29510. return;
  29511. }
  29512. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  29513. };
  29514. /**
  29515. * Sets a Color4 on a uniform variable
  29516. * @param uniform defines the uniform location
  29517. * @param color4 defines the value to be set
  29518. */
  29519. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  29520. if (!uniform) {
  29521. return;
  29522. }
  29523. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  29524. };
  29525. // States
  29526. /**
  29527. * Set various states to the webGL context
  29528. * @param culling defines backface culling state
  29529. * @param zOffset defines the value to apply to zOffset (0 by default)
  29530. * @param force defines if states must be applied even if cache is up to date
  29531. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29532. */
  29533. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  29534. if (zOffset === void 0) { zOffset = 0; }
  29535. if (reverseSide === void 0) { reverseSide = false; }
  29536. // Culling
  29537. if (this._depthCullingState.cull !== culling || force) {
  29538. this._depthCullingState.cull = culling;
  29539. }
  29540. // Cull face
  29541. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  29542. if (this._depthCullingState.cullFace !== cullFace || force) {
  29543. this._depthCullingState.cullFace = cullFace;
  29544. }
  29545. // Z offset
  29546. this.setZOffset(zOffset);
  29547. // Front face
  29548. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  29549. if (this._depthCullingState.frontFace !== frontFace || force) {
  29550. this._depthCullingState.frontFace = frontFace;
  29551. }
  29552. };
  29553. /**
  29554. * Set the z offset to apply to current rendering
  29555. * @param value defines the offset to apply
  29556. */
  29557. Engine.prototype.setZOffset = function (value) {
  29558. this._depthCullingState.zOffset = value;
  29559. };
  29560. /**
  29561. * Gets the current value of the zOffset
  29562. * @returns the current zOffset state
  29563. */
  29564. Engine.prototype.getZOffset = function () {
  29565. return this._depthCullingState.zOffset;
  29566. };
  29567. /**
  29568. * Enable or disable depth buffering
  29569. * @param enable defines the state to set
  29570. */
  29571. Engine.prototype.setDepthBuffer = function (enable) {
  29572. this._depthCullingState.depthTest = enable;
  29573. };
  29574. /**
  29575. * Gets a boolean indicating if depth writing is enabled
  29576. * @returns the current depth writing state
  29577. */
  29578. Engine.prototype.getDepthWrite = function () {
  29579. return this._depthCullingState.depthMask;
  29580. };
  29581. /**
  29582. * Enable or disable depth writing
  29583. * @param enable defines the state to set
  29584. */
  29585. Engine.prototype.setDepthWrite = function (enable) {
  29586. this._depthCullingState.depthMask = enable;
  29587. };
  29588. /**
  29589. * Enable or disable color writing
  29590. * @param enable defines the state to set
  29591. */
  29592. Engine.prototype.setColorWrite = function (enable) {
  29593. this._gl.colorMask(enable, enable, enable, enable);
  29594. this._colorWrite = enable;
  29595. };
  29596. /**
  29597. * Gets a boolean indicating if color writing is enabled
  29598. * @returns the current color writing state
  29599. */
  29600. Engine.prototype.getColorWrite = function () {
  29601. return this._colorWrite;
  29602. };
  29603. /**
  29604. * Sets alpha constants used by some alpha blending modes
  29605. * @param r defines the red component
  29606. * @param g defines the green component
  29607. * @param b defines the blue component
  29608. * @param a defines the alpha component
  29609. */
  29610. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  29611. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  29612. };
  29613. /**
  29614. * Sets the current alpha mode
  29615. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29616. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29617. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29618. */
  29619. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  29620. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  29621. if (this._alphaMode === mode) {
  29622. return;
  29623. }
  29624. switch (mode) {
  29625. case Engine.ALPHA_DISABLE:
  29626. this._alphaState.alphaBlend = false;
  29627. break;
  29628. case Engine.ALPHA_PREMULTIPLIED:
  29629. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29630. this._alphaState.alphaBlend = true;
  29631. break;
  29632. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  29633. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29634. this._alphaState.alphaBlend = true;
  29635. break;
  29636. case Engine.ALPHA_COMBINE:
  29637. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29638. this._alphaState.alphaBlend = true;
  29639. break;
  29640. case Engine.ALPHA_ONEONE:
  29641. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29642. this._alphaState.alphaBlend = true;
  29643. break;
  29644. case Engine.ALPHA_ADD:
  29645. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29646. this._alphaState.alphaBlend = true;
  29647. break;
  29648. case Engine.ALPHA_SUBTRACT:
  29649. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29650. this._alphaState.alphaBlend = true;
  29651. break;
  29652. case Engine.ALPHA_MULTIPLY:
  29653. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  29654. this._alphaState.alphaBlend = true;
  29655. break;
  29656. case Engine.ALPHA_MAXIMIZED:
  29657. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29658. this._alphaState.alphaBlend = true;
  29659. break;
  29660. case Engine.ALPHA_INTERPOLATE:
  29661. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  29662. this._alphaState.alphaBlend = true;
  29663. break;
  29664. case Engine.ALPHA_SCREENMODE:
  29665. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29666. this._alphaState.alphaBlend = true;
  29667. break;
  29668. }
  29669. if (!noDepthWriteChange) {
  29670. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  29671. }
  29672. this._alphaMode = mode;
  29673. };
  29674. /**
  29675. * Gets the current alpha mode
  29676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29677. * @returns the current alpha mode
  29678. */
  29679. Engine.prototype.getAlphaMode = function () {
  29680. return this._alphaMode;
  29681. };
  29682. // Textures
  29683. /**
  29684. * Clears the list of texture accessible through engine.
  29685. * This can help preventing texture load conflict due to name collision.
  29686. */
  29687. Engine.prototype.clearInternalTexturesCache = function () {
  29688. this._internalTexturesCache = [];
  29689. };
  29690. /**
  29691. * Force the entire cache to be cleared
  29692. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29693. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29694. */
  29695. Engine.prototype.wipeCaches = function (bruteForce) {
  29696. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  29697. return;
  29698. }
  29699. this._currentEffect = null;
  29700. this._viewportCached.x = 0;
  29701. this._viewportCached.y = 0;
  29702. this._viewportCached.z = 0;
  29703. this._viewportCached.w = 0;
  29704. if (bruteForce) {
  29705. this.resetTextureCache();
  29706. this._currentProgram = null;
  29707. this._stencilState.reset();
  29708. this._depthCullingState.reset();
  29709. this.setDepthFunctionToLessOrEqual();
  29710. this._alphaState.reset();
  29711. this._unpackFlipYCached = null;
  29712. }
  29713. this._resetVertexBufferBinding();
  29714. this._cachedIndexBuffer = null;
  29715. this._cachedEffectForVertexBuffers = null;
  29716. this._unbindVertexArrayObject();
  29717. this.bindIndexBuffer(null);
  29718. };
  29719. /**
  29720. * Set the compressed texture format to use, based on the formats you have, and the formats
  29721. * supported by the hardware / browser.
  29722. *
  29723. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29724. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29725. * to API arguments needed to compressed textures. This puts the burden on the container
  29726. * generator to house the arcane code for determining these for current & future formats.
  29727. *
  29728. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29729. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29730. *
  29731. * Note: The result of this call is not taken into account when a texture is base64.
  29732. *
  29733. * @param formatsAvailable defines the list of those format families you have created
  29734. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29735. *
  29736. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29737. * @returns The extension selected.
  29738. */
  29739. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  29740. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  29741. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  29742. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  29743. return this._textureFormatInUse = this._texturesSupported[i];
  29744. }
  29745. }
  29746. }
  29747. // actively set format to nothing, to allow this to be called more than once
  29748. // and possibly fail the 2nd time
  29749. this._textureFormatInUse = null;
  29750. return null;
  29751. };
  29752. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  29753. var gl = this._gl;
  29754. var magFilter = gl.NEAREST;
  29755. var minFilter = gl.NEAREST;
  29756. switch (samplingMode) {
  29757. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  29758. magFilter = gl.LINEAR;
  29759. if (generateMipMaps) {
  29760. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  29761. }
  29762. else {
  29763. minFilter = gl.LINEAR;
  29764. }
  29765. break;
  29766. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  29767. magFilter = gl.LINEAR;
  29768. if (generateMipMaps) {
  29769. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  29770. }
  29771. else {
  29772. minFilter = gl.LINEAR;
  29773. }
  29774. break;
  29775. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  29776. magFilter = gl.NEAREST;
  29777. if (generateMipMaps) {
  29778. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  29779. }
  29780. else {
  29781. minFilter = gl.NEAREST;
  29782. }
  29783. break;
  29784. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  29785. magFilter = gl.NEAREST;
  29786. if (generateMipMaps) {
  29787. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  29788. }
  29789. else {
  29790. minFilter = gl.NEAREST;
  29791. }
  29792. break;
  29793. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  29794. magFilter = gl.NEAREST;
  29795. if (generateMipMaps) {
  29796. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  29797. }
  29798. else {
  29799. minFilter = gl.LINEAR;
  29800. }
  29801. break;
  29802. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  29803. magFilter = gl.NEAREST;
  29804. if (generateMipMaps) {
  29805. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  29806. }
  29807. else {
  29808. minFilter = gl.LINEAR;
  29809. }
  29810. break;
  29811. case Engine.TEXTURE_NEAREST_LINEAR:
  29812. magFilter = gl.NEAREST;
  29813. minFilter = gl.LINEAR;
  29814. break;
  29815. case Engine.TEXTURE_NEAREST_NEAREST:
  29816. magFilter = gl.NEAREST;
  29817. minFilter = gl.NEAREST;
  29818. break;
  29819. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  29820. magFilter = gl.LINEAR;
  29821. if (generateMipMaps) {
  29822. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  29823. }
  29824. else {
  29825. minFilter = gl.NEAREST;
  29826. }
  29827. break;
  29828. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  29829. magFilter = gl.LINEAR;
  29830. if (generateMipMaps) {
  29831. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  29832. }
  29833. else {
  29834. minFilter = gl.NEAREST;
  29835. }
  29836. break;
  29837. case Engine.TEXTURE_LINEAR_LINEAR:
  29838. magFilter = gl.LINEAR;
  29839. minFilter = gl.LINEAR;
  29840. break;
  29841. case Engine.TEXTURE_LINEAR_NEAREST:
  29842. magFilter = gl.LINEAR;
  29843. minFilter = gl.NEAREST;
  29844. break;
  29845. }
  29846. return {
  29847. min: minFilter,
  29848. mag: magFilter
  29849. };
  29850. };
  29851. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  29852. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  29853. var img;
  29854. var onload = function () {
  29855. loadedImages[index] = img;
  29856. loadedImages._internalCount++;
  29857. if (scene) {
  29858. scene._removePendingData(img);
  29859. }
  29860. if (loadedImages._internalCount === 6) {
  29861. onfinish(loadedImages);
  29862. }
  29863. };
  29864. var onerror = function (message, exception) {
  29865. if (scene) {
  29866. scene._removePendingData(img);
  29867. }
  29868. if (onErrorCallBack) {
  29869. onErrorCallBack(message, exception);
  29870. }
  29871. };
  29872. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  29873. if (scene) {
  29874. scene._addPendingData(img);
  29875. }
  29876. };
  29877. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  29878. if (onError === void 0) { onError = null; }
  29879. var loadedImages = [];
  29880. loadedImages._internalCount = 0;
  29881. for (var index = 0; index < 6; index++) {
  29882. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  29883. }
  29884. };
  29885. /** @hidden */
  29886. Engine.prototype._createTexture = function () {
  29887. var texture = this._gl.createTexture();
  29888. if (!texture) {
  29889. throw new Error("Unable to create texture");
  29890. }
  29891. return texture;
  29892. };
  29893. /**
  29894. * Usually called from Texture.ts.
  29895. * Passed information to create a WebGLTexture
  29896. * @param urlArg defines a value which contains one of the following:
  29897. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29898. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29899. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29901. * @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)
  29902. * @param scene needed for loading to the correct scene
  29903. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29904. * @param onLoad optional callback to be called upon successful completion
  29905. * @param onError optional callback to be called upon failure
  29906. * @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
  29907. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29908. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29909. * @param forcedExtension defines the extension to use to pick the right loader
  29910. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29911. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29912. */
  29913. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  29914. var _this = this;
  29915. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  29916. if (onLoad === void 0) { onLoad = null; }
  29917. if (onError === void 0) { onError = null; }
  29918. if (buffer === void 0) { buffer = null; }
  29919. if (fallback === void 0) { fallback = null; }
  29920. if (format === void 0) { format = null; }
  29921. if (forcedExtension === void 0) { forcedExtension = null; }
  29922. if (excludeLoaders === void 0) { excludeLoaders = []; }
  29923. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  29924. var fromData = url.substr(0, 5) === "data:";
  29925. var fromBlob = url.substr(0, 5) === "blob:";
  29926. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  29927. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  29928. // establish the file extension, if possible
  29929. var lastDot = url.lastIndexOf('.');
  29930. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  29931. var loader = null;
  29932. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  29933. var availableLoader = _a[_i];
  29934. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  29935. loader = availableLoader;
  29936. break;
  29937. }
  29938. }
  29939. if (loader) {
  29940. url = loader.transformUrl(url, this._textureFormatInUse);
  29941. }
  29942. if (scene) {
  29943. scene._addPendingData(texture);
  29944. }
  29945. texture.url = url;
  29946. texture.generateMipMaps = !noMipmap;
  29947. texture.samplingMode = samplingMode;
  29948. texture.invertY = invertY;
  29949. if (!this._doNotHandleContextLost) {
  29950. // Keep a link to the buffer only if we plan to handle context lost
  29951. texture._buffer = buffer;
  29952. }
  29953. var onLoadObserver = null;
  29954. if (onLoad && !fallback) {
  29955. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  29956. }
  29957. if (!fallback) {
  29958. this._internalTexturesCache.push(texture);
  29959. }
  29960. var onInternalError = function (message, exception) {
  29961. if (scene) {
  29962. scene._removePendingData(texture);
  29963. }
  29964. var customFallback = false;
  29965. if (loader) {
  29966. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  29967. if (fallbackUrl) {
  29968. // Add Back
  29969. customFallback = true;
  29970. excludeLoaders.push(loader);
  29971. _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");
  29972. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  29973. }
  29974. }
  29975. if (!customFallback) {
  29976. if (onLoadObserver) {
  29977. texture.onLoadedObservable.remove(onLoadObserver);
  29978. }
  29979. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  29980. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  29981. }
  29982. }
  29983. if (onError) {
  29984. onError(message || "Unknown error", exception);
  29985. }
  29986. };
  29987. // processing for non-image formats
  29988. if (loader) {
  29989. var callback = function (data) {
  29990. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  29991. if (loadFailed) {
  29992. onInternalError("TextureLoader failed to load data");
  29993. }
  29994. else {
  29995. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  29996. done();
  29997. return false;
  29998. }, samplingMode);
  29999. }
  30000. });
  30001. };
  30002. if (!buffer) {
  30003. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30004. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30005. });
  30006. }
  30007. else {
  30008. callback(buffer);
  30009. }
  30010. }
  30011. else {
  30012. var onload = function (img) {
  30013. if (fromBlob && !_this._doNotHandleContextLost) {
  30014. // We need to store the image if we need to rebuild the texture
  30015. // in case of a webgl context lost
  30016. texture._buffer = img;
  30017. }
  30018. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30019. var gl = _this._gl;
  30020. var isPot = (img.width === potWidth && img.height === potHeight);
  30021. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30022. if (isPot) {
  30023. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30024. return false;
  30025. }
  30026. var maxTextureSize = _this._caps.maxTextureSize;
  30027. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30028. _this._prepareWorkingCanvas();
  30029. if (!_this._workingCanvas || !_this._workingContext) {
  30030. return false;
  30031. }
  30032. _this._workingCanvas.width = potWidth;
  30033. _this._workingCanvas.height = potHeight;
  30034. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30035. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30036. texture.width = potWidth;
  30037. texture.height = potHeight;
  30038. return false;
  30039. }
  30040. else {
  30041. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30042. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30043. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30044. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30045. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30046. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30047. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30048. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30049. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30050. _this._releaseTexture(source_1);
  30051. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30052. continuationCallback();
  30053. });
  30054. }
  30055. return true;
  30056. }, samplingMode);
  30057. };
  30058. if (!fromData || isBase64) {
  30059. if (buffer instanceof HTMLImageElement) {
  30060. onload(buffer);
  30061. }
  30062. else {
  30063. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30064. }
  30065. }
  30066. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30067. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30068. }
  30069. else {
  30070. onload(buffer);
  30071. }
  30072. }
  30073. return texture;
  30074. };
  30075. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30076. var _this = this;
  30077. var rtt = this.createRenderTargetTexture({
  30078. width: destination.width,
  30079. height: destination.height,
  30080. }, {
  30081. generateMipMaps: false,
  30082. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30083. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30084. generateDepthBuffer: false,
  30085. generateStencilBuffer: false
  30086. });
  30087. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  30088. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  30089. }
  30090. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  30091. _this._rescalePostProcess.onApply = function (effect) {
  30092. effect._bindTexture("textureSampler", source);
  30093. };
  30094. var hostingScene = scene;
  30095. if (!hostingScene) {
  30096. hostingScene = _this.scenes[_this.scenes.length - 1];
  30097. }
  30098. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  30099. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  30100. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  30101. _this.unBindFramebuffer(rtt);
  30102. _this._releaseTexture(rtt);
  30103. if (onComplete) {
  30104. onComplete();
  30105. }
  30106. });
  30107. };
  30108. /**
  30109. * Update a raw texture
  30110. * @param texture defines the texture to update
  30111. * @param data defines the data to store in the texture
  30112. * @param format defines the format of the data
  30113. * @param invertY defines if data must be stored with Y axis inverted
  30114. * @param compression defines the compression used (null by default)
  30115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30116. */
  30117. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  30118. if (compression === void 0) { compression = null; }
  30119. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30120. if (!texture) {
  30121. return;
  30122. }
  30123. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  30124. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  30125. // babylon's internalFormat but gl's texImage2D format
  30126. var internalFormat = this._getInternalFormat(format);
  30127. var textureType = this._getWebGLTextureType(type);
  30128. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30129. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  30130. if (!this._doNotHandleContextLost) {
  30131. texture._bufferView = data;
  30132. texture.format = format;
  30133. texture.type = type;
  30134. texture.invertY = invertY;
  30135. texture._compression = compression;
  30136. }
  30137. if (texture.width % 4 !== 0) {
  30138. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  30139. }
  30140. if (compression && data) {
  30141. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  30142. }
  30143. else {
  30144. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  30145. }
  30146. if (texture.generateMipMaps) {
  30147. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30148. }
  30149. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30150. // this.resetTextureCache();
  30151. texture.isReady = true;
  30152. };
  30153. /**
  30154. * Creates a raw texture
  30155. * @param data defines the data to store in the texture
  30156. * @param width defines the width of the texture
  30157. * @param height defines the height of the texture
  30158. * @param format defines the format of the data
  30159. * @param generateMipMaps defines if the engine should generate the mip levels
  30160. * @param invertY defines if data must be stored with Y axis inverted
  30161. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30162. * @param compression defines the compression used (null by default)
  30163. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30164. * @returns the raw texture inside an InternalTexture
  30165. */
  30166. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  30167. if (compression === void 0) { compression = null; }
  30168. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30169. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  30170. texture.baseWidth = width;
  30171. texture.baseHeight = height;
  30172. texture.width = width;
  30173. texture.height = height;
  30174. texture.format = format;
  30175. texture.generateMipMaps = generateMipMaps;
  30176. texture.samplingMode = samplingMode;
  30177. texture.invertY = invertY;
  30178. texture._compression = compression;
  30179. texture.type = type;
  30180. if (!this._doNotHandleContextLost) {
  30181. texture._bufferView = data;
  30182. }
  30183. this.updateRawTexture(texture, data, format, invertY, compression, type);
  30184. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30185. // Filters
  30186. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30187. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  30188. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30189. if (generateMipMaps) {
  30190. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30191. }
  30192. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30193. this._internalTexturesCache.push(texture);
  30194. return texture;
  30195. };
  30196. /** @hidden */
  30197. Engine.prototype._unpackFlipY = function (value) {
  30198. if (this._unpackFlipYCached !== value) {
  30199. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  30200. if (this.enableUnpackFlipYCached) {
  30201. this._unpackFlipYCached = value;
  30202. }
  30203. }
  30204. };
  30205. /** @hidden */
  30206. Engine.prototype._getUnpackAlignement = function () {
  30207. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  30208. };
  30209. /**
  30210. * Creates a dynamic texture
  30211. * @param width defines the width of the texture
  30212. * @param height defines the height of the texture
  30213. * @param generateMipMaps defines if the engine should generate the mip levels
  30214. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30215. * @returns the dynamic texture inside an InternalTexture
  30216. */
  30217. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  30218. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  30219. texture.baseWidth = width;
  30220. texture.baseHeight = height;
  30221. if (generateMipMaps) {
  30222. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  30223. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  30224. }
  30225. // this.resetTextureCache();
  30226. texture.width = width;
  30227. texture.height = height;
  30228. texture.isReady = false;
  30229. texture.generateMipMaps = generateMipMaps;
  30230. texture.samplingMode = samplingMode;
  30231. this.updateTextureSamplingMode(samplingMode, texture);
  30232. this._internalTexturesCache.push(texture);
  30233. return texture;
  30234. };
  30235. /**
  30236. * Update the sampling mode of a given texture
  30237. * @param samplingMode defines the required sampling mode
  30238. * @param texture defines the texture to update
  30239. */
  30240. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  30241. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  30242. if (texture.isCube) {
  30243. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30244. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30245. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30246. }
  30247. else if (texture.is3D) {
  30248. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30249. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30250. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  30251. }
  30252. else {
  30253. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30254. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30255. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30256. }
  30257. texture.samplingMode = samplingMode;
  30258. };
  30259. /**
  30260. * Update the content of a dynamic texture
  30261. * @param texture defines the texture to update
  30262. * @param canvas defines the canvas containing the source
  30263. * @param invertY defines if data must be stored with Y axis inverted
  30264. * @param premulAlpha defines if alpha is stored as premultiplied
  30265. * @param format defines the format of the data
  30266. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30267. */
  30268. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  30269. if (premulAlpha === void 0) { premulAlpha = false; }
  30270. if (forceBindTexture === void 0) { forceBindTexture = false; }
  30271. if (!texture) {
  30272. return;
  30273. }
  30274. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  30275. this._unpackFlipY(invertY);
  30276. if (premulAlpha) {
  30277. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  30278. }
  30279. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  30280. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  30281. if (texture.generateMipMaps) {
  30282. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30283. }
  30284. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30285. if (premulAlpha) {
  30286. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  30287. }
  30288. texture.isReady = true;
  30289. };
  30290. /**
  30291. * Update a video texture
  30292. * @param texture defines the texture to update
  30293. * @param video defines the video element to use
  30294. * @param invertY defines if data must be stored with Y axis inverted
  30295. */
  30296. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  30297. if (!texture || texture._isDisabled) {
  30298. return;
  30299. }
  30300. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30301. this._unpackFlipY(!invertY); // Video are upside down by default
  30302. try {
  30303. // Testing video texture support
  30304. if (this._videoTextureSupported === undefined) {
  30305. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30306. if (this._gl.getError() !== 0) {
  30307. this._videoTextureSupported = false;
  30308. }
  30309. else {
  30310. this._videoTextureSupported = true;
  30311. }
  30312. }
  30313. // Copy video through the current working canvas if video texture is not supported
  30314. if (!this._videoTextureSupported) {
  30315. if (!texture._workingCanvas) {
  30316. texture._workingCanvas = document.createElement("canvas");
  30317. var context = texture._workingCanvas.getContext("2d");
  30318. if (!context) {
  30319. throw new Error("Unable to get 2d context");
  30320. }
  30321. texture._workingContext = context;
  30322. texture._workingCanvas.width = texture.width;
  30323. texture._workingCanvas.height = texture.height;
  30324. }
  30325. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  30326. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  30327. }
  30328. else {
  30329. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30330. }
  30331. if (texture.generateMipMaps) {
  30332. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30333. }
  30334. if (!wasPreviouslyBound) {
  30335. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30336. }
  30337. // this.resetTextureCache();
  30338. texture.isReady = true;
  30339. }
  30340. catch (ex) {
  30341. // Something unexpected
  30342. // Let's disable the texture
  30343. texture._isDisabled = true;
  30344. }
  30345. };
  30346. /**
  30347. * Updates a depth texture Comparison Mode and Function.
  30348. * If the comparison Function is equal to 0, the mode will be set to none.
  30349. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30350. * @param texture The texture to set the comparison function for
  30351. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30352. */
  30353. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  30354. if (this.webGLVersion === 1) {
  30355. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  30356. return;
  30357. }
  30358. var gl = this._gl;
  30359. if (texture.isCube) {
  30360. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  30361. if (comparisonFunction === 0) {
  30362. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30363. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30364. }
  30365. else {
  30366. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30367. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30368. }
  30369. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30370. }
  30371. else {
  30372. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30373. if (comparisonFunction === 0) {
  30374. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30375. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30376. }
  30377. else {
  30378. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30379. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30380. }
  30381. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30382. }
  30383. texture._comparisonFunction = comparisonFunction;
  30384. };
  30385. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  30386. var width = size.width || size;
  30387. var height = size.height || size;
  30388. internalTexture.baseWidth = width;
  30389. internalTexture.baseHeight = height;
  30390. internalTexture.width = width;
  30391. internalTexture.height = height;
  30392. internalTexture.isReady = true;
  30393. internalTexture.samples = 1;
  30394. internalTexture.generateMipMaps = false;
  30395. internalTexture._generateDepthBuffer = true;
  30396. internalTexture._generateStencilBuffer = generateStencil;
  30397. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30398. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30399. internalTexture._comparisonFunction = comparisonFunction;
  30400. var gl = this._gl;
  30401. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  30402. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  30403. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  30404. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  30405. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30406. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30407. if (comparisonFunction === 0) {
  30408. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30409. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30410. }
  30411. else {
  30412. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30413. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30414. }
  30415. };
  30416. /**
  30417. * Creates a depth stencil texture.
  30418. * This is only available in WebGL 2 or with the depth texture extension available.
  30419. * @param size The size of face edge in the texture.
  30420. * @param options The options defining the texture.
  30421. * @returns The texture
  30422. */
  30423. Engine.prototype.createDepthStencilTexture = function (size, options) {
  30424. if (options.isCube) {
  30425. var width = size.width || size;
  30426. return this._createDepthStencilCubeTexture(width, options);
  30427. }
  30428. else {
  30429. return this._createDepthStencilTexture(size, options);
  30430. }
  30431. };
  30432. /**
  30433. * Creates a depth stencil texture.
  30434. * This is only available in WebGL 2 or with the depth texture extension available.
  30435. * @param size The size of face edge in the texture.
  30436. * @param options The options defining the texture.
  30437. * @returns The texture
  30438. */
  30439. Engine.prototype._createDepthStencilTexture = function (size, options) {
  30440. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  30441. if (!this._caps.depthTextureExtension) {
  30442. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  30443. return internalTexture;
  30444. }
  30445. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30446. var gl = this._gl;
  30447. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  30448. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30449. if (this.webGLVersion > 1) {
  30450. if (internalOptions.generateStencil) {
  30451. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30452. }
  30453. else {
  30454. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30455. }
  30456. }
  30457. else {
  30458. if (internalOptions.generateStencil) {
  30459. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30460. }
  30461. else {
  30462. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30463. }
  30464. }
  30465. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30466. return internalTexture;
  30467. };
  30468. /**
  30469. * Creates a depth stencil cube texture.
  30470. * This is only available in WebGL 2.
  30471. * @param size The size of face edge in the cube texture.
  30472. * @param options The options defining the cube texture.
  30473. * @returns The cube texture
  30474. */
  30475. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  30476. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  30477. internalTexture.isCube = true;
  30478. if (this.webGLVersion === 1) {
  30479. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  30480. return internalTexture;
  30481. }
  30482. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30483. var gl = this._gl;
  30484. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  30485. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30486. // Create the depth/stencil buffer
  30487. for (var face = 0; face < 6; face++) {
  30488. if (internalOptions.generateStencil) {
  30489. 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);
  30490. }
  30491. else {
  30492. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30493. }
  30494. }
  30495. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30496. return internalTexture;
  30497. };
  30498. /**
  30499. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30500. * @param renderTarget The render target to set the frame buffer for
  30501. */
  30502. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  30503. // Create the framebuffer
  30504. var internalTexture = renderTarget.getInternalTexture();
  30505. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  30506. return;
  30507. }
  30508. var gl = this._gl;
  30509. var depthStencilTexture = renderTarget.depthStencilTexture;
  30510. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  30511. if (depthStencilTexture.isCube) {
  30512. if (depthStencilTexture._generateStencilBuffer) {
  30513. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30514. }
  30515. else {
  30516. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30517. }
  30518. }
  30519. else {
  30520. if (depthStencilTexture._generateStencilBuffer) {
  30521. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30522. }
  30523. else {
  30524. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30525. }
  30526. }
  30527. this.bindUnboundFramebuffer(null);
  30528. };
  30529. /**
  30530. * Creates a new render target texture
  30531. * @param size defines the size of the texture
  30532. * @param options defines the options used to create the texture
  30533. * @returns a new render target texture stored in an InternalTexture
  30534. */
  30535. Engine.prototype.createRenderTargetTexture = function (size, options) {
  30536. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  30537. if (options !== undefined && typeof options === "object") {
  30538. fullOptions.generateMipMaps = options.generateMipMaps;
  30539. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30540. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  30541. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  30542. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  30543. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  30544. }
  30545. else {
  30546. fullOptions.generateMipMaps = options;
  30547. fullOptions.generateDepthBuffer = true;
  30548. fullOptions.generateStencilBuffer = false;
  30549. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30550. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30551. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  30552. }
  30553. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30554. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30555. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30556. }
  30557. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30558. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30559. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30560. }
  30561. var gl = this._gl;
  30562. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  30563. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30564. var width = size.width || size;
  30565. var height = size.height || size;
  30566. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  30567. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30568. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30569. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30570. }
  30571. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30572. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30573. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30574. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30575. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  30576. // Create the framebuffer
  30577. var currentFrameBuffer = this._currentFramebuffer;
  30578. var framebuffer = gl.createFramebuffer();
  30579. this.bindUnboundFramebuffer(framebuffer);
  30580. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30581. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  30582. if (fullOptions.generateMipMaps) {
  30583. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30584. }
  30585. // Unbind
  30586. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30587. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30588. this.bindUnboundFramebuffer(currentFrameBuffer);
  30589. texture._framebuffer = framebuffer;
  30590. texture.baseWidth = width;
  30591. texture.baseHeight = height;
  30592. texture.width = width;
  30593. texture.height = height;
  30594. texture.isReady = true;
  30595. texture.samples = 1;
  30596. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  30597. texture.samplingMode = fullOptions.samplingMode;
  30598. texture.type = fullOptions.type;
  30599. texture.format = fullOptions.format;
  30600. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  30601. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  30602. // this.resetTextureCache();
  30603. this._internalTexturesCache.push(texture);
  30604. return texture;
  30605. };
  30606. /**
  30607. * Create a multi render target texture
  30608. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  30609. * @param size defines the size of the texture
  30610. * @param options defines the creation options
  30611. * @returns the cube texture as an InternalTexture
  30612. */
  30613. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  30614. var generateMipMaps = false;
  30615. var generateDepthBuffer = true;
  30616. var generateStencilBuffer = false;
  30617. var generateDepthTexture = false;
  30618. var textureCount = 1;
  30619. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  30620. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30621. var types = new Array();
  30622. var samplingModes = new Array();
  30623. if (options !== undefined) {
  30624. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  30625. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30626. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  30627. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  30628. textureCount = options.textureCount || 1;
  30629. if (options.types) {
  30630. types = options.types;
  30631. }
  30632. if (options.samplingModes) {
  30633. samplingModes = options.samplingModes;
  30634. }
  30635. }
  30636. var gl = this._gl;
  30637. // Create the framebuffer
  30638. var framebuffer = gl.createFramebuffer();
  30639. this.bindUnboundFramebuffer(framebuffer);
  30640. var width = size.width || size;
  30641. var height = size.height || size;
  30642. var textures = [];
  30643. var attachments = [];
  30644. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  30645. for (var i = 0; i < textureCount; i++) {
  30646. var samplingMode = samplingModes[i] || defaultSamplingMode;
  30647. var type = types[i] || defaultType;
  30648. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30649. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30650. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30651. }
  30652. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30653. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30654. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30655. }
  30656. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30657. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30658. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30659. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30660. }
  30661. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30662. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30663. textures.push(texture);
  30664. attachments.push(attachment);
  30665. gl.activeTexture(gl["TEXTURE" + i]);
  30666. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  30667. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30668. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30669. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30670. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30671. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  30672. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30673. if (generateMipMaps) {
  30674. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30675. }
  30676. // Unbind
  30677. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30678. texture._framebuffer = framebuffer;
  30679. texture._depthStencilBuffer = depthStencilBuffer;
  30680. texture.baseWidth = width;
  30681. texture.baseHeight = height;
  30682. texture.width = width;
  30683. texture.height = height;
  30684. texture.isReady = true;
  30685. texture.samples = 1;
  30686. texture.generateMipMaps = generateMipMaps;
  30687. texture.samplingMode = samplingMode;
  30688. texture.type = type;
  30689. texture._generateDepthBuffer = generateDepthBuffer;
  30690. texture._generateStencilBuffer = generateStencilBuffer;
  30691. texture._attachments = attachments;
  30692. this._internalTexturesCache.push(texture);
  30693. }
  30694. if (generateDepthTexture && this._caps.depthTextureExtension) {
  30695. // Depth texture
  30696. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30697. gl.activeTexture(gl.TEXTURE0);
  30698. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  30699. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  30700. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  30701. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30702. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30703. 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);
  30704. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  30705. depthTexture._framebuffer = framebuffer;
  30706. depthTexture.baseWidth = width;
  30707. depthTexture.baseHeight = height;
  30708. depthTexture.width = width;
  30709. depthTexture.height = height;
  30710. depthTexture.isReady = true;
  30711. depthTexture.samples = 1;
  30712. depthTexture.generateMipMaps = generateMipMaps;
  30713. depthTexture.samplingMode = gl.NEAREST;
  30714. depthTexture._generateDepthBuffer = generateDepthBuffer;
  30715. depthTexture._generateStencilBuffer = generateStencilBuffer;
  30716. textures.push(depthTexture);
  30717. this._internalTexturesCache.push(depthTexture);
  30718. }
  30719. gl.drawBuffers(attachments);
  30720. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30721. this.bindUnboundFramebuffer(null);
  30722. this.resetTextureCache();
  30723. return textures;
  30724. };
  30725. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  30726. if (samples === void 0) { samples = 1; }
  30727. var depthStencilBuffer = null;
  30728. var gl = this._gl;
  30729. // Create the depth/stencil buffer
  30730. if (generateStencilBuffer) {
  30731. depthStencilBuffer = gl.createRenderbuffer();
  30732. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30733. if (samples > 1) {
  30734. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  30735. }
  30736. else {
  30737. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  30738. }
  30739. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  30740. }
  30741. else if (generateDepthBuffer) {
  30742. depthStencilBuffer = gl.createRenderbuffer();
  30743. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30744. if (samples > 1) {
  30745. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  30746. }
  30747. else {
  30748. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  30749. }
  30750. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  30751. }
  30752. return depthStencilBuffer;
  30753. };
  30754. /**
  30755. * Updates the sample count of a render target texture
  30756. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30757. * @param texture defines the texture to update
  30758. * @param samples defines the sample count to set
  30759. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30760. */
  30761. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  30762. if (this.webGLVersion < 2 || !texture) {
  30763. return 1;
  30764. }
  30765. if (texture.samples === samples) {
  30766. return samples;
  30767. }
  30768. var gl = this._gl;
  30769. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  30770. // Dispose previous render buffers
  30771. if (texture._depthStencilBuffer) {
  30772. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  30773. texture._depthStencilBuffer = null;
  30774. }
  30775. if (texture._MSAAFramebuffer) {
  30776. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  30777. texture._MSAAFramebuffer = null;
  30778. }
  30779. if (texture._MSAARenderBuffer) {
  30780. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  30781. texture._MSAARenderBuffer = null;
  30782. }
  30783. if (samples > 1) {
  30784. var framebuffer = gl.createFramebuffer();
  30785. if (!framebuffer) {
  30786. throw new Error("Unable to create multi sampled framebuffer");
  30787. }
  30788. texture._MSAAFramebuffer = framebuffer;
  30789. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  30790. var colorRenderbuffer = gl.createRenderbuffer();
  30791. if (!colorRenderbuffer) {
  30792. throw new Error("Unable to create multi sampled framebuffer");
  30793. }
  30794. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  30795. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  30796. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  30797. texture._MSAARenderBuffer = colorRenderbuffer;
  30798. }
  30799. else {
  30800. this.bindUnboundFramebuffer(texture._framebuffer);
  30801. }
  30802. texture.samples = samples;
  30803. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  30804. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30805. this.bindUnboundFramebuffer(null);
  30806. return samples;
  30807. };
  30808. /**
  30809. * Update the sample count for a given multiple render target texture
  30810. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30811. * @param textures defines the textures to update
  30812. * @param samples defines the sample count to set
  30813. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30814. */
  30815. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  30816. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  30817. return 1;
  30818. }
  30819. if (textures[0].samples === samples) {
  30820. return samples;
  30821. }
  30822. var gl = this._gl;
  30823. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  30824. // Dispose previous render buffers
  30825. if (textures[0]._depthStencilBuffer) {
  30826. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  30827. textures[0]._depthStencilBuffer = null;
  30828. }
  30829. if (textures[0]._MSAAFramebuffer) {
  30830. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  30831. textures[0]._MSAAFramebuffer = null;
  30832. }
  30833. for (var i = 0; i < textures.length; i++) {
  30834. if (textures[i]._MSAARenderBuffer) {
  30835. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  30836. textures[i]._MSAARenderBuffer = null;
  30837. }
  30838. }
  30839. if (samples > 1) {
  30840. var framebuffer = gl.createFramebuffer();
  30841. if (!framebuffer) {
  30842. throw new Error("Unable to create multi sampled framebuffer");
  30843. }
  30844. this.bindUnboundFramebuffer(framebuffer);
  30845. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  30846. var attachments = [];
  30847. for (var i = 0; i < textures.length; i++) {
  30848. var texture = textures[i];
  30849. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30850. var colorRenderbuffer = gl.createRenderbuffer();
  30851. if (!colorRenderbuffer) {
  30852. throw new Error("Unable to create multi sampled framebuffer");
  30853. }
  30854. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  30855. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  30856. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  30857. texture._MSAAFramebuffer = framebuffer;
  30858. texture._MSAARenderBuffer = colorRenderbuffer;
  30859. texture.samples = samples;
  30860. texture._depthStencilBuffer = depthStencilBuffer;
  30861. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30862. attachments.push(attachment);
  30863. }
  30864. gl.drawBuffers(attachments);
  30865. }
  30866. else {
  30867. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30868. }
  30869. this.bindUnboundFramebuffer(null);
  30870. return samples;
  30871. };
  30872. /** @hidden */
  30873. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  30874. if (faceIndex === void 0) { faceIndex = 0; }
  30875. if (lod === void 0) { lod = 0; }
  30876. var gl = this._gl;
  30877. var target = gl.TEXTURE_2D;
  30878. if (texture.isCube) {
  30879. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  30880. }
  30881. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  30882. };
  30883. /** @hidden */
  30884. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  30885. if (faceIndex === void 0) { faceIndex = 0; }
  30886. if (lod === void 0) { lod = 0; }
  30887. var gl = this._gl;
  30888. var textureType = this._getWebGLTextureType(texture.type);
  30889. var format = this._getInternalFormat(texture.format);
  30890. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  30891. this._unpackFlipY(texture.invertY);
  30892. var target = gl.TEXTURE_2D;
  30893. if (texture.isCube) {
  30894. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  30895. }
  30896. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  30897. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  30898. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  30899. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  30900. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  30901. };
  30902. /** @hidden */
  30903. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  30904. if (faceIndex === void 0) { faceIndex = 0; }
  30905. if (lod === void 0) { lod = 0; }
  30906. var gl = this._gl;
  30907. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  30908. this._bindTextureDirectly(bindTarget, texture, true);
  30909. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  30910. this._bindTextureDirectly(bindTarget, null, true);
  30911. };
  30912. /** @hidden */
  30913. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  30914. if (faceIndex === void 0) { faceIndex = 0; }
  30915. if (lod === void 0) { lod = 0; }
  30916. var gl = this._gl;
  30917. var textureType = this._getWebGLTextureType(texture.type);
  30918. var format = this._getInternalFormat(texture.format);
  30919. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  30920. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  30921. this._bindTextureDirectly(bindTarget, texture, true);
  30922. this._unpackFlipY(texture.invertY);
  30923. var target = gl.TEXTURE_2D;
  30924. if (texture.isCube) {
  30925. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  30926. }
  30927. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  30928. this._bindTextureDirectly(bindTarget, null, true);
  30929. };
  30930. /**
  30931. * Creates a new render target cube texture
  30932. * @param size defines the size of the texture
  30933. * @param options defines the options used to create the texture
  30934. * @returns a new render target cube texture stored in an InternalTexture
  30935. */
  30936. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  30937. 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);
  30938. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  30939. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30940. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30941. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30942. }
  30943. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30944. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30945. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30946. }
  30947. var gl = this._gl;
  30948. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  30949. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  30950. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  30951. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30952. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30953. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  30954. }
  30955. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  30956. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  30957. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30958. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30959. for (var face = 0; face < 6; face++) {
  30960. 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);
  30961. }
  30962. // Create the framebuffer
  30963. var framebuffer = gl.createFramebuffer();
  30964. this.bindUnboundFramebuffer(framebuffer);
  30965. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  30966. // MipMaps
  30967. if (fullOptions.generateMipMaps) {
  30968. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  30969. }
  30970. // Unbind
  30971. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30972. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30973. this.bindUnboundFramebuffer(null);
  30974. texture._framebuffer = framebuffer;
  30975. texture.width = size;
  30976. texture.height = size;
  30977. texture.isReady = true;
  30978. texture.isCube = true;
  30979. texture.samples = 1;
  30980. texture.generateMipMaps = fullOptions.generateMipMaps;
  30981. texture.samplingMode = fullOptions.samplingMode;
  30982. texture.type = fullOptions.type;
  30983. texture.format = fullOptions.format;
  30984. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  30985. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  30986. this._internalTexturesCache.push(texture);
  30987. return texture;
  30988. };
  30989. /**
  30990. * Creates a cube texture
  30991. * @param rootUrl defines the url where the files to load is located
  30992. * @param scene defines the current scene
  30993. * @param files defines the list of files to load (1 per face)
  30994. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  30995. * @param onLoad defines an optional callback raised when the texture is loaded
  30996. * @param onError defines an optional callback raised if there is an issue to load the texture
  30997. * @param format defines the format of the data
  30998. * @param forcedExtension defines the extension to use to pick the right loader
  30999. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31000. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31001. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31002. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31003. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31004. * @returns the cube texture as an InternalTexture
  31005. */
  31006. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31007. var _this = this;
  31008. if (onLoad === void 0) { onLoad = null; }
  31009. if (onError === void 0) { onError = null; }
  31010. if (forcedExtension === void 0) { forcedExtension = null; }
  31011. if (createPolynomials === void 0) { createPolynomials = false; }
  31012. if (lodScale === void 0) { lodScale = 0; }
  31013. if (lodOffset === void 0) { lodOffset = 0; }
  31014. if (fallback === void 0) { fallback = null; }
  31015. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31016. var gl = this._gl;
  31017. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31018. texture.isCube = true;
  31019. texture.url = rootUrl;
  31020. texture.generateMipMaps = !noMipmap;
  31021. texture._lodGenerationScale = lodScale;
  31022. texture._lodGenerationOffset = lodOffset;
  31023. if (!this._doNotHandleContextLost) {
  31024. texture._extension = forcedExtension;
  31025. texture._files = files;
  31026. }
  31027. var lastDot = rootUrl.lastIndexOf('.');
  31028. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31029. var loader = null;
  31030. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31031. var availableLoader = _a[_i];
  31032. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31033. loader = availableLoader;
  31034. break;
  31035. }
  31036. }
  31037. var onInternalError = function (request, exception) {
  31038. if (loader) {
  31039. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31040. _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");
  31041. if (fallbackUrl) {
  31042. excludeLoaders.push(loader);
  31043. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31044. return;
  31045. }
  31046. }
  31047. if (onError && request) {
  31048. onError(request.status + " " + request.statusText, exception);
  31049. }
  31050. };
  31051. if (loader) {
  31052. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31053. var onloaddata = function (data) {
  31054. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31055. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31056. };
  31057. if (files && files.length === 6) {
  31058. if (loader.supportCascades) {
  31059. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31060. }
  31061. else if (onError) {
  31062. onError("Textures type does not support cascades.");
  31063. }
  31064. }
  31065. else {
  31066. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31067. }
  31068. }
  31069. else {
  31070. if (!files) {
  31071. throw new Error("Cannot load cubemap because files were not defined");
  31072. }
  31073. this._cascadeLoadImgs(scene, function (imgs) {
  31074. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31075. var height = width;
  31076. _this._prepareWorkingCanvas();
  31077. if (!_this._workingCanvas || !_this._workingContext) {
  31078. return;
  31079. }
  31080. _this._workingCanvas.width = width;
  31081. _this._workingCanvas.height = height;
  31082. var faces = [
  31083. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31084. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31085. ];
  31086. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31087. _this._unpackFlipY(false);
  31088. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  31089. for (var index = 0; index < faces.length; index++) {
  31090. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  31091. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31092. }
  31093. if (!noMipmap) {
  31094. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31095. }
  31096. _this._setCubeMapTextureParams(!noMipmap);
  31097. texture.width = width;
  31098. texture.height = height;
  31099. texture.isReady = true;
  31100. if (format) {
  31101. texture.format = format;
  31102. }
  31103. texture.onLoadedObservable.notifyObservers(texture);
  31104. texture.onLoadedObservable.clear();
  31105. if (onLoad) {
  31106. onLoad();
  31107. }
  31108. }, files, onError);
  31109. }
  31110. this._internalTexturesCache.push(texture);
  31111. return texture;
  31112. };
  31113. /**
  31114. * @hidden
  31115. */
  31116. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  31117. var gl = this._gl;
  31118. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31119. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  31120. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31121. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31122. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31123. // this.resetTextureCache();
  31124. };
  31125. /**
  31126. * Update a raw cube texture
  31127. * @param texture defines the texture to udpdate
  31128. * @param data defines the data to store
  31129. * @param format defines the data format
  31130. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31131. * @param invertY defines if data must be stored with Y axis inverted
  31132. * @param compression defines the compression used (null by default)
  31133. * @param level defines which level of the texture to update
  31134. */
  31135. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  31136. if (compression === void 0) { compression = null; }
  31137. if (level === void 0) { level = 0; }
  31138. texture._bufferViewArray = data;
  31139. texture.format = format;
  31140. texture.type = type;
  31141. texture.invertY = invertY;
  31142. texture._compression = compression;
  31143. var gl = this._gl;
  31144. var textureType = this._getWebGLTextureType(type);
  31145. var internalFormat = this._getInternalFormat(format);
  31146. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  31147. var needConversion = false;
  31148. if (internalFormat === gl.RGB) {
  31149. internalFormat = gl.RGBA;
  31150. needConversion = true;
  31151. }
  31152. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31153. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31154. if (texture.width % 4 !== 0) {
  31155. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  31156. }
  31157. // Data are known to be in +X +Y +Z -X -Y -Z
  31158. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31159. var faceData = data[faceIndex];
  31160. if (compression) {
  31161. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  31162. }
  31163. else {
  31164. if (needConversion) {
  31165. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  31166. }
  31167. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  31168. }
  31169. }
  31170. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31171. if (isPot && texture.generateMipMaps && level === 0) {
  31172. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31173. }
  31174. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31175. // this.resetTextureCache();
  31176. texture.isReady = true;
  31177. };
  31178. /**
  31179. * Creates a new raw cube texture
  31180. * @param data defines the array of data to use to create each face
  31181. * @param size defines the size of the textures
  31182. * @param format defines the format of the data
  31183. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31184. * @param generateMipMaps defines if the engine should generate the mip levels
  31185. * @param invertY defines if data must be stored with Y axis inverted
  31186. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31187. * @param compression defines the compression used (null by default)
  31188. * @returns the cube texture as an InternalTexture
  31189. */
  31190. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  31191. if (compression === void 0) { compression = null; }
  31192. var gl = this._gl;
  31193. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  31194. texture.isCube = true;
  31195. texture.format = format;
  31196. texture.type = type;
  31197. if (!this._doNotHandleContextLost) {
  31198. texture._bufferViewArray = data;
  31199. }
  31200. var textureType = this._getWebGLTextureType(type);
  31201. var internalFormat = this._getInternalFormat(format);
  31202. if (internalFormat === gl.RGB) {
  31203. internalFormat = gl.RGBA;
  31204. }
  31205. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  31206. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  31207. generateMipMaps = false;
  31208. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31209. _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.");
  31210. }
  31211. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  31212. generateMipMaps = false;
  31213. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31214. _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.");
  31215. }
  31216. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  31217. generateMipMaps = false;
  31218. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  31219. }
  31220. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  31221. generateMipMaps = false;
  31222. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  31223. }
  31224. var width = size;
  31225. var height = width;
  31226. texture.width = width;
  31227. texture.height = height;
  31228. // Double check on POT to generate Mips.
  31229. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31230. if (!isPot) {
  31231. generateMipMaps = false;
  31232. }
  31233. // Upload data if needed. The texture won't be ready until then.
  31234. if (data) {
  31235. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  31236. }
  31237. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31238. // Filters
  31239. if (data && generateMipMaps) {
  31240. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31241. }
  31242. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31243. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31244. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31245. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31246. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31247. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31248. texture.generateMipMaps = generateMipMaps;
  31249. return texture;
  31250. };
  31251. /**
  31252. * Creates a new raw cube texture from a specified url
  31253. * @param url defines the url where the data is located
  31254. * @param scene defines the current scene
  31255. * @param size defines the size of the textures
  31256. * @param format defines the format of the data
  31257. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31258. * @param noMipmap defines if the engine should avoid generating the mip levels
  31259. * @param callback defines a callback used to extract texture data from loaded data
  31260. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  31261. * @param onLoad defines a callback called when texture is loaded
  31262. * @param onError defines a callback called if there is an error
  31263. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31264. * @param invertY defines if data must be stored with Y axis inverted
  31265. * @returns the cube texture as an InternalTexture
  31266. */
  31267. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  31268. var _this = this;
  31269. if (onLoad === void 0) { onLoad = null; }
  31270. if (onError === void 0) { onError = null; }
  31271. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31272. if (invertY === void 0) { invertY = false; }
  31273. var gl = this._gl;
  31274. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  31275. scene._addPendingData(texture);
  31276. texture.url = url;
  31277. this._internalTexturesCache.push(texture);
  31278. var onerror = function (request, exception) {
  31279. scene._removePendingData(texture);
  31280. if (onError && request) {
  31281. onError(request.status + " " + request.statusText, exception);
  31282. }
  31283. };
  31284. var internalCallback = function (data) {
  31285. var width = texture.width;
  31286. var faceDataArrays = callback(data);
  31287. if (!faceDataArrays) {
  31288. return;
  31289. }
  31290. if (mipmapGenerator) {
  31291. var textureType = _this._getWebGLTextureType(type);
  31292. var internalFormat = _this._getInternalFormat(format);
  31293. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  31294. var needConversion = false;
  31295. if (internalFormat === gl.RGB) {
  31296. internalFormat = gl.RGBA;
  31297. needConversion = true;
  31298. }
  31299. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31300. _this._unpackFlipY(false);
  31301. var mipData = mipmapGenerator(faceDataArrays);
  31302. for (var level = 0; level < mipData.length; level++) {
  31303. var mipSize = width >> level;
  31304. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31305. var mipFaceData = mipData[level][faceIndex];
  31306. if (needConversion) {
  31307. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  31308. }
  31309. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  31310. }
  31311. }
  31312. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31313. }
  31314. else {
  31315. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  31316. }
  31317. texture.isReady = true;
  31318. // this.resetTextureCache();
  31319. scene._removePendingData(texture);
  31320. if (onLoad) {
  31321. onLoad();
  31322. }
  31323. };
  31324. this._loadFile(url, function (data) {
  31325. internalCallback(data);
  31326. }, undefined, scene.offlineProvider, true, onerror);
  31327. return texture;
  31328. };
  31329. /**
  31330. * Update a raw 3D texture
  31331. * @param texture defines the texture to update
  31332. * @param data defines the data to store
  31333. * @param format defines the data format
  31334. * @param invertY defines if data must be stored with Y axis inverted
  31335. * @param compression defines the used compression (can be null)
  31336. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31337. */
  31338. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  31339. if (compression === void 0) { compression = null; }
  31340. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31341. var internalType = this._getWebGLTextureType(textureType);
  31342. var internalFormat = this._getInternalFormat(format);
  31343. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  31344. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31345. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31346. if (!this._doNotHandleContextLost) {
  31347. texture._bufferView = data;
  31348. texture.format = format;
  31349. texture.invertY = invertY;
  31350. texture._compression = compression;
  31351. }
  31352. if (texture.width % 4 !== 0) {
  31353. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31354. }
  31355. if (compression && data) {
  31356. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  31357. }
  31358. else {
  31359. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  31360. }
  31361. if (texture.generateMipMaps) {
  31362. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31363. }
  31364. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31365. // this.resetTextureCache();
  31366. texture.isReady = true;
  31367. };
  31368. /**
  31369. * Creates a new raw 3D texture
  31370. * @param data defines the data used to create the texture
  31371. * @param width defines the width of the texture
  31372. * @param height defines the height of the texture
  31373. * @param depth defines the depth of the texture
  31374. * @param format defines the format of the texture
  31375. * @param generateMipMaps defines if the engine must generate mip levels
  31376. * @param invertY defines if data must be stored with Y axis inverted
  31377. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31378. * @param compression defines the compressed used (can be null)
  31379. * @param textureType defines the compressed used (can be null)
  31380. * @returns a new raw 3D texture (stored in an InternalTexture)
  31381. */
  31382. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  31383. if (compression === void 0) { compression = null; }
  31384. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31385. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  31386. texture.baseWidth = width;
  31387. texture.baseHeight = height;
  31388. texture.baseDepth = depth;
  31389. texture.width = width;
  31390. texture.height = height;
  31391. texture.depth = depth;
  31392. texture.format = format;
  31393. texture.type = textureType;
  31394. texture.generateMipMaps = generateMipMaps;
  31395. texture.samplingMode = samplingMode;
  31396. texture.is3D = true;
  31397. if (!this._doNotHandleContextLost) {
  31398. texture._bufferView = data;
  31399. }
  31400. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  31401. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31402. // Filters
  31403. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31404. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31405. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31406. if (generateMipMaps) {
  31407. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31408. }
  31409. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31410. this._internalTexturesCache.push(texture);
  31411. return texture;
  31412. };
  31413. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  31414. var gl = this._gl;
  31415. if (!gl) {
  31416. return;
  31417. }
  31418. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  31419. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31420. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31421. if (!noMipmap && !isCompressed) {
  31422. gl.generateMipmap(gl.TEXTURE_2D);
  31423. }
  31424. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31425. // this.resetTextureCache();
  31426. if (scene) {
  31427. scene._removePendingData(texture);
  31428. }
  31429. texture.onLoadedObservable.notifyObservers(texture);
  31430. texture.onLoadedObservable.clear();
  31431. };
  31432. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  31433. var _this = this;
  31434. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31435. var maxTextureSize = this.getCaps().maxTextureSize;
  31436. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  31437. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  31438. var gl = this._gl;
  31439. if (!gl) {
  31440. return;
  31441. }
  31442. if (!texture._webGLTexture) {
  31443. // this.resetTextureCache();
  31444. if (scene) {
  31445. scene._removePendingData(texture);
  31446. }
  31447. return;
  31448. }
  31449. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31450. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31451. texture.baseWidth = width;
  31452. texture.baseHeight = height;
  31453. texture.width = potWidth;
  31454. texture.height = potHeight;
  31455. texture.isReady = true;
  31456. if (processFunction(potWidth, potHeight, function () {
  31457. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31458. })) {
  31459. // Returning as texture needs extra async steps
  31460. return;
  31461. }
  31462. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31463. };
  31464. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  31465. // Create new RGBA data container.
  31466. var rgbaData;
  31467. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  31468. rgbaData = new Float32Array(width * height * 4);
  31469. }
  31470. else {
  31471. rgbaData = new Uint32Array(width * height * 4);
  31472. }
  31473. // Convert each pixel.
  31474. for (var x = 0; x < width; x++) {
  31475. for (var y = 0; y < height; y++) {
  31476. var index = (y * width + x) * 3;
  31477. var newIndex = (y * width + x) * 4;
  31478. // Map Old Value to new value.
  31479. rgbaData[newIndex + 0] = rgbData[index + 0];
  31480. rgbaData[newIndex + 1] = rgbData[index + 1];
  31481. rgbaData[newIndex + 2] = rgbData[index + 2];
  31482. // Add fully opaque alpha channel.
  31483. rgbaData[newIndex + 3] = 1;
  31484. }
  31485. }
  31486. return rgbaData;
  31487. };
  31488. /** @hidden */
  31489. Engine.prototype._releaseFramebufferObjects = function (texture) {
  31490. var gl = this._gl;
  31491. if (texture._framebuffer) {
  31492. gl.deleteFramebuffer(texture._framebuffer);
  31493. texture._framebuffer = null;
  31494. }
  31495. if (texture._depthStencilBuffer) {
  31496. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31497. texture._depthStencilBuffer = null;
  31498. }
  31499. if (texture._MSAAFramebuffer) {
  31500. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31501. texture._MSAAFramebuffer = null;
  31502. }
  31503. if (texture._MSAARenderBuffer) {
  31504. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31505. texture._MSAARenderBuffer = null;
  31506. }
  31507. };
  31508. /** @hidden */
  31509. Engine.prototype._releaseTexture = function (texture) {
  31510. var gl = this._gl;
  31511. this._releaseFramebufferObjects(texture);
  31512. gl.deleteTexture(texture._webGLTexture);
  31513. // Unbind channels
  31514. this.unbindAllTextures();
  31515. var index = this._internalTexturesCache.indexOf(texture);
  31516. if (index !== -1) {
  31517. this._internalTexturesCache.splice(index, 1);
  31518. }
  31519. // Integrated fixed lod samplers.
  31520. if (texture._lodTextureHigh) {
  31521. texture._lodTextureHigh.dispose();
  31522. }
  31523. if (texture._lodTextureMid) {
  31524. texture._lodTextureMid.dispose();
  31525. }
  31526. if (texture._lodTextureLow) {
  31527. texture._lodTextureLow.dispose();
  31528. }
  31529. // Set output texture of post process to null if the texture has been released/disposed
  31530. this.scenes.forEach(function (scene) {
  31531. scene.postProcesses.forEach(function (postProcess) {
  31532. if (postProcess._outputTexture == texture) {
  31533. postProcess._outputTexture = null;
  31534. }
  31535. });
  31536. scene.cameras.forEach(function (camera) {
  31537. camera._postProcesses.forEach(function (postProcess) {
  31538. if (postProcess) {
  31539. if (postProcess._outputTexture == texture) {
  31540. postProcess._outputTexture = null;
  31541. }
  31542. }
  31543. });
  31544. });
  31545. });
  31546. };
  31547. Engine.prototype.setProgram = function (program) {
  31548. if (this._currentProgram !== program) {
  31549. this._gl.useProgram(program);
  31550. this._currentProgram = program;
  31551. }
  31552. };
  31553. /**
  31554. * Binds an effect to the webGL context
  31555. * @param effect defines the effect to bind
  31556. */
  31557. Engine.prototype.bindSamplers = function (effect) {
  31558. this.setProgram(effect.getProgram());
  31559. var samplers = effect.getSamplers();
  31560. for (var index = 0; index < samplers.length; index++) {
  31561. var uniform = effect.getUniform(samplers[index]);
  31562. if (uniform) {
  31563. this._boundUniforms[index] = uniform;
  31564. }
  31565. }
  31566. this._currentEffect = null;
  31567. };
  31568. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  31569. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  31570. return;
  31571. }
  31572. // Remove
  31573. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31574. // Bind last to it
  31575. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  31576. // Bind to dummy
  31577. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  31578. };
  31579. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  31580. if (!internalTexture) {
  31581. return -1;
  31582. }
  31583. internalTexture._initialSlot = channel;
  31584. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  31585. if (channel !== internalTexture._designatedSlot) {
  31586. this._textureCollisions.addCount(1, false);
  31587. }
  31588. }
  31589. else {
  31590. if (channel !== internalTexture._designatedSlot) {
  31591. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  31592. return internalTexture._designatedSlot;
  31593. }
  31594. else {
  31595. // No slot for this texture, let's pick a new one (if we find a free slot)
  31596. if (this._nextFreeTextureSlots.length) {
  31597. return this._nextFreeTextureSlots[0];
  31598. }
  31599. // We need to recycle the oldest bound texture, sorry.
  31600. this._textureCollisions.addCount(1, false);
  31601. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  31602. }
  31603. }
  31604. }
  31605. return channel;
  31606. };
  31607. Engine.prototype._linkTrackers = function (previous, next) {
  31608. previous.next = next;
  31609. next.previous = previous;
  31610. };
  31611. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  31612. var currentSlot = internalTexture._designatedSlot;
  31613. if (currentSlot === -1) {
  31614. return -1;
  31615. }
  31616. internalTexture._designatedSlot = -1;
  31617. if (this.disableTextureBindingOptimization) {
  31618. return -1;
  31619. }
  31620. // Remove from bound list
  31621. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31622. // Free the slot
  31623. this._boundTexturesCache[currentSlot] = null;
  31624. this._nextFreeTextureSlots.push(currentSlot);
  31625. return currentSlot;
  31626. };
  31627. Engine.prototype._activateCurrentTexture = function () {
  31628. if (this._currentTextureChannel !== this._activeChannel) {
  31629. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  31630. this._currentTextureChannel = this._activeChannel;
  31631. }
  31632. };
  31633. /** @hidden */
  31634. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  31635. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  31636. if (force === void 0) { force = false; }
  31637. var wasPreviouslyBound = false;
  31638. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  31639. this._activeChannel = texture._designatedSlot;
  31640. }
  31641. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  31642. var isTextureForRendering = texture && texture._initialSlot > -1;
  31643. if (currentTextureBound !== texture || force) {
  31644. if (currentTextureBound) {
  31645. this._removeDesignatedSlot(currentTextureBound);
  31646. }
  31647. this._activateCurrentTexture();
  31648. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  31649. this._boundTexturesCache[this._activeChannel] = texture;
  31650. if (texture) {
  31651. if (!this.disableTextureBindingOptimization) {
  31652. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  31653. if (slotIndex > -1) {
  31654. this._nextFreeTextureSlots.splice(slotIndex, 1);
  31655. }
  31656. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  31657. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  31658. }
  31659. texture._designatedSlot = this._activeChannel;
  31660. }
  31661. }
  31662. else if (forTextureDataUpdate) {
  31663. wasPreviouslyBound = true;
  31664. this._activateCurrentTexture();
  31665. }
  31666. if (isTextureForRendering && !forTextureDataUpdate) {
  31667. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  31668. }
  31669. return wasPreviouslyBound;
  31670. };
  31671. /** @hidden */
  31672. Engine.prototype._bindTexture = function (channel, texture) {
  31673. if (channel < 0) {
  31674. return;
  31675. }
  31676. if (texture) {
  31677. channel = this._getCorrectTextureChannel(channel, texture);
  31678. }
  31679. this._activeChannel = channel;
  31680. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  31681. };
  31682. /**
  31683. * Sets a texture to the webGL context from a postprocess
  31684. * @param channel defines the channel to use
  31685. * @param postProcess defines the source postprocess
  31686. */
  31687. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  31688. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  31689. };
  31690. /**
  31691. * Binds the output of the passed in post process to the texture channel specified
  31692. * @param channel The channel the texture should be bound to
  31693. * @param postProcess The post process which's output should be bound
  31694. */
  31695. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  31696. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  31697. };
  31698. /**
  31699. * Unbind all textures from the webGL context
  31700. */
  31701. Engine.prototype.unbindAllTextures = function () {
  31702. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  31703. this._activeChannel = channel;
  31704. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31705. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31706. if (this.webGLVersion > 1) {
  31707. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31708. }
  31709. }
  31710. };
  31711. /**
  31712. * Sets a texture to the according uniform.
  31713. * @param channel The texture channel
  31714. * @param uniform The uniform to set
  31715. * @param texture The texture to apply
  31716. */
  31717. Engine.prototype.setTexture = function (channel, uniform, texture) {
  31718. if (channel < 0) {
  31719. return;
  31720. }
  31721. if (uniform) {
  31722. this._boundUniforms[channel] = uniform;
  31723. }
  31724. this._setTexture(channel, texture);
  31725. };
  31726. /**
  31727. * Sets a depth stencil texture from a render target to the according uniform.
  31728. * @param channel The texture channel
  31729. * @param uniform The uniform to set
  31730. * @param texture The render target texture containing the depth stencil texture to apply
  31731. */
  31732. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  31733. if (channel < 0) {
  31734. return;
  31735. }
  31736. if (uniform) {
  31737. this._boundUniforms[channel] = uniform;
  31738. }
  31739. if (!texture || !texture.depthStencilTexture) {
  31740. this._setTexture(channel, null);
  31741. }
  31742. else {
  31743. this._setTexture(channel, texture, false, true);
  31744. }
  31745. };
  31746. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  31747. var uniform = this._boundUniforms[sourceSlot];
  31748. if (uniform._currentState === destination) {
  31749. return;
  31750. }
  31751. this._gl.uniform1i(uniform, destination);
  31752. uniform._currentState = destination;
  31753. };
  31754. Engine.prototype._getTextureWrapMode = function (mode) {
  31755. switch (mode) {
  31756. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  31757. return this._gl.REPEAT;
  31758. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  31759. return this._gl.CLAMP_TO_EDGE;
  31760. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  31761. return this._gl.MIRRORED_REPEAT;
  31762. }
  31763. return this._gl.REPEAT;
  31764. };
  31765. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  31766. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  31767. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  31768. // Not ready?
  31769. if (!texture) {
  31770. if (this._boundTexturesCache[channel] != null) {
  31771. this._activeChannel = channel;
  31772. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31773. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31774. if (this.webGLVersion > 1) {
  31775. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31776. }
  31777. }
  31778. return false;
  31779. }
  31780. // Video
  31781. if (texture.video) {
  31782. this._activeChannel = channel;
  31783. texture.update();
  31784. }
  31785. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  31786. texture.delayLoad();
  31787. return false;
  31788. }
  31789. var internalTexture;
  31790. if (depthStencilTexture) {
  31791. internalTexture = texture.depthStencilTexture;
  31792. }
  31793. else if (texture.isReady()) {
  31794. internalTexture = texture.getInternalTexture();
  31795. }
  31796. else if (texture.isCube) {
  31797. internalTexture = this.emptyCubeTexture;
  31798. }
  31799. else if (texture.is3D) {
  31800. internalTexture = this.emptyTexture3D;
  31801. }
  31802. else {
  31803. internalTexture = this.emptyTexture;
  31804. }
  31805. if (!isPartOfTextureArray) {
  31806. channel = this._getCorrectTextureChannel(channel, internalTexture);
  31807. }
  31808. var needToBind = true;
  31809. if (this._boundTexturesCache[channel] === internalTexture) {
  31810. this._moveBoundTextureOnTop(internalTexture);
  31811. if (!isPartOfTextureArray) {
  31812. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  31813. }
  31814. needToBind = false;
  31815. }
  31816. this._activeChannel = channel;
  31817. if (internalTexture && internalTexture.is3D) {
  31818. if (needToBind) {
  31819. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  31820. }
  31821. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  31822. internalTexture._cachedWrapU = texture.wrapU;
  31823. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  31824. }
  31825. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  31826. internalTexture._cachedWrapV = texture.wrapV;
  31827. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  31828. }
  31829. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  31830. internalTexture._cachedWrapR = texture.wrapR;
  31831. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  31832. }
  31833. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  31834. }
  31835. else if (internalTexture && internalTexture.isCube) {
  31836. if (needToBind) {
  31837. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  31838. }
  31839. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  31840. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  31841. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  31842. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  31843. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  31844. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  31845. }
  31846. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  31847. }
  31848. else {
  31849. if (needToBind) {
  31850. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  31851. }
  31852. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  31853. internalTexture._cachedWrapU = texture.wrapU;
  31854. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  31855. }
  31856. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  31857. internalTexture._cachedWrapV = texture.wrapV;
  31858. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  31859. }
  31860. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  31861. }
  31862. return true;
  31863. };
  31864. /**
  31865. * Sets an array of texture to the webGL context
  31866. * @param channel defines the channel where the texture array must be set
  31867. * @param uniform defines the associated uniform location
  31868. * @param textures defines the array of textures to bind
  31869. */
  31870. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  31871. if (channel < 0 || !uniform) {
  31872. return;
  31873. }
  31874. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  31875. this._textureUnits = new Int32Array(textures.length);
  31876. }
  31877. for (var i = 0; i < textures.length; i++) {
  31878. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  31879. }
  31880. this._gl.uniform1iv(uniform, this._textureUnits);
  31881. for (var index = 0; index < textures.length; index++) {
  31882. this._setTexture(this._textureUnits[index], textures[index], true);
  31883. }
  31884. };
  31885. /** @hidden */
  31886. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  31887. var internalTexture = texture.getInternalTexture();
  31888. if (!internalTexture) {
  31889. return;
  31890. }
  31891. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  31892. var value = texture.anisotropicFilteringLevel;
  31893. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  31894. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  31895. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  31896. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  31897. }
  31898. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  31899. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  31900. internalTexture._cachedAnisotropicFilteringLevel = value;
  31901. }
  31902. };
  31903. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  31904. this._bindTextureDirectly(target, texture, true, true);
  31905. this._gl.texParameterf(target, parameter, value);
  31906. };
  31907. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  31908. if (texture) {
  31909. this._bindTextureDirectly(target, texture, true, true);
  31910. }
  31911. this._gl.texParameteri(target, parameter, value);
  31912. };
  31913. /**
  31914. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31915. * @param x defines the x coordinate of the rectangle where pixels must be read
  31916. * @param y defines the y coordinate of the rectangle where pixels must be read
  31917. * @param width defines the width of the rectangle where pixels must be read
  31918. * @param height defines the height of the rectangle where pixels must be read
  31919. * @returns a Uint8Array containing RGBA colors
  31920. */
  31921. Engine.prototype.readPixels = function (x, y, width, height) {
  31922. var data = new Uint8Array(height * width * 4);
  31923. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  31924. return data;
  31925. };
  31926. /**
  31927. * Add an externaly attached data from its key.
  31928. * This method call will fail and return false, if such key already exists.
  31929. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31930. * @param key the unique key that identifies the data
  31931. * @param data the data object to associate to the key for this Engine instance
  31932. * @return true if no such key were already present and the data was added successfully, false otherwise
  31933. */
  31934. Engine.prototype.addExternalData = function (key, data) {
  31935. if (!this._externalData) {
  31936. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  31937. }
  31938. return this._externalData.add(key, data);
  31939. };
  31940. /**
  31941. * Get an externaly attached data from its key
  31942. * @param key the unique key that identifies the data
  31943. * @return the associated data, if present (can be null), or undefined if not present
  31944. */
  31945. Engine.prototype.getExternalData = function (key) {
  31946. if (!this._externalData) {
  31947. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  31948. }
  31949. return this._externalData.get(key);
  31950. };
  31951. /**
  31952. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31953. * @param key the unique key that identifies the data
  31954. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31955. * @return the associated data, can be null if the factory returned null.
  31956. */
  31957. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  31958. if (!this._externalData) {
  31959. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  31960. }
  31961. return this._externalData.getOrAddWithFactory(key, factory);
  31962. };
  31963. /**
  31964. * Remove an externaly attached data from the Engine instance
  31965. * @param key the unique key that identifies the data
  31966. * @return true if the data was successfully removed, false if it doesn't exist
  31967. */
  31968. Engine.prototype.removeExternalData = function (key) {
  31969. if (!this._externalData) {
  31970. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  31971. }
  31972. return this._externalData.remove(key);
  31973. };
  31974. /**
  31975. * Unbind all vertex attributes from the webGL context
  31976. */
  31977. Engine.prototype.unbindAllAttributes = function () {
  31978. if (this._mustWipeVertexAttributes) {
  31979. this._mustWipeVertexAttributes = false;
  31980. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  31981. this._gl.disableVertexAttribArray(i);
  31982. this._vertexAttribArraysEnabled[i] = false;
  31983. this._currentBufferPointers[i].active = false;
  31984. }
  31985. return;
  31986. }
  31987. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  31988. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  31989. continue;
  31990. }
  31991. this._gl.disableVertexAttribArray(i);
  31992. this._vertexAttribArraysEnabled[i] = false;
  31993. this._currentBufferPointers[i].active = false;
  31994. }
  31995. };
  31996. /**
  31997. * 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
  31998. */
  31999. Engine.prototype.releaseEffects = function () {
  32000. for (var name in this._compiledEffects) {
  32001. this._deleteProgram(this._compiledEffects[name]._program);
  32002. }
  32003. this._compiledEffects = {};
  32004. };
  32005. /**
  32006. * Dispose and release all associated resources
  32007. */
  32008. Engine.prototype.dispose = function () {
  32009. this.hideLoadingUI();
  32010. this.stopRenderLoop();
  32011. this.onNewSceneAddedObservable.clear();
  32012. // Release postProcesses
  32013. while (this.postProcesses.length) {
  32014. this.postProcesses[0].dispose();
  32015. }
  32016. // Empty texture
  32017. if (this._emptyTexture) {
  32018. this._releaseTexture(this._emptyTexture);
  32019. this._emptyTexture = null;
  32020. }
  32021. if (this._emptyCubeTexture) {
  32022. this._releaseTexture(this._emptyCubeTexture);
  32023. this._emptyCubeTexture = null;
  32024. }
  32025. // Rescale PP
  32026. if (this._rescalePostProcess) {
  32027. this._rescalePostProcess.dispose();
  32028. }
  32029. // Release scenes
  32030. while (this.scenes.length) {
  32031. this.scenes[0].dispose();
  32032. }
  32033. // Release audio engine
  32034. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32035. Engine.audioEngine.dispose();
  32036. }
  32037. // Release effects
  32038. this.releaseEffects();
  32039. // Unbind
  32040. this.unbindAllAttributes();
  32041. this._boundUniforms = [];
  32042. if (this._dummyFramebuffer) {
  32043. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32044. }
  32045. //WebVR
  32046. this.disableVR();
  32047. // Events
  32048. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32049. window.removeEventListener("blur", this._onBlur);
  32050. window.removeEventListener("focus", this._onFocus);
  32051. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32052. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32053. if (this._renderingCanvas) {
  32054. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32055. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32056. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32057. if (!this._doNotHandleContextLost) {
  32058. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32059. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32060. }
  32061. }
  32062. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32063. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32064. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32065. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32066. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32067. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32068. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32069. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32070. if (this._onVrDisplayConnect) {
  32071. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32072. if (this._onVrDisplayDisconnect) {
  32073. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32074. }
  32075. if (this._onVrDisplayPresentChange) {
  32076. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32077. }
  32078. this._onVrDisplayConnect = null;
  32079. this._onVrDisplayDisconnect = null;
  32080. }
  32081. }
  32082. // Remove from Instances
  32083. var index = Engine.Instances.indexOf(this);
  32084. if (index >= 0) {
  32085. Engine.Instances.splice(index, 1);
  32086. }
  32087. this._workingCanvas = null;
  32088. this._workingContext = null;
  32089. this._currentBufferPointers = [];
  32090. this._renderingCanvas = null;
  32091. this._currentProgram = null;
  32092. this._bindedRenderFunction = null;
  32093. this.onResizeObservable.clear();
  32094. this.onCanvasBlurObservable.clear();
  32095. this.onCanvasFocusObservable.clear();
  32096. this.onCanvasPointerOutObservable.clear();
  32097. this.onBeginFrameObservable.clear();
  32098. this.onEndFrameObservable.clear();
  32099. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  32100. // Abort active requests
  32101. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  32102. var request = _a[_i];
  32103. request.abort();
  32104. }
  32105. };
  32106. // Loading screen
  32107. /**
  32108. * Display the loading screen
  32109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32110. */
  32111. Engine.prototype.displayLoadingUI = function () {
  32112. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32113. return;
  32114. }
  32115. var loadingScreen = this.loadingScreen;
  32116. if (loadingScreen) {
  32117. loadingScreen.displayLoadingUI();
  32118. }
  32119. };
  32120. /**
  32121. * Hide the loading screen
  32122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32123. */
  32124. Engine.prototype.hideLoadingUI = function () {
  32125. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32126. return;
  32127. }
  32128. var loadingScreen = this.loadingScreen;
  32129. if (loadingScreen) {
  32130. loadingScreen.hideLoadingUI();
  32131. }
  32132. };
  32133. Object.defineProperty(Engine.prototype, "loadingScreen", {
  32134. /**
  32135. * Gets the current loading screen object
  32136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32137. */
  32138. get: function () {
  32139. if (!this._loadingScreen && this._renderingCanvas) {
  32140. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  32141. }
  32142. return this._loadingScreen;
  32143. },
  32144. /**
  32145. * Sets the current loading screen object
  32146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32147. */
  32148. set: function (loadingScreen) {
  32149. this._loadingScreen = loadingScreen;
  32150. },
  32151. enumerable: true,
  32152. configurable: true
  32153. });
  32154. Object.defineProperty(Engine.prototype, "loadingUIText", {
  32155. /**
  32156. * Sets the current loading screen text
  32157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32158. */
  32159. set: function (text) {
  32160. this.loadingScreen.loadingUIText = text;
  32161. },
  32162. enumerable: true,
  32163. configurable: true
  32164. });
  32165. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  32166. /**
  32167. * Sets the current loading screen background color
  32168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32169. */
  32170. set: function (color) {
  32171. this.loadingScreen.loadingUIBackgroundColor = color;
  32172. },
  32173. enumerable: true,
  32174. configurable: true
  32175. });
  32176. /**
  32177. * Attach a new callback raised when context lost event is fired
  32178. * @param callback defines the callback to call
  32179. */
  32180. Engine.prototype.attachContextLostEvent = function (callback) {
  32181. if (this._renderingCanvas) {
  32182. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  32183. }
  32184. };
  32185. /**
  32186. * Attach a new callback raised when context restored event is fired
  32187. * @param callback defines the callback to call
  32188. */
  32189. Engine.prototype.attachContextRestoredEvent = function (callback) {
  32190. if (this._renderingCanvas) {
  32191. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  32192. }
  32193. };
  32194. /**
  32195. * Gets the source code of the vertex shader associated with a specific webGL program
  32196. * @param program defines the program to use
  32197. * @returns a string containing the source code of the vertex shader associated with the program
  32198. */
  32199. Engine.prototype.getVertexShaderSource = function (program) {
  32200. var shaders = this._gl.getAttachedShaders(program);
  32201. if (!shaders) {
  32202. return null;
  32203. }
  32204. return this._gl.getShaderSource(shaders[0]);
  32205. };
  32206. /**
  32207. * Gets the source code of the fragment shader associated with a specific webGL program
  32208. * @param program defines the program to use
  32209. * @returns a string containing the source code of the fragment shader associated with the program
  32210. */
  32211. Engine.prototype.getFragmentShaderSource = function (program) {
  32212. var shaders = this._gl.getAttachedShaders(program);
  32213. if (!shaders) {
  32214. return null;
  32215. }
  32216. return this._gl.getShaderSource(shaders[1]);
  32217. };
  32218. /**
  32219. * Get the current error code of the webGL context
  32220. * @returns the error code
  32221. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32222. */
  32223. Engine.prototype.getError = function () {
  32224. return this._gl.getError();
  32225. };
  32226. // FPS
  32227. /**
  32228. * Gets the current framerate
  32229. * @returns a number representing the framerate
  32230. */
  32231. Engine.prototype.getFps = function () {
  32232. return this._fps;
  32233. };
  32234. /**
  32235. * Gets the time spent between current and previous frame
  32236. * @returns a number representing the delta time in ms
  32237. */
  32238. Engine.prototype.getDeltaTime = function () {
  32239. return this._deltaTime;
  32240. };
  32241. Engine.prototype._measureFps = function () {
  32242. this._performanceMonitor.sampleFrame();
  32243. this._fps = this._performanceMonitor.averageFPS;
  32244. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  32245. };
  32246. /** @hidden */
  32247. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  32248. if (faceIndex === void 0) { faceIndex = -1; }
  32249. if (level === void 0) { level = 0; }
  32250. if (buffer === void 0) { buffer = null; }
  32251. var gl = this._gl;
  32252. if (!this._dummyFramebuffer) {
  32253. var dummy = gl.createFramebuffer();
  32254. if (!dummy) {
  32255. throw new Error("Unable to create dummy framebuffer");
  32256. }
  32257. this._dummyFramebuffer = dummy;
  32258. }
  32259. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  32260. if (faceIndex > -1) {
  32261. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  32262. }
  32263. else {
  32264. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  32265. }
  32266. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  32267. switch (readType) {
  32268. case gl.UNSIGNED_BYTE:
  32269. if (!buffer) {
  32270. buffer = new Uint8Array(4 * width * height);
  32271. }
  32272. readType = gl.UNSIGNED_BYTE;
  32273. break;
  32274. default:
  32275. if (!buffer) {
  32276. buffer = new Float32Array(4 * width * height);
  32277. }
  32278. readType = gl.FLOAT;
  32279. break;
  32280. }
  32281. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  32282. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  32283. return buffer;
  32284. };
  32285. Engine.prototype._canRenderToFloatFramebuffer = function () {
  32286. if (this._webGLVersion > 1) {
  32287. return this._caps.colorBufferFloat;
  32288. }
  32289. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  32290. };
  32291. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  32292. if (this._webGLVersion > 1) {
  32293. return this._caps.colorBufferFloat;
  32294. }
  32295. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  32296. };
  32297. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  32298. Engine.prototype._canRenderToFramebuffer = function (type) {
  32299. var gl = this._gl;
  32300. //clear existing errors
  32301. while (gl.getError() !== gl.NO_ERROR) { }
  32302. var successful = true;
  32303. var texture = gl.createTexture();
  32304. gl.bindTexture(gl.TEXTURE_2D, texture);
  32305. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32306. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32307. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32308. var fb = gl.createFramebuffer();
  32309. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  32310. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  32311. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  32312. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  32313. successful = successful && (gl.getError() === gl.NO_ERROR);
  32314. //try render by clearing frame buffer's color buffer
  32315. if (successful) {
  32316. gl.clear(gl.COLOR_BUFFER_BIT);
  32317. successful = successful && (gl.getError() === gl.NO_ERROR);
  32318. }
  32319. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  32320. if (successful) {
  32321. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  32322. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32323. var readFormat = gl.RGBA;
  32324. var readType = gl.UNSIGNED_BYTE;
  32325. var buffer = new Uint8Array(4);
  32326. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  32327. successful = successful && (gl.getError() === gl.NO_ERROR);
  32328. }
  32329. //clean up
  32330. gl.deleteTexture(texture);
  32331. gl.deleteFramebuffer(fb);
  32332. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32333. //clear accumulated errors
  32334. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  32335. return successful;
  32336. };
  32337. /** @hidden */
  32338. Engine.prototype._getWebGLTextureType = function (type) {
  32339. if (this._webGLVersion === 1) {
  32340. switch (type) {
  32341. case Engine.TEXTURETYPE_FLOAT:
  32342. return this._gl.FLOAT;
  32343. case Engine.TEXTURETYPE_HALF_FLOAT:
  32344. return this._gl.HALF_FLOAT_OES;
  32345. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32346. return this._gl.UNSIGNED_BYTE;
  32347. }
  32348. return this._gl.UNSIGNED_BYTE;
  32349. }
  32350. switch (type) {
  32351. case Engine.TEXTURETYPE_BYTE:
  32352. return this._gl.BYTE;
  32353. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32354. return this._gl.UNSIGNED_BYTE;
  32355. case Engine.TEXTURETYPE_SHORT:
  32356. return this._gl.SHORT;
  32357. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32358. return this._gl.UNSIGNED_SHORT;
  32359. case Engine.TEXTURETYPE_INT:
  32360. return this._gl.INT;
  32361. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32362. return this._gl.UNSIGNED_INT;
  32363. case Engine.TEXTURETYPE_FLOAT:
  32364. return this._gl.FLOAT;
  32365. case Engine.TEXTURETYPE_HALF_FLOAT:
  32366. return this._gl.HALF_FLOAT;
  32367. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32368. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  32369. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32370. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  32371. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32372. return this._gl.UNSIGNED_SHORT_5_6_5;
  32373. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32374. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  32375. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  32376. return this._gl.UNSIGNED_INT_24_8;
  32377. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32378. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  32379. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32380. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  32381. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  32382. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  32383. }
  32384. return this._gl.UNSIGNED_BYTE;
  32385. };
  32386. Engine.prototype._getInternalFormat = function (format) {
  32387. var internalFormat = this._gl.RGBA;
  32388. switch (format) {
  32389. case Engine.TEXTUREFORMAT_ALPHA:
  32390. internalFormat = this._gl.ALPHA;
  32391. break;
  32392. case Engine.TEXTUREFORMAT_LUMINANCE:
  32393. internalFormat = this._gl.LUMINANCE;
  32394. break;
  32395. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32396. internalFormat = this._gl.LUMINANCE_ALPHA;
  32397. break;
  32398. case Engine.TEXTUREFORMAT_RED:
  32399. internalFormat = this._gl.RED;
  32400. break;
  32401. case Engine.TEXTUREFORMAT_RG:
  32402. internalFormat = this._gl.RG;
  32403. break;
  32404. case Engine.TEXTUREFORMAT_RGB:
  32405. internalFormat = this._gl.RGB;
  32406. break;
  32407. case Engine.TEXTUREFORMAT_RGBA:
  32408. internalFormat = this._gl.RGBA;
  32409. break;
  32410. }
  32411. if (this._webGLVersion > 1) {
  32412. switch (format) {
  32413. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32414. internalFormat = this._gl.RED_INTEGER;
  32415. break;
  32416. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32417. internalFormat = this._gl.RG_INTEGER;
  32418. break;
  32419. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32420. internalFormat = this._gl.RGB_INTEGER;
  32421. break;
  32422. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32423. internalFormat = this._gl.RGBA_INTEGER;
  32424. break;
  32425. }
  32426. }
  32427. return internalFormat;
  32428. };
  32429. /** @hidden */
  32430. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  32431. if (this._webGLVersion === 1) {
  32432. if (format !== undefined) {
  32433. switch (format) {
  32434. case Engine.TEXTUREFORMAT_ALPHA:
  32435. return this._gl.ALPHA;
  32436. case Engine.TEXTUREFORMAT_LUMINANCE:
  32437. return this._gl.LUMINANCE;
  32438. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32439. return this._gl.LUMINANCE_ALPHA;
  32440. }
  32441. }
  32442. return this._gl.RGBA;
  32443. }
  32444. switch (type) {
  32445. case Engine.TEXTURETYPE_BYTE:
  32446. switch (format) {
  32447. case Engine.TEXTUREFORMAT_RED:
  32448. return this._gl.R8_SNORM;
  32449. case Engine.TEXTUREFORMAT_RG:
  32450. return this._gl.RG8_SNORM;
  32451. case Engine.TEXTUREFORMAT_RGB:
  32452. return this._gl.RGB8_SNORM;
  32453. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32454. return this._gl.R8I;
  32455. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32456. return this._gl.RG8I;
  32457. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32458. return this._gl.RGB8I;
  32459. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32460. return this._gl.RGBA8I;
  32461. default:
  32462. return this._gl.RGBA8_SNORM;
  32463. }
  32464. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32465. switch (format) {
  32466. case Engine.TEXTUREFORMAT_RED:
  32467. return this._gl.R8;
  32468. case Engine.TEXTUREFORMAT_RG:
  32469. return this._gl.RG8;
  32470. case Engine.TEXTUREFORMAT_RGB:
  32471. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  32472. case Engine.TEXTUREFORMAT_RGBA:
  32473. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  32474. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32475. return this._gl.R8UI;
  32476. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32477. return this._gl.RG8UI;
  32478. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32479. return this._gl.RGB8UI;
  32480. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32481. return this._gl.RGBA8UI;
  32482. default:
  32483. return this._gl.RGBA8;
  32484. }
  32485. case Engine.TEXTURETYPE_SHORT:
  32486. switch (format) {
  32487. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32488. return this._gl.R16I;
  32489. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32490. return this._gl.RG16I;
  32491. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32492. return this._gl.RGB16I;
  32493. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32494. return this._gl.RGBA16I;
  32495. default:
  32496. return this._gl.RGBA16I;
  32497. }
  32498. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32499. switch (format) {
  32500. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32501. return this._gl.R16UI;
  32502. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32503. return this._gl.RG16UI;
  32504. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32505. return this._gl.RGB16UI;
  32506. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32507. return this._gl.RGBA16UI;
  32508. default:
  32509. return this._gl.RGBA16UI;
  32510. }
  32511. case Engine.TEXTURETYPE_INT:
  32512. switch (format) {
  32513. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32514. return this._gl.R32I;
  32515. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32516. return this._gl.RG32I;
  32517. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32518. return this._gl.RGB32I;
  32519. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32520. return this._gl.RGBA32I;
  32521. default:
  32522. return this._gl.RGBA32I;
  32523. }
  32524. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32525. switch (format) {
  32526. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32527. return this._gl.R32UI;
  32528. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32529. return this._gl.RG32UI;
  32530. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32531. return this._gl.RGB32UI;
  32532. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32533. return this._gl.RGBA32UI;
  32534. default:
  32535. return this._gl.RGBA32UI;
  32536. }
  32537. case Engine.TEXTURETYPE_FLOAT:
  32538. switch (format) {
  32539. case Engine.TEXTUREFORMAT_RED:
  32540. return this._gl.R32F; // By default. Other possibility is R16F.
  32541. case Engine.TEXTUREFORMAT_RG:
  32542. return this._gl.RG32F; // By default. Other possibility is RG16F.
  32543. case Engine.TEXTUREFORMAT_RGB:
  32544. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  32545. case Engine.TEXTUREFORMAT_RGBA:
  32546. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  32547. default:
  32548. return this._gl.RGBA32F;
  32549. }
  32550. case Engine.TEXTURETYPE_HALF_FLOAT:
  32551. switch (format) {
  32552. case Engine.TEXTUREFORMAT_RED:
  32553. return this._gl.R16F;
  32554. case Engine.TEXTUREFORMAT_RG:
  32555. return this._gl.RG16F;
  32556. case Engine.TEXTUREFORMAT_RGB:
  32557. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  32558. case Engine.TEXTUREFORMAT_RGBA:
  32559. return this._gl.RGBA16F;
  32560. default:
  32561. return this._gl.RGBA16F;
  32562. }
  32563. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32564. return this._gl.RGB565;
  32565. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32566. return this._gl.R11F_G11F_B10F;
  32567. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32568. return this._gl.RGB9_E5;
  32569. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32570. return this._gl.RGBA4;
  32571. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32572. return this._gl.RGB5_A1;
  32573. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32574. switch (format) {
  32575. case Engine.TEXTUREFORMAT_RGBA:
  32576. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  32577. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32578. return this._gl.RGB10_A2UI;
  32579. default:
  32580. return this._gl.RGB10_A2;
  32581. }
  32582. }
  32583. return this._gl.RGBA8;
  32584. };
  32585. /** @hidden */
  32586. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  32587. if (type === Engine.TEXTURETYPE_FLOAT) {
  32588. return this._gl.RGBA32F;
  32589. }
  32590. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  32591. return this._gl.RGBA16F;
  32592. }
  32593. return this._gl.RGBA8;
  32594. };
  32595. /** @hidden */
  32596. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  32597. var _this = this;
  32598. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  32599. this._activeRequests.push(request);
  32600. request.onCompleteObservable.add(function (request) {
  32601. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  32602. });
  32603. return request;
  32604. };
  32605. /** @hidden */
  32606. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  32607. var _this = this;
  32608. return new Promise(function (resolve, reject) {
  32609. _this._loadFile(url, function (data) {
  32610. resolve(data);
  32611. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  32612. reject(exception);
  32613. });
  32614. });
  32615. };
  32616. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  32617. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  32618. var onload = function (data) {
  32619. loadedFiles[index] = data;
  32620. loadedFiles._internalCount++;
  32621. if (loadedFiles._internalCount === 6) {
  32622. onfinish(loadedFiles);
  32623. }
  32624. };
  32625. var onerror = function (request, exception) {
  32626. if (onErrorCallBack && request) {
  32627. onErrorCallBack(request.status + " " + request.statusText, exception);
  32628. }
  32629. };
  32630. this._loadFile(url, onload, undefined, undefined, true, onerror);
  32631. };
  32632. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  32633. if (onError === void 0) { onError = null; }
  32634. var loadedFiles = [];
  32635. loadedFiles._internalCount = 0;
  32636. for (var index = 0; index < 6; index++) {
  32637. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  32638. }
  32639. };
  32640. // Statics
  32641. /**
  32642. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32643. * @returns true if the engine can be created
  32644. * @ignorenaming
  32645. */
  32646. Engine.isSupported = function () {
  32647. try {
  32648. var tempcanvas = document.createElement("canvas");
  32649. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  32650. return gl != null && !!window.WebGLRenderingContext;
  32651. }
  32652. catch (e) {
  32653. return false;
  32654. }
  32655. };
  32656. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32657. Engine.ExceptionList = [
  32658. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  32659. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32660. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32661. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32662. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32663. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  32664. ];
  32665. /**
  32666. * Hidden
  32667. */
  32668. Engine._TextureLoaders = [];
  32669. // Const statics
  32670. /** Defines that alpha blending is disabled */
  32671. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  32672. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32673. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  32674. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32675. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  32676. /** Defines that alpha blending to DEST - SRC * DEST */
  32677. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  32678. /** Defines that alpha blending to SRC * DEST */
  32679. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  32680. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32681. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  32682. /** Defines that alpha blending to SRC + DEST */
  32683. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  32684. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32685. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  32686. /**
  32687. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32688. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32689. */
  32690. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  32691. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32692. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  32693. /**
  32694. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32695. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32696. */
  32697. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  32698. /** Defines that the ressource is not delayed*/
  32699. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  32700. /** Defines that the ressource was successfully delay loaded */
  32701. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  32702. /** Defines that the ressource is currently delay loading */
  32703. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  32704. /** Defines that the ressource is delayed and has not started loading */
  32705. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  32706. // Depht or Stencil test Constants.
  32707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32708. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  32709. /** 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 */
  32710. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  32711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32712. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  32713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32714. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  32715. /** 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 */
  32716. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  32717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32718. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  32719. /** 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 */
  32720. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  32721. /** 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 */
  32722. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  32723. // Stencil Actions Constants.
  32724. /** Passed to stencilOperation to specify that stencil value must be kept */
  32725. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  32726. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32727. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  32728. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32729. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  32730. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32731. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  32732. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32733. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  32734. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32735. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  32736. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32737. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  32738. /** Texture is not repeating outside of 0..1 UVs */
  32739. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  32740. /** Texture is repeating outside of 0..1 UVs */
  32741. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  32742. /** Texture is repeating and mirrored */
  32743. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  32744. /** ALPHA */
  32745. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  32746. /** LUMINANCE */
  32747. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  32748. /** LUMINANCE_ALPHA */
  32749. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  32750. /** RGB */
  32751. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  32752. /** RGBA */
  32753. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  32754. /** RED */
  32755. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  32756. /** RED (2nd reference) */
  32757. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  32758. /** RG */
  32759. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  32760. /** RED_INTEGER */
  32761. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  32762. /** RED_INTEGER (2nd reference) */
  32763. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  32764. /** RG_INTEGER */
  32765. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  32766. /** RGB_INTEGER */
  32767. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  32768. /** RGBA_INTEGER */
  32769. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  32770. /** UNSIGNED_BYTE */
  32771. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  32772. /** UNSIGNED_BYTE (2nd reference) */
  32773. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  32774. /** FLOAT */
  32775. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  32776. /** HALF_FLOAT */
  32777. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  32778. /** BYTE */
  32779. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  32780. /** SHORT */
  32781. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  32782. /** UNSIGNED_SHORT */
  32783. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  32784. /** INT */
  32785. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  32786. /** UNSIGNED_INT */
  32787. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  32788. /** UNSIGNED_SHORT_4_4_4_4 */
  32789. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  32790. /** UNSIGNED_SHORT_5_5_5_1 */
  32791. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  32792. /** UNSIGNED_SHORT_5_6_5 */
  32793. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  32794. /** UNSIGNED_INT_2_10_10_10_REV */
  32795. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  32796. /** UNSIGNED_INT_24_8 */
  32797. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  32798. /** UNSIGNED_INT_10F_11F_11F_REV */
  32799. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  32800. /** UNSIGNED_INT_5_9_9_9_REV */
  32801. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  32802. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32803. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  32804. /** nearest is mag = nearest and min = nearest and mip = linear */
  32805. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  32806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32807. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  32808. /** Trilinear is mag = linear and min = linear and mip = linear */
  32809. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  32810. /** nearest is mag = nearest and min = nearest and mip = linear */
  32811. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  32812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32813. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  32814. /** Trilinear is mag = linear and min = linear and mip = linear */
  32815. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  32816. /** mag = nearest and min = nearest and mip = nearest */
  32817. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  32818. /** mag = nearest and min = linear and mip = nearest */
  32819. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  32820. /** mag = nearest and min = linear and mip = linear */
  32821. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  32822. /** mag = nearest and min = linear and mip = none */
  32823. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  32824. /** mag = nearest and min = nearest and mip = none */
  32825. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  32826. /** mag = linear and min = nearest and mip = nearest */
  32827. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  32828. /** mag = linear and min = nearest and mip = linear */
  32829. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  32830. /** mag = linear and min = linear and mip = none */
  32831. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  32832. /** mag = linear and min = nearest and mip = none */
  32833. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  32834. /** Explicit coordinates mode */
  32835. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  32836. /** Spherical coordinates mode */
  32837. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  32838. /** Planar coordinates mode */
  32839. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  32840. /** Cubic coordinates mode */
  32841. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  32842. /** Projection coordinates mode */
  32843. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  32844. /** Skybox coordinates mode */
  32845. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  32846. /** Inverse Cubic coordinates mode */
  32847. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  32848. /** Equirectangular coordinates mode */
  32849. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  32850. /** Equirectangular Fixed coordinates mode */
  32851. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  32852. /** Equirectangular Fixed Mirrored coordinates mode */
  32853. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  32854. // Texture rescaling mode
  32855. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32856. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  32857. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32858. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  32859. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32860. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  32861. // Updatable statics so stick with vars here
  32862. /**
  32863. * Gets or sets the epsilon value used by collision engine
  32864. */
  32865. Engine.CollisionsEpsilon = 0.001;
  32866. /**
  32867. * Method called to create the default rescale post process on each engine.
  32868. */
  32869. Engine._RescalePostProcessFactory = null;
  32870. return Engine;
  32871. }());
  32872. /***/ }),
  32873. /***/ "./Engines/engineStore.ts":
  32874. /*!********************************!*\
  32875. !*** ./Engines/engineStore.ts ***!
  32876. \********************************/
  32877. /*! exports provided: EngineStore */
  32878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32879. "use strict";
  32880. __webpack_require__.r(__webpack_exports__);
  32881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  32882. /**
  32883. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32884. * during the life time of the application.
  32885. */
  32886. var EngineStore = /** @class */ (function () {
  32887. function EngineStore() {
  32888. }
  32889. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  32890. /**
  32891. * Gets the latest created engine
  32892. */
  32893. get: function () {
  32894. if (this.Instances.length === 0) {
  32895. return null;
  32896. }
  32897. return this.Instances[this.Instances.length - 1];
  32898. },
  32899. enumerable: true,
  32900. configurable: true
  32901. });
  32902. Object.defineProperty(EngineStore, "LastCreatedScene", {
  32903. /**
  32904. * Gets the latest created scene
  32905. */
  32906. get: function () {
  32907. var lastCreatedEngine = this.LastCreatedEngine;
  32908. if (!lastCreatedEngine) {
  32909. return null;
  32910. }
  32911. if (lastCreatedEngine.scenes.length === 0) {
  32912. return null;
  32913. }
  32914. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  32915. },
  32916. enumerable: true,
  32917. configurable: true
  32918. });
  32919. /** Gets the list of created engines */
  32920. EngineStore.Instances = new Array();
  32921. return EngineStore;
  32922. }());
  32923. /***/ }),
  32924. /***/ "./Engines/index.ts":
  32925. /*!**************************!*\
  32926. !*** ./Engines/index.ts ***!
  32927. \**************************/
  32928. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  32929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32930. "use strict";
  32931. __webpack_require__.r(__webpack_exports__);
  32932. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  32933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  32934. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  32935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  32936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  32937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  32938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  32939. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  32940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  32941. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  32942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  32943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  32944. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  32945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  32946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  32947. /***/ }),
  32948. /***/ "./Engines/nullEngine.ts":
  32949. /*!*******************************!*\
  32950. !*** ./Engines/nullEngine.ts ***!
  32951. \*******************************/
  32952. /*! exports provided: NullEngineOptions, NullEngine */
  32953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32954. "use strict";
  32955. __webpack_require__.r(__webpack_exports__);
  32956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  32957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  32958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  32959. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  32960. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  32961. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  32962. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  32963. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  32964. /**
  32965. * Options to create the null engine
  32966. */
  32967. var NullEngineOptions = /** @class */ (function () {
  32968. function NullEngineOptions() {
  32969. /**
  32970. * Render width (Default: 512)
  32971. */
  32972. this.renderWidth = 512;
  32973. /**
  32974. * Render height (Default: 256)
  32975. */
  32976. this.renderHeight = 256;
  32977. /**
  32978. * Texture size (Default: 512)
  32979. */
  32980. this.textureSize = 512;
  32981. /**
  32982. * If delta time between frames should be constant
  32983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32984. */
  32985. this.deterministicLockstep = false;
  32986. /**
  32987. * Maximum about of steps between frames (Default: 4)
  32988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32989. */
  32990. this.lockstepMaxSteps = 4;
  32991. }
  32992. return NullEngineOptions;
  32993. }());
  32994. /**
  32995. * The null engine class provides support for headless version of babylon.js.
  32996. * This can be used in server side scenario or for testing purposes
  32997. */
  32998. var NullEngine = /** @class */ (function (_super) {
  32999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33000. function NullEngine(options) {
  33001. if (options === void 0) { options = new NullEngineOptions(); }
  33002. var _this = _super.call(this, null) || this;
  33003. if (options.deterministicLockstep === undefined) {
  33004. options.deterministicLockstep = false;
  33005. }
  33006. if (options.lockstepMaxSteps === undefined) {
  33007. options.lockstepMaxSteps = 4;
  33008. }
  33009. _this._options = options;
  33010. // Init caps
  33011. // We consider we are on a webgl1 capable device
  33012. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33013. _this._caps.maxTexturesImageUnits = 16;
  33014. _this._caps.maxVertexTextureImageUnits = 16;
  33015. _this._caps.maxTextureSize = 512;
  33016. _this._caps.maxCubemapTextureSize = 512;
  33017. _this._caps.maxRenderTextureSize = 512;
  33018. _this._caps.maxVertexAttribs = 16;
  33019. _this._caps.maxVaryingVectors = 16;
  33020. _this._caps.maxFragmentUniformVectors = 16;
  33021. _this._caps.maxVertexUniformVectors = 16;
  33022. // Extensions
  33023. _this._caps.standardDerivatives = false;
  33024. _this._caps.astc = null;
  33025. _this._caps.s3tc = null;
  33026. _this._caps.pvrtc = null;
  33027. _this._caps.etc1 = null;
  33028. _this._caps.etc2 = null;
  33029. _this._caps.textureAnisotropicFilterExtension = null;
  33030. _this._caps.maxAnisotropy = 0;
  33031. _this._caps.uintIndices = false;
  33032. _this._caps.fragmentDepthSupported = false;
  33033. _this._caps.highPrecisionShaderSupported = true;
  33034. _this._caps.colorBufferFloat = false;
  33035. _this._caps.textureFloat = false;
  33036. _this._caps.textureFloatLinearFiltering = false;
  33037. _this._caps.textureFloatRender = false;
  33038. _this._caps.textureHalfFloat = false;
  33039. _this._caps.textureHalfFloatLinearFiltering = false;
  33040. _this._caps.textureHalfFloatRender = false;
  33041. _this._caps.textureLOD = false;
  33042. _this._caps.drawBuffersExtension = false;
  33043. _this._caps.depthTextureExtension = false;
  33044. _this._caps.vertexArrayObject = false;
  33045. _this._caps.instancedArrays = false;
  33046. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33047. // Wrappers
  33048. if (typeof URL === "undefined") {
  33049. URL = {
  33050. createObjectURL: function () { },
  33051. revokeObjectURL: function () { }
  33052. };
  33053. }
  33054. if (typeof Blob === "undefined") {
  33055. Blob = function () { };
  33056. }
  33057. return _this;
  33058. }
  33059. /**
  33060. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33061. */
  33062. NullEngine.prototype.isDeterministicLockStep = function () {
  33063. return this._options.deterministicLockstep;
  33064. };
  33065. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33066. NullEngine.prototype.getLockstepMaxSteps = function () {
  33067. return this._options.lockstepMaxSteps;
  33068. };
  33069. /**
  33070. * Sets hardware scaling, used to save performance if needed
  33071. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33072. */
  33073. NullEngine.prototype.getHardwareScalingLevel = function () {
  33074. return 1.0;
  33075. };
  33076. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33077. return {
  33078. capacity: 0,
  33079. references: 1,
  33080. is32Bits: false
  33081. };
  33082. };
  33083. NullEngine.prototype.createIndexBuffer = function (indices) {
  33084. return {
  33085. capacity: 0,
  33086. references: 1,
  33087. is32Bits: false
  33088. };
  33089. };
  33090. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  33091. if (stencil === void 0) { stencil = false; }
  33092. };
  33093. NullEngine.prototype.getRenderWidth = function (useScreen) {
  33094. if (useScreen === void 0) { useScreen = false; }
  33095. if (!useScreen && this._currentRenderTarget) {
  33096. return this._currentRenderTarget.width;
  33097. }
  33098. return this._options.renderWidth;
  33099. };
  33100. NullEngine.prototype.getRenderHeight = function (useScreen) {
  33101. if (useScreen === void 0) { useScreen = false; }
  33102. if (!useScreen && this._currentRenderTarget) {
  33103. return this._currentRenderTarget.height;
  33104. }
  33105. return this._options.renderHeight;
  33106. };
  33107. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  33108. this._cachedViewport = viewport;
  33109. };
  33110. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  33111. return {
  33112. transformFeedback: null,
  33113. __SPECTOR_rebuildProgram: null,
  33114. isParallelCompiled: false
  33115. };
  33116. };
  33117. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  33118. return [];
  33119. };
  33120. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  33121. return [];
  33122. };
  33123. NullEngine.prototype.bindSamplers = function (effect) {
  33124. this._currentEffect = null;
  33125. };
  33126. NullEngine.prototype.enableEffect = function (effect) {
  33127. this._currentEffect = effect;
  33128. if (effect.onBind) {
  33129. effect.onBind(effect);
  33130. }
  33131. if (effect._onBindObservable) {
  33132. effect._onBindObservable.notifyObservers(effect);
  33133. }
  33134. };
  33135. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  33136. if (zOffset === void 0) { zOffset = 0; }
  33137. if (reverseSide === void 0) { reverseSide = false; }
  33138. };
  33139. NullEngine.prototype.setIntArray = function (uniform, array) {
  33140. };
  33141. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  33142. };
  33143. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  33144. };
  33145. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  33146. };
  33147. NullEngine.prototype.setFloatArray = function (uniform, array) {
  33148. };
  33149. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  33150. };
  33151. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  33152. };
  33153. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  33154. };
  33155. NullEngine.prototype.setArray = function (uniform, array) {
  33156. };
  33157. NullEngine.prototype.setArray2 = function (uniform, array) {
  33158. };
  33159. NullEngine.prototype.setArray3 = function (uniform, array) {
  33160. };
  33161. NullEngine.prototype.setArray4 = function (uniform, array) {
  33162. };
  33163. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  33164. };
  33165. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  33166. };
  33167. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  33168. };
  33169. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  33170. };
  33171. NullEngine.prototype.setFloat = function (uniform, value) {
  33172. };
  33173. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  33174. };
  33175. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  33176. };
  33177. NullEngine.prototype.setBool = function (uniform, bool) {
  33178. };
  33179. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  33180. };
  33181. NullEngine.prototype.setColor3 = function (uniform, color3) {
  33182. };
  33183. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  33184. };
  33185. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  33186. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  33187. if (this._alphaMode === mode) {
  33188. return;
  33189. }
  33190. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33191. if (!noDepthWriteChange) {
  33192. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33193. }
  33194. this._alphaMode = mode;
  33195. };
  33196. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  33197. };
  33198. NullEngine.prototype.wipeCaches = function (bruteForce) {
  33199. if (this.preventCacheWipeBetweenFrames) {
  33200. return;
  33201. }
  33202. this.resetTextureCache();
  33203. this._currentEffect = null;
  33204. if (bruteForce) {
  33205. this._currentProgram = null;
  33206. this._stencilState.reset();
  33207. this._depthCullingState.reset();
  33208. this._alphaState.reset();
  33209. }
  33210. this._cachedVertexBuffers = null;
  33211. this._cachedIndexBuffer = null;
  33212. this._cachedEffectForVertexBuffers = null;
  33213. };
  33214. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  33215. };
  33216. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  33217. };
  33218. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  33219. };
  33220. /** @hidden */
  33221. NullEngine.prototype._createTexture = function () {
  33222. return {};
  33223. };
  33224. /** @hidden */
  33225. NullEngine.prototype._releaseTexture = function (texture) {
  33226. };
  33227. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  33228. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33229. if (onLoad === void 0) { onLoad = null; }
  33230. if (onError === void 0) { onError = null; }
  33231. if (buffer === void 0) { buffer = null; }
  33232. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  33233. var url = String(urlArg);
  33234. texture.url = url;
  33235. texture.generateMipMaps = !noMipmap;
  33236. texture.samplingMode = samplingMode;
  33237. texture.invertY = invertY;
  33238. texture.baseWidth = this._options.textureSize;
  33239. texture.baseHeight = this._options.textureSize;
  33240. texture.width = this._options.textureSize;
  33241. texture.height = this._options.textureSize;
  33242. if (format) {
  33243. texture.format = format;
  33244. }
  33245. texture.isReady = true;
  33246. if (onLoad) {
  33247. onLoad();
  33248. }
  33249. this._internalTexturesCache.push(texture);
  33250. return texture;
  33251. };
  33252. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  33253. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  33254. if (options !== undefined && typeof options === "object") {
  33255. fullOptions.generateMipMaps = options.generateMipMaps;
  33256. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  33257. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  33258. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  33259. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  33260. }
  33261. else {
  33262. fullOptions.generateMipMaps = options;
  33263. fullOptions.generateDepthBuffer = true;
  33264. fullOptions.generateStencilBuffer = false;
  33265. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33266. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33267. }
  33268. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  33269. var width = size.width || size;
  33270. var height = size.height || size;
  33271. texture._depthStencilBuffer = {};
  33272. texture._framebuffer = {};
  33273. texture.baseWidth = width;
  33274. texture.baseHeight = height;
  33275. texture.width = width;
  33276. texture.height = height;
  33277. texture.isReady = true;
  33278. texture.samples = 1;
  33279. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  33280. texture.samplingMode = fullOptions.samplingMode;
  33281. texture.type = fullOptions.type;
  33282. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  33283. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  33284. this._internalTexturesCache.push(texture);
  33285. return texture;
  33286. };
  33287. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  33288. texture.samplingMode = samplingMode;
  33289. };
  33290. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  33291. if (this._currentRenderTarget) {
  33292. this.unBindFramebuffer(this._currentRenderTarget);
  33293. }
  33294. this._currentRenderTarget = texture;
  33295. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  33296. if (this._cachedViewport && !forceFullscreenViewport) {
  33297. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  33298. }
  33299. };
  33300. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  33301. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  33302. this._currentRenderTarget = null;
  33303. if (onBeforeUnbind) {
  33304. if (texture._MSAAFramebuffer) {
  33305. this._currentFramebuffer = texture._framebuffer;
  33306. }
  33307. onBeforeUnbind();
  33308. }
  33309. this._currentFramebuffer = null;
  33310. };
  33311. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  33312. var vbo = {
  33313. capacity: 1,
  33314. references: 1,
  33315. is32Bits: false
  33316. };
  33317. return vbo;
  33318. };
  33319. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  33320. if (premulAlpha === void 0) { premulAlpha = false; }
  33321. };
  33322. NullEngine.prototype.areAllEffectsReady = function () {
  33323. return true;
  33324. };
  33325. /**
  33326. * @hidden
  33327. * Get the current error code of the webGL context
  33328. * @returns the error code
  33329. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33330. */
  33331. NullEngine.prototype.getError = function () {
  33332. return 0;
  33333. };
  33334. /** @hidden */
  33335. NullEngine.prototype._getUnpackAlignement = function () {
  33336. return 1;
  33337. };
  33338. /** @hidden */
  33339. NullEngine.prototype._unpackFlipY = function (value) {
  33340. };
  33341. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  33342. if (offset === void 0) { offset = 0; }
  33343. };
  33344. /**
  33345. * Updates a dynamic vertex buffer.
  33346. * @param vertexBuffer the vertex buffer to update
  33347. * @param data the data used to update the vertex buffer
  33348. * @param byteOffset the byte offset of the data (optional)
  33349. * @param byteLength the byte length of the data (optional)
  33350. */
  33351. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  33352. };
  33353. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  33354. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  33355. this._boundTexturesCache[this._activeChannel] = texture;
  33356. return true;
  33357. }
  33358. return false;
  33359. };
  33360. /** @hidden */
  33361. NullEngine.prototype._bindTexture = function (channel, texture) {
  33362. if (channel < 0) {
  33363. return;
  33364. }
  33365. this._bindTextureDirectly(0, texture);
  33366. };
  33367. /** @hidden */
  33368. NullEngine.prototype._releaseBuffer = function (buffer) {
  33369. buffer.references--;
  33370. if (buffer.references === 0) {
  33371. return true;
  33372. }
  33373. return false;
  33374. };
  33375. NullEngine.prototype.releaseEffects = function () {
  33376. };
  33377. NullEngine.prototype.displayLoadingUI = function () {
  33378. };
  33379. NullEngine.prototype.hideLoadingUI = function () {
  33380. };
  33381. /** @hidden */
  33382. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  33383. if (faceIndex === void 0) { faceIndex = 0; }
  33384. if (lod === void 0) { lod = 0; }
  33385. };
  33386. /** @hidden */
  33387. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  33388. if (faceIndex === void 0) { faceIndex = 0; }
  33389. if (lod === void 0) { lod = 0; }
  33390. };
  33391. /** @hidden */
  33392. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  33393. if (faceIndex === void 0) { faceIndex = 0; }
  33394. if (lod === void 0) { lod = 0; }
  33395. };
  33396. /** @hidden */
  33397. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  33398. if (faceIndex === void 0) { faceIndex = 0; }
  33399. if (lod === void 0) { lod = 0; }
  33400. };
  33401. return NullEngine;
  33402. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  33403. /***/ }),
  33404. /***/ "./Events/clipboardEvents.ts":
  33405. /*!***********************************!*\
  33406. !*** ./Events/clipboardEvents.ts ***!
  33407. \***********************************/
  33408. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  33409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33410. "use strict";
  33411. __webpack_require__.r(__webpack_exports__);
  33412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  33413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  33414. /**
  33415. * Gather the list of clipboard event types as constants.
  33416. */
  33417. var ClipboardEventTypes = /** @class */ (function () {
  33418. function ClipboardEventTypes() {
  33419. }
  33420. /**
  33421. * The clipboard event is fired when a copy command is active (pressed).
  33422. */
  33423. ClipboardEventTypes.COPY = 0x01; //
  33424. /**
  33425. * The clipboard event is fired when a cut command is active (pressed).
  33426. */
  33427. ClipboardEventTypes.CUT = 0x02;
  33428. /**
  33429. * The clipboard event is fired when a paste command is active (pressed).
  33430. */
  33431. ClipboardEventTypes.PASTE = 0x03;
  33432. return ClipboardEventTypes;
  33433. }());
  33434. /**
  33435. * This class is used to store clipboard related info for the onClipboardObservable event.
  33436. */
  33437. var ClipboardInfo = /** @class */ (function () {
  33438. /**
  33439. *Creates an instance of ClipboardInfo.
  33440. * @param {number} type
  33441. * @param {ClipboardEvent} event
  33442. */
  33443. function ClipboardInfo(
  33444. /**
  33445. * Defines the type of event (BABYLON.ClipboardEventTypes)
  33446. */
  33447. type,
  33448. /**
  33449. * Defines the related dom event
  33450. */
  33451. event) {
  33452. this.type = type;
  33453. this.event = event;
  33454. }
  33455. /**
  33456. * Get the clipboard event's type from the keycode.
  33457. * @param keyCode Defines the keyCode for the current keyboard event.
  33458. * @return {number}
  33459. */
  33460. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  33461. var charCode = keyCode;
  33462. //TODO: add codes for extended ASCII
  33463. switch (charCode) {
  33464. case 67: return ClipboardEventTypes.COPY;
  33465. case 86: return ClipboardEventTypes.PASTE;
  33466. case 88: return ClipboardEventTypes.CUT;
  33467. default: return -1;
  33468. }
  33469. };
  33470. return ClipboardInfo;
  33471. }());
  33472. /***/ }),
  33473. /***/ "./Events/index.ts":
  33474. /*!*************************!*\
  33475. !*** ./Events/index.ts ***!
  33476. \*************************/
  33477. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  33478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33479. "use strict";
  33480. __webpack_require__.r(__webpack_exports__);
  33481. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  33482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  33483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  33484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  33485. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  33486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  33487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  33488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  33489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  33490. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  33491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  33492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  33493. /***/ }),
  33494. /***/ "./Events/keyboardEvents.ts":
  33495. /*!**********************************!*\
  33496. !*** ./Events/keyboardEvents.ts ***!
  33497. \**********************************/
  33498. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  33499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33500. "use strict";
  33501. __webpack_require__.r(__webpack_exports__);
  33502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  33503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  33504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  33505. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33506. /**
  33507. * Gather the list of keyboard event types as constants.
  33508. */
  33509. var KeyboardEventTypes = /** @class */ (function () {
  33510. function KeyboardEventTypes() {
  33511. }
  33512. /**
  33513. * The keydown event is fired when a key becomes active (pressed).
  33514. */
  33515. KeyboardEventTypes.KEYDOWN = 0x01;
  33516. /**
  33517. * The keyup event is fired when a key has been released.
  33518. */
  33519. KeyboardEventTypes.KEYUP = 0x02;
  33520. return KeyboardEventTypes;
  33521. }());
  33522. /**
  33523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33524. */
  33525. var KeyboardInfo = /** @class */ (function () {
  33526. /**
  33527. * Instantiates a new keyboard info.
  33528. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33529. * @param type Defines the type of event (KeyboardEventTypes)
  33530. * @param event Defines the related dom event
  33531. */
  33532. function KeyboardInfo(
  33533. /**
  33534. * Defines the type of event (KeyboardEventTypes)
  33535. */
  33536. type,
  33537. /**
  33538. * Defines the related dom event
  33539. */
  33540. event) {
  33541. this.type = type;
  33542. this.event = event;
  33543. }
  33544. return KeyboardInfo;
  33545. }());
  33546. /**
  33547. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33548. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  33549. */
  33550. var KeyboardInfoPre = /** @class */ (function (_super) {
  33551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  33552. /**
  33553. * Instantiates a new keyboard pre info.
  33554. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33555. * @param type Defines the type of event (KeyboardEventTypes)
  33556. * @param event Defines the related dom event
  33557. */
  33558. function KeyboardInfoPre(
  33559. /**
  33560. * Defines the type of event (KeyboardEventTypes)
  33561. */
  33562. type,
  33563. /**
  33564. * Defines the related dom event
  33565. */
  33566. event) {
  33567. var _this = _super.call(this, type, event) || this;
  33568. _this.type = type;
  33569. _this.event = event;
  33570. _this.skipOnPointerObservable = false;
  33571. return _this;
  33572. }
  33573. return KeyboardInfoPre;
  33574. }(KeyboardInfo));
  33575. /***/ }),
  33576. /***/ "./Events/pointerEvents.ts":
  33577. /*!*********************************!*\
  33578. !*** ./Events/pointerEvents.ts ***!
  33579. \*********************************/
  33580. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  33581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33582. "use strict";
  33583. __webpack_require__.r(__webpack_exports__);
  33584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  33585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  33586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  33587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  33588. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  33590. /**
  33591. * Gather the list of pointer event types as constants.
  33592. */
  33593. var PointerEventTypes = /** @class */ (function () {
  33594. function PointerEventTypes() {
  33595. }
  33596. /**
  33597. * 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.
  33598. */
  33599. PointerEventTypes.POINTERDOWN = 0x01;
  33600. /**
  33601. * The pointerup event is fired when a pointer is no longer active.
  33602. */
  33603. PointerEventTypes.POINTERUP = 0x02;
  33604. /**
  33605. * The pointermove event is fired when a pointer changes coordinates.
  33606. */
  33607. PointerEventTypes.POINTERMOVE = 0x04;
  33608. /**
  33609. * The pointerwheel event is fired when a mouse wheel has been rotated.
  33610. */
  33611. PointerEventTypes.POINTERWHEEL = 0x08;
  33612. /**
  33613. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  33614. */
  33615. PointerEventTypes.POINTERPICK = 0x10;
  33616. /**
  33617. * The pointertap event is fired when a the object has been touched and released without drag.
  33618. */
  33619. PointerEventTypes.POINTERTAP = 0x20;
  33620. /**
  33621. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  33622. */
  33623. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  33624. return PointerEventTypes;
  33625. }());
  33626. /**
  33627. * Base class of pointer info types.
  33628. */
  33629. var PointerInfoBase = /** @class */ (function () {
  33630. /**
  33631. * Instantiates the base class of pointers info.
  33632. * @param type Defines the type of event (PointerEventTypes)
  33633. * @param event Defines the related dom event
  33634. */
  33635. function PointerInfoBase(
  33636. /**
  33637. * Defines the type of event (PointerEventTypes)
  33638. */
  33639. type,
  33640. /**
  33641. * Defines the related dom event
  33642. */
  33643. event) {
  33644. this.type = type;
  33645. this.event = event;
  33646. }
  33647. return PointerInfoBase;
  33648. }());
  33649. /**
  33650. * This class is used to store pointer related info for the onPrePointerObservable event.
  33651. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  33652. */
  33653. var PointerInfoPre = /** @class */ (function (_super) {
  33654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  33655. /**
  33656. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  33657. * @param type Defines the type of event (PointerEventTypes)
  33658. * @param event Defines the related dom event
  33659. * @param localX Defines the local x coordinates of the pointer when the event occured
  33660. * @param localY Defines the local y coordinates of the pointer when the event occured
  33661. */
  33662. function PointerInfoPre(type, event, localX, localY) {
  33663. var _this = _super.call(this, type, event) || this;
  33664. /**
  33665. * Ray from a pointer if availible (eg. 6dof controller)
  33666. */
  33667. _this.ray = null;
  33668. _this.skipOnPointerObservable = false;
  33669. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  33670. return _this;
  33671. }
  33672. return PointerInfoPre;
  33673. }(PointerInfoBase));
  33674. /**
  33675. * This type contains all the data related to a pointer event in Babylon.js.
  33676. * 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.
  33677. */
  33678. var PointerInfo = /** @class */ (function (_super) {
  33679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  33680. /**
  33681. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  33682. * @param type Defines the type of event (PointerEventTypes)
  33683. * @param event Defines the related dom event
  33684. * @param pickInfo Defines the picking info associated to the info (if any)\
  33685. */
  33686. function PointerInfo(type, event,
  33687. /**
  33688. * Defines the picking info associated to the info (if any)\
  33689. */
  33690. pickInfo) {
  33691. var _this = _super.call(this, type, event) || this;
  33692. _this.pickInfo = pickInfo;
  33693. return _this;
  33694. }
  33695. return PointerInfo;
  33696. }(PointerInfoBase));
  33697. /***/ }),
  33698. /***/ "./Gamepads/Controllers/daydreamController.ts":
  33699. /*!****************************************************!*\
  33700. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  33701. \****************************************************/
  33702. /*! exports provided: DaydreamController */
  33703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33704. "use strict";
  33705. __webpack_require__.r(__webpack_exports__);
  33706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  33707. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33708. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  33709. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33710. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33711. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33712. /**
  33713. * Google Daydream controller
  33714. */
  33715. var DaydreamController = /** @class */ (function (_super) {
  33716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  33717. /**
  33718. * Creates a new DaydreamController from a gamepad
  33719. * @param vrGamepad the gamepad that the controller should be created from
  33720. */
  33721. function DaydreamController(vrGamepad) {
  33722. var _this = _super.call(this, vrGamepad) || this;
  33723. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  33724. return _this;
  33725. }
  33726. /**
  33727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33728. * @param scene scene in which to add meshes
  33729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33730. */
  33731. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33732. var _this = this;
  33733. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  33734. _this._defaultModel = newMeshes[1];
  33735. _this.attachToMesh(_this._defaultModel);
  33736. if (meshLoaded) {
  33737. meshLoaded(_this._defaultModel);
  33738. }
  33739. });
  33740. };
  33741. /**
  33742. * Called once for each button that changed state since the last frame
  33743. * @param buttonIdx Which button index changed
  33744. * @param state New state of the button
  33745. * @param changes Which properties on the state changed since last frame
  33746. */
  33747. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  33748. // Daydream controller only has 1 GamepadButton (on the trackpad).
  33749. if (buttonIdx === 0) {
  33750. var observable = this.onTriggerStateChangedObservable;
  33751. if (observable) {
  33752. observable.notifyObservers(state);
  33753. }
  33754. }
  33755. else {
  33756. // If the app or home buttons are ever made available
  33757. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  33758. }
  33759. };
  33760. /**
  33761. * Base Url for the controller model.
  33762. */
  33763. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  33764. /**
  33765. * File name for the controller model.
  33766. */
  33767. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  33768. /**
  33769. * Gamepad Id prefix used to identify Daydream Controller.
  33770. */
  33771. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  33772. return DaydreamController;
  33773. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  33774. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  33775. canCreate: function (gamepadInfo) {
  33776. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  33777. },
  33778. create: function (gamepadInfo) {
  33779. return new DaydreamController(gamepadInfo);
  33780. }
  33781. });
  33782. /***/ }),
  33783. /***/ "./Gamepads/Controllers/gearVRController.ts":
  33784. /*!**************************************************!*\
  33785. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  33786. \**************************************************/
  33787. /*! exports provided: GearVRController */
  33788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33789. "use strict";
  33790. __webpack_require__.r(__webpack_exports__);
  33791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  33792. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33793. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  33794. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  33795. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33796. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33797. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33798. /**
  33799. * Gear VR Controller
  33800. */
  33801. var GearVRController = /** @class */ (function (_super) {
  33802. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  33803. /**
  33804. * Creates a new GearVRController from a gamepad
  33805. * @param vrGamepad the gamepad that the controller should be created from
  33806. */
  33807. function GearVRController(vrGamepad) {
  33808. var _this = _super.call(this, vrGamepad) || this;
  33809. _this._buttonIndexToObservableNameMap = [
  33810. 'onTrackpadChangedObservable',
  33811. 'onTriggerStateChangedObservable' // Trigger
  33812. ];
  33813. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  33814. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  33815. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  33816. _this._disableTrackPosition(_this._calculatedPosition);
  33817. return _this;
  33818. }
  33819. /**
  33820. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33821. * @param scene scene in which to add meshes
  33822. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33823. */
  33824. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33825. var _this = this;
  33826. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  33827. // Offset the controller so it will rotate around the users wrist
  33828. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  33829. newMeshes[1].parent = mesh;
  33830. newMeshes[1].position.z = -0.15;
  33831. _this._defaultModel = mesh;
  33832. _this.attachToMesh(_this._defaultModel);
  33833. if (meshLoaded) {
  33834. meshLoaded(_this._defaultModel);
  33835. }
  33836. });
  33837. };
  33838. /**
  33839. * Called once for each button that changed state since the last frame
  33840. * @param buttonIdx Which button index changed
  33841. * @param state New state of the button
  33842. * @param changes Which properties on the state changed since last frame
  33843. */
  33844. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  33845. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  33846. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  33847. // Only emit events for buttons that we know how to map from index to observable
  33848. var observable = this[observableName];
  33849. if (observable) {
  33850. observable.notifyObservers(state);
  33851. }
  33852. }
  33853. };
  33854. /**
  33855. * Base Url for the controller model.
  33856. */
  33857. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  33858. /**
  33859. * File name for the controller model.
  33860. */
  33861. GearVRController.MODEL_FILENAME = 'generic.babylon';
  33862. /**
  33863. * Gamepad Id prefix used to identify this controller.
  33864. */
  33865. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  33866. return GearVRController;
  33867. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  33868. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  33869. canCreate: function (gamepadInfo) {
  33870. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  33871. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  33872. },
  33873. create: function (gamepadInfo) {
  33874. return new GearVRController(gamepadInfo);
  33875. }
  33876. });
  33877. /***/ }),
  33878. /***/ "./Gamepads/Controllers/genericController.ts":
  33879. /*!***************************************************!*\
  33880. !*** ./Gamepads/Controllers/genericController.ts ***!
  33881. \***************************************************/
  33882. /*! exports provided: GenericController */
  33883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33884. "use strict";
  33885. __webpack_require__.r(__webpack_exports__);
  33886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  33887. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33888. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33889. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33890. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33891. /**
  33892. * Generic Controller
  33893. */
  33894. var GenericController = /** @class */ (function (_super) {
  33895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  33896. /**
  33897. * Creates a new GenericController from a gamepad
  33898. * @param vrGamepad the gamepad that the controller should be created from
  33899. */
  33900. function GenericController(vrGamepad) {
  33901. return _super.call(this, vrGamepad) || this;
  33902. }
  33903. /**
  33904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33905. * @param scene scene in which to add meshes
  33906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33907. */
  33908. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33909. var _this = this;
  33910. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  33911. _this._defaultModel = newMeshes[1];
  33912. _this.attachToMesh(_this._defaultModel);
  33913. if (meshLoaded) {
  33914. meshLoaded(_this._defaultModel);
  33915. }
  33916. });
  33917. };
  33918. /**
  33919. * Called once for each button that changed state since the last frame
  33920. * @param buttonIdx Which button index changed
  33921. * @param state New state of the button
  33922. * @param changes Which properties on the state changed since last frame
  33923. */
  33924. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  33925. console.log("Button id: " + buttonIdx + "state: ");
  33926. console.dir(state);
  33927. };
  33928. /**
  33929. * Base Url for the controller model.
  33930. */
  33931. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  33932. /**
  33933. * File name for the controller model.
  33934. */
  33935. GenericController.MODEL_FILENAME = 'generic.babylon';
  33936. return GenericController;
  33937. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  33938. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  33939. /***/ }),
  33940. /***/ "./Gamepads/Controllers/index.ts":
  33941. /*!***************************************!*\
  33942. !*** ./Gamepads/Controllers/index.ts ***!
  33943. \***************************************/
  33944. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  33945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33946. "use strict";
  33947. __webpack_require__.r(__webpack_exports__);
  33948. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  33949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  33950. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  33951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  33952. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  33953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  33954. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  33955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  33956. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  33958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  33959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  33960. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  33961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  33962. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  33964. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  33965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  33966. /***/ }),
  33967. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  33968. /*!*******************************************************!*\
  33969. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  33970. \*******************************************************/
  33971. /*! exports provided: OculusTouchController */
  33972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33973. "use strict";
  33974. __webpack_require__.r(__webpack_exports__);
  33975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  33976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33977. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  33978. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33979. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33980. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33981. /**
  33982. * Oculus Touch Controller
  33983. */
  33984. var OculusTouchController = /** @class */ (function (_super) {
  33985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  33986. /**
  33987. * Creates a new OculusTouchController from a gamepad
  33988. * @param vrGamepad the gamepad that the controller should be created from
  33989. */
  33990. function OculusTouchController(vrGamepad) {
  33991. var _this = _super.call(this, vrGamepad) || this;
  33992. /**
  33993. * Fired when the secondary trigger on this controller is modified
  33994. */
  33995. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  33996. /**
  33997. * Fired when the thumb rest on this controller is modified
  33998. */
  33999. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34000. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34001. return _this;
  34002. }
  34003. /**
  34004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34005. * @param scene scene in which to add meshes
  34006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34007. */
  34008. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34009. var _this = this;
  34010. var meshName;
  34011. // Hand
  34012. if (this.hand === 'left') {
  34013. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34014. }
  34015. else { // Right is the default if no hand is specified
  34016. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34017. }
  34018. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34019. /*
  34020. Parent Mesh name: oculus_touch_left
  34021. - body
  34022. - trigger
  34023. - thumbstick
  34024. - grip
  34025. - button_y
  34026. - button_x
  34027. - button_enter
  34028. */
  34029. _this._defaultModel = newMeshes[1];
  34030. _this.attachToMesh(_this._defaultModel);
  34031. if (meshLoaded) {
  34032. meshLoaded(_this._defaultModel);
  34033. }
  34034. });
  34035. };
  34036. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34037. /**
  34038. * Fired when the A button on this controller is modified
  34039. */
  34040. get: function () {
  34041. if (this.hand === 'right') {
  34042. return this.onMainButtonStateChangedObservable;
  34043. }
  34044. else {
  34045. throw new Error('No A button on left hand');
  34046. }
  34047. },
  34048. enumerable: true,
  34049. configurable: true
  34050. });
  34051. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34052. /**
  34053. * Fired when the B button on this controller is modified
  34054. */
  34055. get: function () {
  34056. if (this.hand === 'right') {
  34057. return this.onSecondaryButtonStateChangedObservable;
  34058. }
  34059. else {
  34060. throw new Error('No B button on left hand');
  34061. }
  34062. },
  34063. enumerable: true,
  34064. configurable: true
  34065. });
  34066. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34067. /**
  34068. * Fired when the X button on this controller is modified
  34069. */
  34070. get: function () {
  34071. if (this.hand === 'left') {
  34072. return this.onMainButtonStateChangedObservable;
  34073. }
  34074. else {
  34075. throw new Error('No X button on right hand');
  34076. }
  34077. },
  34078. enumerable: true,
  34079. configurable: true
  34080. });
  34081. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34082. /**
  34083. * Fired when the Y button on this controller is modified
  34084. */
  34085. get: function () {
  34086. if (this.hand === 'left') {
  34087. return this.onSecondaryButtonStateChangedObservable;
  34088. }
  34089. else {
  34090. throw new Error('No Y button on right hand');
  34091. }
  34092. },
  34093. enumerable: true,
  34094. configurable: true
  34095. });
  34096. /**
  34097. * Called once for each button that changed state since the last frame
  34098. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34099. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34100. * 2) secondary trigger (same)
  34101. * 3) A (right) X (left), touch, pressed = value
  34102. * 4) B / Y
  34103. * 5) thumb rest
  34104. * @param buttonIdx Which button index changed
  34105. * @param state New state of the button
  34106. * @param changes Which properties on the state changed since last frame
  34107. */
  34108. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34109. var notifyObject = state; //{ state: state, changes: changes };
  34110. var triggerDirection = this.hand === 'right' ? -1 : 1;
  34111. switch (buttonIdx) {
  34112. case 0:
  34113. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34114. return;
  34115. case 1: // index trigger
  34116. if (this._defaultModel) {
  34117. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  34118. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  34119. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  34120. }
  34121. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34122. return;
  34123. case 2: // secondary trigger
  34124. if (this._defaultModel) {
  34125. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  34126. }
  34127. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  34128. return;
  34129. case 3:
  34130. if (this._defaultModel) {
  34131. if (notifyObject.pressed) {
  34132. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  34133. }
  34134. else {
  34135. (this._defaultModel.getChildren()[1]).position.y = 0;
  34136. }
  34137. }
  34138. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34139. return;
  34140. case 4:
  34141. if (this._defaultModel) {
  34142. if (notifyObject.pressed) {
  34143. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34144. }
  34145. else {
  34146. (this._defaultModel.getChildren()[2]).position.y = 0;
  34147. }
  34148. }
  34149. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34150. return;
  34151. case 5:
  34152. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  34153. return;
  34154. }
  34155. };
  34156. /**
  34157. * Base Url for the controller model.
  34158. */
  34159. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  34160. /**
  34161. * File name for the left controller model.
  34162. */
  34163. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  34164. /**
  34165. * File name for the right controller model.
  34166. */
  34167. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  34168. return OculusTouchController;
  34169. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34170. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34171. canCreate: function (gamepadInfo) {
  34172. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  34173. },
  34174. create: function (gamepadInfo) {
  34175. return new OculusTouchController(gamepadInfo);
  34176. }
  34177. });
  34178. /***/ }),
  34179. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  34180. /*!*******************************************************!*\
  34181. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  34182. \*******************************************************/
  34183. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  34184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34185. "use strict";
  34186. __webpack_require__.r(__webpack_exports__);
  34187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  34188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  34189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  34190. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34191. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34192. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34193. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34194. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  34195. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  34196. /**
  34197. * Defines the types of pose enabled controllers that are supported
  34198. */
  34199. var PoseEnabledControllerType;
  34200. (function (PoseEnabledControllerType) {
  34201. /**
  34202. * HTC Vive
  34203. */
  34204. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  34205. /**
  34206. * Oculus Rift
  34207. */
  34208. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  34209. /**
  34210. * Windows mixed reality
  34211. */
  34212. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  34213. /**
  34214. * Samsung gear VR
  34215. */
  34216. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  34217. /**
  34218. * Google Daydream
  34219. */
  34220. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  34221. /**
  34222. * Generic
  34223. */
  34224. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  34225. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  34226. /**
  34227. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34228. */
  34229. var PoseEnabledControllerHelper = /** @class */ (function () {
  34230. function PoseEnabledControllerHelper() {
  34231. }
  34232. /**
  34233. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34234. * @param vrGamepad the gamepad to initialized
  34235. * @returns a vr controller of the type the gamepad identified as
  34236. */
  34237. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  34238. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  34239. var factory = _a[_i];
  34240. if (factory.canCreate(vrGamepad)) {
  34241. return factory.create(vrGamepad);
  34242. }
  34243. }
  34244. if (this._DefaultControllerFactory) {
  34245. return this._DefaultControllerFactory(vrGamepad);
  34246. }
  34247. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  34248. };
  34249. /** @hidden */
  34250. PoseEnabledControllerHelper._ControllerFactories = [];
  34251. /** @hidden */
  34252. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  34253. return PoseEnabledControllerHelper;
  34254. }());
  34255. /**
  34256. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34257. */
  34258. var PoseEnabledController = /** @class */ (function (_super) {
  34259. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  34260. /**
  34261. * Creates a new PoseEnabledController from a gamepad
  34262. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34263. */
  34264. function PoseEnabledController(browserGamepad) {
  34265. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  34266. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  34267. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34268. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34269. /**
  34270. * The device position in babylon space
  34271. */
  34272. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34273. /**
  34274. * The device rotation in babylon space
  34275. */
  34276. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34277. /**
  34278. * The scale factor of the device in babylon space
  34279. */
  34280. _this.deviceScaleFactor = 1;
  34281. // Used to convert 6dof controllers to 3dof
  34282. _this._trackPosition = true;
  34283. _this._maxRotationDistFromHeadset = Math.PI / 5;
  34284. _this._draggedRoomRotation = 0;
  34285. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34286. /**
  34287. * Internal, matrix used to convert room space to babylon space
  34288. * @hidden
  34289. */
  34290. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34291. /**
  34292. * Node to be used when casting a ray from the controller
  34293. * @hidden
  34294. */
  34295. _this._pointingPoseNode = null;
  34296. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34297. /**
  34298. * @hidden
  34299. */
  34300. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34301. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  34302. _this.controllerType = PoseEnabledControllerType.GENERIC;
  34303. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34304. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34305. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34306. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34307. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  34308. return _this;
  34309. }
  34310. /**
  34311. * @hidden
  34312. */
  34313. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  34314. if (this._trackPosition) {
  34315. this._calculatedPosition.copyFrom(fixedPosition);
  34316. this._trackPosition = false;
  34317. }
  34318. };
  34319. /**
  34320. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34321. */
  34322. PoseEnabledController.prototype.update = function () {
  34323. _super.prototype.update.call(this);
  34324. this._updatePoseAndMesh();
  34325. };
  34326. /**
  34327. * Updates only the pose device and mesh without doing any button event checking
  34328. */
  34329. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  34330. var pose = this.browserGamepad.pose;
  34331. this.updateFromDevice(pose);
  34332. 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) {
  34333. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  34334. camera._computeDevicePosition();
  34335. this._deviceToWorld.setTranslation(camera.devicePosition);
  34336. if (camera.deviceRotationQuaternion) {
  34337. var camera = camera;
  34338. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  34339. // Find the radian distance away that the headset is from the controllers rotation
  34340. 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));
  34341. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  34342. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  34343. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  34344. this._draggedRoomRotation += rotationAmount;
  34345. // Rotate controller around headset
  34346. var sin = Math.sin(-rotationAmount);
  34347. var cos = Math.cos(-rotationAmount);
  34348. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  34349. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  34350. }
  34351. }
  34352. }
  34353. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  34354. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  34355. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  34356. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  34357. if (this._mesh) {
  34358. this._mesh.position.copyFrom(this.devicePosition);
  34359. if (this._mesh.rotationQuaternion) {
  34360. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  34361. }
  34362. }
  34363. };
  34364. /**
  34365. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34366. * @param poseData raw pose fromthe device
  34367. */
  34368. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  34369. if (poseData) {
  34370. this.rawPose = poseData;
  34371. if (poseData.position) {
  34372. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  34373. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  34374. this._deviceRoomPosition.z *= -1;
  34375. }
  34376. if (this._trackPosition) {
  34377. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  34378. }
  34379. this._calculatedPosition.addInPlace(this.position);
  34380. }
  34381. var pose = this.rawPose;
  34382. if (poseData.orientation && pose.orientation) {
  34383. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  34384. if (this._mesh) {
  34385. if (this._mesh.getScene().useRightHandedSystem) {
  34386. this._deviceRoomRotationQuaternion.z *= -1;
  34387. this._deviceRoomRotationQuaternion.w *= -1;
  34388. }
  34389. else {
  34390. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  34391. }
  34392. }
  34393. // if the camera is set, rotate to the camera's rotation
  34394. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  34395. }
  34396. }
  34397. };
  34398. /**
  34399. * Attaches a mesh to the controller
  34400. * @param mesh the mesh to be attached
  34401. */
  34402. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  34403. if (this._mesh) {
  34404. this._mesh.parent = null;
  34405. }
  34406. this._mesh = mesh;
  34407. if (this._poseControlledCamera) {
  34408. this._mesh.parent = this._poseControlledCamera;
  34409. }
  34410. if (!this._mesh.rotationQuaternion) {
  34411. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34412. }
  34413. // 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
  34414. this._updatePoseAndMesh();
  34415. if (this._pointingPoseNode) {
  34416. var parents = [];
  34417. var obj = this._pointingPoseNode;
  34418. while (obj.parent) {
  34419. parents.push(obj.parent);
  34420. obj = obj.parent;
  34421. }
  34422. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  34423. }
  34424. this._meshAttachedObservable.notifyObservers(mesh);
  34425. };
  34426. /**
  34427. * Attaches the controllers mesh to a camera
  34428. * @param camera the camera the mesh should be attached to
  34429. */
  34430. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  34431. this._poseControlledCamera = camera;
  34432. if (this._mesh) {
  34433. this._mesh.parent = this._poseControlledCamera;
  34434. }
  34435. };
  34436. /**
  34437. * Disposes of the controller
  34438. */
  34439. PoseEnabledController.prototype.dispose = function () {
  34440. if (this._mesh) {
  34441. this._mesh.dispose();
  34442. }
  34443. this._mesh = null;
  34444. _super.prototype.dispose.call(this);
  34445. };
  34446. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  34447. /**
  34448. * The mesh that is attached to the controller
  34449. */
  34450. get: function () {
  34451. return this._mesh;
  34452. },
  34453. enumerable: true,
  34454. configurable: true
  34455. });
  34456. /**
  34457. * Gets the ray of the controller in the direction the controller is pointing
  34458. * @param length the length the resulting ray should be
  34459. * @returns a ray in the direction the controller is pointing
  34460. */
  34461. PoseEnabledController.prototype.getForwardRay = function (length) {
  34462. if (length === void 0) { length = 100; }
  34463. if (!this.mesh) {
  34464. 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);
  34465. }
  34466. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  34467. var origin = m.getTranslation();
  34468. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  34469. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  34470. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  34471. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  34472. };
  34473. /**
  34474. * Name of the child mesh that can be used to cast a ray from the controller
  34475. */
  34476. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  34477. return PoseEnabledController;
  34478. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  34479. /***/ }),
  34480. /***/ "./Gamepads/Controllers/viveController.ts":
  34481. /*!************************************************!*\
  34482. !*** ./Gamepads/Controllers/viveController.ts ***!
  34483. \************************************************/
  34484. /*! exports provided: ViveController */
  34485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34486. "use strict";
  34487. __webpack_require__.r(__webpack_exports__);
  34488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  34489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34490. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34491. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34492. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34493. /**
  34494. * Vive Controller
  34495. */
  34496. var ViveController = /** @class */ (function (_super) {
  34497. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  34498. /**
  34499. * Creates a new ViveController from a gamepad
  34500. * @param vrGamepad the gamepad that the controller should be created from
  34501. */
  34502. function ViveController(vrGamepad) {
  34503. var _this = _super.call(this, vrGamepad) || this;
  34504. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  34505. _this._invertLeftStickY = true;
  34506. return _this;
  34507. }
  34508. /**
  34509. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34510. * @param scene scene in which to add meshes
  34511. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34512. */
  34513. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34514. var _this = this;
  34515. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  34516. /*
  34517. Parent Mesh name: ViveWand
  34518. - body
  34519. - r_gripper
  34520. - l_gripper
  34521. - menu_button
  34522. - system_button
  34523. - trackpad
  34524. - trigger
  34525. - LED
  34526. */
  34527. _this._defaultModel = newMeshes[1];
  34528. _this.attachToMesh(_this._defaultModel);
  34529. if (meshLoaded) {
  34530. meshLoaded(_this._defaultModel);
  34531. }
  34532. });
  34533. };
  34534. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  34535. /**
  34536. * Fired when the left button on this controller is modified
  34537. */
  34538. get: function () {
  34539. return this.onMainButtonStateChangedObservable;
  34540. },
  34541. enumerable: true,
  34542. configurable: true
  34543. });
  34544. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  34545. /**
  34546. * Fired when the right button on this controller is modified
  34547. */
  34548. get: function () {
  34549. return this.onMainButtonStateChangedObservable;
  34550. },
  34551. enumerable: true,
  34552. configurable: true
  34553. });
  34554. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  34555. /**
  34556. * Fired when the menu button on this controller is modified
  34557. */
  34558. get: function () {
  34559. return this.onSecondaryButtonStateChangedObservable;
  34560. },
  34561. enumerable: true,
  34562. configurable: true
  34563. });
  34564. /**
  34565. * Called once for each button that changed state since the last frame
  34566. * Vive mapping:
  34567. * 0: touchpad
  34568. * 1: trigger
  34569. * 2: left AND right buttons
  34570. * 3: menu button
  34571. * @param buttonIdx Which button index changed
  34572. * @param state New state of the button
  34573. * @param changes Which properties on the state changed since last frame
  34574. */
  34575. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34576. var notifyObject = state; //{ state: state, changes: changes };
  34577. switch (buttonIdx) {
  34578. case 0:
  34579. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34580. return;
  34581. case 1: // index trigger
  34582. if (this._defaultModel) {
  34583. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  34584. }
  34585. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34586. return;
  34587. case 2: // left AND right button
  34588. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34589. return;
  34590. case 3:
  34591. if (this._defaultModel) {
  34592. if (notifyObject.pressed) {
  34593. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34594. }
  34595. else {
  34596. (this._defaultModel.getChildren()[2]).position.y = 0;
  34597. }
  34598. }
  34599. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34600. return;
  34601. }
  34602. };
  34603. /**
  34604. * Base Url for the controller model.
  34605. */
  34606. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  34607. /**
  34608. * File name for the controller model.
  34609. */
  34610. ViveController.MODEL_FILENAME = 'wand.babylon';
  34611. return ViveController;
  34612. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34613. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34614. canCreate: function (gamepadInfo) {
  34615. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  34616. },
  34617. create: function (gamepadInfo) {
  34618. return new ViveController(gamepadInfo);
  34619. }
  34620. });
  34621. /***/ }),
  34622. /***/ "./Gamepads/Controllers/webVRController.ts":
  34623. /*!*************************************************!*\
  34624. !*** ./Gamepads/Controllers/webVRController.ts ***!
  34625. \*************************************************/
  34626. /*! exports provided: WebVRController */
  34627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34628. "use strict";
  34629. __webpack_require__.r(__webpack_exports__);
  34630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  34631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34632. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34633. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34634. /**
  34635. * Defines the WebVRController object that represents controllers tracked in 3D space
  34636. */
  34637. var WebVRController = /** @class */ (function (_super) {
  34638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  34639. /**
  34640. * Creates a new WebVRController from a gamepad
  34641. * @param vrGamepad the gamepad that the WebVRController should be created from
  34642. */
  34643. function WebVRController(vrGamepad) {
  34644. var _this = _super.call(this, vrGamepad) || this;
  34645. // Observables
  34646. /**
  34647. * Fired when the trigger state has changed
  34648. */
  34649. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34650. /**
  34651. * Fired when the main button state has changed
  34652. */
  34653. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34654. /**
  34655. * Fired when the secondary button state has changed
  34656. */
  34657. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34658. /**
  34659. * Fired when the pad state has changed
  34660. */
  34661. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34662. /**
  34663. * Fired when controllers stick values have changed
  34664. */
  34665. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34666. /**
  34667. * X and Y axis corrisponding to the controllers joystick
  34668. */
  34669. _this.pad = { x: 0, y: 0 };
  34670. // avoid GC, store state in a tmp object
  34671. _this._changes = {
  34672. pressChanged: false,
  34673. touchChanged: false,
  34674. valueChanged: false,
  34675. changed: false
  34676. };
  34677. _this._buttons = new Array(vrGamepad.buttons.length);
  34678. _this.hand = vrGamepad.hand;
  34679. return _this;
  34680. }
  34681. /**
  34682. * Fired when a controller button's state has changed
  34683. * @param callback the callback containing the button that was modified
  34684. */
  34685. WebVRController.prototype.onButtonStateChange = function (callback) {
  34686. this._onButtonStateChange = callback;
  34687. };
  34688. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  34689. /**
  34690. * The default controller model for the controller
  34691. */
  34692. get: function () {
  34693. return this._defaultModel;
  34694. },
  34695. enumerable: true,
  34696. configurable: true
  34697. });
  34698. /**
  34699. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34700. */
  34701. WebVRController.prototype.update = function () {
  34702. _super.prototype.update.call(this);
  34703. for (var index = 0; index < this._buttons.length; index++) {
  34704. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  34705. }
  34706. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  34707. this.pad.x = this.leftStick.x;
  34708. this.pad.y = this.leftStick.y;
  34709. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  34710. }
  34711. };
  34712. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  34713. if (!newState) {
  34714. newState = {
  34715. pressed: false,
  34716. touched: false,
  34717. value: 0
  34718. };
  34719. }
  34720. if (!currentState) {
  34721. this._buttons[buttonIndex] = {
  34722. pressed: newState.pressed,
  34723. touched: newState.touched,
  34724. value: newState.value
  34725. };
  34726. return;
  34727. }
  34728. this._checkChanges(newState, currentState);
  34729. if (this._changes.changed) {
  34730. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  34731. this._handleButtonChange(buttonIndex, newState, this._changes);
  34732. }
  34733. this._buttons[buttonIndex].pressed = newState.pressed;
  34734. this._buttons[buttonIndex].touched = newState.touched;
  34735. // oculus triggers are never 0, thou not touched.
  34736. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  34737. };
  34738. WebVRController.prototype._checkChanges = function (newState, currentState) {
  34739. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  34740. this._changes.touchChanged = newState.touched !== currentState.touched;
  34741. this._changes.valueChanged = newState.value !== currentState.value;
  34742. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  34743. return this._changes;
  34744. };
  34745. /**
  34746. * Disposes of th webVRCOntroller
  34747. */
  34748. WebVRController.prototype.dispose = function () {
  34749. _super.prototype.dispose.call(this);
  34750. this.onTriggerStateChangedObservable.clear();
  34751. this.onMainButtonStateChangedObservable.clear();
  34752. this.onSecondaryButtonStateChangedObservable.clear();
  34753. this.onPadStateChangedObservable.clear();
  34754. this.onPadValuesChangedObservable.clear();
  34755. };
  34756. return WebVRController;
  34757. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  34758. /***/ }),
  34759. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  34760. /*!*********************************************************!*\
  34761. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  34762. \*********************************************************/
  34763. /*! exports provided: WindowsMotionController */
  34764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34765. "use strict";
  34766. __webpack_require__.r(__webpack_exports__);
  34767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  34768. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34769. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34770. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34771. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34772. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34773. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34774. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34775. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34776. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34777. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34778. /**
  34779. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  34780. */
  34781. var LoadedMeshInfo = /** @class */ (function () {
  34782. function LoadedMeshInfo() {
  34783. /**
  34784. * Map of the button meshes contained in the controller
  34785. */
  34786. this.buttonMeshes = {};
  34787. /**
  34788. * Map of the axis meshes contained in the controller
  34789. */
  34790. this.axisMeshes = {};
  34791. }
  34792. return LoadedMeshInfo;
  34793. }());
  34794. /**
  34795. * Defines the WindowsMotionController object that the state of the windows motion controller
  34796. */
  34797. var WindowsMotionController = /** @class */ (function (_super) {
  34798. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  34799. /**
  34800. * Creates a new WindowsMotionController from a gamepad
  34801. * @param vrGamepad the gamepad that the controller should be created from
  34802. */
  34803. function WindowsMotionController(vrGamepad) {
  34804. var _this = _super.call(this, vrGamepad) || this;
  34805. _this._mapping = {
  34806. // Semantic button names
  34807. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  34808. // A mapping of the button name to glTF model node name
  34809. // that should be transformed by button value.
  34810. buttonMeshNames: {
  34811. 'trigger': 'SELECT',
  34812. 'menu': 'MENU',
  34813. 'grip': 'GRASP',
  34814. 'thumbstick': 'THUMBSTICK_PRESS',
  34815. 'trackpad': 'TOUCHPAD_PRESS'
  34816. },
  34817. // This mapping is used to translate from the Motion Controller to Babylon semantics
  34818. buttonObservableNames: {
  34819. 'trigger': 'onTriggerStateChangedObservable',
  34820. 'menu': 'onSecondaryButtonStateChangedObservable',
  34821. 'grip': 'onMainButtonStateChangedObservable',
  34822. 'thumbstick': 'onPadStateChangedObservable',
  34823. 'trackpad': 'onTrackpadChangedObservable'
  34824. },
  34825. // A mapping of the axis name to glTF model node name
  34826. // that should be transformed by axis value.
  34827. // This array mirrors the browserGamepad.axes array, such that
  34828. // the mesh corresponding to axis 0 is in this array index 0.
  34829. axisMeshNames: [
  34830. 'THUMBSTICK_X',
  34831. 'THUMBSTICK_Y',
  34832. 'TOUCHPAD_TOUCH_X',
  34833. 'TOUCHPAD_TOUCH_Y'
  34834. ],
  34835. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  34836. };
  34837. /**
  34838. * Fired when the trackpad on this controller is clicked
  34839. */
  34840. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  34841. /**
  34842. * Fired when the trackpad on this controller is modified
  34843. */
  34844. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  34845. /**
  34846. * The current x and y values of this controller's trackpad
  34847. */
  34848. _this.trackpad = { x: 0, y: 0 };
  34849. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  34850. _this._loadedMeshInfo = null;
  34851. return _this;
  34852. }
  34853. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  34854. /**
  34855. * Fired when the trigger on this controller is modified
  34856. */
  34857. get: function () {
  34858. return this.onTriggerStateChangedObservable;
  34859. },
  34860. enumerable: true,
  34861. configurable: true
  34862. });
  34863. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  34864. /**
  34865. * Fired when the menu button on this controller is modified
  34866. */
  34867. get: function () {
  34868. return this.onSecondaryButtonStateChangedObservable;
  34869. },
  34870. enumerable: true,
  34871. configurable: true
  34872. });
  34873. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  34874. /**
  34875. * Fired when the grip button on this controller is modified
  34876. */
  34877. get: function () {
  34878. return this.onMainButtonStateChangedObservable;
  34879. },
  34880. enumerable: true,
  34881. configurable: true
  34882. });
  34883. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  34884. /**
  34885. * Fired when the thumbstick button on this controller is modified
  34886. */
  34887. get: function () {
  34888. return this.onPadStateChangedObservable;
  34889. },
  34890. enumerable: true,
  34891. configurable: true
  34892. });
  34893. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  34894. /**
  34895. * Fired when the touchpad button on this controller is modified
  34896. */
  34897. get: function () {
  34898. return this.onTrackpadChangedObservable;
  34899. },
  34900. enumerable: true,
  34901. configurable: true
  34902. });
  34903. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  34904. /**
  34905. * Fired when the touchpad values on this controller are modified
  34906. */
  34907. get: function () {
  34908. return this.onTrackpadValuesChangedObservable;
  34909. },
  34910. enumerable: true,
  34911. configurable: true
  34912. });
  34913. WindowsMotionController.prototype._updateTrackpad = function () {
  34914. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  34915. this.trackpad.x = this.browserGamepad["axes"][2];
  34916. this.trackpad.y = this.browserGamepad["axes"][3];
  34917. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  34918. }
  34919. };
  34920. /**
  34921. * Called once per frame by the engine.
  34922. */
  34923. WindowsMotionController.prototype.update = function () {
  34924. _super.prototype.update.call(this);
  34925. if (this.browserGamepad.axes) {
  34926. this._updateTrackpad();
  34927. // Only need to animate axes if there is a loaded mesh
  34928. if (this._loadedMeshInfo) {
  34929. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  34930. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  34931. }
  34932. }
  34933. }
  34934. };
  34935. /**
  34936. * Called once for each button that changed state since the last frame
  34937. * @param buttonIdx Which button index changed
  34938. * @param state New state of the button
  34939. * @param changes Which properties on the state changed since last frame
  34940. */
  34941. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34942. var buttonName = this._mapping.buttons[buttonIdx];
  34943. if (!buttonName) {
  34944. return;
  34945. }
  34946. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  34947. this._updateTrackpad();
  34948. // Only emit events for buttons that we know how to map from index to name
  34949. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  34950. if (observable) {
  34951. observable.notifyObservers(state);
  34952. }
  34953. this._lerpButtonTransform(buttonName, state.value);
  34954. };
  34955. /**
  34956. * Moves the buttons on the controller mesh based on their current state
  34957. * @param buttonName the name of the button to move
  34958. * @param buttonValue the value of the button which determines the buttons new position
  34959. */
  34960. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  34961. // If there is no loaded mesh, there is nothing to transform.
  34962. if (!this._loadedMeshInfo) {
  34963. return;
  34964. }
  34965. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  34966. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  34967. return;
  34968. }
  34969. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  34970. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  34971. };
  34972. /**
  34973. * Moves the axis on the controller mesh based on its current state
  34974. * @param axis the index of the axis
  34975. * @param axisValue the value of the axis which determines the meshes new position
  34976. * @hidden
  34977. */
  34978. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  34979. if (!this._loadedMeshInfo) {
  34980. return;
  34981. }
  34982. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  34983. if (!meshInfo) {
  34984. return;
  34985. }
  34986. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  34987. return;
  34988. }
  34989. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  34990. var lerpValue = axisValue * 0.5 + 0.5;
  34991. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  34992. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  34993. };
  34994. /**
  34995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34996. * @param scene scene in which to add meshes
  34997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34998. */
  34999. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35000. var _this = this;
  35001. if (forceDefault === void 0) { forceDefault = false; }
  35002. var path;
  35003. var filename;
  35004. // Checking if GLB loader is present
  35005. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35006. // Determine the device specific folder based on the ID suffix
  35007. var device = 'default';
  35008. if (this.id && !forceDefault) {
  35009. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35010. device = ((match && match[0]) || device);
  35011. }
  35012. // Hand
  35013. if (this.hand === 'left') {
  35014. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35015. }
  35016. else { // Right is the default if no hand is specified
  35017. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35018. }
  35019. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35020. }
  35021. else {
  35022. _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");
  35023. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35024. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35025. }
  35026. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35027. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35028. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35029. if (!_this._loadedMeshInfo) {
  35030. return;
  35031. }
  35032. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35033. _this.attachToMesh(_this._defaultModel);
  35034. if (meshLoaded) {
  35035. meshLoaded(_this._defaultModel);
  35036. }
  35037. }, null, function (scene, message) {
  35038. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35039. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35040. if (!forceDefault) {
  35041. _this.initControllerMesh(scene, meshLoaded, true);
  35042. }
  35043. });
  35044. };
  35045. /**
  35046. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35047. * can be transformed by button presses and axes values, based on this._mapping.
  35048. *
  35049. * @param scene scene in which the meshes exist
  35050. * @param meshes list of meshes that make up the controller model to process
  35051. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35052. */
  35053. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35054. var loadedMeshInfo = null;
  35055. // Create a new mesh to contain the glTF hierarchy
  35056. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35057. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35058. var childMesh = null;
  35059. for (var i = 0; i < meshes.length; i++) {
  35060. var mesh = meshes[i];
  35061. if (!mesh.parent) {
  35062. // Exclude controller meshes from picking results
  35063. mesh.isPickable = false;
  35064. // Handle root node, attach to the new parentMesh
  35065. childMesh = mesh;
  35066. break;
  35067. }
  35068. }
  35069. if (childMesh) {
  35070. childMesh.setParent(parentMesh);
  35071. // Create our mesh info. Note that this method will always return non-null.
  35072. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35073. }
  35074. else {
  35075. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35076. }
  35077. return loadedMeshInfo;
  35078. };
  35079. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35080. var loadedMeshInfo = new LoadedMeshInfo();
  35081. var i;
  35082. loadedMeshInfo.rootNode = rootNode;
  35083. // Reset the caches
  35084. loadedMeshInfo.buttonMeshes = {};
  35085. loadedMeshInfo.axisMeshes = {};
  35086. // Button Meshes
  35087. for (i = 0; i < this._mapping.buttons.length; i++) {
  35088. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  35089. if (!buttonMeshName) {
  35090. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  35091. continue;
  35092. }
  35093. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  35094. if (!buttonMesh) {
  35095. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  35096. continue;
  35097. }
  35098. var buttonMeshInfo = {
  35099. index: i,
  35100. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  35101. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  35102. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  35103. };
  35104. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  35105. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  35106. }
  35107. else {
  35108. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  35109. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  35110. '(VALUE: ' + !!buttonMeshInfo.value +
  35111. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  35112. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  35113. ')');
  35114. }
  35115. }
  35116. // Axis Meshes
  35117. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  35118. var axisMeshName = this._mapping.axisMeshNames[i];
  35119. if (!axisMeshName) {
  35120. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  35121. continue;
  35122. }
  35123. var axisMesh = getChildByName(rootNode, axisMeshName);
  35124. if (!axisMesh) {
  35125. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  35126. continue;
  35127. }
  35128. var axisMeshInfo = {
  35129. index: i,
  35130. value: getImmediateChildByName(axisMesh, 'VALUE'),
  35131. min: getImmediateChildByName(axisMesh, 'MIN'),
  35132. max: getImmediateChildByName(axisMesh, 'MAX')
  35133. };
  35134. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  35135. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  35136. }
  35137. else {
  35138. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  35139. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  35140. '(VALUE: ' + !!axisMeshInfo.value +
  35141. ', MIN: ' + !!axisMeshInfo.min +
  35142. ', MAX:' + !!axisMeshInfo.max +
  35143. ')');
  35144. }
  35145. }
  35146. // Pointing Ray
  35147. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  35148. if (!loadedMeshInfo.pointingPoseNode) {
  35149. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  35150. }
  35151. else {
  35152. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  35153. }
  35154. return loadedMeshInfo;
  35155. // Look through all children recursively. This will return null if no mesh exists with the given name.
  35156. function getChildByName(node, name) {
  35157. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  35158. }
  35159. // Look through only immediate children. This will return null if no mesh exists with the given name.
  35160. function getImmediateChildByName(node, name) {
  35161. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  35162. }
  35163. };
  35164. /**
  35165. * Gets the ray of the controller in the direction the controller is pointing
  35166. * @param length the length the resulting ray should be
  35167. * @returns a ray in the direction the controller is pointing
  35168. */
  35169. WindowsMotionController.prototype.getForwardRay = function (length) {
  35170. if (length === void 0) { length = 100; }
  35171. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  35172. return _super.prototype.getForwardRay.call(this, length);
  35173. }
  35174. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  35175. var origin = m.getTranslation();
  35176. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  35177. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  35178. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  35179. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  35180. };
  35181. /**
  35182. * Disposes of the controller
  35183. */
  35184. WindowsMotionController.prototype.dispose = function () {
  35185. _super.prototype.dispose.call(this);
  35186. this.onTrackpadChangedObservable.clear();
  35187. };
  35188. /**
  35189. * The base url used to load the left and right controller models
  35190. */
  35191. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  35192. /**
  35193. * The name of the left controller model file
  35194. */
  35195. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  35196. /**
  35197. * The name of the right controller model file
  35198. */
  35199. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  35200. /**
  35201. * The controller name prefix for this controller type
  35202. */
  35203. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  35204. /**
  35205. * The controller id pattern for this controller type
  35206. */
  35207. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  35208. return WindowsMotionController;
  35209. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  35210. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35211. canCreate: function (gamepadInfo) {
  35212. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  35213. },
  35214. create: function (gamepadInfo) {
  35215. return new WindowsMotionController(gamepadInfo);
  35216. }
  35217. });
  35218. /***/ }),
  35219. /***/ "./Gamepads/gamepad.ts":
  35220. /*!*****************************!*\
  35221. !*** ./Gamepads/gamepad.ts ***!
  35222. \*****************************/
  35223. /*! exports provided: StickValues, Gamepad, GenericPad */
  35224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35225. "use strict";
  35226. __webpack_require__.r(__webpack_exports__);
  35227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  35228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  35229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  35230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35231. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35232. /**
  35233. * Represents a gamepad control stick position
  35234. */
  35235. var StickValues = /** @class */ (function () {
  35236. /**
  35237. * Initializes the gamepad x and y control stick values
  35238. * @param x The x component of the gamepad control stick value
  35239. * @param y The y component of the gamepad control stick value
  35240. */
  35241. function StickValues(
  35242. /**
  35243. * The x component of the control stick
  35244. */
  35245. x,
  35246. /**
  35247. * The y component of the control stick
  35248. */
  35249. y) {
  35250. this.x = x;
  35251. this.y = y;
  35252. }
  35253. return StickValues;
  35254. }());
  35255. /**
  35256. * Represents a gamepad
  35257. */
  35258. var Gamepad = /** @class */ (function () {
  35259. /**
  35260. * Initializes the gamepad
  35261. * @param id The id of the gamepad
  35262. * @param index The index of the gamepad
  35263. * @param browserGamepad The browser gamepad
  35264. * @param leftStickX The x component of the left joystick
  35265. * @param leftStickY The y component of the left joystick
  35266. * @param rightStickX The x component of the right joystick
  35267. * @param rightStickY The y component of the right joystick
  35268. */
  35269. function Gamepad(
  35270. /**
  35271. * The id of the gamepad
  35272. */
  35273. id,
  35274. /**
  35275. * The index of the gamepad
  35276. */
  35277. index,
  35278. /**
  35279. * The browser gamepad
  35280. */
  35281. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  35282. if (leftStickX === void 0) { leftStickX = 0; }
  35283. if (leftStickY === void 0) { leftStickY = 1; }
  35284. if (rightStickX === void 0) { rightStickX = 2; }
  35285. if (rightStickY === void 0) { rightStickY = 3; }
  35286. this.id = id;
  35287. this.index = index;
  35288. this.browserGamepad = browserGamepad;
  35289. this._leftStick = { x: 0, y: 0 };
  35290. this._rightStick = { x: 0, y: 0 };
  35291. /** @hidden */
  35292. this._isConnected = true;
  35293. /**
  35294. * Specifies whether the left control stick should be Y-inverted
  35295. */
  35296. this._invertLeftStickY = false;
  35297. this.type = Gamepad.GAMEPAD;
  35298. this._leftStickAxisX = leftStickX;
  35299. this._leftStickAxisY = leftStickY;
  35300. this._rightStickAxisX = rightStickX;
  35301. this._rightStickAxisY = rightStickY;
  35302. if (this.browserGamepad.axes.length >= 2) {
  35303. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35304. }
  35305. if (this.browserGamepad.axes.length >= 4) {
  35306. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35307. }
  35308. }
  35309. Object.defineProperty(Gamepad.prototype, "isConnected", {
  35310. /**
  35311. * Specifies if the gamepad has been connected
  35312. */
  35313. get: function () {
  35314. return this._isConnected;
  35315. },
  35316. enumerable: true,
  35317. configurable: true
  35318. });
  35319. /**
  35320. * Callback triggered when the left joystick has changed
  35321. * @param callback
  35322. */
  35323. Gamepad.prototype.onleftstickchanged = function (callback) {
  35324. this._onleftstickchanged = callback;
  35325. };
  35326. /**
  35327. * Callback triggered when the right joystick has changed
  35328. * @param callback
  35329. */
  35330. Gamepad.prototype.onrightstickchanged = function (callback) {
  35331. this._onrightstickchanged = callback;
  35332. };
  35333. Object.defineProperty(Gamepad.prototype, "leftStick", {
  35334. /**
  35335. * Gets the left joystick
  35336. */
  35337. get: function () {
  35338. return this._leftStick;
  35339. },
  35340. /**
  35341. * Sets the left joystick values
  35342. */
  35343. set: function (newValues) {
  35344. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  35345. this._onleftstickchanged(newValues);
  35346. }
  35347. this._leftStick = newValues;
  35348. },
  35349. enumerable: true,
  35350. configurable: true
  35351. });
  35352. Object.defineProperty(Gamepad.prototype, "rightStick", {
  35353. /**
  35354. * Gets the right joystick
  35355. */
  35356. get: function () {
  35357. return this._rightStick;
  35358. },
  35359. /**
  35360. * Sets the right joystick value
  35361. */
  35362. set: function (newValues) {
  35363. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  35364. this._onrightstickchanged(newValues);
  35365. }
  35366. this._rightStick = newValues;
  35367. },
  35368. enumerable: true,
  35369. configurable: true
  35370. });
  35371. /**
  35372. * Updates the gamepad joystick positions
  35373. */
  35374. Gamepad.prototype.update = function () {
  35375. if (this._leftStick) {
  35376. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35377. if (this._invertLeftStickY) {
  35378. this.leftStick.y *= -1;
  35379. }
  35380. }
  35381. if (this._rightStick) {
  35382. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35383. }
  35384. };
  35385. /**
  35386. * Disposes the gamepad
  35387. */
  35388. Gamepad.prototype.dispose = function () {
  35389. };
  35390. /**
  35391. * Represents a gamepad controller
  35392. */
  35393. Gamepad.GAMEPAD = 0;
  35394. /**
  35395. * Represents a generic controller
  35396. */
  35397. Gamepad.GENERIC = 1;
  35398. /**
  35399. * Represents an XBox controller
  35400. */
  35401. Gamepad.XBOX = 2;
  35402. /**
  35403. * Represents a pose-enabled controller
  35404. */
  35405. Gamepad.POSE_ENABLED = 3;
  35406. return Gamepad;
  35407. }());
  35408. /**
  35409. * Represents a generic gamepad
  35410. */
  35411. var GenericPad = /** @class */ (function (_super) {
  35412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  35413. /**
  35414. * Initializes the generic gamepad
  35415. * @param id The id of the generic gamepad
  35416. * @param index The index of the generic gamepad
  35417. * @param browserGamepad The browser gamepad
  35418. */
  35419. function GenericPad(id, index, browserGamepad) {
  35420. var _this = _super.call(this, id, index, browserGamepad) || this;
  35421. /**
  35422. * Observable triggered when a button has been pressed
  35423. */
  35424. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35425. /**
  35426. * Observable triggered when a button has been released
  35427. */
  35428. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35429. _this.type = Gamepad.GENERIC;
  35430. _this._buttons = new Array(browserGamepad.buttons.length);
  35431. return _this;
  35432. }
  35433. /**
  35434. * Callback triggered when a button has been pressed
  35435. * @param callback Called when a button has been pressed
  35436. */
  35437. GenericPad.prototype.onbuttondown = function (callback) {
  35438. this._onbuttondown = callback;
  35439. };
  35440. /**
  35441. * Callback triggered when a button has been released
  35442. * @param callback Called when a button has been released
  35443. */
  35444. GenericPad.prototype.onbuttonup = function (callback) {
  35445. this._onbuttonup = callback;
  35446. };
  35447. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  35448. if (newValue !== currentValue) {
  35449. if (newValue === 1) {
  35450. if (this._onbuttondown) {
  35451. this._onbuttondown(buttonIndex);
  35452. }
  35453. this.onButtonDownObservable.notifyObservers(buttonIndex);
  35454. }
  35455. if (newValue === 0) {
  35456. if (this._onbuttonup) {
  35457. this._onbuttonup(buttonIndex);
  35458. }
  35459. this.onButtonUpObservable.notifyObservers(buttonIndex);
  35460. }
  35461. }
  35462. return newValue;
  35463. };
  35464. /**
  35465. * Updates the generic gamepad
  35466. */
  35467. GenericPad.prototype.update = function () {
  35468. _super.prototype.update.call(this);
  35469. for (var index = 0; index < this._buttons.length; index++) {
  35470. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  35471. }
  35472. };
  35473. /**
  35474. * Disposes the generic gamepad
  35475. */
  35476. GenericPad.prototype.dispose = function () {
  35477. _super.prototype.dispose.call(this);
  35478. this.onButtonDownObservable.clear();
  35479. this.onButtonUpObservable.clear();
  35480. };
  35481. return GenericPad;
  35482. }(Gamepad));
  35483. /***/ }),
  35484. /***/ "./Gamepads/gamepadManager.ts":
  35485. /*!************************************!*\
  35486. !*** ./Gamepads/gamepadManager.ts ***!
  35487. \************************************/
  35488. /*! exports provided: GamepadManager */
  35489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35490. "use strict";
  35491. __webpack_require__.r(__webpack_exports__);
  35492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  35493. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  35494. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35495. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  35496. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35497. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  35498. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  35499. /**
  35500. * Manager for handling gamepads
  35501. */
  35502. var GamepadManager = /** @class */ (function () {
  35503. /**
  35504. * Initializes the gamepad manager
  35505. * @param _scene BabylonJS scene
  35506. */
  35507. function GamepadManager(_scene) {
  35508. var _this = this;
  35509. this._scene = _scene;
  35510. this._babylonGamepads = [];
  35511. this._oneGamepadConnected = false;
  35512. /** @hidden */
  35513. this._isMonitoring = false;
  35514. /**
  35515. * observable to be triggered when the gamepad controller has been disconnected
  35516. */
  35517. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35518. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  35519. this._gamepadEventSupported = false;
  35520. }
  35521. else {
  35522. this._gamepadEventSupported = 'GamepadEvent' in window;
  35523. this._gamepadSupport = (navigator.getGamepads ||
  35524. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  35525. }
  35526. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  35527. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  35528. for (var i in _this._babylonGamepads) {
  35529. var gamepad = _this._babylonGamepads[i];
  35530. if (gamepad && gamepad._isConnected) {
  35531. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  35532. }
  35533. }
  35534. });
  35535. this._onGamepadConnectedEvent = function (evt) {
  35536. var gamepad = evt.gamepad;
  35537. if (gamepad.index in _this._babylonGamepads) {
  35538. if (_this._babylonGamepads[gamepad.index].isConnected) {
  35539. return;
  35540. }
  35541. }
  35542. var newGamepad;
  35543. if (_this._babylonGamepads[gamepad.index]) {
  35544. newGamepad = _this._babylonGamepads[gamepad.index];
  35545. newGamepad.browserGamepad = gamepad;
  35546. newGamepad._isConnected = true;
  35547. }
  35548. else {
  35549. newGamepad = _this._addNewGamepad(gamepad);
  35550. }
  35551. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35552. _this._startMonitoringGamepads();
  35553. };
  35554. this._onGamepadDisconnectedEvent = function (evt) {
  35555. var gamepad = evt.gamepad;
  35556. // Remove the gamepad from the list of gamepads to monitor.
  35557. for (var i in _this._babylonGamepads) {
  35558. if (_this._babylonGamepads[i].index === gamepad.index) {
  35559. var disconnectedGamepad = _this._babylonGamepads[i];
  35560. disconnectedGamepad._isConnected = false;
  35561. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  35562. break;
  35563. }
  35564. }
  35565. };
  35566. if (this._gamepadSupport) {
  35567. //first add already-connected gamepads
  35568. this._updateGamepadObjects();
  35569. if (this._babylonGamepads.length) {
  35570. this._startMonitoringGamepads();
  35571. }
  35572. // Checking if the gamepad connected event is supported (like in Firefox)
  35573. if (this._gamepadEventSupported) {
  35574. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  35575. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  35576. }
  35577. else {
  35578. this._startMonitoringGamepads();
  35579. }
  35580. }
  35581. }
  35582. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  35583. /**
  35584. * The gamepads in the game pad manager
  35585. */
  35586. get: function () {
  35587. return this._babylonGamepads;
  35588. },
  35589. enumerable: true,
  35590. configurable: true
  35591. });
  35592. /**
  35593. * Get the gamepad controllers based on type
  35594. * @param type The type of gamepad controller
  35595. * @returns Nullable gamepad
  35596. */
  35597. GamepadManager.prototype.getGamepadByType = function (type) {
  35598. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  35599. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  35600. var gamepad = _a[_i];
  35601. if (gamepad && gamepad.type === type) {
  35602. return gamepad;
  35603. }
  35604. }
  35605. return null;
  35606. };
  35607. /**
  35608. * Disposes the gamepad manager
  35609. */
  35610. GamepadManager.prototype.dispose = function () {
  35611. if (this._gamepadEventSupported) {
  35612. if (this._onGamepadConnectedEvent) {
  35613. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  35614. }
  35615. if (this._onGamepadDisconnectedEvent) {
  35616. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  35617. }
  35618. this._onGamepadConnectedEvent = null;
  35619. this._onGamepadDisconnectedEvent = null;
  35620. }
  35621. this._babylonGamepads.forEach(function (gamepad) {
  35622. gamepad.dispose();
  35623. });
  35624. this.onGamepadConnectedObservable.clear();
  35625. this.onGamepadDisconnectedObservable.clear();
  35626. this._oneGamepadConnected = false;
  35627. this._stopMonitoringGamepads();
  35628. this._babylonGamepads = [];
  35629. };
  35630. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  35631. if (!this._oneGamepadConnected) {
  35632. this._oneGamepadConnected = true;
  35633. }
  35634. var newGamepad;
  35635. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  35636. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  35637. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  35638. }
  35639. // if pose is supported, use the (WebVR) pose enabled controller
  35640. else if (gamepad.pose) {
  35641. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  35642. }
  35643. else {
  35644. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  35645. }
  35646. this._babylonGamepads[newGamepad.index] = newGamepad;
  35647. return newGamepad;
  35648. };
  35649. GamepadManager.prototype._startMonitoringGamepads = function () {
  35650. if (!this._isMonitoring) {
  35651. this._isMonitoring = true;
  35652. //back-comp
  35653. if (!this._scene) {
  35654. this._checkGamepadsStatus();
  35655. }
  35656. }
  35657. };
  35658. GamepadManager.prototype._stopMonitoringGamepads = function () {
  35659. this._isMonitoring = false;
  35660. };
  35661. /** @hidden */
  35662. GamepadManager.prototype._checkGamepadsStatus = function () {
  35663. var _this = this;
  35664. // Hack to be compatible Chrome
  35665. this._updateGamepadObjects();
  35666. for (var i in this._babylonGamepads) {
  35667. var gamepad = this._babylonGamepads[i];
  35668. if (!gamepad || !gamepad.isConnected) {
  35669. continue;
  35670. }
  35671. gamepad.update();
  35672. }
  35673. if (this._isMonitoring && !this._scene) {
  35674. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  35675. }
  35676. };
  35677. // This function is called only on Chrome, which does not properly support
  35678. // connection/disconnection events and forces you to recopy again the gamepad object
  35679. GamepadManager.prototype._updateGamepadObjects = function () {
  35680. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  35681. for (var i = 0; i < gamepads.length; i++) {
  35682. var gamepad = gamepads[i];
  35683. if (gamepad) {
  35684. if (!this._babylonGamepads[gamepad.index]) {
  35685. var newGamepad = this._addNewGamepad(gamepad);
  35686. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35687. }
  35688. else {
  35689. // Forced to copy again this object for Chrome for unknown reason
  35690. this._babylonGamepads[i].browserGamepad = gamepad;
  35691. if (!this._babylonGamepads[i].isConnected) {
  35692. this._babylonGamepads[i]._isConnected = true;
  35693. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  35694. }
  35695. }
  35696. }
  35697. }
  35698. };
  35699. return GamepadManager;
  35700. }());
  35701. /***/ }),
  35702. /***/ "./Gamepads/gamepadSceneComponent.ts":
  35703. /*!*******************************************!*\
  35704. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  35705. \*******************************************/
  35706. /*! exports provided: GamepadSystemSceneComponent */
  35707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35708. "use strict";
  35709. __webpack_require__.r(__webpack_exports__);
  35710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  35711. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  35712. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  35713. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  35714. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  35715. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  35716. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  35717. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  35718. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  35719. get: function () {
  35720. if (!this._gamepadManager) {
  35721. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  35722. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  35723. if (!component) {
  35724. component = new GamepadSystemSceneComponent(this);
  35725. this._addComponent(component);
  35726. }
  35727. }
  35728. return this._gamepadManager;
  35729. },
  35730. enumerable: true,
  35731. configurable: true
  35732. });
  35733. /**
  35734. * Adds a gamepad to the free camera inputs manager
  35735. */
  35736. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  35737. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  35738. return this;
  35739. };
  35740. /**
  35741. * Adds a gamepad to the arc rotate camera inputs manager
  35742. */
  35743. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  35744. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  35745. return this;
  35746. };
  35747. /**
  35748. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  35749. */
  35750. var GamepadSystemSceneComponent = /** @class */ (function () {
  35751. /**
  35752. * Creates a new instance of the component for the given scene
  35753. * @param scene Defines the scene to register the component in
  35754. */
  35755. function GamepadSystemSceneComponent(scene) {
  35756. /**
  35757. * The component name helpfull to identify the component in the list of scene components.
  35758. */
  35759. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  35760. this.scene = scene;
  35761. }
  35762. /**
  35763. * Registers the component in a given scene
  35764. */
  35765. GamepadSystemSceneComponent.prototype.register = function () {
  35766. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  35767. };
  35768. /**
  35769. * Rebuilds the elements related to this component in case of
  35770. * context lost for instance.
  35771. */
  35772. GamepadSystemSceneComponent.prototype.rebuild = function () {
  35773. // Nothing to do for gamepads
  35774. };
  35775. /**
  35776. * Disposes the component and the associated ressources
  35777. */
  35778. GamepadSystemSceneComponent.prototype.dispose = function () {
  35779. var gamepadManager = this.scene._gamepadManager;
  35780. if (gamepadManager) {
  35781. gamepadManager.dispose();
  35782. this.scene._gamepadManager = null;
  35783. }
  35784. };
  35785. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  35786. var gamepadManager = this.scene._gamepadManager;
  35787. if (gamepadManager && gamepadManager._isMonitoring) {
  35788. gamepadManager._checkGamepadsStatus();
  35789. }
  35790. };
  35791. return GamepadSystemSceneComponent;
  35792. }());
  35793. /***/ }),
  35794. /***/ "./Gamepads/index.ts":
  35795. /*!***************************!*\
  35796. !*** ./Gamepads/index.ts ***!
  35797. \***************************/
  35798. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  35799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35800. "use strict";
  35801. __webpack_require__.r(__webpack_exports__);
  35802. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  35803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  35805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  35806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  35807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  35808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  35809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  35810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  35811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  35812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  35813. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  35814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  35815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  35816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  35817. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  35818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  35819. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  35820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  35821. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  35822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  35823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  35824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  35825. /***/ }),
  35826. /***/ "./Gamepads/xboxGamepad.ts":
  35827. /*!*********************************!*\
  35828. !*** ./Gamepads/xboxGamepad.ts ***!
  35829. \*********************************/
  35830. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  35831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35832. "use strict";
  35833. __webpack_require__.r(__webpack_exports__);
  35834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  35835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  35836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  35837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35838. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35839. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35840. /**
  35841. * Defines supported buttons for XBox360 compatible gamepads
  35842. */
  35843. var Xbox360Button;
  35844. (function (Xbox360Button) {
  35845. /** A */
  35846. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  35847. /** B */
  35848. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  35849. /** X */
  35850. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  35851. /** Y */
  35852. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  35853. /** Start */
  35854. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  35855. /** Back */
  35856. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  35857. /** Left button */
  35858. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  35859. /** Right button */
  35860. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  35861. /** Left stick */
  35862. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  35863. /** Right stick */
  35864. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  35865. })(Xbox360Button || (Xbox360Button = {}));
  35866. /** Defines values for XBox360 DPad */
  35867. var Xbox360Dpad;
  35868. (function (Xbox360Dpad) {
  35869. /** Up */
  35870. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  35871. /** Down */
  35872. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  35873. /** Left */
  35874. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  35875. /** Right */
  35876. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  35877. })(Xbox360Dpad || (Xbox360Dpad = {}));
  35878. /**
  35879. * Defines a XBox360 gamepad
  35880. */
  35881. var Xbox360Pad = /** @class */ (function (_super) {
  35882. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  35883. /**
  35884. * Creates a new XBox360 gamepad object
  35885. * @param id defines the id of this gamepad
  35886. * @param index defines its index
  35887. * @param gamepad defines the internal HTML gamepad object
  35888. * @param xboxOne defines if it is a XBox One gamepad
  35889. */
  35890. function Xbox360Pad(id, index, gamepad, xboxOne) {
  35891. if (xboxOne === void 0) { xboxOne = false; }
  35892. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  35893. _this._leftTrigger = 0;
  35894. _this._rightTrigger = 0;
  35895. /** Observable raised when a button is pressed */
  35896. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35897. /** Observable raised when a button is released */
  35898. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35899. /** Observable raised when a pad is pressed */
  35900. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35901. /** Observable raised when a pad is released */
  35902. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35903. _this._buttonA = 0;
  35904. _this._buttonB = 0;
  35905. _this._buttonX = 0;
  35906. _this._buttonY = 0;
  35907. _this._buttonBack = 0;
  35908. _this._buttonStart = 0;
  35909. _this._buttonLB = 0;
  35910. _this._buttonRB = 0;
  35911. _this._buttonLeftStick = 0;
  35912. _this._buttonRightStick = 0;
  35913. _this._dPadUp = 0;
  35914. _this._dPadDown = 0;
  35915. _this._dPadLeft = 0;
  35916. _this._dPadRight = 0;
  35917. _this._isXboxOnePad = false;
  35918. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  35919. _this._isXboxOnePad = xboxOne;
  35920. return _this;
  35921. }
  35922. /**
  35923. * Defines the callback to call when left trigger is pressed
  35924. * @param callback defines the callback to use
  35925. */
  35926. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  35927. this._onlefttriggerchanged = callback;
  35928. };
  35929. /**
  35930. * Defines the callback to call when right trigger is pressed
  35931. * @param callback defines the callback to use
  35932. */
  35933. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  35934. this._onrighttriggerchanged = callback;
  35935. };
  35936. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  35937. /**
  35938. * Gets the left trigger value
  35939. */
  35940. get: function () {
  35941. return this._leftTrigger;
  35942. },
  35943. /**
  35944. * Sets the left trigger value
  35945. */
  35946. set: function (newValue) {
  35947. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  35948. this._onlefttriggerchanged(newValue);
  35949. }
  35950. this._leftTrigger = newValue;
  35951. },
  35952. enumerable: true,
  35953. configurable: true
  35954. });
  35955. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  35956. /**
  35957. * Gets the right trigger value
  35958. */
  35959. get: function () {
  35960. return this._rightTrigger;
  35961. },
  35962. /**
  35963. * Sets the right trigger value
  35964. */
  35965. set: function (newValue) {
  35966. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  35967. this._onrighttriggerchanged(newValue);
  35968. }
  35969. this._rightTrigger = newValue;
  35970. },
  35971. enumerable: true,
  35972. configurable: true
  35973. });
  35974. /**
  35975. * Defines the callback to call when a button is pressed
  35976. * @param callback defines the callback to use
  35977. */
  35978. Xbox360Pad.prototype.onbuttondown = function (callback) {
  35979. this._onbuttondown = callback;
  35980. };
  35981. /**
  35982. * Defines the callback to call when a button is released
  35983. * @param callback defines the callback to use
  35984. */
  35985. Xbox360Pad.prototype.onbuttonup = function (callback) {
  35986. this._onbuttonup = callback;
  35987. };
  35988. /**
  35989. * Defines the callback to call when a pad is pressed
  35990. * @param callback defines the callback to use
  35991. */
  35992. Xbox360Pad.prototype.ondpaddown = function (callback) {
  35993. this._ondpaddown = callback;
  35994. };
  35995. /**
  35996. * Defines the callback to call when a pad is released
  35997. * @param callback defines the callback to use
  35998. */
  35999. Xbox360Pad.prototype.ondpadup = function (callback) {
  36000. this._ondpadup = callback;
  36001. };
  36002. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36003. if (newValue !== currentValue) {
  36004. if (newValue === 1) {
  36005. if (this._onbuttondown) {
  36006. this._onbuttondown(buttonType);
  36007. }
  36008. this.onButtonDownObservable.notifyObservers(buttonType);
  36009. }
  36010. if (newValue === 0) {
  36011. if (this._onbuttonup) {
  36012. this._onbuttonup(buttonType);
  36013. }
  36014. this.onButtonUpObservable.notifyObservers(buttonType);
  36015. }
  36016. }
  36017. return newValue;
  36018. };
  36019. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36020. if (newValue !== currentValue) {
  36021. if (newValue === 1) {
  36022. if (this._ondpaddown) {
  36023. this._ondpaddown(buttonType);
  36024. }
  36025. this.onPadDownObservable.notifyObservers(buttonType);
  36026. }
  36027. if (newValue === 0) {
  36028. if (this._ondpadup) {
  36029. this._ondpadup(buttonType);
  36030. }
  36031. this.onPadUpObservable.notifyObservers(buttonType);
  36032. }
  36033. }
  36034. return newValue;
  36035. };
  36036. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36037. /**
  36038. * Gets the value of the `A` button
  36039. */
  36040. get: function () {
  36041. return this._buttonA;
  36042. },
  36043. /**
  36044. * Sets the value of the `A` button
  36045. */
  36046. set: function (value) {
  36047. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36048. },
  36049. enumerable: true,
  36050. configurable: true
  36051. });
  36052. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36053. /**
  36054. * Gets the value of the `B` button
  36055. */
  36056. get: function () {
  36057. return this._buttonB;
  36058. },
  36059. /**
  36060. * Sets the value of the `B` button
  36061. */
  36062. set: function (value) {
  36063. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36064. },
  36065. enumerable: true,
  36066. configurable: true
  36067. });
  36068. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36069. /**
  36070. * Gets the value of the `X` button
  36071. */
  36072. get: function () {
  36073. return this._buttonX;
  36074. },
  36075. /**
  36076. * Sets the value of the `X` button
  36077. */
  36078. set: function (value) {
  36079. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36080. },
  36081. enumerable: true,
  36082. configurable: true
  36083. });
  36084. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36085. /**
  36086. * Gets the value of the `Y` button
  36087. */
  36088. get: function () {
  36089. return this._buttonY;
  36090. },
  36091. /**
  36092. * Sets the value of the `Y` button
  36093. */
  36094. set: function (value) {
  36095. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  36096. },
  36097. enumerable: true,
  36098. configurable: true
  36099. });
  36100. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  36101. /**
  36102. * Gets the value of the `Start` button
  36103. */
  36104. get: function () {
  36105. return this._buttonStart;
  36106. },
  36107. /**
  36108. * Sets the value of the `Start` button
  36109. */
  36110. set: function (value) {
  36111. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  36112. },
  36113. enumerable: true,
  36114. configurable: true
  36115. });
  36116. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  36117. /**
  36118. * Gets the value of the `Back` button
  36119. */
  36120. get: function () {
  36121. return this._buttonBack;
  36122. },
  36123. /**
  36124. * Sets the value of the `Back` button
  36125. */
  36126. set: function (value) {
  36127. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  36128. },
  36129. enumerable: true,
  36130. configurable: true
  36131. });
  36132. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  36133. /**
  36134. * Gets the value of the `Left` button
  36135. */
  36136. get: function () {
  36137. return this._buttonLB;
  36138. },
  36139. /**
  36140. * Sets the value of the `Left` button
  36141. */
  36142. set: function (value) {
  36143. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  36144. },
  36145. enumerable: true,
  36146. configurable: true
  36147. });
  36148. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  36149. /**
  36150. * Gets the value of the `Right` button
  36151. */
  36152. get: function () {
  36153. return this._buttonRB;
  36154. },
  36155. /**
  36156. * Sets the value of the `Right` button
  36157. */
  36158. set: function (value) {
  36159. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  36160. },
  36161. enumerable: true,
  36162. configurable: true
  36163. });
  36164. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  36165. /**
  36166. * Gets the value of the Left joystick
  36167. */
  36168. get: function () {
  36169. return this._buttonLeftStick;
  36170. },
  36171. /**
  36172. * Sets the value of the Left joystick
  36173. */
  36174. set: function (value) {
  36175. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  36176. },
  36177. enumerable: true,
  36178. configurable: true
  36179. });
  36180. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  36181. /**
  36182. * Gets the value of the Right joystick
  36183. */
  36184. get: function () {
  36185. return this._buttonRightStick;
  36186. },
  36187. /**
  36188. * Sets the value of the Right joystick
  36189. */
  36190. set: function (value) {
  36191. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  36192. },
  36193. enumerable: true,
  36194. configurable: true
  36195. });
  36196. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  36197. /**
  36198. * Gets the value of D-pad up
  36199. */
  36200. get: function () {
  36201. return this._dPadUp;
  36202. },
  36203. /**
  36204. * Sets the value of D-pad up
  36205. */
  36206. set: function (value) {
  36207. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  36208. },
  36209. enumerable: true,
  36210. configurable: true
  36211. });
  36212. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  36213. /**
  36214. * Gets the value of D-pad down
  36215. */
  36216. get: function () {
  36217. return this._dPadDown;
  36218. },
  36219. /**
  36220. * Sets the value of D-pad down
  36221. */
  36222. set: function (value) {
  36223. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  36224. },
  36225. enumerable: true,
  36226. configurable: true
  36227. });
  36228. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  36229. /**
  36230. * Gets the value of D-pad left
  36231. */
  36232. get: function () {
  36233. return this._dPadLeft;
  36234. },
  36235. /**
  36236. * Sets the value of D-pad left
  36237. */
  36238. set: function (value) {
  36239. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  36240. },
  36241. enumerable: true,
  36242. configurable: true
  36243. });
  36244. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  36245. /**
  36246. * Gets the value of D-pad right
  36247. */
  36248. get: function () {
  36249. return this._dPadRight;
  36250. },
  36251. /**
  36252. * Sets the value of D-pad right
  36253. */
  36254. set: function (value) {
  36255. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  36256. },
  36257. enumerable: true,
  36258. configurable: true
  36259. });
  36260. /**
  36261. * Force the gamepad to synchronize with device values
  36262. */
  36263. Xbox360Pad.prototype.update = function () {
  36264. _super.prototype.update.call(this);
  36265. if (this._isXboxOnePad) {
  36266. this.buttonA = this.browserGamepad.buttons[0].value;
  36267. this.buttonB = this.browserGamepad.buttons[1].value;
  36268. this.buttonX = this.browserGamepad.buttons[2].value;
  36269. this.buttonY = this.browserGamepad.buttons[3].value;
  36270. this.buttonLB = this.browserGamepad.buttons[4].value;
  36271. this.buttonRB = this.browserGamepad.buttons[5].value;
  36272. this.leftTrigger = this.browserGamepad.axes[2];
  36273. this.rightTrigger = this.browserGamepad.axes[5];
  36274. this.buttonBack = this.browserGamepad.buttons[9].value;
  36275. this.buttonStart = this.browserGamepad.buttons[8].value;
  36276. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  36277. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  36278. this.dPadUp = this.browserGamepad.buttons[11].value;
  36279. this.dPadDown = this.browserGamepad.buttons[12].value;
  36280. this.dPadLeft = this.browserGamepad.buttons[13].value;
  36281. this.dPadRight = this.browserGamepad.buttons[14].value;
  36282. }
  36283. else {
  36284. this.buttonA = this.browserGamepad.buttons[0].value;
  36285. this.buttonB = this.browserGamepad.buttons[1].value;
  36286. this.buttonX = this.browserGamepad.buttons[2].value;
  36287. this.buttonY = this.browserGamepad.buttons[3].value;
  36288. this.buttonLB = this.browserGamepad.buttons[4].value;
  36289. this.buttonRB = this.browserGamepad.buttons[5].value;
  36290. this.leftTrigger = this.browserGamepad.buttons[6].value;
  36291. this.rightTrigger = this.browserGamepad.buttons[7].value;
  36292. this.buttonBack = this.browserGamepad.buttons[8].value;
  36293. this.buttonStart = this.browserGamepad.buttons[9].value;
  36294. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  36295. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  36296. this.dPadUp = this.browserGamepad.buttons[12].value;
  36297. this.dPadDown = this.browserGamepad.buttons[13].value;
  36298. this.dPadLeft = this.browserGamepad.buttons[14].value;
  36299. this.dPadRight = this.browserGamepad.buttons[15].value;
  36300. }
  36301. };
  36302. /**
  36303. * Disposes the gamepad
  36304. */
  36305. Xbox360Pad.prototype.dispose = function () {
  36306. _super.prototype.dispose.call(this);
  36307. this.onButtonDownObservable.clear();
  36308. this.onButtonUpObservable.clear();
  36309. this.onPadDownObservable.clear();
  36310. this.onPadUpObservable.clear();
  36311. };
  36312. return Xbox360Pad;
  36313. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  36314. /***/ }),
  36315. /***/ "./Gizmos/axisDragGizmo.ts":
  36316. /*!*********************************!*\
  36317. !*** ./Gizmos/axisDragGizmo.ts ***!
  36318. \*********************************/
  36319. /*! exports provided: AxisDragGizmo */
  36320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36321. "use strict";
  36322. __webpack_require__.r(__webpack_exports__);
  36323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  36324. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36325. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36326. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36327. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  36328. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36329. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36330. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36331. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36332. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36333. /**
  36334. * Single axis drag gizmo
  36335. */
  36336. var AxisDragGizmo = /** @class */ (function (_super) {
  36337. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  36338. /**
  36339. * Creates an AxisDragGizmo
  36340. * @param gizmoLayer The utility layer the gizmo will be added to
  36341. * @param dragAxis The axis which the gizmo will be able to drag on
  36342. * @param color The color of the gizmo
  36343. */
  36344. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  36345. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36346. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36347. var _this = _super.call(this, gizmoLayer) || this;
  36348. _this._pointerObserver = null;
  36349. /**
  36350. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36351. */
  36352. _this.snapDistance = 0;
  36353. /**
  36354. * Event that fires each time the gizmo snaps to a new location.
  36355. * * snapDistance is the the change in distance
  36356. */
  36357. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36358. // Create Material
  36359. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36360. coloredMaterial.disableLighting = true;
  36361. coloredMaterial.emissiveColor = color;
  36362. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36363. hoverMaterial.disableLighting = true;
  36364. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36365. // Build mesh on root node
  36366. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  36367. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36368. arrow.scaling.scaleInPlace(1 / 3);
  36369. arrow.parent = _this._rootMesh;
  36370. var currentSnapDragDistance = 0;
  36371. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36372. var tmpSnapEvent = { snapDistance: 0 };
  36373. // Add drag behavior to handle events when the gizmo is dragged
  36374. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36375. _this.dragBehavior.moveAttached = false;
  36376. _this._rootMesh.addBehavior(_this.dragBehavior);
  36377. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36378. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  36379. _this.dragBehavior.onDragObservable.add(function (event) {
  36380. if (_this.attachedMesh) {
  36381. // Convert delta to local translation if it has a parent
  36382. if (_this.attachedMesh.parent) {
  36383. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  36384. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  36385. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  36386. }
  36387. else {
  36388. localDelta.copyFrom(event.delta);
  36389. }
  36390. // Snapping logic
  36391. if (_this.snapDistance == 0) {
  36392. _this.attachedMesh.position.addInPlace(localDelta);
  36393. }
  36394. else {
  36395. currentSnapDragDistance += event.dragDistance;
  36396. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36397. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36398. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36399. localDelta.normalizeToRef(tmpVector);
  36400. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  36401. _this.attachedMesh.position.addInPlace(tmpVector);
  36402. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36403. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36404. }
  36405. }
  36406. }
  36407. });
  36408. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36409. if (_this._customMeshSet) {
  36410. return;
  36411. }
  36412. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36413. var material = isHovered ? hoverMaterial : coloredMaterial;
  36414. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36415. m.material = material;
  36416. if (m.color) {
  36417. m.color = material.emissiveColor;
  36418. }
  36419. });
  36420. });
  36421. return _this;
  36422. }
  36423. /** @hidden */
  36424. AxisDragGizmo._CreateArrow = function (scene, material) {
  36425. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36426. var cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  36427. var line = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateLines("line", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, scene);
  36428. line.color = material.emissiveColor;
  36429. cylinder.parent = arrow;
  36430. line.parent = arrow;
  36431. // Position arrow pointing in its drag axis
  36432. cylinder.scaling.scaleInPlace(0.05);
  36433. cylinder.material = material;
  36434. cylinder.rotation.x = Math.PI / 2;
  36435. cylinder.position.z += 0.3;
  36436. line.scaling.scaleInPlace(0.26);
  36437. line.rotation.x = Math.PI / 2;
  36438. line.material = material;
  36439. return arrow;
  36440. };
  36441. /** @hidden */
  36442. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  36443. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36444. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  36445. var mesh = _a[_i];
  36446. var childInstance = mesh.createInstance(mesh.name);
  36447. childInstance.parent = instance;
  36448. }
  36449. return instance;
  36450. };
  36451. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  36452. if (this.dragBehavior) {
  36453. this.dragBehavior.enabled = value ? true : false;
  36454. }
  36455. };
  36456. /**
  36457. * Disposes of the gizmo
  36458. */
  36459. AxisDragGizmo.prototype.dispose = function () {
  36460. this.onSnapObservable.clear();
  36461. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36462. this.dragBehavior.detach();
  36463. _super.prototype.dispose.call(this);
  36464. };
  36465. return AxisDragGizmo;
  36466. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  36467. /***/ }),
  36468. /***/ "./Gizmos/axisScaleGizmo.ts":
  36469. /*!**********************************!*\
  36470. !*** ./Gizmos/axisScaleGizmo.ts ***!
  36471. \**********************************/
  36472. /*! exports provided: AxisScaleGizmo */
  36473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36474. "use strict";
  36475. __webpack_require__.r(__webpack_exports__);
  36476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  36477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36480. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36481. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36482. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36483. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36484. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36485. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36486. /**
  36487. * Single axis scale gizmo
  36488. */
  36489. var AxisScaleGizmo = /** @class */ (function (_super) {
  36490. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  36491. /**
  36492. * Creates an AxisScaleGizmo
  36493. * @param gizmoLayer The utility layer the gizmo will be added to
  36494. * @param dragAxis The axis which the gizmo will be able to scale on
  36495. * @param color The color of the gizmo
  36496. */
  36497. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  36498. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36499. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36500. var _this = _super.call(this, gizmoLayer) || this;
  36501. _this._pointerObserver = null;
  36502. /**
  36503. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36504. */
  36505. _this.snapDistance = 0;
  36506. /**
  36507. * Event that fires each time the gizmo snaps to a new location.
  36508. * * snapDistance is the the change in distance
  36509. */
  36510. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36511. /**
  36512. * If the scaling operation should be done on all axis (default: false)
  36513. */
  36514. _this.uniformScaling = false;
  36515. // Create Material
  36516. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36517. _this._coloredMaterial.disableLighting = true;
  36518. _this._coloredMaterial.emissiveColor = color;
  36519. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36520. hoverMaterial.disableLighting = true;
  36521. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36522. // Build mesh on root node
  36523. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36524. var arrowMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  36525. var arrowTail = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateLines("yPosMesh", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, gizmoLayer.utilityLayerScene);
  36526. arrowTail.color = _this._coloredMaterial.emissiveColor;
  36527. arrow.addChild(arrowMesh);
  36528. arrow.addChild(arrowTail);
  36529. // Position arrow pointing in its drag axis
  36530. arrowMesh.scaling.scaleInPlace(0.1);
  36531. arrowMesh.material = _this._coloredMaterial;
  36532. arrowMesh.rotation.x = Math.PI / 2;
  36533. arrowMesh.position.z += 0.3;
  36534. arrowTail.scaling.scaleInPlace(0.26);
  36535. arrowTail.rotation.x = Math.PI / 2;
  36536. arrowTail.material = _this._coloredMaterial;
  36537. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36538. _this._rootMesh.addChild(arrow);
  36539. arrow.scaling.scaleInPlace(1 / 3);
  36540. // Add drag behavior to handle events when the gizmo is dragged
  36541. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36542. _this.dragBehavior.moveAttached = false;
  36543. _this._rootMesh.addBehavior(_this.dragBehavior);
  36544. var currentSnapDragDistance = 0;
  36545. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36546. var tmpSnapEvent = { snapDistance: 0 };
  36547. _this.dragBehavior.onDragObservable.add(function (event) {
  36548. if (_this.attachedMesh) {
  36549. // Snapping logic
  36550. var snapped = false;
  36551. var dragSteps = 0;
  36552. if (_this.uniformScaling) {
  36553. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  36554. if (tmpVector.y < 0) {
  36555. tmpVector.scaleInPlace(-1);
  36556. }
  36557. }
  36558. else {
  36559. tmpVector.copyFrom(dragAxis);
  36560. }
  36561. if (_this.snapDistance == 0) {
  36562. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  36563. }
  36564. else {
  36565. currentSnapDragDistance += event.dragDistance;
  36566. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36567. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36568. if (currentSnapDragDistance < 0) {
  36569. dragSteps *= -1;
  36570. }
  36571. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36572. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  36573. snapped = true;
  36574. }
  36575. else {
  36576. tmpVector.scaleInPlace(0);
  36577. }
  36578. }
  36579. _this.attachedMesh.scaling.addInPlace(tmpVector);
  36580. if (snapped) {
  36581. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36582. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36583. }
  36584. }
  36585. });
  36586. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36587. if (_this._customMeshSet) {
  36588. return;
  36589. }
  36590. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36591. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  36592. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36593. m.material = material;
  36594. if (m.color) {
  36595. m.color = material.emissiveColor;
  36596. }
  36597. });
  36598. });
  36599. return _this;
  36600. }
  36601. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  36602. if (this.dragBehavior) {
  36603. this.dragBehavior.enabled = value ? true : false;
  36604. }
  36605. };
  36606. /**
  36607. * Disposes of the gizmo
  36608. */
  36609. AxisScaleGizmo.prototype.dispose = function () {
  36610. this.onSnapObservable.clear();
  36611. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36612. this.dragBehavior.detach();
  36613. _super.prototype.dispose.call(this);
  36614. };
  36615. /**
  36616. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  36617. * @param mesh The mesh to replace the default mesh of the gizmo
  36618. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  36619. */
  36620. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  36621. var _this = this;
  36622. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  36623. _super.prototype.setCustomMesh.call(this, mesh);
  36624. if (useGizmoMaterial) {
  36625. this._rootMesh.getChildMeshes().forEach(function (m) {
  36626. m.material = _this._coloredMaterial;
  36627. if (m.color) {
  36628. m.color = _this._coloredMaterial.emissiveColor;
  36629. }
  36630. });
  36631. this._customMeshSet = false;
  36632. }
  36633. };
  36634. return AxisScaleGizmo;
  36635. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  36636. /***/ }),
  36637. /***/ "./Gizmos/boundingBoxGizmo.ts":
  36638. /*!************************************!*\
  36639. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  36640. \************************************/
  36641. /*! exports provided: BoundingBoxGizmo */
  36642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36643. "use strict";
  36644. __webpack_require__.r(__webpack_exports__);
  36645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  36646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36647. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36648. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  36649. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36650. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36651. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  36652. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36653. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36654. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36655. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36656. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36657. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  36658. /**
  36659. * Bounding box gizmo
  36660. */
  36661. var BoundingBoxGizmo = /** @class */ (function (_super) {
  36662. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  36663. /**
  36664. * Creates an BoundingBoxGizmo
  36665. * @param gizmoLayer The utility layer the gizmo will be added to
  36666. * @param color The color of the gizmo
  36667. */
  36668. function BoundingBoxGizmo(color, gizmoLayer) {
  36669. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  36670. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  36671. var _this = _super.call(this, gizmoLayer) || this;
  36672. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  36673. _this._renderObserver = null;
  36674. _this._pointerObserver = null;
  36675. _this._scaleDragSpeed = 0.2;
  36676. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36677. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  36678. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  36679. /**
  36680. * 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)
  36681. */
  36682. _this.ignoreChildren = false;
  36683. /**
  36684. * 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)
  36685. */
  36686. _this.includeChildPredicate = null;
  36687. /**
  36688. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  36689. */
  36690. _this.rotationSphereSize = 0.1;
  36691. /**
  36692. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  36693. */
  36694. _this.scaleBoxSize = 0.1;
  36695. /**
  36696. * 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)
  36697. */
  36698. _this.fixedDragMeshScreenSize = false;
  36699. /**
  36700. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  36701. */
  36702. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  36703. /**
  36704. * Fired when a rotation sphere or scale box is dragged
  36705. */
  36706. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36707. /**
  36708. * Fired when a scale box is dragged
  36709. */
  36710. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36711. /**
  36712. * Fired when a scale box drag is ended
  36713. */
  36714. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36715. /**
  36716. * Fired when a rotation sphere is dragged
  36717. */
  36718. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36719. /**
  36720. * Fired when a rotation sphere drag is ended
  36721. */
  36722. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36723. /**
  36724. * 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)
  36725. */
  36726. _this.scalePivot = null;
  36727. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  36728. // Dragging
  36729. _this._dragMesh = null;
  36730. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]();
  36731. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  36732. _this._updateScale = false;
  36733. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  36734. // Create Materials
  36735. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36736. coloredMaterial.disableLighting = true;
  36737. coloredMaterial.emissiveColor = color;
  36738. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36739. hoverColoredMaterial.disableLighting = true;
  36740. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  36741. // Build bounding box out of lines
  36742. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36743. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36744. var lines = [];
  36745. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0)] }, gizmoLayer.utilityLayerScene));
  36746. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  36747. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36748. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  36749. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36750. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  36751. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36752. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36753. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36754. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, _this._boundingDimensions.y, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36755. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, 0, _this._boundingDimensions.z)] }, gizmoLayer.utilityLayerScene));
  36756. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateLines("lines", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, _this._boundingDimensions.z), new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](_this._boundingDimensions.x, _this._boundingDimensions.y, 0)] }, gizmoLayer.utilityLayerScene));
  36757. lines.forEach(function (l) {
  36758. l.color = color;
  36759. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  36760. l.isPickable = false;
  36761. _this._lineBoundingBox.addChild(l);
  36762. });
  36763. _this._rootMesh.addChild(_this._lineBoundingBox);
  36764. // Create rotation spheres
  36765. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36766. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36767. var _loop_1 = function (i_1) {
  36768. var sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  36769. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36770. sphere.material = coloredMaterial;
  36771. // Drag behavior
  36772. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({});
  36773. _dragBehavior.moveAttached = false;
  36774. _dragBehavior.updateDragPlane = false;
  36775. sphere.addBehavior(_dragBehavior);
  36776. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  36777. var totalTurnAmountOfDrag = 0;
  36778. _dragBehavior.onDragStartObservable.add(function () {
  36779. startingTurnDirection.copyFrom(sphere.forward);
  36780. totalTurnAmountOfDrag = 0;
  36781. });
  36782. _dragBehavior.onDragObservable.add(function (event) {
  36783. _this.onRotationSphereDragObservable.notifyObservers({});
  36784. if (_this.attachedMesh) {
  36785. var originalParent = _this.attachedMesh.parent;
  36786. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  36787. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  36788. return;
  36789. }
  36790. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  36791. var worldDragDirection = startingTurnDirection;
  36792. // Project the world right on to the drag plane
  36793. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  36794. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  36795. // project drag delta on to the resulting drag axis and rotate based on that
  36796. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  36797. // Make rotation relative to size of mesh.
  36798. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  36799. // Rotate based on axis
  36800. if (!_this.attachedMesh.rotationQuaternion) {
  36801. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  36802. }
  36803. if (!_this._anchorMesh.rotationQuaternion) {
  36804. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  36805. }
  36806. // Do not allow the object to turn more than a full circle
  36807. totalTurnAmountOfDrag += projectDist;
  36808. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  36809. if (i_1 >= 8) {
  36810. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  36811. }
  36812. else if (i_1 >= 4) {
  36813. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  36814. }
  36815. else {
  36816. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  36817. }
  36818. // Rotate around center of bounding box
  36819. _this._anchorMesh.addChild(_this.attachedMesh);
  36820. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  36821. _this._anchorMesh.removeChild(_this.attachedMesh);
  36822. _this.attachedMesh.setParent(originalParent);
  36823. }
  36824. _this.updateBoundingBox();
  36825. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  36826. }
  36827. _this._updateDummy();
  36828. });
  36829. // Selection/deselection
  36830. _dragBehavior.onDragStartObservable.add(function () {
  36831. _this.onDragStartObservable.notifyObservers({});
  36832. _this._selectNode(sphere);
  36833. });
  36834. _dragBehavior.onDragEndObservable.add(function () {
  36835. _this.onRotationSphereDragEndObservable.notifyObservers({});
  36836. _this._selectNode(null);
  36837. _this._updateDummy();
  36838. });
  36839. this_1._rotateSpheresParent.addChild(sphere);
  36840. };
  36841. var this_1 = this, _dragBehavior;
  36842. for (var i_1 = 0; i_1 < 12; i_1++) {
  36843. _loop_1(i_1);
  36844. }
  36845. _this._rootMesh.addChild(_this._rotateSpheresParent);
  36846. // Create scale cubes
  36847. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36848. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36849. for (var i = 0; i < 2; i++) {
  36850. for (var j = 0; j < 2; j++) {
  36851. var _loop_2 = function () {
  36852. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  36853. box.material = coloredMaterial;
  36854. // Dragging logic
  36855. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  36856. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36857. _dragBehavior.moveAttached = false;
  36858. box.addBehavior(_dragBehavior);
  36859. _dragBehavior.onDragObservable.add(function (event) {
  36860. _this.onScaleBoxDragObservable.notifyObservers({});
  36861. if (_this.attachedMesh) {
  36862. var originalParent = _this.attachedMesh.parent;
  36863. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  36864. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  36865. return;
  36866. }
  36867. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  36868. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  36869. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  36870. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  36871. _this.updateBoundingBox();
  36872. if (_this.scalePivot) {
  36873. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  36874. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  36875. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  36876. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  36877. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  36878. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  36879. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  36880. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  36881. }
  36882. else {
  36883. // Scale from the position of the opposite corner
  36884. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  36885. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  36886. }
  36887. _this._anchorMesh.addChild(_this.attachedMesh);
  36888. _this._anchorMesh.scaling.addInPlace(deltaScale);
  36889. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  36890. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  36891. }
  36892. _this._anchorMesh.removeChild(_this.attachedMesh);
  36893. _this.attachedMesh.setParent(originalParent);
  36894. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  36895. }
  36896. _this._updateDummy();
  36897. });
  36898. // Selection/deselection
  36899. _dragBehavior.onDragStartObservable.add(function () {
  36900. _this.onDragStartObservable.notifyObservers({});
  36901. _this._selectNode(box);
  36902. });
  36903. _dragBehavior.onDragEndObservable.add(function () {
  36904. _this.onScaleBoxDragEndObservable.notifyObservers({});
  36905. _this._selectNode(null);
  36906. _this._updateDummy();
  36907. });
  36908. this_2._scaleBoxesParent.addChild(box);
  36909. };
  36910. var this_2 = this, _dragBehavior;
  36911. for (var k = 0; k < 2; k++) {
  36912. _loop_2();
  36913. }
  36914. }
  36915. }
  36916. _this._rootMesh.addChild(_this._scaleBoxesParent);
  36917. // Hover color change
  36918. var pointerIds = new Array();
  36919. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36920. if (!pointerIds[pointerInfo.event.pointerId]) {
  36921. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  36922. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  36923. pointerIds[pointerInfo.event.pointerId] = mesh;
  36924. mesh.material = hoverColoredMaterial;
  36925. }
  36926. });
  36927. }
  36928. else {
  36929. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  36930. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  36931. delete pointerIds[pointerInfo.event.pointerId];
  36932. }
  36933. }
  36934. });
  36935. // Update bounding box positions
  36936. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  36937. // Only update the bouding box if scaling has changed
  36938. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  36939. _this.updateBoundingBox();
  36940. }
  36941. else if (_this.fixedDragMeshScreenSize) {
  36942. _this._updateRotationSpheres();
  36943. _this._updateScaleBoxes();
  36944. }
  36945. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  36946. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  36947. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  36948. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  36949. }
  36950. });
  36951. _this.updateBoundingBox();
  36952. return _this;
  36953. }
  36954. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  36955. var _this = this;
  36956. if (value) {
  36957. // Reset anchor mesh to match attached mesh's scale
  36958. // This is needed to avoid invalid box/sphere position on first drag
  36959. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(value);
  36960. var originalParent = value.parent;
  36961. this._anchorMesh.addChild(value);
  36962. this._anchorMesh.removeChild(value);
  36963. value.setParent(originalParent);
  36964. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(value);
  36965. this.updateBoundingBox();
  36966. value.getChildMeshes(false).forEach(function (m) {
  36967. m.markAsDirty("scaling");
  36968. });
  36969. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  36970. _this._updateDummy();
  36971. });
  36972. }
  36973. };
  36974. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  36975. this._rotateSpheresParent.getChildMeshes()
  36976. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  36977. m.isVisible = (!selectedMesh || m == selectedMesh);
  36978. });
  36979. };
  36980. /**
  36981. * Updates the bounding box information for the Gizmo
  36982. */
  36983. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  36984. if (this.attachedMesh) {
  36985. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  36986. var originalParent = this.attachedMesh.parent;
  36987. this.attachedMesh.setParent(null);
  36988. this._update();
  36989. // Rotate based on axis
  36990. if (!this.attachedMesh.rotationQuaternion) {
  36991. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  36992. }
  36993. if (!this._anchorMesh.rotationQuaternion) {
  36994. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  36995. }
  36996. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  36997. // Store original position and reset mesh to origin before computing the bounding box
  36998. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  36999. this._tmpVector.copyFrom(this.attachedMesh.position);
  37000. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37001. this.attachedMesh.position.set(0, 0, 0);
  37002. // Update bounding dimensions/positions
  37003. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37004. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37005. // Update gizmo to match bounding box scaling and rotation
  37006. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37007. 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);
  37008. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37009. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37010. this._lineBoundingBox.computeWorldMatrix();
  37011. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37012. // restore position/rotation values
  37013. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37014. this.attachedMesh.position.copyFrom(this._tmpVector);
  37015. this.attachedMesh.setParent(originalParent);
  37016. }
  37017. this._updateRotationSpheres();
  37018. this._updateScaleBoxes();
  37019. if (this.attachedMesh) {
  37020. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37021. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37022. }
  37023. };
  37024. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37025. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37026. for (var i = 0; i < 3; i++) {
  37027. for (var j = 0; j < 2; j++) {
  37028. for (var k = 0; k < 2; k++) {
  37029. var index = ((i * 4) + (j * 2)) + k;
  37030. if (i == 0) {
  37031. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37032. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37033. 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));
  37034. }
  37035. if (i == 1) {
  37036. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37037. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37038. 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));
  37039. }
  37040. if (i == 2) {
  37041. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37042. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37043. 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));
  37044. }
  37045. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37046. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37047. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37048. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37049. }
  37050. else {
  37051. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37052. }
  37053. }
  37054. }
  37055. }
  37056. };
  37057. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37058. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37059. for (var i = 0; i < 2; i++) {
  37060. for (var j = 0; j < 2; j++) {
  37061. for (var k = 0; k < 2; k++) {
  37062. var index = ((i * 4) + (j * 2)) + k;
  37063. if (scaleBoxes[index]) {
  37064. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37065. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37066. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37067. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37068. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37069. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37070. }
  37071. else {
  37072. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37073. }
  37074. }
  37075. }
  37076. }
  37077. }
  37078. };
  37079. /**
  37080. * Enables rotation on the specified axis and disables rotation on the others
  37081. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37082. */
  37083. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  37084. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  37085. if (i < 4) {
  37086. m.setEnabled(axis.indexOf("x") != -1);
  37087. }
  37088. else if (i < 8) {
  37089. m.setEnabled(axis.indexOf("y") != -1);
  37090. }
  37091. else {
  37092. m.setEnabled(axis.indexOf("z") != -1);
  37093. }
  37094. });
  37095. };
  37096. /**
  37097. * Enables/disables scaling
  37098. * @param enable if scaling should be enabled
  37099. */
  37100. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  37101. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  37102. m.setEnabled(enable);
  37103. });
  37104. };
  37105. BoundingBoxGizmo.prototype._updateDummy = function () {
  37106. if (this._dragMesh) {
  37107. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  37108. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  37109. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  37110. }
  37111. };
  37112. /**
  37113. * Enables a pointer drag behavior on the bounding box of the gizmo
  37114. */
  37115. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  37116. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  37117. this._dragMesh.visibility = 0;
  37118. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37119. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  37120. this._dragMesh.addBehavior(this.pointerDragBehavior);
  37121. };
  37122. /**
  37123. * Disposes of the gizmo
  37124. */
  37125. BoundingBoxGizmo.prototype.dispose = function () {
  37126. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37127. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  37128. this._lineBoundingBox.dispose();
  37129. this._rotateSpheresParent.dispose();
  37130. this._scaleBoxesParent.dispose();
  37131. if (this._dragMesh) {
  37132. this._dragMesh.dispose();
  37133. }
  37134. _super.prototype.dispose.call(this);
  37135. };
  37136. /**
  37137. * 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)
  37138. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  37139. * @returns the bounding box mesh with the passed in mesh as a child
  37140. */
  37141. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  37142. var makeNotPickable = function (root) {
  37143. root.isPickable = false;
  37144. root.getChildMeshes().forEach(function (c) {
  37145. makeNotPickable(c);
  37146. });
  37147. };
  37148. makeNotPickable(mesh);
  37149. // Reset position to get boudning box from origin with no rotation
  37150. if (!mesh.rotationQuaternion) {
  37151. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  37152. }
  37153. var oldPos = mesh.position.clone();
  37154. var oldRot = mesh.rotationQuaternion.clone();
  37155. mesh.rotationQuaternion.set(0, 0, 0, 1);
  37156. mesh.position.set(0, 0, 0);
  37157. // Update bounding dimensions/positions
  37158. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  37159. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  37160. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  37161. // Adjust scale to avoid undefined behavior when adding child
  37162. if (box.scaling.y === 0) {
  37163. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37164. }
  37165. if (box.scaling.x === 0) {
  37166. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37167. }
  37168. if (box.scaling.z === 0) {
  37169. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37170. }
  37171. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  37172. // Restore original positions
  37173. mesh.addChild(box);
  37174. mesh.rotationQuaternion.copyFrom(oldRot);
  37175. mesh.position.copyFrom(oldPos);
  37176. // Reverse parenting
  37177. mesh.removeChild(box);
  37178. box.addChild(mesh);
  37179. box.visibility = 0;
  37180. return box;
  37181. };
  37182. /**
  37183. * CustomMeshes are not supported by this gizmo
  37184. * @param mesh The mesh to replace the default mesh of the gizmo
  37185. */
  37186. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  37187. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  37188. };
  37189. return BoundingBoxGizmo;
  37190. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37191. /***/ }),
  37192. /***/ "./Gizmos/gizmo.ts":
  37193. /*!*************************!*\
  37194. !*** ./Gizmos/gizmo.ts ***!
  37195. \*************************/
  37196. /*! exports provided: Gizmo */
  37197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37198. "use strict";
  37199. __webpack_require__.r(__webpack_exports__);
  37200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  37201. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37202. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37203. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37204. /**
  37205. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  37206. */
  37207. var Gizmo = /** @class */ (function () {
  37208. /**
  37209. * Creates a gizmo
  37210. * @param gizmoLayer The utility layer the gizmo will be added to
  37211. */
  37212. function Gizmo(
  37213. /** The utility layer the gizmo will be added to */
  37214. gizmoLayer) {
  37215. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37216. var _this = this;
  37217. this.gizmoLayer = gizmoLayer;
  37218. /**
  37219. * Ratio for the scale of the gizmo (Default: 1)
  37220. */
  37221. this.scaleRatio = 1;
  37222. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  37223. /**
  37224. * If a custom mesh has been set (Default: false)
  37225. */
  37226. this._customMeshSet = false;
  37227. /**
  37228. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  37229. */
  37230. this.updateGizmoRotationToMatchAttachedMesh = true;
  37231. /**
  37232. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  37233. */
  37234. this.updateGizmoPositionToMatchAttachedMesh = true;
  37235. /**
  37236. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  37237. */
  37238. this._updateScale = true;
  37239. this._interactionsEnabled = true;
  37240. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  37241. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  37242. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  37243. _this._update();
  37244. });
  37245. this.attachedMesh = null;
  37246. }
  37247. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  37248. /**
  37249. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  37250. * * When set, interactions will be enabled
  37251. */
  37252. get: function () {
  37253. return this._attachedMesh;
  37254. },
  37255. set: function (value) {
  37256. this._attachedMesh = value;
  37257. this._rootMesh.setEnabled(value ? true : false);
  37258. this._attachedMeshChanged(value);
  37259. },
  37260. enumerable: true,
  37261. configurable: true
  37262. });
  37263. /**
  37264. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37265. * @param mesh The mesh to replace the default mesh of the gizmo
  37266. */
  37267. Gizmo.prototype.setCustomMesh = function (mesh) {
  37268. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  37269. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  37270. }
  37271. this._rootMesh.getChildMeshes().forEach(function (c) {
  37272. c.dispose();
  37273. });
  37274. mesh.parent = this._rootMesh;
  37275. this._customMeshSet = true;
  37276. };
  37277. Gizmo.prototype._attachedMeshChanged = function (value) {
  37278. };
  37279. /**
  37280. * @hidden
  37281. * Updates the gizmo to match the attached mesh's position/rotation
  37282. */
  37283. Gizmo.prototype._update = function () {
  37284. if (this.attachedMesh) {
  37285. if (this.updateGizmoRotationToMatchAttachedMesh) {
  37286. if (!this._rootMesh.rotationQuaternion) {
  37287. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  37288. }
  37289. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  37290. this._tempVector.copyFrom(this.attachedMesh.scaling);
  37291. if (this.attachedMesh.scaling.x < 0) {
  37292. this.attachedMesh.scaling.x *= -1;
  37293. }
  37294. if (this.attachedMesh.scaling.y < 0) {
  37295. this.attachedMesh.scaling.y *= -1;
  37296. }
  37297. if (this.attachedMesh.scaling.z < 0) {
  37298. this.attachedMesh.scaling.z *= -1;
  37299. }
  37300. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  37301. this.attachedMesh.scaling.copyFrom(this._tempVector);
  37302. this.attachedMesh.computeWorldMatrix();
  37303. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  37304. }
  37305. else if (this._rootMesh.rotationQuaternion) {
  37306. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  37307. }
  37308. if (this.updateGizmoPositionToMatchAttachedMesh) {
  37309. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  37310. }
  37311. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  37312. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  37313. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  37314. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  37315. }
  37316. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  37317. var dist = this._tempVector.length() * this.scaleRatio;
  37318. this._rootMesh.scaling.set(dist, dist, dist);
  37319. }
  37320. }
  37321. };
  37322. /**
  37323. * Disposes of the gizmo
  37324. */
  37325. Gizmo.prototype.dispose = function () {
  37326. this._rootMesh.dispose();
  37327. if (this._beforeRenderObserver) {
  37328. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  37329. }
  37330. };
  37331. return Gizmo;
  37332. }());
  37333. /***/ }),
  37334. /***/ "./Gizmos/gizmoManager.ts":
  37335. /*!********************************!*\
  37336. !*** ./Gizmos/gizmoManager.ts ***!
  37337. \********************************/
  37338. /*! exports provided: GizmoManager */
  37339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37340. "use strict";
  37341. __webpack_require__.r(__webpack_exports__);
  37342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  37343. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37344. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  37345. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37346. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37347. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37348. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  37349. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37350. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37351. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37352. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37353. /**
  37354. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  37355. */
  37356. var GizmoManager = /** @class */ (function () {
  37357. /**
  37358. * Instatiates a gizmo manager
  37359. * @param scene the scene to overlay the gizmos on top of
  37360. */
  37361. function GizmoManager(scene) {
  37362. var _this = this;
  37363. this.scene = scene;
  37364. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  37365. this.clearGizmoOnEmptyPointerEvent = false;
  37366. /** Fires an event when the manager is attached to a mesh */
  37367. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  37368. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  37369. this._pointerObserver = null;
  37370. this._attachedMesh = null;
  37371. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  37372. /**
  37373. * When bounding box gizmo is enabled, this can be used to track drag/end events
  37374. */
  37375. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  37376. /**
  37377. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  37378. */
  37379. this.attachableMeshes = null;
  37380. /**
  37381. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  37382. */
  37383. this.usePointerToAttachGizmos = true;
  37384. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37385. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  37386. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37387. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  37388. // Instatiate/dispose gizmos based on pointer actions
  37389. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  37390. if (!_this.usePointerToAttachGizmos) {
  37391. return;
  37392. }
  37393. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  37394. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  37395. var node = pointerInfo.pickInfo.pickedMesh;
  37396. if (_this.attachableMeshes == null) {
  37397. // Attach to the most parent node
  37398. while (node && node.parent != null) {
  37399. node = node.parent;
  37400. }
  37401. }
  37402. else {
  37403. // Attach to the parent node that is an attachableMesh
  37404. var found = false;
  37405. _this.attachableMeshes.forEach(function (mesh) {
  37406. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  37407. node = mesh;
  37408. found = true;
  37409. }
  37410. });
  37411. if (!found) {
  37412. node = null;
  37413. }
  37414. }
  37415. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  37416. if (_this._attachedMesh != node) {
  37417. _this.attachToMesh(node);
  37418. }
  37419. }
  37420. else {
  37421. if (_this.clearGizmoOnEmptyPointerEvent) {
  37422. _this.attachToMesh(null);
  37423. }
  37424. }
  37425. }
  37426. else {
  37427. if (_this.clearGizmoOnEmptyPointerEvent) {
  37428. _this.attachToMesh(null);
  37429. }
  37430. }
  37431. }
  37432. });
  37433. }
  37434. /**
  37435. * Attaches a set of gizmos to the specified mesh
  37436. * @param mesh The mesh the gizmo's should be attached to
  37437. */
  37438. GizmoManager.prototype.attachToMesh = function (mesh) {
  37439. if (this._attachedMesh) {
  37440. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37441. }
  37442. this._attachedMesh = mesh;
  37443. for (var key in this.gizmos) {
  37444. var gizmo = (this.gizmos[key]);
  37445. if (gizmo && this._gizmosEnabled[key]) {
  37446. gizmo.attachedMesh = mesh;
  37447. }
  37448. }
  37449. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  37450. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37451. }
  37452. this.onAttachedToMeshObservable.notifyObservers(mesh);
  37453. };
  37454. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  37455. get: function () {
  37456. return this._gizmosEnabled.positionGizmo;
  37457. },
  37458. /**
  37459. * If the position gizmo is enabled
  37460. */
  37461. set: function (value) {
  37462. if (value) {
  37463. if (!this.gizmos.positionGizmo) {
  37464. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  37465. }
  37466. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  37467. }
  37468. else if (this.gizmos.positionGizmo) {
  37469. this.gizmos.positionGizmo.attachedMesh = null;
  37470. }
  37471. this._gizmosEnabled.positionGizmo = value;
  37472. },
  37473. enumerable: true,
  37474. configurable: true
  37475. });
  37476. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  37477. get: function () {
  37478. return this._gizmosEnabled.rotationGizmo;
  37479. },
  37480. /**
  37481. * If the rotation gizmo is enabled
  37482. */
  37483. set: function (value) {
  37484. if (value) {
  37485. if (!this.gizmos.rotationGizmo) {
  37486. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  37487. }
  37488. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  37489. }
  37490. else if (this.gizmos.rotationGizmo) {
  37491. this.gizmos.rotationGizmo.attachedMesh = null;
  37492. }
  37493. this._gizmosEnabled.rotationGizmo = value;
  37494. },
  37495. enumerable: true,
  37496. configurable: true
  37497. });
  37498. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  37499. get: function () {
  37500. return this._gizmosEnabled.scaleGizmo;
  37501. },
  37502. /**
  37503. * If the scale gizmo is enabled
  37504. */
  37505. set: function (value) {
  37506. if (value) {
  37507. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  37508. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  37509. }
  37510. else if (this.gizmos.scaleGizmo) {
  37511. this.gizmos.scaleGizmo.attachedMesh = null;
  37512. }
  37513. this._gizmosEnabled.scaleGizmo = value;
  37514. },
  37515. enumerable: true,
  37516. configurable: true
  37517. });
  37518. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  37519. get: function () {
  37520. return this._gizmosEnabled.boundingBoxGizmo;
  37521. },
  37522. /**
  37523. * If the boundingBox gizmo is enabled
  37524. */
  37525. set: function (value) {
  37526. if (value) {
  37527. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  37528. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  37529. if (this._attachedMesh) {
  37530. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37531. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37532. }
  37533. }
  37534. else if (this.gizmos.boundingBoxGizmo) {
  37535. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  37536. }
  37537. this._gizmosEnabled.boundingBoxGizmo = value;
  37538. },
  37539. enumerable: true,
  37540. configurable: true
  37541. });
  37542. /**
  37543. * Disposes of the gizmo manager
  37544. */
  37545. GizmoManager.prototype.dispose = function () {
  37546. this.scene.onPointerObservable.remove(this._pointerObserver);
  37547. for (var key in this.gizmos) {
  37548. var gizmo = (this.gizmos[key]);
  37549. if (gizmo) {
  37550. gizmo.dispose();
  37551. }
  37552. }
  37553. this._defaultKeepDepthUtilityLayer.dispose();
  37554. this._defaultUtilityLayer.dispose();
  37555. this.boundingBoxDragBehavior.detach();
  37556. this.onAttachedToMeshObservable.clear();
  37557. };
  37558. return GizmoManager;
  37559. }());
  37560. /***/ }),
  37561. /***/ "./Gizmos/index.ts":
  37562. /*!*************************!*\
  37563. !*** ./Gizmos/index.ts ***!
  37564. \*************************/
  37565. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo */
  37566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37567. "use strict";
  37568. __webpack_require__.r(__webpack_exports__);
  37569. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  37570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  37571. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  37572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  37573. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  37575. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  37577. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  37578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  37579. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  37580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  37581. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  37583. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  37585. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  37587. /***/ }),
  37588. /***/ "./Gizmos/planeRotationGizmo.ts":
  37589. /*!**************************************!*\
  37590. !*** ./Gizmos/planeRotationGizmo.ts ***!
  37591. \**************************************/
  37592. /*! exports provided: PlaneRotationGizmo */
  37593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37594. "use strict";
  37595. __webpack_require__.r(__webpack_exports__);
  37596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  37597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37598. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37599. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37600. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37601. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37602. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37603. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37604. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37605. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37606. /**
  37607. * Single plane rotation gizmo
  37608. */
  37609. var PlaneRotationGizmo = /** @class */ (function (_super) {
  37610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  37611. /**
  37612. * Creates a PlaneRotationGizmo
  37613. * @param gizmoLayer The utility layer the gizmo will be added to
  37614. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  37615. * @param color The color of the gizmo
  37616. * @param tessellation Amount of tessellation to be used when creating rotation circles
  37617. */
  37618. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  37619. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37620. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37621. if (tessellation === void 0) { tessellation = 32; }
  37622. var _this = _super.call(this, gizmoLayer) || this;
  37623. _this._pointerObserver = null;
  37624. /**
  37625. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  37626. */
  37627. _this.snapDistance = 0;
  37628. /**
  37629. * Event that fires each time the gizmo snaps to a new location.
  37630. * * snapDistance is the the change in distance
  37631. */
  37632. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37633. // Create Material
  37634. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37635. coloredMaterial.disableLighting = true;
  37636. coloredMaterial.emissiveColor = color;
  37637. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37638. hoverMaterial.disableLighting = true;
  37639. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37640. // Build mesh on root node
  37641. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37642. // Create circle out of lines
  37643. var radius = 0.8;
  37644. var points = new Array();
  37645. for (var i = 0; i < tessellation; i++) {
  37646. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  37647. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  37648. }
  37649. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  37650. rotationMesh.color = coloredMaterial.emissiveColor;
  37651. // Position arrow pointing in its drag axis
  37652. rotationMesh.scaling.scaleInPlace(0.26);
  37653. rotationMesh.material = coloredMaterial;
  37654. rotationMesh.rotation.x = Math.PI / 2;
  37655. parentMesh.addChild(rotationMesh);
  37656. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  37657. _this._rootMesh.addChild(parentMesh);
  37658. parentMesh.scaling.scaleInPlace(1 / 3);
  37659. // Add drag behavior to handle events when the gizmo is dragged
  37660. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  37661. _this.dragBehavior.moveAttached = false;
  37662. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  37663. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  37664. _this._rootMesh.addBehavior(_this.dragBehavior);
  37665. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37666. _this.dragBehavior.onDragStartObservable.add(function (e) {
  37667. if (_this.attachedMesh) {
  37668. lastDragPosition.copyFrom(e.dragPlanePoint);
  37669. }
  37670. });
  37671. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37672. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37673. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37674. var tmpSnapEvent = { snapDistance: 0 };
  37675. var currentSnapDragDistance = 0;
  37676. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37677. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37678. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37679. _this.dragBehavior.onDragObservable.add(function (event) {
  37680. if (_this.attachedMesh) {
  37681. if (!_this.attachedMesh.rotationQuaternion) {
  37682. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37683. }
  37684. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  37685. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  37686. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  37687. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  37688. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  37689. var angle = Math.atan2(cross.length(), dot);
  37690. planeNormalTowardsCamera.copyFrom(planeNormal);
  37691. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  37692. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37693. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  37694. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  37695. }
  37696. // Flip up vector depending on which side the camera is on
  37697. if (gizmoLayer.utilityLayerScene.activeCamera) {
  37698. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  37699. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  37700. planeNormalTowardsCamera.scaleInPlace(-1);
  37701. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  37702. }
  37703. }
  37704. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  37705. if (halfCircleSide) {
  37706. angle = -angle;
  37707. }
  37708. // Snapping logic
  37709. var snapped = false;
  37710. if (_this.snapDistance != 0) {
  37711. currentSnapDragDistance += angle;
  37712. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37713. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37714. if (currentSnapDragDistance < 0) {
  37715. dragSteps *= -1;
  37716. }
  37717. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37718. angle = _this.snapDistance * dragSteps;
  37719. snapped = true;
  37720. }
  37721. else {
  37722. angle = 0;
  37723. }
  37724. }
  37725. // If the mesh has a parent, convert needed world rotation to local rotation
  37726. tmpMatrix.reset();
  37727. if (_this.attachedMesh.parent) {
  37728. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37729. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  37730. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  37731. }
  37732. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  37733. var quaternionCoefficient = Math.sin(angle / 2);
  37734. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  37735. // 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
  37736. if (tmpMatrix.determinant() > 0) {
  37737. amountToRotate.toEulerAnglesToRef(tmpVector);
  37738. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  37739. }
  37740. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37741. // Rotate selected mesh quaternion over fixed axis
  37742. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  37743. }
  37744. else {
  37745. // Rotate selected mesh quaternion over rotated axis
  37746. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  37747. }
  37748. lastDragPosition.copyFrom(event.dragPlanePoint);
  37749. if (snapped) {
  37750. tmpSnapEvent.snapDistance = angle;
  37751. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37752. }
  37753. }
  37754. });
  37755. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37756. if (_this._customMeshSet) {
  37757. return;
  37758. }
  37759. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37760. var material = isHovered ? hoverMaterial : coloredMaterial;
  37761. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37762. m.material = material;
  37763. if (m.color) {
  37764. m.color = material.emissiveColor;
  37765. }
  37766. });
  37767. });
  37768. return _this;
  37769. }
  37770. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  37771. if (this.dragBehavior) {
  37772. this.dragBehavior.enabled = value ? true : false;
  37773. }
  37774. };
  37775. /**
  37776. * Disposes of the gizmo
  37777. */
  37778. PlaneRotationGizmo.prototype.dispose = function () {
  37779. this.onSnapObservable.clear();
  37780. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37781. this.dragBehavior.detach();
  37782. _super.prototype.dispose.call(this);
  37783. };
  37784. return PlaneRotationGizmo;
  37785. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  37786. /***/ }),
  37787. /***/ "./Gizmos/positionGizmo.ts":
  37788. /*!*********************************!*\
  37789. !*** ./Gizmos/positionGizmo.ts ***!
  37790. \*********************************/
  37791. /*! exports provided: PositionGizmo */
  37792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37793. "use strict";
  37794. __webpack_require__.r(__webpack_exports__);
  37795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  37796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37797. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37798. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37800. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37801. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  37802. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37803. /**
  37804. * Gizmo that enables dragging a mesh along 3 axis
  37805. */
  37806. var PositionGizmo = /** @class */ (function (_super) {
  37807. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  37808. /**
  37809. * Creates a PositionGizmo
  37810. * @param gizmoLayer The utility layer the gizmo will be added to
  37811. */
  37812. function PositionGizmo(gizmoLayer) {
  37813. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37814. var _this = _super.call(this, gizmoLayer) || this;
  37815. /** Fires an event when any of it's sub gizmos are dragged */
  37816. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37817. /** Fires an event when any of it's sub gizmos are released from dragging */
  37818. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37819. _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);
  37820. _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);
  37821. _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);
  37822. // Relay drag events
  37823. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  37824. gizmo.dragBehavior.onDragStartObservable.add(function () {
  37825. _this.onDragStartObservable.notifyObservers({});
  37826. });
  37827. gizmo.dragBehavior.onDragEndObservable.add(function () {
  37828. _this.onDragEndObservable.notifyObservers({});
  37829. });
  37830. });
  37831. _this.attachedMesh = null;
  37832. return _this;
  37833. }
  37834. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  37835. set: function (mesh) {
  37836. if (this.xGizmo) {
  37837. this.xGizmo.attachedMesh = mesh;
  37838. this.yGizmo.attachedMesh = mesh;
  37839. this.zGizmo.attachedMesh = mesh;
  37840. }
  37841. },
  37842. enumerable: true,
  37843. configurable: true
  37844. });
  37845. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  37846. get: function () {
  37847. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  37848. },
  37849. set: function (value) {
  37850. if (this.xGizmo) {
  37851. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37852. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37853. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37854. }
  37855. },
  37856. enumerable: true,
  37857. configurable: true
  37858. });
  37859. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  37860. get: function () {
  37861. return this.xGizmo.snapDistance;
  37862. },
  37863. /**
  37864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37865. */
  37866. set: function (value) {
  37867. if (this.xGizmo) {
  37868. this.xGizmo.snapDistance = value;
  37869. this.yGizmo.snapDistance = value;
  37870. this.zGizmo.snapDistance = value;
  37871. }
  37872. },
  37873. enumerable: true,
  37874. configurable: true
  37875. });
  37876. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  37877. get: function () {
  37878. return this.xGizmo.scaleRatio;
  37879. },
  37880. /**
  37881. * Ratio for the scale of the gizmo (Default: 1)
  37882. */
  37883. set: function (value) {
  37884. if (this.xGizmo) {
  37885. this.xGizmo.scaleRatio = value;
  37886. this.yGizmo.scaleRatio = value;
  37887. this.zGizmo.scaleRatio = value;
  37888. }
  37889. },
  37890. enumerable: true,
  37891. configurable: true
  37892. });
  37893. /**
  37894. * Disposes of the gizmo
  37895. */
  37896. PositionGizmo.prototype.dispose = function () {
  37897. this.xGizmo.dispose();
  37898. this.yGizmo.dispose();
  37899. this.zGizmo.dispose();
  37900. this.onDragStartObservable.clear();
  37901. this.onDragEndObservable.clear();
  37902. };
  37903. /**
  37904. * CustomMeshes are not supported by this gizmo
  37905. * @param mesh The mesh to replace the default mesh of the gizmo
  37906. */
  37907. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  37908. _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)");
  37909. };
  37910. return PositionGizmo;
  37911. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  37912. /***/ }),
  37913. /***/ "./Gizmos/rotationGizmo.ts":
  37914. /*!*********************************!*\
  37915. !*** ./Gizmos/rotationGizmo.ts ***!
  37916. \*********************************/
  37917. /*! exports provided: RotationGizmo */
  37918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37919. "use strict";
  37920. __webpack_require__.r(__webpack_exports__);
  37921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  37922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37923. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37924. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37925. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37926. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37927. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  37928. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37929. /**
  37930. * Gizmo that enables rotating a mesh along 3 axis
  37931. */
  37932. var RotationGizmo = /** @class */ (function (_super) {
  37933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  37934. /**
  37935. * Creates a RotationGizmo
  37936. * @param gizmoLayer The utility layer the gizmo will be added to
  37937. * @param tessellation Amount of tessellation to be used when creating rotation circles
  37938. */
  37939. function RotationGizmo(gizmoLayer, tessellation) {
  37940. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37941. if (tessellation === void 0) { tessellation = 32; }
  37942. var _this = _super.call(this, gizmoLayer) || this;
  37943. /** Fires an event when any of it's sub gizmos are dragged */
  37944. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37945. /** Fires an event when any of it's sub gizmos are released from dragging */
  37946. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37947. _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);
  37948. _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);
  37949. _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);
  37950. // Relay drag events
  37951. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  37952. gizmo.dragBehavior.onDragStartObservable.add(function () {
  37953. _this.onDragStartObservable.notifyObservers({});
  37954. });
  37955. gizmo.dragBehavior.onDragEndObservable.add(function () {
  37956. _this.onDragEndObservable.notifyObservers({});
  37957. });
  37958. });
  37959. _this.attachedMesh = null;
  37960. return _this;
  37961. }
  37962. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  37963. set: function (mesh) {
  37964. if (this.xGizmo) {
  37965. this.xGizmo.attachedMesh = mesh;
  37966. this.yGizmo.attachedMesh = mesh;
  37967. this.zGizmo.attachedMesh = mesh;
  37968. }
  37969. },
  37970. enumerable: true,
  37971. configurable: true
  37972. });
  37973. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  37974. get: function () {
  37975. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  37976. },
  37977. set: function (value) {
  37978. if (this.xGizmo) {
  37979. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37980. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37981. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37982. }
  37983. },
  37984. enumerable: true,
  37985. configurable: true
  37986. });
  37987. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  37988. get: function () {
  37989. return this.xGizmo.snapDistance;
  37990. },
  37991. /**
  37992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37993. */
  37994. set: function (value) {
  37995. if (this.xGizmo) {
  37996. this.xGizmo.snapDistance = value;
  37997. this.yGizmo.snapDistance = value;
  37998. this.zGizmo.snapDistance = value;
  37999. }
  38000. },
  38001. enumerable: true,
  38002. configurable: true
  38003. });
  38004. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  38005. get: function () {
  38006. return this.xGizmo.scaleRatio;
  38007. },
  38008. /**
  38009. * Ratio for the scale of the gizmo (Default: 1)
  38010. */
  38011. set: function (value) {
  38012. if (this.xGizmo) {
  38013. this.xGizmo.scaleRatio = value;
  38014. this.yGizmo.scaleRatio = value;
  38015. this.zGizmo.scaleRatio = value;
  38016. }
  38017. },
  38018. enumerable: true,
  38019. configurable: true
  38020. });
  38021. /**
  38022. * Disposes of the gizmo
  38023. */
  38024. RotationGizmo.prototype.dispose = function () {
  38025. this.xGizmo.dispose();
  38026. this.yGizmo.dispose();
  38027. this.zGizmo.dispose();
  38028. this.onDragStartObservable.clear();
  38029. this.onDragEndObservable.clear();
  38030. };
  38031. /**
  38032. * CustomMeshes are not supported by this gizmo
  38033. * @param mesh The mesh to replace the default mesh of the gizmo
  38034. */
  38035. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  38036. _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)");
  38037. };
  38038. return RotationGizmo;
  38039. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38040. /***/ }),
  38041. /***/ "./Gizmos/scaleGizmo.ts":
  38042. /*!******************************!*\
  38043. !*** ./Gizmos/scaleGizmo.ts ***!
  38044. \******************************/
  38045. /*! exports provided: ScaleGizmo */
  38046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38047. "use strict";
  38048. __webpack_require__.r(__webpack_exports__);
  38049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  38050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38051. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38054. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38055. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38056. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38057. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38058. /**
  38059. * Gizmo that enables scaling a mesh along 3 axis
  38060. */
  38061. var ScaleGizmo = /** @class */ (function (_super) {
  38062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  38063. /**
  38064. * Creates a ScaleGizmo
  38065. * @param gizmoLayer The utility layer the gizmo will be added to
  38066. */
  38067. function ScaleGizmo(gizmoLayer) {
  38068. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38069. var _this = _super.call(this, gizmoLayer) || this;
  38070. /** Fires an event when any of it's sub gizmos are dragged */
  38071. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38072. /** Fires an event when any of it's sub gizmos are released from dragging */
  38073. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38074. _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);
  38075. _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);
  38076. _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);
  38077. // Create uniform scale gizmo
  38078. _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);
  38079. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  38080. _this.uniformScaleGizmo.uniformScaling = true;
  38081. var uniformScalingMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38082. uniformScalingMesh.scaling.scaleInPlace(0.02);
  38083. uniformScalingMesh.visibility = 0;
  38084. var octahedron = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38085. octahedron.scaling.scaleInPlace(0.007);
  38086. uniformScalingMesh.addChild(octahedron);
  38087. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  38088. // Relay drag events
  38089. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  38090. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38091. _this.onDragStartObservable.notifyObservers({});
  38092. });
  38093. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38094. _this.onDragEndObservable.notifyObservers({});
  38095. });
  38096. });
  38097. _this.attachedMesh = null;
  38098. return _this;
  38099. }
  38100. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  38101. set: function (mesh) {
  38102. if (this.xGizmo) {
  38103. this.xGizmo.attachedMesh = mesh;
  38104. this.yGizmo.attachedMesh = mesh;
  38105. this.zGizmo.attachedMesh = mesh;
  38106. this.uniformScaleGizmo.attachedMesh = mesh;
  38107. }
  38108. },
  38109. enumerable: true,
  38110. configurable: true
  38111. });
  38112. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38113. get: function () {
  38114. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38115. },
  38116. set: function (value) {
  38117. if (!value) {
  38118. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  38119. }
  38120. if (this.xGizmo) {
  38121. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38122. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38123. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38124. }
  38125. },
  38126. enumerable: true,
  38127. configurable: true
  38128. });
  38129. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  38130. get: function () {
  38131. return this.xGizmo.snapDistance;
  38132. },
  38133. /**
  38134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38135. */
  38136. set: function (value) {
  38137. if (this.xGizmo) {
  38138. this.xGizmo.snapDistance = value;
  38139. this.yGizmo.snapDistance = value;
  38140. this.zGizmo.snapDistance = value;
  38141. this.uniformScaleGizmo.snapDistance = value;
  38142. }
  38143. },
  38144. enumerable: true,
  38145. configurable: true
  38146. });
  38147. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  38148. get: function () {
  38149. return this.xGizmo.scaleRatio;
  38150. },
  38151. /**
  38152. * Ratio for the scale of the gizmo (Default: 1)
  38153. */
  38154. set: function (value) {
  38155. if (this.xGizmo) {
  38156. this.xGizmo.scaleRatio = value;
  38157. this.yGizmo.scaleRatio = value;
  38158. this.zGizmo.scaleRatio = value;
  38159. this.uniformScaleGizmo.scaleRatio = value;
  38160. }
  38161. },
  38162. enumerable: true,
  38163. configurable: true
  38164. });
  38165. /**
  38166. * Disposes of the gizmo
  38167. */
  38168. ScaleGizmo.prototype.dispose = function () {
  38169. this.xGizmo.dispose();
  38170. this.yGizmo.dispose();
  38171. this.zGizmo.dispose();
  38172. this.uniformScaleGizmo.dispose();
  38173. this.onDragStartObservable.clear();
  38174. this.onDragEndObservable.clear();
  38175. };
  38176. return ScaleGizmo;
  38177. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  38178. /***/ }),
  38179. /***/ "./Helpers/environmentHelper.ts":
  38180. /*!**************************************!*\
  38181. !*** ./Helpers/environmentHelper.ts ***!
  38182. \**************************************/
  38183. /*! exports provided: EnvironmentHelper */
  38184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38185. "use strict";
  38186. __webpack_require__.r(__webpack_exports__);
  38187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  38188. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38189. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38190. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38192. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38193. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  38194. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38195. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  38196. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  38197. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38198. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  38199. /**
  38200. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  38201. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  38202. * It also helps with the default setup of your imageProcessing configuration.
  38203. */
  38204. var EnvironmentHelper = /** @class */ (function () {
  38205. /**
  38206. * constructor
  38207. * @param options
  38208. * @param scene The scene to add the material to
  38209. */
  38210. function EnvironmentHelper(options, scene) {
  38211. var _this = this;
  38212. this._errorHandler = function (message, exception) {
  38213. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  38214. };
  38215. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  38216. this._scene = scene;
  38217. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38218. this._setupBackground();
  38219. this._setupImageProcessing();
  38220. }
  38221. /**
  38222. * Creates the default options for the helper.
  38223. */
  38224. EnvironmentHelper._getDefaultOptions = function () {
  38225. return {
  38226. createGround: true,
  38227. groundSize: 15,
  38228. groundTexture: this._groundTextureCDNUrl,
  38229. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38230. groundOpacity: 0.9,
  38231. enableGroundShadow: true,
  38232. groundShadowLevel: 0.5,
  38233. enableGroundMirror: false,
  38234. groundMirrorSizeRatio: 0.3,
  38235. groundMirrorBlurKernel: 64,
  38236. groundMirrorAmount: 1,
  38237. groundMirrorFresnelWeight: 1,
  38238. groundMirrorFallOffDistance: 0,
  38239. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  38240. groundYBias: 0.00001,
  38241. createSkybox: true,
  38242. skyboxSize: 20,
  38243. skyboxTexture: this._skyboxTextureCDNUrl,
  38244. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38245. backgroundYRotation: 0,
  38246. sizeAuto: true,
  38247. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  38248. setupImageProcessing: true,
  38249. environmentTexture: this._environmentTextureCDNUrl,
  38250. cameraExposure: 0.8,
  38251. cameraContrast: 1.2,
  38252. toneMappingEnabled: true,
  38253. };
  38254. };
  38255. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  38256. /**
  38257. * Gets the root mesh created by the helper.
  38258. */
  38259. get: function () {
  38260. return this._rootMesh;
  38261. },
  38262. enumerable: true,
  38263. configurable: true
  38264. });
  38265. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  38266. /**
  38267. * Gets the skybox created by the helper.
  38268. */
  38269. get: function () {
  38270. return this._skybox;
  38271. },
  38272. enumerable: true,
  38273. configurable: true
  38274. });
  38275. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  38276. /**
  38277. * Gets the skybox texture created by the helper.
  38278. */
  38279. get: function () {
  38280. return this._skyboxTexture;
  38281. },
  38282. enumerable: true,
  38283. configurable: true
  38284. });
  38285. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  38286. /**
  38287. * Gets the skybox material created by the helper.
  38288. */
  38289. get: function () {
  38290. return this._skyboxMaterial;
  38291. },
  38292. enumerable: true,
  38293. configurable: true
  38294. });
  38295. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  38296. /**
  38297. * Gets the ground mesh created by the helper.
  38298. */
  38299. get: function () {
  38300. return this._ground;
  38301. },
  38302. enumerable: true,
  38303. configurable: true
  38304. });
  38305. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  38306. /**
  38307. * Gets the ground texture created by the helper.
  38308. */
  38309. get: function () {
  38310. return this._groundTexture;
  38311. },
  38312. enumerable: true,
  38313. configurable: true
  38314. });
  38315. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  38316. /**
  38317. * Gets the ground mirror created by the helper.
  38318. */
  38319. get: function () {
  38320. return this._groundMirror;
  38321. },
  38322. enumerable: true,
  38323. configurable: true
  38324. });
  38325. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  38326. /**
  38327. * Gets the ground mirror render list to helps pushing the meshes
  38328. * you wish in the ground reflection.
  38329. */
  38330. get: function () {
  38331. if (this._groundMirror) {
  38332. return this._groundMirror.renderList;
  38333. }
  38334. return null;
  38335. },
  38336. enumerable: true,
  38337. configurable: true
  38338. });
  38339. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  38340. /**
  38341. * Gets the ground material created by the helper.
  38342. */
  38343. get: function () {
  38344. return this._groundMaterial;
  38345. },
  38346. enumerable: true,
  38347. configurable: true
  38348. });
  38349. /**
  38350. * Updates the background according to the new options
  38351. * @param options
  38352. */
  38353. EnvironmentHelper.prototype.updateOptions = function (options) {
  38354. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  38355. if (this._ground && !newOptions.createGround) {
  38356. this._ground.dispose();
  38357. this._ground = null;
  38358. }
  38359. if (this._groundMaterial && !newOptions.createGround) {
  38360. this._groundMaterial.dispose();
  38361. this._groundMaterial = null;
  38362. }
  38363. if (this._groundTexture) {
  38364. if (this._options.groundTexture != newOptions.groundTexture) {
  38365. this._groundTexture.dispose();
  38366. this._groundTexture = null;
  38367. }
  38368. }
  38369. if (this._skybox && !newOptions.createSkybox) {
  38370. this._skybox.dispose();
  38371. this._skybox = null;
  38372. }
  38373. if (this._skyboxMaterial && !newOptions.createSkybox) {
  38374. this._skyboxMaterial.dispose();
  38375. this._skyboxMaterial = null;
  38376. }
  38377. if (this._skyboxTexture) {
  38378. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  38379. this._skyboxTexture.dispose();
  38380. this._skyboxTexture = null;
  38381. }
  38382. }
  38383. if (this._groundMirror && !newOptions.enableGroundMirror) {
  38384. this._groundMirror.dispose();
  38385. this._groundMirror = null;
  38386. }
  38387. if (this._scene.environmentTexture) {
  38388. if (this._options.environmentTexture != newOptions.environmentTexture) {
  38389. this._scene.environmentTexture.dispose();
  38390. }
  38391. }
  38392. this._options = newOptions;
  38393. this._setupBackground();
  38394. this._setupImageProcessing();
  38395. };
  38396. /**
  38397. * Sets the primary color of all the available elements.
  38398. * @param color the main color to affect to the ground and the background
  38399. */
  38400. EnvironmentHelper.prototype.setMainColor = function (color) {
  38401. if (this.groundMaterial) {
  38402. this.groundMaterial.primaryColor = color;
  38403. }
  38404. if (this.skyboxMaterial) {
  38405. this.skyboxMaterial.primaryColor = color;
  38406. }
  38407. if (this.groundMirror) {
  38408. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  38409. }
  38410. };
  38411. /**
  38412. * Setup the image processing according to the specified options.
  38413. */
  38414. EnvironmentHelper.prototype._setupImageProcessing = function () {
  38415. if (this._options.setupImageProcessing) {
  38416. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  38417. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  38418. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  38419. this._setupEnvironmentTexture();
  38420. }
  38421. };
  38422. /**
  38423. * Setup the environment texture according to the specified options.
  38424. */
  38425. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  38426. if (this._scene.environmentTexture) {
  38427. return;
  38428. }
  38429. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38430. this._scene.environmentTexture = this._options.environmentTexture;
  38431. return;
  38432. }
  38433. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  38434. this._scene.environmentTexture = environmentTexture;
  38435. };
  38436. /**
  38437. * Setup the background according to the specified options.
  38438. */
  38439. EnvironmentHelper.prototype._setupBackground = function () {
  38440. if (!this._rootMesh) {
  38441. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  38442. }
  38443. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  38444. var sceneSize = this._getSceneSize();
  38445. if (this._options.createGround) {
  38446. this._setupGround(sceneSize);
  38447. this._setupGroundMaterial();
  38448. this._setupGroundDiffuseTexture();
  38449. if (this._options.enableGroundMirror) {
  38450. this._setupGroundMirrorTexture(sceneSize);
  38451. }
  38452. this._setupMirrorInGroundMaterial();
  38453. }
  38454. if (this._options.createSkybox) {
  38455. this._setupSkybox(sceneSize);
  38456. this._setupSkyboxMaterial();
  38457. this._setupSkyboxReflectionTexture();
  38458. }
  38459. this._rootMesh.position.x = sceneSize.rootPosition.x;
  38460. this._rootMesh.position.z = sceneSize.rootPosition.z;
  38461. this._rootMesh.position.y = sceneSize.rootPosition.y;
  38462. };
  38463. /**
  38464. * Get the scene sizes according to the setup.
  38465. */
  38466. EnvironmentHelper.prototype._getSceneSize = function () {
  38467. var _this = this;
  38468. var groundSize = this._options.groundSize;
  38469. var skyboxSize = this._options.skyboxSize;
  38470. var rootPosition = this._options.rootPosition;
  38471. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  38472. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38473. }
  38474. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  38475. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  38476. });
  38477. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  38478. if (this._options.sizeAuto) {
  38479. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  38480. this._scene.activeCamera.upperRadiusLimit) {
  38481. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  38482. skyboxSize = groundSize;
  38483. }
  38484. var sceneDiagonalLenght = sceneDiagonal.length();
  38485. if (sceneDiagonalLenght > groundSize) {
  38486. groundSize = sceneDiagonalLenght * 2;
  38487. skyboxSize = groundSize;
  38488. }
  38489. // 10 % bigger.
  38490. groundSize *= 1.1;
  38491. skyboxSize *= 1.5;
  38492. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  38493. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  38494. }
  38495. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38496. };
  38497. /**
  38498. * Setup the ground according to the specified options.
  38499. */
  38500. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  38501. var _this = this;
  38502. if (!this._ground || this._ground.isDisposed()) {
  38503. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  38504. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  38505. this._ground.parent = this._rootMesh;
  38506. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  38507. }
  38508. this._ground.receiveShadows = this._options.enableGroundShadow;
  38509. };
  38510. /**
  38511. * Setup the ground material according to the specified options.
  38512. */
  38513. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  38514. if (!this._groundMaterial) {
  38515. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  38516. }
  38517. this._groundMaterial.alpha = this._options.groundOpacity;
  38518. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  38519. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  38520. this._groundMaterial.primaryColor = this._options.groundColor;
  38521. this._groundMaterial.useRGBColor = false;
  38522. this._groundMaterial.enableNoise = true;
  38523. if (this._ground) {
  38524. this._ground.material = this._groundMaterial;
  38525. }
  38526. };
  38527. /**
  38528. * Setup the ground diffuse texture according to the specified options.
  38529. */
  38530. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  38531. if (!this._groundMaterial) {
  38532. return;
  38533. }
  38534. if (this._groundTexture) {
  38535. return;
  38536. }
  38537. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38538. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  38539. return;
  38540. }
  38541. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38542. diffuseTexture.gammaSpace = false;
  38543. diffuseTexture.hasAlpha = true;
  38544. this._groundMaterial.diffuseTexture = diffuseTexture;
  38545. };
  38546. /**
  38547. * Setup the ground mirror texture according to the specified options.
  38548. */
  38549. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  38550. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  38551. if (!this._groundMirror) {
  38552. 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);
  38553. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  38554. this._groundMirror.anisotropicFilteringLevel = 1;
  38555. this._groundMirror.wrapU = wrapping;
  38556. this._groundMirror.wrapV = wrapping;
  38557. this._groundMirror.gammaSpace = false;
  38558. if (this._groundMirror.renderList) {
  38559. for (var i = 0; i < this._scene.meshes.length; i++) {
  38560. var mesh = this._scene.meshes[i];
  38561. if (mesh !== this._ground &&
  38562. mesh !== this._skybox &&
  38563. mesh !== this._rootMesh) {
  38564. this._groundMirror.renderList.push(mesh);
  38565. }
  38566. }
  38567. }
  38568. }
  38569. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  38570. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  38571. };
  38572. /**
  38573. * Setup the ground to receive the mirror texture.
  38574. */
  38575. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  38576. if (this._groundMaterial) {
  38577. this._groundMaterial.reflectionTexture = this._groundMirror;
  38578. this._groundMaterial.reflectionFresnel = true;
  38579. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  38580. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  38581. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  38582. }
  38583. };
  38584. /**
  38585. * Setup the skybox according to the specified options.
  38586. */
  38587. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  38588. var _this = this;
  38589. if (!this._skybox || this._skybox.isDisposed()) {
  38590. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  38591. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  38592. }
  38593. this._skybox.parent = this._rootMesh;
  38594. };
  38595. /**
  38596. * Setup the skybox material according to the specified options.
  38597. */
  38598. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  38599. if (!this._skybox) {
  38600. return;
  38601. }
  38602. if (!this._skyboxMaterial) {
  38603. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  38604. }
  38605. this._skyboxMaterial.useRGBColor = false;
  38606. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  38607. this._skyboxMaterial.enableNoise = true;
  38608. this._skybox.material = this._skyboxMaterial;
  38609. };
  38610. /**
  38611. * Setup the skybox reflection texture according to the specified options.
  38612. */
  38613. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  38614. if (!this._skyboxMaterial) {
  38615. return;
  38616. }
  38617. if (this._skyboxTexture) {
  38618. return;
  38619. }
  38620. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38621. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  38622. return;
  38623. }
  38624. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38625. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  38626. this._skyboxTexture.gammaSpace = false;
  38627. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  38628. };
  38629. /**
  38630. * Dispose all the elements created by the Helper.
  38631. */
  38632. EnvironmentHelper.prototype.dispose = function () {
  38633. if (this._groundMaterial) {
  38634. this._groundMaterial.dispose(true, true);
  38635. }
  38636. if (this._skyboxMaterial) {
  38637. this._skyboxMaterial.dispose(true, true);
  38638. }
  38639. this._rootMesh.dispose(false);
  38640. };
  38641. /**
  38642. * Default ground texture URL.
  38643. */
  38644. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  38645. /**
  38646. * Default skybox texture URL.
  38647. */
  38648. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  38649. /**
  38650. * Default environment texture URL.
  38651. */
  38652. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  38653. return EnvironmentHelper;
  38654. }());
  38655. /***/ }),
  38656. /***/ "./Helpers/index.ts":
  38657. /*!**************************!*\
  38658. !*** ./Helpers/index.ts ***!
  38659. \**************************/
  38660. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  38661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38662. "use strict";
  38663. __webpack_require__.r(__webpack_exports__);
  38664. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  38665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  38666. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  38667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  38668. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  38669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  38670. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  38671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  38672. /***/ }),
  38673. /***/ "./Helpers/photoDome.ts":
  38674. /*!******************************!*\
  38675. !*** ./Helpers/photoDome.ts ***!
  38676. \******************************/
  38677. /*! exports provided: PhotoDome */
  38678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38679. "use strict";
  38680. __webpack_require__.r(__webpack_exports__);
  38681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  38682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38683. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38684. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38685. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38686. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38687. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38688. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38689. /**
  38690. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  38691. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  38692. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  38693. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  38694. */
  38695. var PhotoDome = /** @class */ (function (_super) {
  38696. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  38697. /**
  38698. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  38699. * @param name Element's name, child elements will append suffixes for their own names.
  38700. * @param urlsOfPhoto defines the url of the photo to display
  38701. * @param options defines an object containing optional or exposed sub element properties
  38702. * @param onError defines a callback called when an error occured while loading the texture
  38703. */
  38704. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  38705. if (onError === void 0) { onError = null; }
  38706. var _this = _super.call(this, name, scene) || this;
  38707. _this._useDirectMapping = false;
  38708. /**
  38709. * Observable raised when an error occured while loading the 360 image
  38710. */
  38711. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38712. // set defaults and manage values
  38713. name = name || "photoDome";
  38714. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  38715. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  38716. if (options.useDirectMapping === undefined) {
  38717. _this._useDirectMapping = true;
  38718. }
  38719. else {
  38720. _this._useDirectMapping = options.useDirectMapping;
  38721. }
  38722. _this._setReady(false);
  38723. // create
  38724. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  38725. _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);
  38726. // configure material
  38727. material.opacityFresnel = false;
  38728. material.useEquirectangularFOV = true;
  38729. material.fovMultiplier = 1.0;
  38730. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  38731. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  38732. if (onError) {
  38733. onError(message, exception);
  38734. }
  38735. });
  38736. _this.photoTexture.onLoadObservable.addOnce(function () {
  38737. _this._setReady(true);
  38738. });
  38739. // configure mesh
  38740. _this._mesh.material = material;
  38741. _this._mesh.parent = _this;
  38742. return _this;
  38743. }
  38744. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  38745. /**
  38746. * Gets or sets the texture being displayed on the sphere
  38747. */
  38748. get: function () {
  38749. return this._photoTexture;
  38750. },
  38751. set: function (value) {
  38752. if (this._photoTexture === value) {
  38753. return;
  38754. }
  38755. this._photoTexture = value;
  38756. if (this._useDirectMapping) {
  38757. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38758. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38759. this._material.diffuseTexture = this._photoTexture;
  38760. }
  38761. else {
  38762. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  38763. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38764. this._material.reflectionTexture = this._photoTexture;
  38765. }
  38766. },
  38767. enumerable: true,
  38768. configurable: true
  38769. });
  38770. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  38771. /**
  38772. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  38773. * Also see the options.resolution property.
  38774. */
  38775. get: function () {
  38776. return this._material.fovMultiplier;
  38777. },
  38778. set: function (value) {
  38779. this._material.fovMultiplier = value;
  38780. },
  38781. enumerable: true,
  38782. configurable: true
  38783. });
  38784. /**
  38785. * Releases resources associated with this node.
  38786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38788. */
  38789. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  38790. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  38791. this._photoTexture.dispose();
  38792. this._mesh.dispose();
  38793. this._material.dispose();
  38794. this.onLoadErrorObservable.clear();
  38795. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  38796. };
  38797. return PhotoDome;
  38798. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  38799. /***/ }),
  38800. /***/ "./Helpers/sceneHelpers.ts":
  38801. /*!*********************************!*\
  38802. !*** ./Helpers/sceneHelpers.ts ***!
  38803. \*********************************/
  38804. /*! exports provided: _forceSceneHelpersToBundle */
  38805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38806. "use strict";
  38807. __webpack_require__.r(__webpack_exports__);
  38808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  38809. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38810. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  38811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38812. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38813. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38814. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38815. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  38816. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  38817. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  38818. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  38819. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38820. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  38821. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  38822. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  38823. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  38824. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  38825. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38826. /** @hidden */
  38827. var _forceSceneHelpersToBundle = true;
  38828. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  38829. if (replace === void 0) { replace = false; }
  38830. // Dispose existing light in replace mode.
  38831. if (replace) {
  38832. if (this.lights) {
  38833. for (var i = 0; i < this.lights.length; i++) {
  38834. this.lights[i].dispose();
  38835. }
  38836. }
  38837. }
  38838. // Light
  38839. if (this.lights.length === 0) {
  38840. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  38841. }
  38842. };
  38843. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  38844. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  38845. if (replace === void 0) { replace = false; }
  38846. if (attachCameraControls === void 0) { attachCameraControls = false; }
  38847. // Dispose existing camera in replace mode.
  38848. if (replace) {
  38849. if (this.activeCamera) {
  38850. this.activeCamera.dispose();
  38851. this.activeCamera = null;
  38852. }
  38853. }
  38854. // Camera
  38855. if (!this.activeCamera) {
  38856. var worldExtends = this.getWorldExtends();
  38857. var worldSize = worldExtends.max.subtract(worldExtends.min);
  38858. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  38859. var camera;
  38860. var radius = worldSize.length() * 1.5;
  38861. // empty scene scenario!
  38862. if (!isFinite(radius)) {
  38863. radius = 1;
  38864. worldCenter.copyFromFloats(0, 0, 0);
  38865. }
  38866. if (createArcRotateCamera) {
  38867. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  38868. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  38869. arcRotateCamera.wheelPrecision = 100 / radius;
  38870. camera = arcRotateCamera;
  38871. }
  38872. else {
  38873. 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);
  38874. freeCamera.setTarget(worldCenter);
  38875. camera = freeCamera;
  38876. }
  38877. camera.minZ = radius * 0.01;
  38878. camera.maxZ = radius * 1000;
  38879. camera.speed = radius * 0.2;
  38880. this.activeCamera = camera;
  38881. var canvas = this.getEngine().getRenderingCanvas();
  38882. if (attachCameraControls && canvas) {
  38883. camera.attachControl(canvas);
  38884. }
  38885. }
  38886. };
  38887. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  38888. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  38889. if (replace === void 0) { replace = false; }
  38890. if (attachCameraControls === void 0) { attachCameraControls = false; }
  38891. this.createDefaultLight(replace);
  38892. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  38893. };
  38894. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  38895. if (pbr === void 0) { pbr = false; }
  38896. if (scale === void 0) { scale = 1000; }
  38897. if (blur === void 0) { blur = 0; }
  38898. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  38899. if (!environmentTexture) {
  38900. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  38901. return null;
  38902. }
  38903. if (setGlobalEnvTexture) {
  38904. if (environmentTexture) {
  38905. this.environmentTexture = environmentTexture;
  38906. }
  38907. }
  38908. // Skybox
  38909. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  38910. if (pbr) {
  38911. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  38912. hdrSkyboxMaterial.backFaceCulling = false;
  38913. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  38914. if (hdrSkyboxMaterial.reflectionTexture) {
  38915. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  38916. }
  38917. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  38918. hdrSkyboxMaterial.disableLighting = true;
  38919. hdrSkyboxMaterial.twoSidedLighting = true;
  38920. hdrSkybox.infiniteDistance = true;
  38921. hdrSkybox.material = hdrSkyboxMaterial;
  38922. }
  38923. else {
  38924. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  38925. skyboxMaterial.backFaceCulling = false;
  38926. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  38927. if (skyboxMaterial.reflectionTexture) {
  38928. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  38929. }
  38930. skyboxMaterial.disableLighting = true;
  38931. hdrSkybox.infiniteDistance = true;
  38932. hdrSkybox.material = skyboxMaterial;
  38933. }
  38934. hdrSkybox.isPickable = false;
  38935. return hdrSkybox;
  38936. };
  38937. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  38938. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  38939. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  38940. }
  38941. return null;
  38942. };
  38943. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  38944. if (webVROptions === void 0) { webVROptions = {}; }
  38945. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  38946. };
  38947. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  38948. var _this = this;
  38949. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  38950. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  38951. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  38952. .then(function (ui) {
  38953. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  38954. return helper;
  38955. });
  38956. });
  38957. };
  38958. /***/ }),
  38959. /***/ "./Helpers/videoDome.ts":
  38960. /*!******************************!*\
  38961. !*** ./Helpers/videoDome.ts ***!
  38962. \******************************/
  38963. /*! exports provided: VideoDome */
  38964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38965. "use strict";
  38966. __webpack_require__.r(__webpack_exports__);
  38967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  38968. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38969. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38970. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38971. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38972. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  38973. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38974. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38975. /**
  38976. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  38977. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  38978. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  38979. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  38980. */
  38981. var VideoDome = /** @class */ (function (_super) {
  38982. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  38983. /**
  38984. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  38985. * @param name Element's name, child elements will append suffixes for their own names.
  38986. * @param urlsOrVideo defines the url(s) or the video element to use
  38987. * @param options An object containing optional or exposed sub element properties
  38988. */
  38989. function VideoDome(name, urlsOrVideo, options, scene) {
  38990. var _this = _super.call(this, name, scene) || this;
  38991. _this._useDirectMapping = false;
  38992. // set defaults and manage values
  38993. name = name || "videoDome";
  38994. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  38995. options.clickToPlay = Boolean(options.clickToPlay);
  38996. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  38997. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  38998. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  38999. if (options.useDirectMapping === undefined) {
  39000. _this._useDirectMapping = true;
  39001. }
  39002. else {
  39003. _this._useDirectMapping = options.useDirectMapping;
  39004. }
  39005. _this._setReady(false);
  39006. // create
  39007. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  39008. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39009. 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);
  39010. _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);
  39011. texture.onLoadObservable.addOnce(function () {
  39012. _this._setReady(true);
  39013. });
  39014. // configure material
  39015. material.useEquirectangularFOV = true;
  39016. material.fovMultiplier = 1.0;
  39017. material.opacityFresnel = false;
  39018. if (_this._useDirectMapping) {
  39019. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39020. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39021. material.diffuseTexture = texture;
  39022. }
  39023. else {
  39024. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39025. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39026. material.reflectionTexture = texture;
  39027. }
  39028. // configure mesh
  39029. _this._mesh.material = material;
  39030. _this._mesh.parent = _this;
  39031. // optional configuration
  39032. if (options.clickToPlay) {
  39033. scene.onPointerUp = function () {
  39034. _this._videoTexture.video.play();
  39035. };
  39036. }
  39037. return _this;
  39038. }
  39039. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  39040. /**
  39041. * Gets the video texture being displayed on the sphere
  39042. */
  39043. get: function () {
  39044. return this._videoTexture;
  39045. },
  39046. enumerable: true,
  39047. configurable: true
  39048. });
  39049. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  39050. /**
  39051. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39052. * Also see the options.resolution property.
  39053. */
  39054. get: function () {
  39055. return this._material.fovMultiplier;
  39056. },
  39057. set: function (value) {
  39058. this._material.fovMultiplier = value;
  39059. },
  39060. enumerable: true,
  39061. configurable: true
  39062. });
  39063. /**
  39064. * Releases resources associated with this node.
  39065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39067. */
  39068. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39069. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39070. this._videoTexture.dispose();
  39071. this._mesh.dispose();
  39072. this._material.dispose();
  39073. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39074. };
  39075. return VideoDome;
  39076. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  39077. /***/ }),
  39078. /***/ "./Instrumentation/engineInstrumentation.ts":
  39079. /*!**************************************************!*\
  39080. !*** ./Instrumentation/engineInstrumentation.ts ***!
  39081. \**************************************************/
  39082. /*! exports provided: EngineInstrumentation */
  39083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39084. "use strict";
  39085. __webpack_require__.r(__webpack_exports__);
  39086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  39087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39088. /**
  39089. * This class can be used to get instrumentation data from a Babylon engine
  39090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39091. */
  39092. var EngineInstrumentation = /** @class */ (function () {
  39093. /**
  39094. * Instantiates a new engine instrumentation.
  39095. * This class can be used to get instrumentation data from a Babylon engine
  39096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39097. * @param engine Defines the engine to instrument
  39098. */
  39099. function EngineInstrumentation(
  39100. /**
  39101. * Define the instrumented engine.
  39102. */
  39103. engine) {
  39104. this.engine = engine;
  39105. this._captureGPUFrameTime = false;
  39106. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39107. this._captureShaderCompilationTime = false;
  39108. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39109. // Observers
  39110. this._onBeginFrameObserver = null;
  39111. this._onEndFrameObserver = null;
  39112. this._onBeforeShaderCompilationObserver = null;
  39113. this._onAfterShaderCompilationObserver = null;
  39114. }
  39115. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  39116. // Properties
  39117. /**
  39118. * Gets the perf counter used for GPU frame time
  39119. */
  39120. get: function () {
  39121. return this._gpuFrameTime;
  39122. },
  39123. enumerable: true,
  39124. configurable: true
  39125. });
  39126. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  39127. /**
  39128. * Gets the GPU frame time capture status
  39129. */
  39130. get: function () {
  39131. return this._captureGPUFrameTime;
  39132. },
  39133. /**
  39134. * Enable or disable the GPU frame time capture
  39135. */
  39136. set: function (value) {
  39137. var _this = this;
  39138. if (value === this._captureGPUFrameTime) {
  39139. return;
  39140. }
  39141. this._captureGPUFrameTime = value;
  39142. if (value) {
  39143. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  39144. if (!_this._gpuFrameTimeToken) {
  39145. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  39146. }
  39147. });
  39148. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  39149. if (!_this._gpuFrameTimeToken) {
  39150. return;
  39151. }
  39152. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  39153. if (time > -1) {
  39154. _this._gpuFrameTimeToken = null;
  39155. _this._gpuFrameTime.fetchNewFrame();
  39156. _this._gpuFrameTime.addCount(time, true);
  39157. }
  39158. });
  39159. }
  39160. else {
  39161. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39162. this._onBeginFrameObserver = null;
  39163. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39164. this._onEndFrameObserver = null;
  39165. }
  39166. },
  39167. enumerable: true,
  39168. configurable: true
  39169. });
  39170. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  39171. /**
  39172. * Gets the perf counter used for shader compilation time
  39173. */
  39174. get: function () {
  39175. return this._shaderCompilationTime;
  39176. },
  39177. enumerable: true,
  39178. configurable: true
  39179. });
  39180. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  39181. /**
  39182. * Gets the shader compilation time capture status
  39183. */
  39184. get: function () {
  39185. return this._captureShaderCompilationTime;
  39186. },
  39187. /**
  39188. * Enable or disable the shader compilation time capture
  39189. */
  39190. set: function (value) {
  39191. var _this = this;
  39192. if (value === this._captureShaderCompilationTime) {
  39193. return;
  39194. }
  39195. this._captureShaderCompilationTime = value;
  39196. if (value) {
  39197. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  39198. _this._shaderCompilationTime.fetchNewFrame();
  39199. _this._shaderCompilationTime.beginMonitoring();
  39200. });
  39201. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  39202. _this._shaderCompilationTime.endMonitoring();
  39203. });
  39204. }
  39205. else {
  39206. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39207. this._onBeforeShaderCompilationObserver = null;
  39208. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39209. this._onAfterShaderCompilationObserver = null;
  39210. }
  39211. },
  39212. enumerable: true,
  39213. configurable: true
  39214. });
  39215. /**
  39216. * Dispose and release associated resources.
  39217. */
  39218. EngineInstrumentation.prototype.dispose = function () {
  39219. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39220. this._onBeginFrameObserver = null;
  39221. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39222. this._onEndFrameObserver = null;
  39223. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39224. this._onBeforeShaderCompilationObserver = null;
  39225. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39226. this._onAfterShaderCompilationObserver = null;
  39227. this.engine = null;
  39228. };
  39229. return EngineInstrumentation;
  39230. }());
  39231. /***/ }),
  39232. /***/ "./Instrumentation/index.ts":
  39233. /*!**********************************!*\
  39234. !*** ./Instrumentation/index.ts ***!
  39235. \**********************************/
  39236. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  39237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39238. "use strict";
  39239. __webpack_require__.r(__webpack_exports__);
  39240. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  39241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  39242. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  39243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  39244. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  39245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  39246. /***/ }),
  39247. /***/ "./Instrumentation/sceneInstrumentation.ts":
  39248. /*!*************************************************!*\
  39249. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  39250. \*************************************************/
  39251. /*! exports provided: SceneInstrumentation */
  39252. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39253. "use strict";
  39254. __webpack_require__.r(__webpack_exports__);
  39255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  39256. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39257. /**
  39258. * This class can be used to get instrumentation data from a Babylon engine
  39259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39260. */
  39261. var SceneInstrumentation = /** @class */ (function () {
  39262. /**
  39263. * Instantiates a new scene instrumentation.
  39264. * This class can be used to get instrumentation data from a Babylon engine
  39265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39266. * @param scene Defines the scene to instrument
  39267. */
  39268. function SceneInstrumentation(
  39269. /**
  39270. * Defines the scene to instrument
  39271. */
  39272. scene) {
  39273. var _this = this;
  39274. this.scene = scene;
  39275. this._captureActiveMeshesEvaluationTime = false;
  39276. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39277. this._captureRenderTargetsRenderTime = false;
  39278. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39279. this._captureFrameTime = false;
  39280. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39281. this._captureRenderTime = false;
  39282. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39283. this._captureInterFrameTime = false;
  39284. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39285. this._captureParticlesRenderTime = false;
  39286. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39287. this._captureSpritesRenderTime = false;
  39288. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39289. this._capturePhysicsTime = false;
  39290. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39291. this._captureAnimationsTime = false;
  39292. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39293. this._captureCameraRenderTime = false;
  39294. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39295. // Observers
  39296. this._onBeforeActiveMeshesEvaluationObserver = null;
  39297. this._onAfterActiveMeshesEvaluationObserver = null;
  39298. this._onBeforeRenderTargetsRenderObserver = null;
  39299. this._onAfterRenderTargetsRenderObserver = null;
  39300. this._onAfterRenderObserver = null;
  39301. this._onBeforeDrawPhaseObserver = null;
  39302. this._onAfterDrawPhaseObserver = null;
  39303. this._onBeforeAnimationsObserver = null;
  39304. this._onBeforeParticlesRenderingObserver = null;
  39305. this._onAfterParticlesRenderingObserver = null;
  39306. this._onBeforeSpritesRenderingObserver = null;
  39307. this._onAfterSpritesRenderingObserver = null;
  39308. this._onBeforePhysicsObserver = null;
  39309. this._onAfterPhysicsObserver = null;
  39310. this._onAfterAnimationsObserver = null;
  39311. this._onBeforeCameraRenderObserver = null;
  39312. this._onAfterCameraRenderObserver = null;
  39313. // Before render
  39314. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  39315. if (_this._captureActiveMeshesEvaluationTime) {
  39316. _this._activeMeshesEvaluationTime.fetchNewFrame();
  39317. }
  39318. if (_this._captureRenderTargetsRenderTime) {
  39319. _this._renderTargetsRenderTime.fetchNewFrame();
  39320. }
  39321. if (_this._captureFrameTime) {
  39322. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  39323. _this._frameTime.beginMonitoring();
  39324. }
  39325. if (_this._captureInterFrameTime) {
  39326. _this._interFrameTime.endMonitoring();
  39327. }
  39328. if (_this._captureParticlesRenderTime) {
  39329. _this._particlesRenderTime.fetchNewFrame();
  39330. }
  39331. if (_this._captureSpritesRenderTime) {
  39332. _this._spritesRenderTime.fetchNewFrame();
  39333. }
  39334. if (_this._captureAnimationsTime) {
  39335. _this._animationsTime.beginMonitoring();
  39336. }
  39337. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  39338. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  39339. });
  39340. // After render
  39341. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  39342. if (_this._captureFrameTime) {
  39343. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  39344. _this._frameTime.endMonitoring();
  39345. }
  39346. if (_this._captureRenderTime) {
  39347. _this._renderTime.endMonitoring(false);
  39348. }
  39349. if (_this._captureInterFrameTime) {
  39350. _this._interFrameTime.beginMonitoring();
  39351. }
  39352. });
  39353. }
  39354. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  39355. // Properties
  39356. /**
  39357. * Gets the perf counter used for active meshes evaluation time
  39358. */
  39359. get: function () {
  39360. return this._activeMeshesEvaluationTime;
  39361. },
  39362. enumerable: true,
  39363. configurable: true
  39364. });
  39365. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  39366. /**
  39367. * Gets the active meshes evaluation time capture status
  39368. */
  39369. get: function () {
  39370. return this._captureActiveMeshesEvaluationTime;
  39371. },
  39372. /**
  39373. * Enable or disable the active meshes evaluation time capture
  39374. */
  39375. set: function (value) {
  39376. var _this = this;
  39377. if (value === this._captureActiveMeshesEvaluationTime) {
  39378. return;
  39379. }
  39380. this._captureActiveMeshesEvaluationTime = value;
  39381. if (value) {
  39382. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  39383. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  39384. _this._activeMeshesEvaluationTime.beginMonitoring();
  39385. });
  39386. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  39387. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  39388. _this._activeMeshesEvaluationTime.endMonitoring();
  39389. });
  39390. }
  39391. else {
  39392. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  39393. this._onBeforeActiveMeshesEvaluationObserver = null;
  39394. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  39395. this._onAfterActiveMeshesEvaluationObserver = null;
  39396. }
  39397. },
  39398. enumerable: true,
  39399. configurable: true
  39400. });
  39401. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  39402. /**
  39403. * Gets the perf counter used for render targets render time
  39404. */
  39405. get: function () {
  39406. return this._renderTargetsRenderTime;
  39407. },
  39408. enumerable: true,
  39409. configurable: true
  39410. });
  39411. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  39412. /**
  39413. * Gets the render targets render time capture status
  39414. */
  39415. get: function () {
  39416. return this._captureRenderTargetsRenderTime;
  39417. },
  39418. /**
  39419. * Enable or disable the render targets render time capture
  39420. */
  39421. set: function (value) {
  39422. var _this = this;
  39423. if (value === this._captureRenderTargetsRenderTime) {
  39424. return;
  39425. }
  39426. this._captureRenderTargetsRenderTime = value;
  39427. if (value) {
  39428. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  39429. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  39430. _this._renderTargetsRenderTime.beginMonitoring();
  39431. });
  39432. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  39433. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  39434. _this._renderTargetsRenderTime.endMonitoring(false);
  39435. });
  39436. }
  39437. else {
  39438. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  39439. this._onBeforeRenderTargetsRenderObserver = null;
  39440. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  39441. this._onAfterRenderTargetsRenderObserver = null;
  39442. }
  39443. },
  39444. enumerable: true,
  39445. configurable: true
  39446. });
  39447. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  39448. /**
  39449. * Gets the perf counter used for particles render time
  39450. */
  39451. get: function () {
  39452. return this._particlesRenderTime;
  39453. },
  39454. enumerable: true,
  39455. configurable: true
  39456. });
  39457. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  39458. /**
  39459. * Gets the particles render time capture status
  39460. */
  39461. get: function () {
  39462. return this._captureParticlesRenderTime;
  39463. },
  39464. /**
  39465. * Enable or disable the particles render time capture
  39466. */
  39467. set: function (value) {
  39468. var _this = this;
  39469. if (value === this._captureParticlesRenderTime) {
  39470. return;
  39471. }
  39472. this._captureParticlesRenderTime = value;
  39473. if (value) {
  39474. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  39475. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  39476. _this._particlesRenderTime.beginMonitoring();
  39477. });
  39478. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  39479. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  39480. _this._particlesRenderTime.endMonitoring(false);
  39481. });
  39482. }
  39483. else {
  39484. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  39485. this._onBeforeParticlesRenderingObserver = null;
  39486. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  39487. this._onAfterParticlesRenderingObserver = null;
  39488. }
  39489. },
  39490. enumerable: true,
  39491. configurable: true
  39492. });
  39493. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  39494. /**
  39495. * Gets the perf counter used for sprites render time
  39496. */
  39497. get: function () {
  39498. return this._spritesRenderTime;
  39499. },
  39500. enumerable: true,
  39501. configurable: true
  39502. });
  39503. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  39504. /**
  39505. * Gets the sprites render time capture status
  39506. */
  39507. get: function () {
  39508. return this._captureSpritesRenderTime;
  39509. },
  39510. /**
  39511. * Enable or disable the sprites render time capture
  39512. */
  39513. set: function (value) {
  39514. var _this = this;
  39515. if (value === this._captureSpritesRenderTime) {
  39516. return;
  39517. }
  39518. this._captureSpritesRenderTime = value;
  39519. if (!this.scene.spriteManagers) {
  39520. return;
  39521. }
  39522. if (value) {
  39523. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  39524. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  39525. _this._spritesRenderTime.beginMonitoring();
  39526. });
  39527. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  39528. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  39529. _this._spritesRenderTime.endMonitoring(false);
  39530. });
  39531. }
  39532. else {
  39533. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  39534. this._onBeforeSpritesRenderingObserver = null;
  39535. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  39536. this._onAfterSpritesRenderingObserver = null;
  39537. }
  39538. },
  39539. enumerable: true,
  39540. configurable: true
  39541. });
  39542. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  39543. /**
  39544. * Gets the perf counter used for physics time
  39545. */
  39546. get: function () {
  39547. return this._physicsTime;
  39548. },
  39549. enumerable: true,
  39550. configurable: true
  39551. });
  39552. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  39553. /**
  39554. * Gets the physics time capture status
  39555. */
  39556. get: function () {
  39557. return this._capturePhysicsTime;
  39558. },
  39559. /**
  39560. * Enable or disable the physics time capture
  39561. */
  39562. set: function (value) {
  39563. var _this = this;
  39564. if (value === this._capturePhysicsTime) {
  39565. return;
  39566. }
  39567. if (!this.scene.onBeforePhysicsObservable) {
  39568. return;
  39569. }
  39570. this._capturePhysicsTime = value;
  39571. if (value) {
  39572. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  39573. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  39574. _this._physicsTime.beginMonitoring();
  39575. });
  39576. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  39577. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  39578. _this._physicsTime.endMonitoring();
  39579. });
  39580. }
  39581. else {
  39582. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  39583. this._onBeforePhysicsObserver = null;
  39584. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  39585. this._onAfterPhysicsObserver = null;
  39586. }
  39587. },
  39588. enumerable: true,
  39589. configurable: true
  39590. });
  39591. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  39592. /**
  39593. * Gets the perf counter used for animations time
  39594. */
  39595. get: function () {
  39596. return this._animationsTime;
  39597. },
  39598. enumerable: true,
  39599. configurable: true
  39600. });
  39601. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  39602. /**
  39603. * Gets the animations time capture status
  39604. */
  39605. get: function () {
  39606. return this._captureAnimationsTime;
  39607. },
  39608. /**
  39609. * Enable or disable the animations time capture
  39610. */
  39611. set: function (value) {
  39612. var _this = this;
  39613. if (value === this._captureAnimationsTime) {
  39614. return;
  39615. }
  39616. this._captureAnimationsTime = value;
  39617. if (value) {
  39618. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  39619. _this._animationsTime.endMonitoring();
  39620. });
  39621. }
  39622. else {
  39623. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  39624. this._onAfterAnimationsObserver = null;
  39625. }
  39626. },
  39627. enumerable: true,
  39628. configurable: true
  39629. });
  39630. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  39631. /**
  39632. * Gets the perf counter used for frame time capture
  39633. */
  39634. get: function () {
  39635. return this._frameTime;
  39636. },
  39637. enumerable: true,
  39638. configurable: true
  39639. });
  39640. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  39641. /**
  39642. * Gets the frame time capture status
  39643. */
  39644. get: function () {
  39645. return this._captureFrameTime;
  39646. },
  39647. /**
  39648. * Enable or disable the frame time capture
  39649. */
  39650. set: function (value) {
  39651. this._captureFrameTime = value;
  39652. },
  39653. enumerable: true,
  39654. configurable: true
  39655. });
  39656. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  39657. /**
  39658. * Gets the perf counter used for inter-frames time capture
  39659. */
  39660. get: function () {
  39661. return this._interFrameTime;
  39662. },
  39663. enumerable: true,
  39664. configurable: true
  39665. });
  39666. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  39667. /**
  39668. * Gets the inter-frames time capture status
  39669. */
  39670. get: function () {
  39671. return this._captureInterFrameTime;
  39672. },
  39673. /**
  39674. * Enable or disable the inter-frames time capture
  39675. */
  39676. set: function (value) {
  39677. this._captureInterFrameTime = value;
  39678. },
  39679. enumerable: true,
  39680. configurable: true
  39681. });
  39682. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  39683. /**
  39684. * Gets the perf counter used for render time capture
  39685. */
  39686. get: function () {
  39687. return this._renderTime;
  39688. },
  39689. enumerable: true,
  39690. configurable: true
  39691. });
  39692. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  39693. /**
  39694. * Gets the render time capture status
  39695. */
  39696. get: function () {
  39697. return this._captureRenderTime;
  39698. },
  39699. /**
  39700. * Enable or disable the render time capture
  39701. */
  39702. set: function (value) {
  39703. var _this = this;
  39704. if (value === this._captureRenderTime) {
  39705. return;
  39706. }
  39707. this._captureRenderTime = value;
  39708. if (value) {
  39709. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  39710. _this._renderTime.beginMonitoring();
  39711. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  39712. });
  39713. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  39714. _this._renderTime.endMonitoring(false);
  39715. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  39716. });
  39717. }
  39718. else {
  39719. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  39720. this._onBeforeDrawPhaseObserver = null;
  39721. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  39722. this._onAfterDrawPhaseObserver = null;
  39723. }
  39724. },
  39725. enumerable: true,
  39726. configurable: true
  39727. });
  39728. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  39729. /**
  39730. * Gets the perf counter used for camera render time capture
  39731. */
  39732. get: function () {
  39733. return this._cameraRenderTime;
  39734. },
  39735. enumerable: true,
  39736. configurable: true
  39737. });
  39738. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  39739. /**
  39740. * Gets the camera render time capture status
  39741. */
  39742. get: function () {
  39743. return this._captureCameraRenderTime;
  39744. },
  39745. /**
  39746. * Enable or disable the camera render time capture
  39747. */
  39748. set: function (value) {
  39749. var _this = this;
  39750. if (value === this._captureCameraRenderTime) {
  39751. return;
  39752. }
  39753. this._captureCameraRenderTime = value;
  39754. if (value) {
  39755. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  39756. _this._cameraRenderTime.beginMonitoring();
  39757. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  39758. });
  39759. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  39760. _this._cameraRenderTime.endMonitoring(false);
  39761. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  39762. });
  39763. }
  39764. else {
  39765. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  39766. this._onBeforeCameraRenderObserver = null;
  39767. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  39768. this._onAfterCameraRenderObserver = null;
  39769. }
  39770. },
  39771. enumerable: true,
  39772. configurable: true
  39773. });
  39774. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  39775. /**
  39776. * Gets the perf counter used for draw calls
  39777. */
  39778. get: function () {
  39779. return this.scene.getEngine()._drawCalls;
  39780. },
  39781. enumerable: true,
  39782. configurable: true
  39783. });
  39784. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  39785. /**
  39786. * Gets the perf counter used for texture collisions
  39787. */
  39788. get: function () {
  39789. return this.scene.getEngine()._textureCollisions;
  39790. },
  39791. enumerable: true,
  39792. configurable: true
  39793. });
  39794. /**
  39795. * Dispose and release associated resources.
  39796. */
  39797. SceneInstrumentation.prototype.dispose = function () {
  39798. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  39799. this._onAfterRenderObserver = null;
  39800. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  39801. this._onBeforeActiveMeshesEvaluationObserver = null;
  39802. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  39803. this._onAfterActiveMeshesEvaluationObserver = null;
  39804. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  39805. this._onBeforeRenderTargetsRenderObserver = null;
  39806. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  39807. this._onAfterRenderTargetsRenderObserver = null;
  39808. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  39809. this._onBeforeAnimationsObserver = null;
  39810. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  39811. this._onBeforeParticlesRenderingObserver = null;
  39812. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  39813. this._onAfterParticlesRenderingObserver = null;
  39814. if (this._onBeforeSpritesRenderingObserver) {
  39815. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  39816. this._onBeforeSpritesRenderingObserver = null;
  39817. }
  39818. if (this._onAfterSpritesRenderingObserver) {
  39819. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  39820. this._onAfterSpritesRenderingObserver = null;
  39821. }
  39822. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  39823. this._onBeforeDrawPhaseObserver = null;
  39824. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  39825. this._onAfterDrawPhaseObserver = null;
  39826. if (this._onBeforePhysicsObserver) {
  39827. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  39828. this._onBeforePhysicsObserver = null;
  39829. }
  39830. if (this._onAfterPhysicsObserver) {
  39831. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  39832. this._onAfterPhysicsObserver = null;
  39833. }
  39834. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  39835. this._onAfterAnimationsObserver = null;
  39836. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  39837. this._onBeforeCameraRenderObserver = null;
  39838. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  39839. this._onAfterCameraRenderObserver = null;
  39840. this.scene = null;
  39841. };
  39842. return SceneInstrumentation;
  39843. }());
  39844. /***/ }),
  39845. /***/ "./Instrumentation/timeToken.ts":
  39846. /*!**************************************!*\
  39847. !*** ./Instrumentation/timeToken.ts ***!
  39848. \**************************************/
  39849. /*! exports provided: _TimeToken */
  39850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39851. "use strict";
  39852. __webpack_require__.r(__webpack_exports__);
  39853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  39854. /**
  39855. * @hidden
  39856. **/
  39857. var _TimeToken = /** @class */ (function () {
  39858. function _TimeToken() {
  39859. this._timeElapsedQueryEnded = false;
  39860. }
  39861. return _TimeToken;
  39862. }());
  39863. /***/ }),
  39864. /***/ "./Layers/effectLayer.ts":
  39865. /*!*******************************!*\
  39866. !*** ./Layers/effectLayer.ts ***!
  39867. \*******************************/
  39868. /*! exports provided: EffectLayer */
  39869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39870. "use strict";
  39871. __webpack_require__.r(__webpack_exports__);
  39872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  39873. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39874. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  39875. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39876. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39878. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  39879. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  39880. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39881. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  39882. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  39883. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  39884. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39885. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  39886. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  39887. /**
  39888. * The effect layer Helps adding post process effect blended with the main pass.
  39889. *
  39890. * This can be for instance use to generate glow or higlight effects on the scene.
  39891. *
  39892. * The effect layer class can not be used directly and is intented to inherited from to be
  39893. * customized per effects.
  39894. */
  39895. var EffectLayer = /** @class */ (function () {
  39896. /**
  39897. * Instantiates a new effect Layer and references it in the scene.
  39898. * @param name The name of the layer
  39899. * @param scene The scene to use the layer in
  39900. */
  39901. function EffectLayer(
  39902. /** The Friendly of the effect in the scene */
  39903. name, scene) {
  39904. this._vertexBuffers = {};
  39905. this._maxSize = 0;
  39906. this._mainTextureDesiredSize = { width: 0, height: 0 };
  39907. this._shouldRender = true;
  39908. this._postProcesses = [];
  39909. this._textures = [];
  39910. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  39911. /**
  39912. * The clear color of the texture used to generate the glow map.
  39913. */
  39914. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  39915. /**
  39916. * Specifies wether the highlight layer is enabled or not.
  39917. */
  39918. this.isEnabled = true;
  39919. /**
  39920. * An event triggered when the effect layer has been disposed.
  39921. */
  39922. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  39923. /**
  39924. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  39925. */
  39926. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  39927. /**
  39928. * An event triggered when the generated texture is being merged in the scene.
  39929. */
  39930. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  39931. /**
  39932. * An event triggered when the generated texture has been merged in the scene.
  39933. */
  39934. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  39935. /**
  39936. * An event triggered when the efffect layer changes its size.
  39937. */
  39938. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  39939. this.name = name;
  39940. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  39941. EffectLayer._SceneComponentInitialization(this._scene);
  39942. this._engine = this._scene.getEngine();
  39943. this._maxSize = this._engine.getCaps().maxTextureSize;
  39944. this._scene.effectLayers.push(this);
  39945. // Generate Buffers
  39946. this._generateIndexBuffer();
  39947. this._genrateVertexBuffer();
  39948. }
  39949. Object.defineProperty(EffectLayer.prototype, "camera", {
  39950. /**
  39951. * Gets the camera attached to the layer.
  39952. */
  39953. get: function () {
  39954. return this._effectLayerOptions.camera;
  39955. },
  39956. enumerable: true,
  39957. configurable: true
  39958. });
  39959. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  39960. /**
  39961. * Gets the rendering group id the layer should render in.
  39962. */
  39963. get: function () {
  39964. return this._effectLayerOptions.renderingGroupId;
  39965. },
  39966. enumerable: true,
  39967. configurable: true
  39968. });
  39969. /**
  39970. * Initializes the effect layer with the required options.
  39971. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  39972. */
  39973. EffectLayer.prototype._init = function (options) {
  39974. // Adapt options
  39975. 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);
  39976. this._setMainTextureSize();
  39977. this._createMainTexture();
  39978. this._createTextureAndPostProcesses();
  39979. this._mergeEffect = this._createMergeEffect();
  39980. };
  39981. /**
  39982. * Generates the index buffer of the full screen quad blending to the main canvas.
  39983. */
  39984. EffectLayer.prototype._generateIndexBuffer = function () {
  39985. // Indices
  39986. var indices = [];
  39987. indices.push(0);
  39988. indices.push(1);
  39989. indices.push(2);
  39990. indices.push(0);
  39991. indices.push(2);
  39992. indices.push(3);
  39993. this._indexBuffer = this._engine.createIndexBuffer(indices);
  39994. };
  39995. /**
  39996. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  39997. */
  39998. EffectLayer.prototype._genrateVertexBuffer = function () {
  39999. // VBO
  40000. var vertices = [];
  40001. vertices.push(1, 1);
  40002. vertices.push(-1, 1);
  40003. vertices.push(-1, -1);
  40004. vertices.push(1, -1);
  40005. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  40006. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  40007. };
  40008. /**
  40009. * Sets the main texture desired size which is the closest power of two
  40010. * of the engine canvas size.
  40011. */
  40012. EffectLayer.prototype._setMainTextureSize = function () {
  40013. if (this._effectLayerOptions.mainTextureFixedSize) {
  40014. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  40015. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  40016. }
  40017. else {
  40018. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  40019. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  40020. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  40021. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  40022. }
  40023. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  40024. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  40025. };
  40026. /**
  40027. * Creates the main texture for the effect layer.
  40028. */
  40029. EffectLayer.prototype._createMainTexture = function () {
  40030. var _this = this;
  40031. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  40032. width: this._mainTextureDesiredSize.width,
  40033. height: this._mainTextureDesiredSize.height
  40034. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  40035. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  40036. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40037. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40038. this._mainTexture.anisotropicFilteringLevel = 1;
  40039. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  40040. this._mainTexture.renderParticles = false;
  40041. this._mainTexture.renderList = null;
  40042. this._mainTexture.ignoreCameraViewport = true;
  40043. // Custom render function
  40044. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  40045. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  40046. var index;
  40047. var engine = _this._scene.getEngine();
  40048. if (depthOnlySubMeshes.length) {
  40049. engine.setColorWrite(false);
  40050. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  40051. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  40052. }
  40053. engine.setColorWrite(true);
  40054. }
  40055. for (index = 0; index < opaqueSubMeshes.length; index++) {
  40056. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  40057. }
  40058. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  40059. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  40060. }
  40061. for (index = 0; index < transparentSubMeshes.length; index++) {
  40062. _this._renderSubMesh(transparentSubMeshes.data[index]);
  40063. }
  40064. };
  40065. this._mainTexture.onClearObservable.add(function (engine) {
  40066. engine.clear(_this.neutralColor, true, true, true);
  40067. });
  40068. };
  40069. /**
  40070. * Adds specific effects defines.
  40071. * @param defines The defines to add specifics to.
  40072. */
  40073. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  40074. // Nothing to add by default.
  40075. };
  40076. /**
  40077. * Checks for the readiness of the element composing the layer.
  40078. * @param subMesh the mesh to check for
  40079. * @param useInstances specify wether or not to use instances to render the mesh
  40080. * @param emissiveTexture the associated emissive texture used to generate the glow
  40081. * @return true if ready otherwise, false
  40082. */
  40083. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  40084. var material = subMesh.getMaterial();
  40085. if (!material) {
  40086. return false;
  40087. }
  40088. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  40089. return false;
  40090. }
  40091. var defines = [];
  40092. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40093. var mesh = subMesh.getMesh();
  40094. var uv1 = false;
  40095. var uv2 = false;
  40096. // Diffuse
  40097. if (material) {
  40098. var needAlphaTest = material.needAlphaTesting();
  40099. var diffuseTexture = material.getAlphaTestTexture();
  40100. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40101. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40102. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40103. defines.push("#define DIFFUSE");
  40104. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40105. diffuseTexture.coordinatesIndex === 1) {
  40106. defines.push("#define DIFFUSEUV2");
  40107. uv2 = true;
  40108. }
  40109. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40110. defines.push("#define DIFFUSEUV1");
  40111. uv1 = true;
  40112. }
  40113. if (needAlphaTest) {
  40114. defines.push("#define ALPHATEST");
  40115. defines.push("#define ALPHATESTVALUE 0.4");
  40116. }
  40117. }
  40118. var opacityTexture = material.opacityTexture;
  40119. if (opacityTexture) {
  40120. defines.push("#define OPACITY");
  40121. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40122. opacityTexture.coordinatesIndex === 1) {
  40123. defines.push("#define OPACITYUV2");
  40124. uv2 = true;
  40125. }
  40126. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40127. defines.push("#define OPACITYUV1");
  40128. uv1 = true;
  40129. }
  40130. }
  40131. }
  40132. // Emissive
  40133. if (emissiveTexture) {
  40134. defines.push("#define EMISSIVE");
  40135. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40136. emissiveTexture.coordinatesIndex === 1) {
  40137. defines.push("#define EMISSIVEUV2");
  40138. uv2 = true;
  40139. }
  40140. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40141. defines.push("#define EMISSIVEUV1");
  40142. uv1 = true;
  40143. }
  40144. }
  40145. // Vertex
  40146. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  40147. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  40148. defines.push("#define VERTEXALPHA");
  40149. }
  40150. if (uv1) {
  40151. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  40152. defines.push("#define UV1");
  40153. }
  40154. if (uv2) {
  40155. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  40156. defines.push("#define UV2");
  40157. }
  40158. // Bones
  40159. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  40160. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  40161. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  40162. if (mesh.numBoneInfluencers > 4) {
  40163. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  40164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  40165. }
  40166. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  40167. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  40168. }
  40169. else {
  40170. defines.push("#define NUM_BONE_INFLUENCERS 0");
  40171. }
  40172. // Morph targets
  40173. var manager = mesh.morphTargetManager;
  40174. var morphInfluencers = 0;
  40175. if (manager) {
  40176. if (manager.numInfluencers > 0) {
  40177. defines.push("#define MORPHTARGETS");
  40178. morphInfluencers = manager.numInfluencers;
  40179. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  40180. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  40181. }
  40182. }
  40183. // Instances
  40184. if (useInstances) {
  40185. defines.push("#define INSTANCES");
  40186. attribs.push("world0");
  40187. attribs.push("world1");
  40188. attribs.push("world2");
  40189. attribs.push("world3");
  40190. }
  40191. this._addCustomEffectDefines(defines);
  40192. // Get correct effect
  40193. var join = defines.join("\n");
  40194. if (this._cachedDefines !== join) {
  40195. this._cachedDefines = join;
  40196. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  40197. "color", "morphTargetInfluences",
  40198. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  40199. }
  40200. return this._effectLayerMapGenerationEffect.isReady();
  40201. };
  40202. /**
  40203. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  40204. */
  40205. EffectLayer.prototype.render = function () {
  40206. var currentEffect = this._mergeEffect;
  40207. // Check
  40208. if (!currentEffect.isReady()) {
  40209. return;
  40210. }
  40211. for (var i = 0; i < this._postProcesses.length; i++) {
  40212. if (!this._postProcesses[i].isReady()) {
  40213. return;
  40214. }
  40215. }
  40216. var engine = this._scene.getEngine();
  40217. this.onBeforeComposeObservable.notifyObservers(this);
  40218. // Render
  40219. engine.enableEffect(currentEffect);
  40220. engine.setState(false);
  40221. // VBOs
  40222. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  40223. // Cache
  40224. var previousAlphaMode = engine.getAlphaMode();
  40225. // Go Blend.
  40226. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  40227. // Blends the map on the main canvas.
  40228. this._internalRender(currentEffect);
  40229. // Restore Alpha
  40230. engine.setAlphaMode(previousAlphaMode);
  40231. this.onAfterComposeObservable.notifyObservers(this);
  40232. // Handle size changes.
  40233. var size = this._mainTexture.getSize();
  40234. this._setMainTextureSize();
  40235. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  40236. // Recreate RTT and post processes on size change.
  40237. this.onSizeChangedObservable.notifyObservers(this);
  40238. this._disposeTextureAndPostProcesses();
  40239. this._createMainTexture();
  40240. this._createTextureAndPostProcesses();
  40241. }
  40242. };
  40243. /**
  40244. * Determine if a given mesh will be used in the current effect.
  40245. * @param mesh mesh to test
  40246. * @returns true if the mesh will be used
  40247. */
  40248. EffectLayer.prototype.hasMesh = function (mesh) {
  40249. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  40250. return true;
  40251. }
  40252. return false;
  40253. };
  40254. /**
  40255. * Returns true if the layer contains information to display, otherwise false.
  40256. * @returns true if the glow layer should be rendered
  40257. */
  40258. EffectLayer.prototype.shouldRender = function () {
  40259. return this.isEnabled && this._shouldRender;
  40260. };
  40261. /**
  40262. * Returns true if the mesh should render, otherwise false.
  40263. * @param mesh The mesh to render
  40264. * @returns true if it should render otherwise false
  40265. */
  40266. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  40267. return true;
  40268. };
  40269. /**
  40270. * Returns true if the mesh can be rendered, otherwise false.
  40271. * @param mesh The mesh to render
  40272. * @param material The material used on the mesh
  40273. * @returns true if it can be rendered otherwise false
  40274. */
  40275. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  40276. return !material.needAlphaBlendingForMesh(mesh);
  40277. };
  40278. /**
  40279. * Returns true if the mesh should render, otherwise false.
  40280. * @param mesh The mesh to render
  40281. * @returns true if it should render otherwise false
  40282. */
  40283. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  40284. return true;
  40285. };
  40286. /**
  40287. * Renders the submesh passed in parameter to the generation map.
  40288. */
  40289. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  40290. var _this = this;
  40291. if (!this.shouldRender()) {
  40292. return;
  40293. }
  40294. var material = subMesh.getMaterial();
  40295. var mesh = subMesh.getRenderingMesh();
  40296. var scene = this._scene;
  40297. var engine = scene.getEngine();
  40298. if (!material) {
  40299. return;
  40300. }
  40301. // Do not block in blend mode.
  40302. if (!this._canRenderMesh(mesh, material)) {
  40303. return;
  40304. }
  40305. // Culling
  40306. engine.setState(material.backFaceCulling);
  40307. // Managing instances
  40308. var batch = mesh._getInstancesRenderList(subMesh._id);
  40309. if (batch.mustReturn) {
  40310. return;
  40311. }
  40312. // Early Exit per mesh
  40313. if (!this._shouldRenderMesh(mesh)) {
  40314. return;
  40315. }
  40316. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  40317. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  40318. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  40319. engine.enableEffect(this._effectLayerMapGenerationEffect);
  40320. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  40321. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  40322. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  40323. var needAlphaTest = material.needAlphaTesting();
  40324. var diffuseTexture = material.getAlphaTestTexture();
  40325. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40326. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40327. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40328. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  40329. var textureMatrix = diffuseTexture.getTextureMatrix();
  40330. if (textureMatrix) {
  40331. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  40332. }
  40333. }
  40334. var opacityTexture = material.opacityTexture;
  40335. if (opacityTexture) {
  40336. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  40337. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  40338. var textureMatrix = opacityTexture.getTextureMatrix();
  40339. if (textureMatrix) {
  40340. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  40341. }
  40342. }
  40343. // Glow emissive only
  40344. if (this._emissiveTextureAndColor.texture) {
  40345. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  40346. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  40347. }
  40348. // Bones
  40349. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  40350. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  40351. }
  40352. // Morph targets
  40353. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  40354. // Draw
  40355. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  40356. }
  40357. else {
  40358. // Need to reset refresh rate of the main map
  40359. this._mainTexture.resetRefreshCounter();
  40360. }
  40361. };
  40362. /**
  40363. * Rebuild the required buffers.
  40364. * @hidden Internal use only.
  40365. */
  40366. EffectLayer.prototype._rebuild = function () {
  40367. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40368. if (vb) {
  40369. vb._rebuild();
  40370. }
  40371. this._generateIndexBuffer();
  40372. };
  40373. /**
  40374. * Dispose only the render target textures and post process.
  40375. */
  40376. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  40377. this._mainTexture.dispose();
  40378. for (var i = 0; i < this._postProcesses.length; i++) {
  40379. if (this._postProcesses[i]) {
  40380. this._postProcesses[i].dispose();
  40381. }
  40382. }
  40383. this._postProcesses = [];
  40384. for (var i = 0; i < this._textures.length; i++) {
  40385. if (this._textures[i]) {
  40386. this._textures[i].dispose();
  40387. }
  40388. }
  40389. this._textures = [];
  40390. };
  40391. /**
  40392. * Dispose the highlight layer and free resources.
  40393. */
  40394. EffectLayer.prototype.dispose = function () {
  40395. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40396. if (vertexBuffer) {
  40397. vertexBuffer.dispose();
  40398. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  40399. }
  40400. if (this._indexBuffer) {
  40401. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  40402. this._indexBuffer = null;
  40403. }
  40404. // Clean textures and post processes
  40405. this._disposeTextureAndPostProcesses();
  40406. // Remove from scene
  40407. var index = this._scene.effectLayers.indexOf(this, 0);
  40408. if (index > -1) {
  40409. this._scene.effectLayers.splice(index, 1);
  40410. }
  40411. // Callback
  40412. this.onDisposeObservable.notifyObservers(this);
  40413. this.onDisposeObservable.clear();
  40414. this.onBeforeRenderMainTextureObservable.clear();
  40415. this.onBeforeComposeObservable.clear();
  40416. this.onAfterComposeObservable.clear();
  40417. this.onSizeChangedObservable.clear();
  40418. };
  40419. /**
  40420. * Gets the class name of the effect layer
  40421. * @returns the string with the class name of the effect layer
  40422. */
  40423. EffectLayer.prototype.getClassName = function () {
  40424. return "EffectLayer";
  40425. };
  40426. /**
  40427. * Creates an effect layer from parsed effect layer data
  40428. * @param parsedEffectLayer defines effect layer data
  40429. * @param scene defines the current scene
  40430. * @param rootUrl defines the root URL containing the effect layer information
  40431. * @returns a parsed effect Layer
  40432. */
  40433. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  40434. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  40435. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  40436. };
  40437. /** @hidden */
  40438. EffectLayer._SceneComponentInitialization = function (_) {
  40439. throw "Import EffectLayerSceneComponent before creating EffectLayer.";
  40440. };
  40441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40443. ], EffectLayer.prototype, "name", void 0);
  40444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  40446. ], EffectLayer.prototype, "neutralColor", void 0);
  40447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40449. ], EffectLayer.prototype, "isEnabled", void 0);
  40450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  40452. ], EffectLayer.prototype, "camera", null);
  40453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40455. ], EffectLayer.prototype, "renderingGroupId", null);
  40456. return EffectLayer;
  40457. }());
  40458. /***/ }),
  40459. /***/ "./Layers/effectLayerSceneComponent.ts":
  40460. /*!*********************************************!*\
  40461. !*** ./Layers/effectLayerSceneComponent.ts ***!
  40462. \*********************************************/
  40463. /*! exports provided: EffectLayerSceneComponent */
  40464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40465. "use strict";
  40466. __webpack_require__.r(__webpack_exports__);
  40467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  40468. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  40469. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  40470. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40471. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40472. // Adds the parser to the scene parsers.
  40473. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  40474. if (parsedData.effectLayers) {
  40475. if (!container.effectLayers) {
  40476. container.effectLayers = new Array();
  40477. }
  40478. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  40479. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  40480. container.effectLayers.push(effectLayer);
  40481. }
  40482. }
  40483. });
  40484. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  40485. var index = this.effectLayers.indexOf(toRemove);
  40486. if (index !== -1) {
  40487. this.effectLayers.splice(index, 1);
  40488. }
  40489. return index;
  40490. };
  40491. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  40492. this.effectLayers.push(newEffectLayer);
  40493. };
  40494. /**
  40495. * Defines the layer scene component responsible to manage any effect layers
  40496. * in a given scene.
  40497. */
  40498. var EffectLayerSceneComponent = /** @class */ (function () {
  40499. /**
  40500. * Creates a new instance of the component for the given scene
  40501. * @param scene Defines the scene to register the component in
  40502. */
  40503. function EffectLayerSceneComponent(scene) {
  40504. /**
  40505. * The component name helpfull to identify the component in the list of scene components.
  40506. */
  40507. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  40508. this._renderEffects = false;
  40509. this._needStencil = false;
  40510. this._previousStencilState = false;
  40511. this.scene = scene;
  40512. this._engine = scene.getEngine();
  40513. scene.effectLayers = new Array();
  40514. }
  40515. /**
  40516. * Registers the component in a given scene
  40517. */
  40518. EffectLayerSceneComponent.prototype.register = function () {
  40519. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  40520. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  40521. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  40522. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  40523. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  40524. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  40525. };
  40526. /**
  40527. * Rebuilds the elements related to this component in case of
  40528. * context lost for instance.
  40529. */
  40530. EffectLayerSceneComponent.prototype.rebuild = function () {
  40531. var layers = this.scene.effectLayers;
  40532. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  40533. var effectLayer = layers_1[_i];
  40534. effectLayer._rebuild();
  40535. }
  40536. };
  40537. /**
  40538. * Serializes the component data to the specified json object
  40539. * @param serializationObject The object to serialize to
  40540. */
  40541. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  40542. // Effect layers
  40543. serializationObject.effectLayers = [];
  40544. var layers = this.scene.effectLayers;
  40545. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  40546. var effectLayer = layers_2[_i];
  40547. if (effectLayer.serialize) {
  40548. serializationObject.effectLayers.push(effectLayer.serialize());
  40549. }
  40550. }
  40551. };
  40552. /**
  40553. * Adds all the element from the container to the scene
  40554. * @param container the container holding the elements
  40555. */
  40556. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  40557. var _this = this;
  40558. if (!container.effectLayers) {
  40559. return;
  40560. }
  40561. container.effectLayers.forEach(function (o) {
  40562. _this.scene.addEffectLayer(o);
  40563. });
  40564. };
  40565. /**
  40566. * Removes all the elements in the container from the scene
  40567. * @param container contains the elements to remove
  40568. */
  40569. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  40570. var _this = this;
  40571. if (!container.effectLayers) {
  40572. return;
  40573. }
  40574. container.effectLayers.forEach(function (o) {
  40575. _this.scene.removeEffectLayer(o);
  40576. });
  40577. };
  40578. /**
  40579. * Disposes the component and the associated ressources.
  40580. */
  40581. EffectLayerSceneComponent.prototype.dispose = function () {
  40582. var layers = this.scene.effectLayers;
  40583. while (layers.length) {
  40584. layers[0].dispose();
  40585. }
  40586. };
  40587. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  40588. var layers = this.scene.effectLayers;
  40589. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  40590. var layer = layers_3[_i];
  40591. if (!layer.hasMesh(mesh)) {
  40592. continue;
  40593. }
  40594. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  40595. var subMesh = _b[_a];
  40596. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  40597. return false;
  40598. }
  40599. }
  40600. }
  40601. return true;
  40602. };
  40603. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  40604. this._renderEffects = false;
  40605. this._needStencil = false;
  40606. var layers = this.scene.effectLayers;
  40607. if (layers && layers.length > 0) {
  40608. this._previousStencilState = this._engine.getStencilBuffer();
  40609. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  40610. var effectLayer = layers_4[_i];
  40611. if (effectLayer.shouldRender() &&
  40612. (!effectLayer.camera ||
  40613. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  40614. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  40615. this._renderEffects = true;
  40616. this._needStencil = this._needStencil || effectLayer.needStencil();
  40617. var renderTarget = effectLayer._mainTexture;
  40618. if (renderTarget._shouldRender()) {
  40619. this.scene.incrementRenderId();
  40620. renderTarget.render(false, false);
  40621. }
  40622. }
  40623. }
  40624. this.scene.incrementRenderId();
  40625. }
  40626. };
  40627. EffectLayerSceneComponent.prototype._setStencil = function () {
  40628. // Activate effect Layer stencil
  40629. if (this._needStencil) {
  40630. this._engine.setStencilBuffer(true);
  40631. }
  40632. };
  40633. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  40634. // Restore effect Layer stencil
  40635. if (this._needStencil) {
  40636. this._engine.setStencilBuffer(this._previousStencilState);
  40637. }
  40638. };
  40639. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  40640. if (this._renderEffects) {
  40641. this._engine.setDepthBuffer(false);
  40642. var layers = this.scene.effectLayers;
  40643. for (var i = 0; i < layers.length; i++) {
  40644. var effectLayer = layers[i];
  40645. if (effectLayer.renderingGroupId === renderingGroupId) {
  40646. if (effectLayer.shouldRender()) {
  40647. effectLayer.render();
  40648. }
  40649. }
  40650. }
  40651. this._engine.setDepthBuffer(true);
  40652. }
  40653. };
  40654. EffectLayerSceneComponent.prototype._drawCamera = function () {
  40655. if (this._renderEffects) {
  40656. this._draw(-1);
  40657. }
  40658. };
  40659. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  40660. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  40661. this._draw(index);
  40662. }
  40663. };
  40664. return EffectLayerSceneComponent;
  40665. }());
  40666. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  40667. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  40668. if (!component) {
  40669. component = new EffectLayerSceneComponent(scene);
  40670. scene._addComponent(component);
  40671. }
  40672. };
  40673. /***/ }),
  40674. /***/ "./Layers/glowLayer.ts":
  40675. /*!*****************************!*\
  40676. !*** ./Layers/glowLayer.ts ***!
  40677. \*****************************/
  40678. /*! exports provided: GlowLayer */
  40679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40680. "use strict";
  40681. __webpack_require__.r(__webpack_exports__);
  40682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  40683. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40684. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40685. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40686. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40687. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40688. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40689. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40690. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40691. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  40692. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40693. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40694. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40695. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  40696. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  40697. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  40698. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  40699. for (var index = 0; index < this.effectLayers.length; index++) {
  40700. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  40701. return this.effectLayers[index];
  40702. }
  40703. }
  40704. return null;
  40705. };
  40706. /**
  40707. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  40708. *
  40709. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  40710. * glowy meshes to your scene.
  40711. *
  40712. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  40713. */
  40714. var GlowLayer = /** @class */ (function (_super) {
  40715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  40716. /**
  40717. * Instantiates a new glow Layer and references it to the scene.
  40718. * @param name The name of the layer
  40719. * @param scene The scene to use the layer in
  40720. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  40721. */
  40722. function GlowLayer(name, scene, options) {
  40723. var _this = _super.call(this, name, scene) || this;
  40724. _this._intensity = 1.0;
  40725. _this._includedOnlyMeshes = [];
  40726. _this._excludedMeshes = [];
  40727. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  40728. // Adapt options
  40729. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  40730. // Initialize the layer
  40731. _this._init({
  40732. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  40733. camera: _this._options.camera,
  40734. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  40735. mainTextureRatio: _this._options.mainTextureRatio,
  40736. renderingGroupId: _this._options.renderingGroupId
  40737. });
  40738. return _this;
  40739. }
  40740. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  40741. /**
  40742. * Gets the kernel size of the blur.
  40743. */
  40744. get: function () {
  40745. return this._horizontalBlurPostprocess1.kernel;
  40746. },
  40747. /**
  40748. * Sets the kernel size of the blur.
  40749. */
  40750. set: function (value) {
  40751. this._horizontalBlurPostprocess1.kernel = value;
  40752. this._verticalBlurPostprocess1.kernel = value;
  40753. this._horizontalBlurPostprocess2.kernel = value;
  40754. this._verticalBlurPostprocess2.kernel = value;
  40755. },
  40756. enumerable: true,
  40757. configurable: true
  40758. });
  40759. Object.defineProperty(GlowLayer.prototype, "intensity", {
  40760. /**
  40761. * Gets the glow intensity.
  40762. */
  40763. get: function () {
  40764. return this._intensity;
  40765. },
  40766. /**
  40767. * Sets the glow intensity.
  40768. */
  40769. set: function (value) {
  40770. this._intensity = value;
  40771. },
  40772. enumerable: true,
  40773. configurable: true
  40774. });
  40775. /**
  40776. * Get the effect name of the layer.
  40777. * @return The effect name
  40778. */
  40779. GlowLayer.prototype.getEffectName = function () {
  40780. return GlowLayer.EffectName;
  40781. };
  40782. /**
  40783. * Create the merge effect. This is the shader use to blit the information back
  40784. * to the main canvas at the end of the scene rendering.
  40785. */
  40786. GlowLayer.prototype._createMergeEffect = function () {
  40787. // Effect
  40788. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  40789. };
  40790. /**
  40791. * Creates the render target textures and post processes used in the glow layer.
  40792. */
  40793. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  40794. var _this = this;
  40795. var blurTextureWidth = this._mainTextureDesiredSize.width;
  40796. var blurTextureHeight = this._mainTextureDesiredSize.height;
  40797. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  40798. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  40799. var textureType = 0;
  40800. if (this._engine.getCaps().textureHalfFloatRender) {
  40801. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  40802. }
  40803. else {
  40804. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  40805. }
  40806. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  40807. width: blurTextureWidth,
  40808. height: blurTextureHeight
  40809. }, this._scene, false, true, textureType);
  40810. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40811. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40812. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  40813. this._blurTexture1.renderParticles = false;
  40814. this._blurTexture1.ignoreCameraViewport = true;
  40815. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  40816. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  40817. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  40818. width: blurTextureWidth2,
  40819. height: blurTextureHeight2
  40820. }, this._scene, false, true, textureType);
  40821. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40822. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40823. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  40824. this._blurTexture2.renderParticles = false;
  40825. this._blurTexture2.ignoreCameraViewport = true;
  40826. this._textures = [this._blurTexture1, this._blurTexture2];
  40827. 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, {
  40828. width: blurTextureWidth,
  40829. height: blurTextureHeight
  40830. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40831. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  40832. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  40833. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  40834. effect.setTexture("textureSampler", _this._mainTexture);
  40835. });
  40836. 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, {
  40837. width: blurTextureWidth,
  40838. height: blurTextureHeight
  40839. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40840. 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, {
  40841. width: blurTextureWidth2,
  40842. height: blurTextureHeight2
  40843. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40844. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  40845. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  40846. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  40847. effect.setTexture("textureSampler", _this._blurTexture1);
  40848. });
  40849. 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, {
  40850. width: blurTextureWidth2,
  40851. height: blurTextureHeight2
  40852. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40853. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  40854. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  40855. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  40856. this._mainTexture.samples = this._options.mainTextureSamples;
  40857. this._mainTexture.onAfterUnbindObservable.add(function () {
  40858. var internalTexture = _this._blurTexture1.getInternalTexture();
  40859. if (internalTexture) {
  40860. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  40861. internalTexture = _this._blurTexture2.getInternalTexture();
  40862. if (internalTexture) {
  40863. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  40864. }
  40865. }
  40866. });
  40867. // Prevent autoClear.
  40868. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  40869. };
  40870. /**
  40871. * Checks for the readiness of the element composing the layer.
  40872. * @param subMesh the mesh to check for
  40873. * @param useInstances specify wether or not to use instances to render the mesh
  40874. * @param emissiveTexture the associated emissive texture used to generate the glow
  40875. * @return true if ready otherwise, false
  40876. */
  40877. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  40878. var material = subMesh.getMaterial();
  40879. var mesh = subMesh.getRenderingMesh();
  40880. if (!material || !mesh) {
  40881. return false;
  40882. }
  40883. var emissiveTexture = material.emissiveTexture;
  40884. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  40885. };
  40886. /**
  40887. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  40888. */
  40889. GlowLayer.prototype.needStencil = function () {
  40890. return false;
  40891. };
  40892. /**
  40893. * Returns true if the mesh can be rendered, otherwise false.
  40894. * @param mesh The mesh to render
  40895. * @param material The material used on the mesh
  40896. * @returns true if it can be rendered otherwise false
  40897. */
  40898. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  40899. return true;
  40900. };
  40901. /**
  40902. * Implementation specific of rendering the generating effect on the main canvas.
  40903. * @param effect The effect used to render through
  40904. */
  40905. GlowLayer.prototype._internalRender = function (effect) {
  40906. // Texture
  40907. effect.setTexture("textureSampler", this._blurTexture1);
  40908. effect.setTexture("textureSampler2", this._blurTexture2);
  40909. effect.setFloat("offset", this._intensity);
  40910. // Cache
  40911. var engine = this._engine;
  40912. var previousStencilBuffer = engine.getStencilBuffer();
  40913. // Draw order
  40914. engine.setStencilBuffer(false);
  40915. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  40916. // Draw order
  40917. engine.setStencilBuffer(previousStencilBuffer);
  40918. };
  40919. /**
  40920. * Sets the required values for both the emissive texture and and the main color.
  40921. */
  40922. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  40923. var textureLevel = 1.0;
  40924. if (this.customEmissiveTextureSelector) {
  40925. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  40926. }
  40927. else {
  40928. if (material) {
  40929. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  40930. if (this._emissiveTextureAndColor.texture) {
  40931. textureLevel = this._emissiveTextureAndColor.texture.level;
  40932. }
  40933. }
  40934. else {
  40935. this._emissiveTextureAndColor.texture = null;
  40936. }
  40937. }
  40938. if (this.customEmissiveColorSelector) {
  40939. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  40940. }
  40941. else {
  40942. if (material.emissiveColor) {
  40943. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  40944. }
  40945. else {
  40946. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  40947. }
  40948. }
  40949. };
  40950. /**
  40951. * Returns true if the mesh should render, otherwise false.
  40952. * @param mesh The mesh to render
  40953. * @returns true if it should render otherwise false
  40954. */
  40955. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  40956. return this.hasMesh(mesh);
  40957. };
  40958. /**
  40959. * Adds specific effects defines.
  40960. * @param defines The defines to add specifics to.
  40961. */
  40962. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  40963. defines.push("#define GLOW");
  40964. };
  40965. /**
  40966. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  40967. * @param mesh The mesh to exclude from the glow layer
  40968. */
  40969. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  40970. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  40971. this._excludedMeshes.push(mesh.uniqueId);
  40972. }
  40973. };
  40974. /**
  40975. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  40976. * @param mesh The mesh to remove
  40977. */
  40978. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  40979. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  40980. if (index !== -1) {
  40981. this._excludedMeshes.splice(index, 1);
  40982. }
  40983. };
  40984. /**
  40985. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  40986. * @param mesh The mesh to include in the glow layer
  40987. */
  40988. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  40989. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  40990. this._includedOnlyMeshes.push(mesh.uniqueId);
  40991. }
  40992. };
  40993. /**
  40994. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  40995. * @param mesh The mesh to remove
  40996. */
  40997. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  40998. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  40999. if (index !== -1) {
  41000. this._includedOnlyMeshes.splice(index, 1);
  41001. }
  41002. };
  41003. /**
  41004. * Determine if a given mesh will be used in the glow layer
  41005. * @param mesh The mesh to test
  41006. * @returns true if the mesh will be highlighted by the current glow layer
  41007. */
  41008. GlowLayer.prototype.hasMesh = function (mesh) {
  41009. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41010. return false;
  41011. }
  41012. // Included Mesh
  41013. if (this._includedOnlyMeshes.length) {
  41014. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  41015. }
  41016. // Excluded Mesh
  41017. if (this._excludedMeshes.length) {
  41018. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  41019. }
  41020. return true;
  41021. };
  41022. /**
  41023. * Free any resources and references associated to a mesh.
  41024. * Internal use
  41025. * @param mesh The mesh to free.
  41026. * @hidden
  41027. */
  41028. GlowLayer.prototype._disposeMesh = function (mesh) {
  41029. this.removeIncludedOnlyMesh(mesh);
  41030. this.removeExcludedMesh(mesh);
  41031. };
  41032. /**
  41033. * Gets the class name of the effect layer
  41034. * @returns the string with the class name of the effect layer
  41035. */
  41036. GlowLayer.prototype.getClassName = function () {
  41037. return "GlowLayer";
  41038. };
  41039. /**
  41040. * Serializes this glow layer
  41041. * @returns a serialized glow layer object
  41042. */
  41043. GlowLayer.prototype.serialize = function () {
  41044. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41045. serializationObject.customType = "BABYLON.GlowLayer";
  41046. var index;
  41047. // Included meshes
  41048. serializationObject.includedMeshes = [];
  41049. if (this._includedOnlyMeshes.length) {
  41050. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  41051. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  41052. if (mesh) {
  41053. serializationObject.includedMeshes.push(mesh.id);
  41054. }
  41055. }
  41056. }
  41057. // Excluded meshes
  41058. serializationObject.excludedMeshes = [];
  41059. if (this._excludedMeshes.length) {
  41060. for (index = 0; index < this._excludedMeshes.length; index++) {
  41061. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  41062. if (mesh) {
  41063. serializationObject.excludedMeshes.push(mesh.id);
  41064. }
  41065. }
  41066. }
  41067. return serializationObject;
  41068. };
  41069. /**
  41070. * Creates a Glow Layer from parsed glow layer data
  41071. * @param parsedGlowLayer defines glow layer data
  41072. * @param scene defines the current scene
  41073. * @param rootUrl defines the root URL containing the glow layer information
  41074. * @returns a parsed Glow Layer
  41075. */
  41076. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  41077. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  41078. var index;
  41079. // Excluded meshes
  41080. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  41081. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  41082. if (mesh) {
  41083. gl.addExcludedMesh(mesh);
  41084. }
  41085. }
  41086. // Included meshes
  41087. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  41088. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  41089. if (mesh) {
  41090. gl.addIncludedOnlyMesh(mesh);
  41091. }
  41092. }
  41093. return gl;
  41094. };
  41095. /**
  41096. * Effect Name of the layer.
  41097. */
  41098. GlowLayer.EffectName = "GlowLayer";
  41099. /**
  41100. * The default blur kernel size used for the glow.
  41101. */
  41102. GlowLayer.DefaultBlurKernelSize = 32;
  41103. /**
  41104. * The default texture size ratio used for the glow.
  41105. */
  41106. GlowLayer.DefaultTextureRatio = 0.5;
  41107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41109. ], GlowLayer.prototype, "blurKernelSize", null);
  41110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41112. ], GlowLayer.prototype, "intensity", null);
  41113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41115. ], GlowLayer.prototype, "_options", void 0);
  41116. return GlowLayer;
  41117. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  41118. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  41119. /***/ }),
  41120. /***/ "./Layers/highlightLayer.ts":
  41121. /*!**********************************!*\
  41122. !*** ./Layers/highlightLayer.ts ***!
  41123. \**********************************/
  41124. /*! exports provided: HighlightLayer */
  41125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41126. "use strict";
  41127. __webpack_require__.r(__webpack_exports__);
  41128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  41129. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41130. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41131. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41132. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41133. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41134. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41135. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41136. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41137. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41138. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  41139. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  41140. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41141. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41142. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41143. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41144. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  41145. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41146. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41147. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41148. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  41149. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  41150. for (var index = 0; index < this.effectLayers.length; index++) {
  41151. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  41152. return this.effectLayers[index];
  41153. }
  41154. }
  41155. return null;
  41156. };
  41157. /**
  41158. * Special Glow Blur post process only blurring the alpha channel
  41159. * It enforces keeping the most luminous color in the color channel.
  41160. */
  41161. var GlowBlurPostProcess = /** @class */ (function (_super) {
  41162. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  41163. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  41164. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  41165. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  41166. _this.direction = direction;
  41167. _this.kernel = kernel;
  41168. _this.onApplyObservable.add(function (effect) {
  41169. effect.setFloat2("screenSize", _this.width, _this.height);
  41170. effect.setVector2("direction", _this.direction);
  41171. effect.setFloat("blurWidth", _this.kernel);
  41172. });
  41173. return _this;
  41174. }
  41175. return GlowBlurPostProcess;
  41176. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  41177. /**
  41178. * The highlight layer Helps adding a glow effect around a mesh.
  41179. *
  41180. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41181. * glowy meshes to your scene.
  41182. *
  41183. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  41184. */
  41185. var HighlightLayer = /** @class */ (function (_super) {
  41186. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  41187. /**
  41188. * Instantiates a new highlight Layer and references it to the scene..
  41189. * @param name The name of the layer
  41190. * @param scene The scene to use the layer in
  41191. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  41192. */
  41193. function HighlightLayer(name, scene, options) {
  41194. var _this = _super.call(this, name, scene) || this;
  41195. _this.name = name;
  41196. /**
  41197. * Specifies whether or not the inner glow is ACTIVE in the layer.
  41198. */
  41199. _this.innerGlow = true;
  41200. /**
  41201. * Specifies whether or not the outer glow is ACTIVE in the layer.
  41202. */
  41203. _this.outerGlow = true;
  41204. /**
  41205. * An event triggered when the highlight layer is being blurred.
  41206. */
  41207. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41208. /**
  41209. * An event triggered when the highlight layer has been blurred.
  41210. */
  41211. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41212. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  41213. _this._meshes = {};
  41214. _this._excludedMeshes = {};
  41215. _this.neutralColor = HighlightLayer.NeutralColor;
  41216. // Warn on stencil
  41217. if (!_this._engine.isStencilEnable) {
  41218. _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 }");
  41219. }
  41220. // Adapt options
  41221. _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);
  41222. // Initialize the layer
  41223. _this._init({
  41224. alphaBlendingMode: _this._options.alphaBlendingMode,
  41225. camera: _this._options.camera,
  41226. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41227. mainTextureRatio: _this._options.mainTextureRatio,
  41228. renderingGroupId: _this._options.renderingGroupId
  41229. });
  41230. // Do not render as long as no meshes have been added
  41231. _this._shouldRender = false;
  41232. return _this;
  41233. }
  41234. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  41235. /**
  41236. * Gets the horizontal size of the blur.
  41237. */
  41238. get: function () {
  41239. return this._horizontalBlurPostprocess.kernel;
  41240. },
  41241. /**
  41242. * Specifies the horizontal size of the blur.
  41243. */
  41244. set: function (value) {
  41245. this._horizontalBlurPostprocess.kernel = value;
  41246. },
  41247. enumerable: true,
  41248. configurable: true
  41249. });
  41250. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  41251. /**
  41252. * Gets the vertical size of the blur.
  41253. */
  41254. get: function () {
  41255. return this._verticalBlurPostprocess.kernel;
  41256. },
  41257. /**
  41258. * Specifies the vertical size of the blur.
  41259. */
  41260. set: function (value) {
  41261. this._verticalBlurPostprocess.kernel = value;
  41262. },
  41263. enumerable: true,
  41264. configurable: true
  41265. });
  41266. /**
  41267. * Get the effect name of the layer.
  41268. * @return The effect name
  41269. */
  41270. HighlightLayer.prototype.getEffectName = function () {
  41271. return HighlightLayer.EffectName;
  41272. };
  41273. /**
  41274. * Create the merge effect. This is the shader use to blit the information back
  41275. * to the main canvas at the end of the scene rendering.
  41276. */
  41277. HighlightLayer.prototype._createMergeEffect = function () {
  41278. // Effect
  41279. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  41280. };
  41281. /**
  41282. * Creates the render target textures and post processes used in the highlight layer.
  41283. */
  41284. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  41285. var _this = this;
  41286. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  41287. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  41288. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41289. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41290. var textureType = 0;
  41291. if (this._engine.getCaps().textureHalfFloatRender) {
  41292. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41293. }
  41294. else {
  41295. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41296. }
  41297. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  41298. width: blurTextureWidth,
  41299. height: blurTextureHeight
  41300. }, this._scene, false, true, textureType);
  41301. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41302. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41303. this._blurTexture.anisotropicFilteringLevel = 16;
  41304. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  41305. this._blurTexture.renderParticles = false;
  41306. this._blurTexture.ignoreCameraViewport = true;
  41307. this._textures = [this._blurTexture];
  41308. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  41309. 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());
  41310. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  41311. effect.setTexture("textureSampler", _this._mainTexture);
  41312. });
  41313. 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());
  41314. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41315. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41316. });
  41317. 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());
  41318. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  41319. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41320. });
  41321. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41322. }
  41323. else {
  41324. 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, {
  41325. width: blurTextureWidth,
  41326. height: blurTextureHeight
  41327. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41328. this._horizontalBlurPostprocess.width = blurTextureWidth;
  41329. this._horizontalBlurPostprocess.height = blurTextureHeight;
  41330. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41331. effect.setTexture("textureSampler", _this._mainTexture);
  41332. });
  41333. 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, {
  41334. width: blurTextureWidth,
  41335. height: blurTextureHeight
  41336. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41337. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41338. }
  41339. this._mainTexture.onAfterUnbindObservable.add(function () {
  41340. _this.onBeforeBlurObservable.notifyObservers(_this);
  41341. var internalTexture = _this._blurTexture.getInternalTexture();
  41342. if (internalTexture) {
  41343. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  41344. }
  41345. _this.onAfterBlurObservable.notifyObservers(_this);
  41346. });
  41347. // Prevent autoClear.
  41348. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41349. };
  41350. /**
  41351. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41352. */
  41353. HighlightLayer.prototype.needStencil = function () {
  41354. return true;
  41355. };
  41356. /**
  41357. * Checks for the readiness of the element composing the layer.
  41358. * @param subMesh the mesh to check for
  41359. * @param useInstances specify wether or not to use instances to render the mesh
  41360. * @param emissiveTexture the associated emissive texture used to generate the glow
  41361. * @return true if ready otherwise, false
  41362. */
  41363. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  41364. var material = subMesh.getMaterial();
  41365. var mesh = subMesh.getRenderingMesh();
  41366. if (!material || !mesh || !this._meshes) {
  41367. return false;
  41368. }
  41369. var emissiveTexture = null;
  41370. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41371. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41372. emissiveTexture = material.emissiveTexture;
  41373. }
  41374. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41375. };
  41376. /**
  41377. * Implementation specific of rendering the generating effect on the main canvas.
  41378. * @param effect The effect used to render through
  41379. */
  41380. HighlightLayer.prototype._internalRender = function (effect) {
  41381. // Texture
  41382. effect.setTexture("textureSampler", this._blurTexture);
  41383. // Cache
  41384. var engine = this._engine;
  41385. var previousStencilBuffer = engine.getStencilBuffer();
  41386. var previousStencilFunction = engine.getStencilFunction();
  41387. var previousStencilMask = engine.getStencilMask();
  41388. var previousStencilOperationPass = engine.getStencilOperationPass();
  41389. var previousStencilOperationFail = engine.getStencilOperationFail();
  41390. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  41391. var previousStencilReference = engine.getStencilFunctionReference();
  41392. // Stencil operations
  41393. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  41394. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41395. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41396. // Draw order
  41397. engine.setStencilMask(0x00);
  41398. engine.setStencilBuffer(true);
  41399. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  41400. // 2 passes inner outer
  41401. if (this.outerGlow) {
  41402. effect.setFloat("offset", 0);
  41403. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  41404. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41405. }
  41406. if (this.innerGlow) {
  41407. effect.setFloat("offset", 1);
  41408. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  41409. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41410. }
  41411. // Restore Cache
  41412. engine.setStencilFunction(previousStencilFunction);
  41413. engine.setStencilMask(previousStencilMask);
  41414. engine.setStencilBuffer(previousStencilBuffer);
  41415. engine.setStencilOperationPass(previousStencilOperationPass);
  41416. engine.setStencilOperationFail(previousStencilOperationFail);
  41417. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  41418. engine.setStencilFunctionReference(previousStencilReference);
  41419. };
  41420. /**
  41421. * Returns true if the layer contains information to display, otherwise false.
  41422. */
  41423. HighlightLayer.prototype.shouldRender = function () {
  41424. if (_super.prototype.shouldRender.call(this)) {
  41425. return this._meshes ? true : false;
  41426. }
  41427. return false;
  41428. };
  41429. /**
  41430. * Returns true if the mesh should render, otherwise false.
  41431. * @param mesh The mesh to render
  41432. * @returns true if it should render otherwise false
  41433. */
  41434. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  41435. // Excluded Mesh
  41436. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  41437. return false;
  41438. }
  41439. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41440. return false;
  41441. }
  41442. return true;
  41443. };
  41444. /**
  41445. * Sets the required values for both the emissive texture and and the main color.
  41446. */
  41447. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41448. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41449. if (highlightLayerMesh) {
  41450. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  41451. }
  41452. else {
  41453. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41454. }
  41455. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41456. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41457. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  41458. }
  41459. else {
  41460. this._emissiveTextureAndColor.texture = null;
  41461. }
  41462. };
  41463. /**
  41464. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  41465. * @param mesh The mesh to exclude from the highlight layer
  41466. */
  41467. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  41468. if (!this._excludedMeshes) {
  41469. return;
  41470. }
  41471. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41472. if (!meshExcluded) {
  41473. this._excludedMeshes[mesh.uniqueId] = {
  41474. mesh: mesh,
  41475. beforeRender: mesh.onBeforeRenderObservable.add(function (mesh) {
  41476. mesh.getEngine().setStencilBuffer(false);
  41477. }),
  41478. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  41479. mesh.getEngine().setStencilBuffer(true);
  41480. }),
  41481. };
  41482. }
  41483. };
  41484. /**
  41485. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  41486. * @param mesh The mesh to highlight
  41487. */
  41488. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  41489. if (!this._excludedMeshes) {
  41490. return;
  41491. }
  41492. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41493. if (meshExcluded) {
  41494. if (meshExcluded.beforeRender) {
  41495. mesh.onBeforeRenderObservable.remove(meshExcluded.beforeRender);
  41496. }
  41497. if (meshExcluded.afterRender) {
  41498. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  41499. }
  41500. }
  41501. this._excludedMeshes[mesh.uniqueId] = null;
  41502. };
  41503. /**
  41504. * Determine if a given mesh will be highlighted by the current HighlightLayer
  41505. * @param mesh mesh to test
  41506. * @returns true if the mesh will be highlighted by the current HighlightLayer
  41507. */
  41508. HighlightLayer.prototype.hasMesh = function (mesh) {
  41509. if (!this._meshes) {
  41510. return false;
  41511. }
  41512. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41513. return false;
  41514. }
  41515. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  41516. };
  41517. /**
  41518. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  41519. * @param mesh The mesh to highlight
  41520. * @param color The color of the highlight
  41521. * @param glowEmissiveOnly Extract the glow from the emissive texture
  41522. */
  41523. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  41524. var _this = this;
  41525. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  41526. if (!this._meshes) {
  41527. return;
  41528. }
  41529. var meshHighlight = this._meshes[mesh.uniqueId];
  41530. if (meshHighlight) {
  41531. meshHighlight.color = color;
  41532. }
  41533. else {
  41534. this._meshes[mesh.uniqueId] = {
  41535. mesh: mesh,
  41536. color: color,
  41537. // Lambda required for capture due to Observable this context
  41538. observerHighlight: mesh.onBeforeRenderObservable.add(function (mesh) {
  41539. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  41540. _this._defaultStencilReference(mesh);
  41541. }
  41542. else {
  41543. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  41544. }
  41545. }),
  41546. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  41547. glowEmissiveOnly: glowEmissiveOnly
  41548. };
  41549. mesh.onDisposeObservable.add(function () {
  41550. _this._disposeMesh(mesh);
  41551. });
  41552. }
  41553. this._shouldRender = true;
  41554. };
  41555. /**
  41556. * Remove a mesh from the highlight layer in order to make it stop glowing.
  41557. * @param mesh The mesh to highlight
  41558. */
  41559. HighlightLayer.prototype.removeMesh = function (mesh) {
  41560. if (!this._meshes) {
  41561. return;
  41562. }
  41563. var meshHighlight = this._meshes[mesh.uniqueId];
  41564. if (meshHighlight) {
  41565. if (meshHighlight.observerHighlight) {
  41566. mesh.onBeforeRenderObservable.remove(meshHighlight.observerHighlight);
  41567. }
  41568. if (meshHighlight.observerDefault) {
  41569. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41570. }
  41571. delete this._meshes[mesh.uniqueId];
  41572. }
  41573. this._shouldRender = false;
  41574. for (var meshHighlightToCheck in this._meshes) {
  41575. if (this._meshes[meshHighlightToCheck]) {
  41576. this._shouldRender = true;
  41577. break;
  41578. }
  41579. }
  41580. };
  41581. /**
  41582. * Force the stencil to the normal expected value for none glowing parts
  41583. */
  41584. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  41585. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  41586. };
  41587. /**
  41588. * Free any resources and references associated to a mesh.
  41589. * Internal use
  41590. * @param mesh The mesh to free.
  41591. * @hidden
  41592. */
  41593. HighlightLayer.prototype._disposeMesh = function (mesh) {
  41594. this.removeMesh(mesh);
  41595. this.removeExcludedMesh(mesh);
  41596. };
  41597. /**
  41598. * Dispose the highlight layer and free resources.
  41599. */
  41600. HighlightLayer.prototype.dispose = function () {
  41601. if (this._meshes) {
  41602. // Clean mesh references
  41603. for (var id in this._meshes) {
  41604. var meshHighlight = this._meshes[id];
  41605. if (meshHighlight && meshHighlight.mesh) {
  41606. if (meshHighlight.observerHighlight) {
  41607. meshHighlight.mesh.onBeforeRenderObservable.remove(meshHighlight.observerHighlight);
  41608. }
  41609. if (meshHighlight.observerDefault) {
  41610. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41611. }
  41612. }
  41613. }
  41614. this._meshes = null;
  41615. }
  41616. if (this._excludedMeshes) {
  41617. for (var id in this._excludedMeshes) {
  41618. var meshHighlight = this._excludedMeshes[id];
  41619. if (meshHighlight) {
  41620. if (meshHighlight.beforeRender) {
  41621. meshHighlight.mesh.onBeforeRenderObservable.remove(meshHighlight.beforeRender);
  41622. }
  41623. if (meshHighlight.afterRender) {
  41624. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  41625. }
  41626. }
  41627. }
  41628. this._excludedMeshes = null;
  41629. }
  41630. _super.prototype.dispose.call(this);
  41631. };
  41632. /**
  41633. * Gets the class name of the effect layer
  41634. * @returns the string with the class name of the effect layer
  41635. */
  41636. HighlightLayer.prototype.getClassName = function () {
  41637. return "HighlightLayer";
  41638. };
  41639. /**
  41640. * Serializes this Highlight layer
  41641. * @returns a serialized Highlight layer object
  41642. */
  41643. HighlightLayer.prototype.serialize = function () {
  41644. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41645. serializationObject.customType = "BABYLON.HighlightLayer";
  41646. // Highlighted meshes
  41647. serializationObject.meshes = [];
  41648. if (this._meshes) {
  41649. for (var m in this._meshes) {
  41650. var mesh = this._meshes[m];
  41651. if (mesh) {
  41652. serializationObject.meshes.push({
  41653. glowEmissiveOnly: mesh.glowEmissiveOnly,
  41654. color: mesh.color.asArray(),
  41655. meshId: mesh.mesh.id
  41656. });
  41657. }
  41658. }
  41659. }
  41660. // Excluded meshes
  41661. serializationObject.excludedMeshes = [];
  41662. if (this._excludedMeshes) {
  41663. for (var e in this._excludedMeshes) {
  41664. var excludedMesh = this._excludedMeshes[e];
  41665. if (excludedMesh) {
  41666. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  41667. }
  41668. }
  41669. }
  41670. return serializationObject;
  41671. };
  41672. /**
  41673. * Creates a Highlight layer from parsed Highlight layer data
  41674. * @param parsedHightlightLayer defines the Highlight layer data
  41675. * @param scene defines the current scene
  41676. * @param rootUrl defines the root URL containing the Highlight layer information
  41677. * @returns a parsed Highlight layer
  41678. */
  41679. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  41680. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  41681. var index;
  41682. // Excluded meshes
  41683. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  41684. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  41685. if (mesh) {
  41686. hl.addExcludedMesh(mesh);
  41687. }
  41688. }
  41689. // Included meshes
  41690. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  41691. var highlightedMesh = parsedHightlightLayer.meshes[index];
  41692. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  41693. if (mesh) {
  41694. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  41695. }
  41696. }
  41697. return hl;
  41698. };
  41699. /**
  41700. * Effect Name of the highlight layer.
  41701. */
  41702. HighlightLayer.EffectName = "HighlightLayer";
  41703. /**
  41704. * The neutral color used during the preparation of the glow effect.
  41705. * This is black by default as the blend operation is a blend operation.
  41706. */
  41707. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  41708. /**
  41709. * Stencil value used for glowing meshes.
  41710. */
  41711. HighlightLayer.GlowingMeshStencilReference = 0x02;
  41712. /**
  41713. * Stencil value used for the other meshes in the scene.
  41714. */
  41715. HighlightLayer.NormalMeshStencilReference = 0x01;
  41716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41718. ], HighlightLayer.prototype, "innerGlow", void 0);
  41719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41721. ], HighlightLayer.prototype, "outerGlow", void 0);
  41722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41724. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  41725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41727. ], HighlightLayer.prototype, "blurVerticalSize", null);
  41728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41730. ], HighlightLayer.prototype, "_options", void 0);
  41731. return HighlightLayer;
  41732. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  41733. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  41734. /***/ }),
  41735. /***/ "./Layers/index.ts":
  41736. /*!*************************!*\
  41737. !*** ./Layers/index.ts ***!
  41738. \*************************/
  41739. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  41740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41741. "use strict";
  41742. __webpack_require__.r(__webpack_exports__);
  41743. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  41745. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  41746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  41747. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  41748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  41749. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  41750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  41751. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  41752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  41753. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  41754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  41755. /***/ }),
  41756. /***/ "./Layers/layer.ts":
  41757. /*!*************************!*\
  41758. !*** ./Layers/layer.ts ***!
  41759. \*************************/
  41760. /*! exports provided: Layer */
  41761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41762. "use strict";
  41763. __webpack_require__.r(__webpack_exports__);
  41764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  41765. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41767. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41768. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41769. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41770. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41771. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41772. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  41773. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41774. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  41775. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  41776. /**
  41777. * This represents a full screen 2d layer.
  41778. * This can be useful to display a picture in the background of your scene for instance.
  41779. * @see https://www.babylonjs-playground.com/#08A2BS#1
  41780. */
  41781. var Layer = /** @class */ (function () {
  41782. /**
  41783. * Instantiates a new layer.
  41784. * This represents a full screen 2d layer.
  41785. * This can be useful to display a picture in the background of your scene for instance.
  41786. * @see https://www.babylonjs-playground.com/#08A2BS#1
  41787. * @param name Define the name of the layer in the scene
  41788. * @param imgUrl Define the url of the texture to display in the layer
  41789. * @param scene Define the scene the layer belongs to
  41790. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  41791. * @param color Defines a color for the layer
  41792. */
  41793. function Layer(
  41794. /**
  41795. * Define the name of the layer.
  41796. */
  41797. name, imgUrl, scene, isBackground, color) {
  41798. this.name = name;
  41799. /**
  41800. * Define the scale of the layer in order to zoom in out of the texture.
  41801. */
  41802. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  41803. /**
  41804. * Define an offset for the layer in order to shift the texture.
  41805. */
  41806. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  41807. /**
  41808. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  41809. */
  41810. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  41811. /**
  41812. * Define a mask to restrict the layer to only some of the scene cameras.
  41813. */
  41814. this.layerMask = 0x0FFFFFFF;
  41815. /**
  41816. * Define the list of render target the layer is visible into.
  41817. */
  41818. this.renderTargetTextures = [];
  41819. /**
  41820. * Define if the layer is only used in renderTarget or if it also
  41821. * renders in the main frame buffer of the canvas.
  41822. */
  41823. this.renderOnlyInRenderTargetTextures = false;
  41824. this._vertexBuffers = {};
  41825. /**
  41826. * An event triggered when the layer is disposed.
  41827. */
  41828. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41829. /**
  41830. * An event triggered before rendering the scene
  41831. */
  41832. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41833. /**
  41834. * An event triggered after rendering the scene
  41835. */
  41836. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41837. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  41838. this.isBackground = isBackground === undefined ? true : isBackground;
  41839. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  41840. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  41841. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  41842. if (!layerComponent) {
  41843. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  41844. this._scene._addComponent(layerComponent);
  41845. }
  41846. this._scene.layers.push(this);
  41847. var engine = this._scene.getEngine();
  41848. // VBO
  41849. var vertices = [];
  41850. vertices.push(1, 1);
  41851. vertices.push(-1, 1);
  41852. vertices.push(-1, -1);
  41853. vertices.push(1, -1);
  41854. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  41855. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  41856. this._createIndexBuffer();
  41857. // Effects
  41858. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  41859. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  41860. }
  41861. Object.defineProperty(Layer.prototype, "onDispose", {
  41862. /**
  41863. * Back compatibility with callback before the onDisposeObservable existed.
  41864. * The set callback will be triggered when the layer has been disposed.
  41865. */
  41866. set: function (callback) {
  41867. if (this._onDisposeObserver) {
  41868. this.onDisposeObservable.remove(this._onDisposeObserver);
  41869. }
  41870. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  41871. },
  41872. enumerable: true,
  41873. configurable: true
  41874. });
  41875. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  41876. /**
  41877. * Back compatibility with callback before the onBeforeRenderObservable existed.
  41878. * The set callback will be triggered just before rendering the layer.
  41879. */
  41880. set: function (callback) {
  41881. if (this._onBeforeRenderObserver) {
  41882. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  41883. }
  41884. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  41885. },
  41886. enumerable: true,
  41887. configurable: true
  41888. });
  41889. Object.defineProperty(Layer.prototype, "onAfterRender", {
  41890. /**
  41891. * Back compatibility with callback before the onAfterRenderObservable existed.
  41892. * The set callback will be triggered just after rendering the layer.
  41893. */
  41894. set: function (callback) {
  41895. if (this._onAfterRenderObserver) {
  41896. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41897. }
  41898. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  41899. },
  41900. enumerable: true,
  41901. configurable: true
  41902. });
  41903. Layer.prototype._createIndexBuffer = function () {
  41904. var engine = this._scene.getEngine();
  41905. // Indices
  41906. var indices = [];
  41907. indices.push(0);
  41908. indices.push(1);
  41909. indices.push(2);
  41910. indices.push(0);
  41911. indices.push(2);
  41912. indices.push(3);
  41913. this._indexBuffer = engine.createIndexBuffer(indices);
  41914. };
  41915. /** @hidden */
  41916. Layer.prototype._rebuild = function () {
  41917. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  41918. if (vb) {
  41919. vb._rebuild();
  41920. }
  41921. this._createIndexBuffer();
  41922. };
  41923. /**
  41924. * Renders the layer in the scene.
  41925. */
  41926. Layer.prototype.render = function () {
  41927. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  41928. // Check
  41929. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  41930. return;
  41931. }
  41932. var engine = this._scene.getEngine();
  41933. this.onBeforeRenderObservable.notifyObservers(this);
  41934. // Render
  41935. engine.enableEffect(currentEffect);
  41936. engine.setState(false);
  41937. // Texture
  41938. currentEffect.setTexture("textureSampler", this.texture);
  41939. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  41940. // Color
  41941. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  41942. // Scale / offset
  41943. currentEffect.setVector2("offset", this.offset);
  41944. currentEffect.setVector2("scale", this.scale);
  41945. // VBOs
  41946. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41947. // Draw order
  41948. if (!this.alphaTest) {
  41949. engine.setAlphaMode(this.alphaBlendingMode);
  41950. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  41951. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  41952. }
  41953. else {
  41954. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  41955. }
  41956. this.onAfterRenderObservable.notifyObservers(this);
  41957. };
  41958. /**
  41959. * Disposes and releases the associated ressources.
  41960. */
  41961. Layer.prototype.dispose = function () {
  41962. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  41963. if (vertexBuffer) {
  41964. vertexBuffer.dispose();
  41965. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  41966. }
  41967. if (this._indexBuffer) {
  41968. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41969. this._indexBuffer = null;
  41970. }
  41971. if (this.texture) {
  41972. this.texture.dispose();
  41973. this.texture = null;
  41974. }
  41975. // Clean RTT list
  41976. this.renderTargetTextures = [];
  41977. // Remove from scene
  41978. var index = this._scene.layers.indexOf(this);
  41979. this._scene.layers.splice(index, 1);
  41980. // Callback
  41981. this.onDisposeObservable.notifyObservers(this);
  41982. this.onDisposeObservable.clear();
  41983. this.onAfterRenderObservable.clear();
  41984. this.onBeforeRenderObservable.clear();
  41985. };
  41986. return Layer;
  41987. }());
  41988. /***/ }),
  41989. /***/ "./Layers/layerSceneComponent.ts":
  41990. /*!***************************************!*\
  41991. !*** ./Layers/layerSceneComponent.ts ***!
  41992. \***************************************/
  41993. /*! exports provided: LayerSceneComponent */
  41994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41995. "use strict";
  41996. __webpack_require__.r(__webpack_exports__);
  41997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  41998. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41999. /**
  42000. * Defines the layer scene component responsible to manage any layers
  42001. * in a given scene.
  42002. */
  42003. var LayerSceneComponent = /** @class */ (function () {
  42004. /**
  42005. * Creates a new instance of the component for the given scene
  42006. * @param scene Defines the scene to register the component in
  42007. */
  42008. function LayerSceneComponent(scene) {
  42009. /**
  42010. * The component name helpfull to identify the component in the list of scene components.
  42011. */
  42012. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  42013. this.scene = scene;
  42014. this._engine = scene.getEngine();
  42015. scene.layers = new Array();
  42016. }
  42017. /**
  42018. * Registers the component in a given scene
  42019. */
  42020. LayerSceneComponent.prototype.register = function () {
  42021. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  42022. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  42023. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  42024. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  42025. };
  42026. /**
  42027. * Rebuilds the elements related to this component in case of
  42028. * context lost for instance.
  42029. */
  42030. LayerSceneComponent.prototype.rebuild = function () {
  42031. var layers = this.scene.layers;
  42032. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42033. var layer = layers_1[_i];
  42034. layer._rebuild();
  42035. }
  42036. };
  42037. /**
  42038. * Disposes the component and the associated ressources.
  42039. */
  42040. LayerSceneComponent.prototype.dispose = function () {
  42041. var layers = this.scene.layers;
  42042. while (layers.length) {
  42043. layers[0].dispose();
  42044. }
  42045. };
  42046. LayerSceneComponent.prototype._draw = function (predicate) {
  42047. var layers = this.scene.layers;
  42048. if (layers.length) {
  42049. this._engine.setDepthBuffer(false);
  42050. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42051. var layer = layers_2[_i];
  42052. if (predicate(layer)) {
  42053. layer.render();
  42054. }
  42055. }
  42056. this._engine.setDepthBuffer(true);
  42057. }
  42058. };
  42059. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  42060. return !layer.renderOnlyInRenderTargetTextures &&
  42061. layer.isBackground === isBackground &&
  42062. ((layer.layerMask & cameraLayerMask) !== 0);
  42063. };
  42064. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  42065. var _this = this;
  42066. this._draw(function (layer) {
  42067. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  42068. });
  42069. };
  42070. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  42071. var _this = this;
  42072. this._draw(function (layer) {
  42073. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  42074. });
  42075. };
  42076. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  42077. return (layer.renderTargetTextures.length > 0) &&
  42078. layer.isBackground === isBackground &&
  42079. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  42080. ((layer.layerMask & cameraLayerMask) !== 0);
  42081. };
  42082. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  42083. var _this = this;
  42084. this._draw(function (layer) {
  42085. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  42086. });
  42087. };
  42088. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  42089. var _this = this;
  42090. this._draw(function (layer) {
  42091. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  42092. });
  42093. };
  42094. return LayerSceneComponent;
  42095. }());
  42096. /***/ }),
  42097. /***/ "./Legacy/legacy.ts":
  42098. /*!**************************!*\
  42099. !*** ./Legacy/legacy.ts ***!
  42100. \**************************/
  42101. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, VRCameraMetrics, Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  42102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42103. "use strict";
  42104. __webpack_require__.r(__webpack_exports__);
  42105. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  42106. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  42107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  42108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  42109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  42110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  42111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  42112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  42113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  42114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  42115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  42116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  42117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  42118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  42119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  42120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  42121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  42122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  42123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  42124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  42125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  42126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  42127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  42128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  42129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  42130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  42131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  42132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  42133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  42134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  42135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  42136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  42137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PathCursor"]; });
  42138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  42139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  42140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  42141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  42142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  42143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  42144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  42145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  42146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  42147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  42148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  42149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  42150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  42151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  42152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  42153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  42154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  42155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  42156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  42157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  42158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  42159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  42160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  42161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  42162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  42163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  42164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  42165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  42166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  42167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  42168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  42169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  42170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  42171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  42172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  42173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  42174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  42175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  42176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  42177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  42178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  42179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  42180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  42181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  42182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  42183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  42184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  42185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  42186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  42187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  42188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  42189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  42190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CollisionCoordinatorLegacy"]; });
  42191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  42192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  42193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  42194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  42195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  42196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  42197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  42198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  42199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  42200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  42201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  42202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  42203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  42204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  42205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  42206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  42207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  42208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  42209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  42210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  42211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  42212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  42213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  42214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  42215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  42216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  42217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  42218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  42219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  42220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  42221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  42222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  42223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  42224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  42225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  42226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  42227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  42228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  42229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  42230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  42231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  42232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  42233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  42234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  42235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  42236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  42237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  42238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  42239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  42240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  42241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  42242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  42243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  42244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  42245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  42246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  42247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  42248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  42249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  42250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  42251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  42252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  42253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  42254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  42256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  42257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  42258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  42259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  42260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  42262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  42263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  42264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  42265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  42266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  42267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  42268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  42269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  42270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  42271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  42272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  42273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  42274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  42275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  42276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  42277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  42278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  42279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  42280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  42281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  42282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  42283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  42284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  42285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  42286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  42287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  42288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  42289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  42290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  42291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  42292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  42293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  42294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  42295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  42296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  42297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  42298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  42299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  42300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  42301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  42302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  42303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  42304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  42305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  42306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  42307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  42308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  42309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  42310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  42311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  42312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  42313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  42314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  42315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  42316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  42317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  42318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  42319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  42320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  42321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  42322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  42323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  42324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  42325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  42326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  42327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  42328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  42329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  42330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  42331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  42332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  42333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  42334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]; });
  42335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonGeometry"]; });
  42336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]; });
  42337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]; });
  42338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscGeometry"]; });
  42339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]; });
  42340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]; });
  42341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]; });
  42342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TiledGroundGeometry"]; });
  42343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneGeometry"]; });
  42344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]; });
  42345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  42346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  42347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  42348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  42349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  42350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  42351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  42352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  42353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  42354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  42355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  42356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  42357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  42358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  42359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  42360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  42361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  42362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  42363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  42364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  42365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  42366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  42367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  42368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  42369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  42370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  42371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  42372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  42373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  42374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  42375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  42376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  42377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  42378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  42379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  42380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  42381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  42382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  42383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  42384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  42385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  42386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  42387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  42388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  42389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  42390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  42391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  42392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  42393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  42394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  42395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  42396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  42397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  42398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  42399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  42400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  42401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  42402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  42403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  42404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  42405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  42406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  42407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  42408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  42409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  42410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  42411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  42412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  42413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  42414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  42415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  42416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  42417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  42418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  42419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  42420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  42421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  42422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  42423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  42424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  42425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  42426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  42427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  42428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  42429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  42430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  42431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  42432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  42433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  42434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  42435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  42436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  42437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  42438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  42439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  42440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  42441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  42442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  42443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  42444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  42445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  42446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  42447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  42448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  42449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  42450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  42451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  42452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  42453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  42454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  42455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  42456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  42457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  42458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  42459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  42460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  42461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  42462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  42463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  42464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  42465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  42466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  42467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  42468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  42469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  42470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  42471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  42472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  42473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  42474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  42475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  42476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  42477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  42478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  42479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  42480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  42481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  42482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  42483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  42484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  42485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  42486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  42487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  42488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  42489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  42490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  42491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  42492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  42493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  42494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  42495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  42496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  42497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  42498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  42499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  42500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  42501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  42502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  42503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  42504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  42505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  42506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  42507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  42508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  42509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  42510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  42511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  42512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  42513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  42514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  42515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  42516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  42517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  42518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  42519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  42520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  42521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  42522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  42523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  42524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  42525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  42526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  42527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  42528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  42529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  42530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  42531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  42532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  42533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  42534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  42535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  42536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  42537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  42538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  42539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  42540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  42541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  42542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  42543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  42544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  42545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  42546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  42547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  42548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  42549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  42550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  42551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  42552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  42553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  42554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  42555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  42556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  42557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  42558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  42559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  42560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  42561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  42562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  42563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  42564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  42565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  42566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  42567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  42568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  42569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  42570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  42571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  42572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  42573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  42574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  42575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  42576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  42577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  42578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  42579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  42580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  42581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  42582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  42583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  42584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  42585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  42586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  42587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  42588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  42589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  42590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  42591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  42592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  42593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  42594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  42595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  42596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  42597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  42598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  42599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  42600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  42601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  42602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  42603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  42604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  42605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  42606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  42607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  42608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  42609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  42610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  42611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  42612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  42613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  42614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  42615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  42616. /**
  42617. * Legacy support, defining window.BABYLON (global variable).
  42618. *
  42619. * This is the entry point for the UMD module.
  42620. * The entry point for a future ESM package should be index.ts
  42621. */
  42622. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  42623. if (typeof globalObject !== "undefined") {
  42624. globalObject.BABYLON = BABYLON;
  42625. globalObject.BABYLON = globalObject.BABYLON || {};
  42626. var BABYLON = globalObject.BABYLON;
  42627. BABYLON.Debug = BABYLON.Debug || {};
  42628. var keys = [];
  42629. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  42630. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  42631. keys.push(key);
  42632. }
  42633. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  42634. // Prevent Reassignment.
  42635. if (keys.indexOf(key) > -1) {
  42636. continue;
  42637. }
  42638. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  42639. }
  42640. }
  42641. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  42642. /***/ }),
  42643. /***/ "./LensFlares/index.ts":
  42644. /*!*****************************!*\
  42645. !*** ./LensFlares/index.ts ***!
  42646. \*****************************/
  42647. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  42648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42649. "use strict";
  42650. __webpack_require__.r(__webpack_exports__);
  42651. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  42652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42653. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  42654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  42655. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  42656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  42657. /***/ }),
  42658. /***/ "./LensFlares/lensFlare.ts":
  42659. /*!*********************************!*\
  42660. !*** ./LensFlares/lensFlare.ts ***!
  42661. \*********************************/
  42662. /*! exports provided: LensFlare */
  42663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42664. "use strict";
  42665. __webpack_require__.r(__webpack_exports__);
  42666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  42667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42668. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42669. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42670. /**
  42671. * This represents one of the lens effect in a `lensFlareSystem`.
  42672. * It controls one of the indiviual texture used in the effect.
  42673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42674. */
  42675. var LensFlare = /** @class */ (function () {
  42676. /**
  42677. * Instantiates a new Lens Flare.
  42678. * This represents one of the lens effect in a `lensFlareSystem`.
  42679. * It controls one of the indiviual texture used in the effect.
  42680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42681. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  42682. * @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.
  42683. * @param color Define the lens color
  42684. * @param imgUrl Define the lens texture url
  42685. * @param system Define the `lensFlareSystem` this flare is part of
  42686. */
  42687. function LensFlare(
  42688. /**
  42689. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  42690. */
  42691. size,
  42692. /**
  42693. * 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.
  42694. */
  42695. position, color, imgUrl, system) {
  42696. this.size = size;
  42697. this.position = position;
  42698. /**
  42699. * Define the alpha mode to render this particular lens.
  42700. */
  42701. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  42702. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  42703. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  42704. this._system = system;
  42705. system.lensFlares.push(this);
  42706. }
  42707. /**
  42708. * Creates a new Lens Flare.
  42709. * This represents one of the lens effect in a `lensFlareSystem`.
  42710. * It controls one of the indiviual texture used in the effect.
  42711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42712. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  42713. * @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.
  42714. * @param color Define the lens color
  42715. * @param imgUrl Define the lens texture url
  42716. * @param system Define the `lensFlareSystem` this flare is part of
  42717. * @returns The newly created Lens Flare
  42718. */
  42719. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  42720. return new LensFlare(size, position, color, imgUrl, system);
  42721. };
  42722. /**
  42723. * Dispose and release the lens flare with its associated resources.
  42724. */
  42725. LensFlare.prototype.dispose = function () {
  42726. if (this.texture) {
  42727. this.texture.dispose();
  42728. }
  42729. // Remove from scene
  42730. var index = this._system.lensFlares.indexOf(this);
  42731. this._system.lensFlares.splice(index, 1);
  42732. };
  42733. return LensFlare;
  42734. }());
  42735. /***/ }),
  42736. /***/ "./LensFlares/lensFlareSystem.ts":
  42737. /*!***************************************!*\
  42738. !*** ./LensFlares/lensFlareSystem.ts ***!
  42739. \***************************************/
  42740. /*! exports provided: LensFlareSystem */
  42741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42742. "use strict";
  42743. __webpack_require__.r(__webpack_exports__);
  42744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  42745. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42746. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42747. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  42748. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42749. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42750. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  42751. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42752. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  42753. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42754. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  42755. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  42756. /**
  42757. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  42758. * It is usually composed of several `lensFlare`.
  42759. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42760. */
  42761. var LensFlareSystem = /** @class */ (function () {
  42762. /**
  42763. * Instantiates a lens flare system.
  42764. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  42765. * It is usually composed of several `lensFlare`.
  42766. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42767. * @param name Define the name of the lens flare system in the scene
  42768. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  42769. * @param scene Define the scene the lens flare system belongs to
  42770. */
  42771. function LensFlareSystem(
  42772. /**
  42773. * Define the name of the lens flare system
  42774. */
  42775. name, emitter, scene) {
  42776. this.name = name;
  42777. /**
  42778. * List of lens flares used in this system.
  42779. */
  42780. this.lensFlares = new Array();
  42781. /**
  42782. * Define a limit from the border the lens flare can be visible.
  42783. */
  42784. this.borderLimit = 300;
  42785. /**
  42786. * Define a viewport border we do not want to see the lens flare in.
  42787. */
  42788. this.viewportBorder = 0;
  42789. /**
  42790. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  42791. */
  42792. this.layerMask = 0x0FFFFFFF;
  42793. this._vertexBuffers = {};
  42794. this._isEnabled = true;
  42795. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  42796. LensFlareSystem._SceneComponentInitialization(this._scene);
  42797. this._emitter = emitter;
  42798. this.id = name;
  42799. scene.lensFlareSystems.push(this);
  42800. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  42801. var engine = scene.getEngine();
  42802. // VBO
  42803. var vertices = [];
  42804. vertices.push(1, 1);
  42805. vertices.push(-1, 1);
  42806. vertices.push(-1, -1);
  42807. vertices.push(1, -1);
  42808. 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);
  42809. // Indices
  42810. var indices = [];
  42811. indices.push(0);
  42812. indices.push(1);
  42813. indices.push(2);
  42814. indices.push(0);
  42815. indices.push(2);
  42816. indices.push(3);
  42817. this._indexBuffer = engine.createIndexBuffer(indices);
  42818. // Effects
  42819. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  42820. }
  42821. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  42822. /**
  42823. * Define if the lens flare system is enabled.
  42824. */
  42825. get: function () {
  42826. return this._isEnabled;
  42827. },
  42828. set: function (value) {
  42829. this._isEnabled = value;
  42830. },
  42831. enumerable: true,
  42832. configurable: true
  42833. });
  42834. /**
  42835. * Get the scene the effects belongs to.
  42836. * @returns the scene holding the lens flare system
  42837. */
  42838. LensFlareSystem.prototype.getScene = function () {
  42839. return this._scene;
  42840. };
  42841. /**
  42842. * Get the emitter of the lens flare system.
  42843. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  42844. * @returns the emitter of the lens flare system
  42845. */
  42846. LensFlareSystem.prototype.getEmitter = function () {
  42847. return this._emitter;
  42848. };
  42849. /**
  42850. * Set the emitter of the lens flare system.
  42851. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  42852. * @param newEmitter Define the new emitter of the system
  42853. */
  42854. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  42855. this._emitter = newEmitter;
  42856. };
  42857. /**
  42858. * Get the lens flare system emitter position.
  42859. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  42860. * @returns the position
  42861. */
  42862. LensFlareSystem.prototype.getEmitterPosition = function () {
  42863. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  42864. };
  42865. /**
  42866. * @hidden
  42867. */
  42868. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  42869. var position = this.getEmitterPosition();
  42870. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  42871. this._positionX = position.x;
  42872. this._positionY = position.y;
  42873. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  42874. if (this.viewportBorder > 0) {
  42875. globalViewport.x -= this.viewportBorder;
  42876. globalViewport.y -= this.viewportBorder;
  42877. globalViewport.width += this.viewportBorder * 2;
  42878. globalViewport.height += this.viewportBorder * 2;
  42879. position.x += this.viewportBorder;
  42880. position.y += this.viewportBorder;
  42881. this._positionX += this.viewportBorder;
  42882. this._positionY += this.viewportBorder;
  42883. }
  42884. if (position.z > 0) {
  42885. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  42886. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  42887. return true;
  42888. }
  42889. }
  42890. return true;
  42891. }
  42892. return false;
  42893. };
  42894. /** @hidden */
  42895. LensFlareSystem.prototype._isVisible = function () {
  42896. if (!this._isEnabled || !this._scene.activeCamera) {
  42897. return false;
  42898. }
  42899. var emitterPosition = this.getEmitterPosition();
  42900. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  42901. var distance = direction.length();
  42902. direction.normalize();
  42903. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  42904. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  42905. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  42906. };
  42907. /**
  42908. * @hidden
  42909. */
  42910. LensFlareSystem.prototype.render = function () {
  42911. if (!this._effect.isReady() || !this._scene.activeCamera) {
  42912. return false;
  42913. }
  42914. var engine = this._scene.getEngine();
  42915. var viewport = this._scene.activeCamera.viewport;
  42916. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  42917. // Position
  42918. if (!this.computeEffectivePosition(globalViewport)) {
  42919. return false;
  42920. }
  42921. // Visibility
  42922. if (!this._isVisible()) {
  42923. return false;
  42924. }
  42925. // Intensity
  42926. var awayX;
  42927. var awayY;
  42928. if (this._positionX < this.borderLimit + globalViewport.x) {
  42929. awayX = this.borderLimit + globalViewport.x - this._positionX;
  42930. }
  42931. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  42932. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  42933. }
  42934. else {
  42935. awayX = 0;
  42936. }
  42937. if (this._positionY < this.borderLimit + globalViewport.y) {
  42938. awayY = this.borderLimit + globalViewport.y - this._positionY;
  42939. }
  42940. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  42941. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  42942. }
  42943. else {
  42944. awayY = 0;
  42945. }
  42946. var away = (awayX > awayY) ? awayX : awayY;
  42947. away -= this.viewportBorder;
  42948. if (away > this.borderLimit) {
  42949. away = this.borderLimit;
  42950. }
  42951. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  42952. if (intensity < 0) {
  42953. return false;
  42954. }
  42955. if (intensity > 1.0) {
  42956. intensity = 1.0;
  42957. }
  42958. if (this.viewportBorder > 0) {
  42959. globalViewport.x += this.viewportBorder;
  42960. globalViewport.y += this.viewportBorder;
  42961. globalViewport.width -= this.viewportBorder * 2;
  42962. globalViewport.height -= this.viewportBorder * 2;
  42963. this._positionX -= this.viewportBorder;
  42964. this._positionY -= this.viewportBorder;
  42965. }
  42966. // Position
  42967. var centerX = globalViewport.x + globalViewport.width / 2;
  42968. var centerY = globalViewport.y + globalViewport.height / 2;
  42969. var distX = centerX - this._positionX;
  42970. var distY = centerY - this._positionY;
  42971. // Effects
  42972. engine.enableEffect(this._effect);
  42973. engine.setState(false);
  42974. engine.setDepthBuffer(false);
  42975. // VBOs
  42976. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  42977. // Flares
  42978. for (var index = 0; index < this.lensFlares.length; index++) {
  42979. var flare = this.lensFlares[index];
  42980. engine.setAlphaMode(flare.alphaMode);
  42981. var x = centerX - (distX * flare.position);
  42982. var y = centerY - (distY * flare.position);
  42983. var cw = flare.size;
  42984. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  42985. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  42986. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  42987. 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);
  42988. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  42989. // Texture
  42990. this._effect.setTexture("textureSampler", flare.texture);
  42991. // Color
  42992. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  42993. // Draw order
  42994. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42995. }
  42996. engine.setDepthBuffer(true);
  42997. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42998. return true;
  42999. };
  43000. /**
  43001. * Dispose and release the lens flare with its associated resources.
  43002. */
  43003. LensFlareSystem.prototype.dispose = function () {
  43004. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  43005. if (vertexBuffer) {
  43006. vertexBuffer.dispose();
  43007. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  43008. }
  43009. if (this._indexBuffer) {
  43010. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43011. this._indexBuffer = null;
  43012. }
  43013. while (this.lensFlares.length) {
  43014. this.lensFlares[0].dispose();
  43015. }
  43016. // Remove from scene
  43017. var index = this._scene.lensFlareSystems.indexOf(this);
  43018. this._scene.lensFlareSystems.splice(index, 1);
  43019. };
  43020. /**
  43021. * Parse a lens flare system from a JSON repressentation
  43022. * @param parsedLensFlareSystem Define the JSON to parse
  43023. * @param scene Define the scene the parsed system should be instantiated in
  43024. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43025. * @returns the parsed system
  43026. */
  43027. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  43028. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  43029. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  43030. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  43031. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  43032. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  43033. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  43034. var parsedFlare = parsedLensFlareSystem.flares[index];
  43035. _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);
  43036. }
  43037. return lensFlareSystem;
  43038. };
  43039. /**
  43040. * Serialize the current Lens Flare System into a JSON representation.
  43041. * @returns the serialized JSON
  43042. */
  43043. LensFlareSystem.prototype.serialize = function () {
  43044. var serializationObject = {};
  43045. serializationObject.id = this.id;
  43046. serializationObject.name = this.name;
  43047. serializationObject.emitterId = this.getEmitter().id;
  43048. serializationObject.borderLimit = this.borderLimit;
  43049. serializationObject.flares = [];
  43050. for (var index = 0; index < this.lensFlares.length; index++) {
  43051. var flare = this.lensFlares[index];
  43052. serializationObject.flares.push({
  43053. size: flare.size,
  43054. position: flare.position,
  43055. color: flare.color.asArray(),
  43056. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  43057. });
  43058. }
  43059. return serializationObject;
  43060. };
  43061. /** @hidden */
  43062. LensFlareSystem._SceneComponentInitialization = function (_) {
  43063. throw "Import LensFlareSystemSceneComponent before creating LensFlareSystem.";
  43064. };
  43065. return LensFlareSystem;
  43066. }());
  43067. /***/ }),
  43068. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  43069. /*!*****************************************************!*\
  43070. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  43071. \*****************************************************/
  43072. /*! exports provided: LensFlareSystemSceneComponent */
  43073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43074. "use strict";
  43075. __webpack_require__.r(__webpack_exports__);
  43076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  43077. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43078. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43079. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43080. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43081. // Adds the parser to the scene parsers.
  43082. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  43083. // Lens flares
  43084. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  43085. if (!container.lensFlareSystems) {
  43086. container.lensFlareSystems = new Array();
  43087. }
  43088. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  43089. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  43090. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  43091. container.lensFlareSystems.push(lf);
  43092. }
  43093. }
  43094. });
  43095. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  43096. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43097. if (this.lensFlareSystems[index].name === name) {
  43098. return this.lensFlareSystems[index];
  43099. }
  43100. }
  43101. return null;
  43102. };
  43103. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  43104. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43105. if (this.lensFlareSystems[index].id === id) {
  43106. return this.lensFlareSystems[index];
  43107. }
  43108. }
  43109. return null;
  43110. };
  43111. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  43112. var index = this.lensFlareSystems.indexOf(toRemove);
  43113. if (index !== -1) {
  43114. this.lensFlareSystems.splice(index, 1);
  43115. }
  43116. return index;
  43117. };
  43118. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  43119. this.lensFlareSystems.push(newLensFlareSystem);
  43120. };
  43121. /**
  43122. * Defines the lens flare scene component responsible to manage any lens flares
  43123. * in a given scene.
  43124. */
  43125. var LensFlareSystemSceneComponent = /** @class */ (function () {
  43126. /**
  43127. * Creates a new instance of the component for the given scene
  43128. * @param scene Defines the scene to register the component in
  43129. */
  43130. function LensFlareSystemSceneComponent(scene) {
  43131. /**
  43132. * The component name helpfull to identify the component in the list of scene components.
  43133. */
  43134. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  43135. this.scene = scene;
  43136. scene.lensFlareSystems = new Array();
  43137. }
  43138. /**
  43139. * Registers the component in a given scene
  43140. */
  43141. LensFlareSystemSceneComponent.prototype.register = function () {
  43142. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  43143. };
  43144. /**
  43145. * Rebuilds the elements related to this component in case of
  43146. * context lost for instance.
  43147. */
  43148. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  43149. // Nothing to do for lens flare
  43150. };
  43151. /**
  43152. * Adds all the element from the container to the scene
  43153. * @param container the container holding the elements
  43154. */
  43155. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  43156. var _this = this;
  43157. if (!container.lensFlareSystems) {
  43158. return;
  43159. }
  43160. container.lensFlareSystems.forEach(function (o) {
  43161. _this.scene.addLensFlareSystem(o);
  43162. });
  43163. };
  43164. /**
  43165. * Removes all the elements in the container from the scene
  43166. * @param container contains the elements to remove
  43167. */
  43168. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  43169. var _this = this;
  43170. if (!container.lensFlareSystems) {
  43171. return;
  43172. }
  43173. container.lensFlareSystems.forEach(function (o) {
  43174. _this.scene.removeLensFlareSystem(o);
  43175. });
  43176. };
  43177. /**
  43178. * Serializes the component data to the specified json object
  43179. * @param serializationObject The object to serialize to
  43180. */
  43181. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  43182. // Lens flares
  43183. serializationObject.lensFlareSystems = [];
  43184. var lensFlareSystems = this.scene.lensFlareSystems;
  43185. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  43186. var lensFlareSystem = lensFlareSystems_1[_i];
  43187. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  43188. }
  43189. };
  43190. /**
  43191. * Disposes the component and the associated ressources.
  43192. */
  43193. LensFlareSystemSceneComponent.prototype.dispose = function () {
  43194. var lensFlareSystems = this.scene.lensFlareSystems;
  43195. while (lensFlareSystems.length) {
  43196. lensFlareSystems[0].dispose();
  43197. }
  43198. };
  43199. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  43200. // Lens flares
  43201. if (this.scene.lensFlaresEnabled) {
  43202. var lensFlareSystems = this.scene.lensFlareSystems;
  43203. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43204. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  43205. var lensFlareSystem = lensFlareSystems_2[_i];
  43206. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  43207. lensFlareSystem.render();
  43208. }
  43209. }
  43210. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43211. }
  43212. };
  43213. return LensFlareSystemSceneComponent;
  43214. }());
  43215. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  43216. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  43217. if (!component) {
  43218. component = new LensFlareSystemSceneComponent(scene);
  43219. scene._addComponent(component);
  43220. }
  43221. };
  43222. /***/ }),
  43223. /***/ "./Lights/Shadows/index.ts":
  43224. /*!*********************************!*\
  43225. !*** ./Lights/Shadows/index.ts ***!
  43226. \*********************************/
  43227. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  43228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43229. "use strict";
  43230. __webpack_require__.r(__webpack_exports__);
  43231. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43233. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  43235. /***/ }),
  43236. /***/ "./Lights/Shadows/shadowGenerator.ts":
  43237. /*!*******************************************!*\
  43238. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  43239. \*******************************************/
  43240. /*! exports provided: ShadowGenerator */
  43241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43242. "use strict";
  43243. __webpack_require__.r(__webpack_exports__);
  43244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  43245. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43246. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  43247. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  43248. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  43249. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  43250. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  43251. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43252. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43253. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43254. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43255. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  43256. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  43257. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  43258. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  43259. /**
  43260. * Default implementation IShadowGenerator.
  43261. * This is the main object responsible of generating shadows in the framework.
  43262. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43263. */
  43264. var ShadowGenerator = /** @class */ (function () {
  43265. /**
  43266. * Creates a ShadowGenerator object.
  43267. * A ShadowGenerator is the required tool to use the shadows.
  43268. * Each light casting shadows needs to use its own ShadowGenerator.
  43269. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  43270. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43271. * @param light The light object generating the shadows.
  43272. * @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.
  43273. */
  43274. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  43275. this._bias = 0.00005;
  43276. this._normalBias = 0;
  43277. this._blurBoxOffset = 1;
  43278. this._blurScale = 2;
  43279. this._blurKernel = 1;
  43280. this._useKernelBlur = false;
  43281. this._filter = ShadowGenerator.FILTER_NONE;
  43282. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  43283. this._contactHardeningLightSizeUVRatio = 0.1;
  43284. this._darkness = 0;
  43285. this._transparencyShadow = false;
  43286. /**
  43287. * Controls the extent to which the shadows fade out at the edge of the frustum
  43288. * Used only by directionals and spots
  43289. */
  43290. this.frustumEdgeFalloff = 0;
  43291. /**
  43292. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43293. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43294. * It might on the other hand introduce peter panning.
  43295. */
  43296. this.forceBackFacesOnly = false;
  43297. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  43298. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43299. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43300. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43301. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43302. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43303. this._currentFaceIndex = 0;
  43304. this._currentFaceIndexCache = 0;
  43305. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  43306. this._mapSize = mapSize;
  43307. this._light = light;
  43308. this._scene = light.getScene();
  43309. light._shadowGenerator = this;
  43310. ShadowGenerator._SceneComponentInitialization(this._scene);
  43311. // Texture type fallback from float to int if not supported.
  43312. var caps = this._scene.getEngine().getCaps();
  43313. if (!usefulFloatFirst) {
  43314. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43315. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43316. }
  43317. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43318. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43319. }
  43320. else {
  43321. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43322. }
  43323. }
  43324. else {
  43325. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43326. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43327. }
  43328. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43329. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43330. }
  43331. else {
  43332. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43333. }
  43334. }
  43335. this._initializeGenerator();
  43336. this._applyFilterValues();
  43337. }
  43338. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  43339. /**
  43340. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43341. */
  43342. get: function () {
  43343. return this._bias;
  43344. },
  43345. /**
  43346. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43347. */
  43348. set: function (bias) {
  43349. this._bias = bias;
  43350. },
  43351. enumerable: true,
  43352. configurable: true
  43353. });
  43354. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  43355. /**
  43356. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43357. */
  43358. get: function () {
  43359. return this._normalBias;
  43360. },
  43361. /**
  43362. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43363. */
  43364. set: function (normalBias) {
  43365. this._normalBias = normalBias;
  43366. },
  43367. enumerable: true,
  43368. configurable: true
  43369. });
  43370. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  43371. /**
  43372. * Gets the blur box offset: offset applied during the blur pass.
  43373. * Only useful if useKernelBlur = false
  43374. */
  43375. get: function () {
  43376. return this._blurBoxOffset;
  43377. },
  43378. /**
  43379. * Sets the blur box offset: offset applied during the blur pass.
  43380. * Only useful if useKernelBlur = false
  43381. */
  43382. set: function (value) {
  43383. if (this._blurBoxOffset === value) {
  43384. return;
  43385. }
  43386. this._blurBoxOffset = value;
  43387. this._disposeBlurPostProcesses();
  43388. },
  43389. enumerable: true,
  43390. configurable: true
  43391. });
  43392. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  43393. /**
  43394. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43395. * 2 means half of the size.
  43396. */
  43397. get: function () {
  43398. return this._blurScale;
  43399. },
  43400. /**
  43401. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43402. * 2 means half of the size.
  43403. */
  43404. set: function (value) {
  43405. if (this._blurScale === value) {
  43406. return;
  43407. }
  43408. this._blurScale = value;
  43409. this._disposeBlurPostProcesses();
  43410. },
  43411. enumerable: true,
  43412. configurable: true
  43413. });
  43414. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  43415. /**
  43416. * Gets the blur kernel: kernel size of the blur pass.
  43417. * Only useful if useKernelBlur = true
  43418. */
  43419. get: function () {
  43420. return this._blurKernel;
  43421. },
  43422. /**
  43423. * Sets the blur kernel: kernel size of the blur pass.
  43424. * Only useful if useKernelBlur = true
  43425. */
  43426. set: function (value) {
  43427. if (this._blurKernel === value) {
  43428. return;
  43429. }
  43430. this._blurKernel = value;
  43431. this._disposeBlurPostProcesses();
  43432. },
  43433. enumerable: true,
  43434. configurable: true
  43435. });
  43436. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  43437. /**
  43438. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43439. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43440. */
  43441. get: function () {
  43442. return this._useKernelBlur;
  43443. },
  43444. /**
  43445. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43446. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43447. */
  43448. set: function (value) {
  43449. if (this._useKernelBlur === value) {
  43450. return;
  43451. }
  43452. this._useKernelBlur = value;
  43453. this._disposeBlurPostProcesses();
  43454. },
  43455. enumerable: true,
  43456. configurable: true
  43457. });
  43458. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  43459. /**
  43460. * Gets the depth scale used in ESM mode.
  43461. */
  43462. get: function () {
  43463. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  43464. },
  43465. /**
  43466. * Sets the depth scale used in ESM mode.
  43467. * This can override the scale stored on the light.
  43468. */
  43469. set: function (value) {
  43470. this._depthScale = value;
  43471. },
  43472. enumerable: true,
  43473. configurable: true
  43474. });
  43475. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  43476. /**
  43477. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43478. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43479. */
  43480. get: function () {
  43481. return this._filter;
  43482. },
  43483. /**
  43484. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43485. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43486. */
  43487. set: function (value) {
  43488. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  43489. if (this._light.needCube()) {
  43490. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43491. this.useExponentialShadowMap = true;
  43492. return;
  43493. }
  43494. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43495. this.useCloseExponentialShadowMap = true;
  43496. return;
  43497. }
  43498. // PCF on cubemap would also be expensive
  43499. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43500. this.usePoissonSampling = true;
  43501. return;
  43502. }
  43503. }
  43504. // Weblg1 fallback for PCF.
  43505. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43506. if (this._scene.getEngine().webGLVersion === 1) {
  43507. this.usePoissonSampling = true;
  43508. return;
  43509. }
  43510. }
  43511. if (this._filter === value) {
  43512. return;
  43513. }
  43514. this._filter = value;
  43515. this._disposeBlurPostProcesses();
  43516. this._applyFilterValues();
  43517. this._light._markMeshesAsLightDirty();
  43518. },
  43519. enumerable: true,
  43520. configurable: true
  43521. });
  43522. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  43523. /**
  43524. * Gets if the current filter is set to Poisson Sampling.
  43525. */
  43526. get: function () {
  43527. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  43528. },
  43529. /**
  43530. * Sets the current filter to Poisson Sampling.
  43531. */
  43532. set: function (value) {
  43533. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  43534. return;
  43535. }
  43536. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  43537. },
  43538. enumerable: true,
  43539. configurable: true
  43540. });
  43541. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  43542. /**
  43543. * Gets if the current filter is set to ESM.
  43544. */
  43545. get: function () {
  43546. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  43547. },
  43548. /**
  43549. * Sets the current filter is to ESM.
  43550. */
  43551. set: function (value) {
  43552. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  43553. return;
  43554. }
  43555. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43556. },
  43557. enumerable: true,
  43558. configurable: true
  43559. });
  43560. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  43561. /**
  43562. * Gets if the current filter is set to filtered ESM.
  43563. */
  43564. get: function () {
  43565. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  43566. },
  43567. /**
  43568. * Gets if the current filter is set to filtered ESM.
  43569. */
  43570. set: function (value) {
  43571. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43572. return;
  43573. }
  43574. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43575. },
  43576. enumerable: true,
  43577. configurable: true
  43578. });
  43579. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  43580. /**
  43581. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43582. * exponential to prevent steep falloff artifacts).
  43583. */
  43584. get: function () {
  43585. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  43586. },
  43587. /**
  43588. * Sets the current filter to "close ESM" (using the inverse of the
  43589. * exponential to prevent steep falloff artifacts).
  43590. */
  43591. set: function (value) {
  43592. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  43593. return;
  43594. }
  43595. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43596. },
  43597. enumerable: true,
  43598. configurable: true
  43599. });
  43600. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  43601. /**
  43602. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43603. * exponential to prevent steep falloff artifacts).
  43604. */
  43605. get: function () {
  43606. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  43607. },
  43608. /**
  43609. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43610. * exponential to prevent steep falloff artifacts).
  43611. */
  43612. set: function (value) {
  43613. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43614. return;
  43615. }
  43616. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43617. },
  43618. enumerable: true,
  43619. configurable: true
  43620. });
  43621. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  43622. /**
  43623. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43624. */
  43625. get: function () {
  43626. return this.filter === ShadowGenerator.FILTER_PCF;
  43627. },
  43628. /**
  43629. * Sets the current filter to "PCF" (percentage closer filtering).
  43630. */
  43631. set: function (value) {
  43632. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  43633. return;
  43634. }
  43635. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  43636. },
  43637. enumerable: true,
  43638. configurable: true
  43639. });
  43640. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  43641. /**
  43642. * Gets the PCF or PCSS Quality.
  43643. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43644. */
  43645. get: function () {
  43646. return this._filteringQuality;
  43647. },
  43648. /**
  43649. * Sets the PCF or PCSS Quality.
  43650. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43651. */
  43652. set: function (filteringQuality) {
  43653. this._filteringQuality = filteringQuality;
  43654. },
  43655. enumerable: true,
  43656. configurable: true
  43657. });
  43658. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  43659. /**
  43660. * Gets if the current filter is set to "PCSS" (contact hardening).
  43661. */
  43662. get: function () {
  43663. return this.filter === ShadowGenerator.FILTER_PCSS;
  43664. },
  43665. /**
  43666. * Sets the current filter to "PCSS" (contact hardening).
  43667. */
  43668. set: function (value) {
  43669. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  43670. return;
  43671. }
  43672. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  43673. },
  43674. enumerable: true,
  43675. configurable: true
  43676. });
  43677. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  43678. /**
  43679. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43680. * Using a ratio helps keeping shape stability independently of the map size.
  43681. *
  43682. * It does not account for the light projection as it was having too much
  43683. * instability during the light setup or during light position changes.
  43684. *
  43685. * Only valid if useContactHardeningShadow is true.
  43686. */
  43687. get: function () {
  43688. return this._contactHardeningLightSizeUVRatio;
  43689. },
  43690. /**
  43691. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43692. * Using a ratio helps keeping shape stability independently of the map size.
  43693. *
  43694. * It does not account for the light projection as it was having too much
  43695. * instability during the light setup or during light position changes.
  43696. *
  43697. * Only valid if useContactHardeningShadow is true.
  43698. */
  43699. set: function (contactHardeningLightSizeUVRatio) {
  43700. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  43701. },
  43702. enumerable: true,
  43703. configurable: true
  43704. });
  43705. /**
  43706. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43707. * 0 means strongest and 1 would means no shadow.
  43708. * @returns the darkness.
  43709. */
  43710. ShadowGenerator.prototype.getDarkness = function () {
  43711. return this._darkness;
  43712. };
  43713. /**
  43714. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43715. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43716. * @returns the shadow generator allowing fluent coding.
  43717. */
  43718. ShadowGenerator.prototype.setDarkness = function (darkness) {
  43719. if (darkness >= 1.0) {
  43720. this._darkness = 1.0;
  43721. }
  43722. else if (darkness <= 0.0) {
  43723. this._darkness = 0.0;
  43724. }
  43725. else {
  43726. this._darkness = darkness;
  43727. }
  43728. return this;
  43729. };
  43730. /**
  43731. * Sets the ability to have transparent shadow (boolean).
  43732. * @param transparent True if transparent else False
  43733. * @returns the shadow generator allowing fluent coding
  43734. */
  43735. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  43736. this._transparencyShadow = transparent;
  43737. return this;
  43738. };
  43739. /**
  43740. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43741. * @returns The render target texture if present otherwise, null
  43742. */
  43743. ShadowGenerator.prototype.getShadowMap = function () {
  43744. return this._shadowMap;
  43745. };
  43746. /**
  43747. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43748. * @returns The render target texture if the shadow map is present otherwise, null
  43749. */
  43750. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  43751. if (this._shadowMap2) {
  43752. return this._shadowMap2;
  43753. }
  43754. return this._shadowMap;
  43755. };
  43756. /**
  43757. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43758. * @param mesh Mesh to add
  43759. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43760. * @returns the Shadow Generator itself
  43761. */
  43762. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  43763. if (includeDescendants === void 0) { includeDescendants = true; }
  43764. var _a;
  43765. if (!this._shadowMap) {
  43766. return this;
  43767. }
  43768. if (!this._shadowMap.renderList) {
  43769. this._shadowMap.renderList = [];
  43770. }
  43771. this._shadowMap.renderList.push(mesh);
  43772. if (includeDescendants) {
  43773. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  43774. }
  43775. return this;
  43776. };
  43777. /**
  43778. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43779. * @param mesh Mesh to remove
  43780. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43781. * @returns the Shadow Generator itself
  43782. */
  43783. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  43784. if (includeDescendants === void 0) { includeDescendants = true; }
  43785. if (!this._shadowMap || !this._shadowMap.renderList) {
  43786. return this;
  43787. }
  43788. var index = this._shadowMap.renderList.indexOf(mesh);
  43789. if (index !== -1) {
  43790. this._shadowMap.renderList.splice(index, 1);
  43791. }
  43792. if (includeDescendants) {
  43793. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  43794. var child = _a[_i];
  43795. this.removeShadowCaster(child);
  43796. }
  43797. }
  43798. return this;
  43799. };
  43800. /**
  43801. * Returns the associated light object.
  43802. * @returns the light generating the shadow
  43803. */
  43804. ShadowGenerator.prototype.getLight = function () {
  43805. return this._light;
  43806. };
  43807. ShadowGenerator.prototype._initializeGenerator = function () {
  43808. this._light._markMeshesAsLightDirty();
  43809. this._initializeShadowMap();
  43810. };
  43811. ShadowGenerator.prototype._initializeShadowMap = function () {
  43812. var _this = this;
  43813. // Render target
  43814. var engine = this._scene.getEngine();
  43815. if (engine.webGLVersion > 1) {
  43816. 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);
  43817. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  43818. }
  43819. else {
  43820. 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());
  43821. }
  43822. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43823. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43824. this._shadowMap.anisotropicFilteringLevel = 1;
  43825. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  43826. this._shadowMap.renderParticles = false;
  43827. this._shadowMap.ignoreCameraViewport = true;
  43828. // Record Face Index before render.
  43829. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  43830. _this._currentFaceIndex = faceIndex;
  43831. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43832. engine.setColorWrite(false);
  43833. }
  43834. });
  43835. // Custom render function.
  43836. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  43837. // Blur if required afer render.
  43838. this._shadowMap.onAfterUnbindObservable.add(function () {
  43839. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43840. engine.setColorWrite(true);
  43841. }
  43842. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  43843. return;
  43844. }
  43845. var shadowMap = _this.getShadowMapForRendering();
  43846. if (shadowMap) {
  43847. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  43848. }
  43849. });
  43850. // Clear according to the chosen filter.
  43851. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  43852. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  43853. this._shadowMap.onClearObservable.add(function (engine) {
  43854. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43855. engine.clear(clearOne, false, true, false);
  43856. }
  43857. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  43858. engine.clear(clearZero, true, true, false);
  43859. }
  43860. else {
  43861. engine.clear(clearOne, true, true, false);
  43862. }
  43863. });
  43864. };
  43865. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  43866. var _this = this;
  43867. var engine = this._scene.getEngine();
  43868. var targetSize = this._mapSize / this.blurScale;
  43869. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  43870. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  43871. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43872. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43873. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  43874. }
  43875. if (this.useKernelBlur) {
  43876. 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);
  43877. this._kernelBlurXPostprocess.width = targetSize;
  43878. this._kernelBlurXPostprocess.height = targetSize;
  43879. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  43880. effect.setTexture("textureSampler", _this._shadowMap);
  43881. });
  43882. 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);
  43883. this._kernelBlurXPostprocess.autoClear = false;
  43884. this._kernelBlurYPostprocess.autoClear = false;
  43885. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  43886. this._kernelBlurXPostprocess.packedFloat = true;
  43887. this._kernelBlurYPostprocess.packedFloat = true;
  43888. }
  43889. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  43890. }
  43891. else {
  43892. 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);
  43893. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  43894. effect.setFloat2("screenSize", targetSize, targetSize);
  43895. effect.setTexture("textureSampler", _this._shadowMap);
  43896. });
  43897. this._boxBlurPostprocess.autoClear = false;
  43898. this._blurPostProcesses = [this._boxBlurPostprocess];
  43899. }
  43900. };
  43901. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  43902. var index;
  43903. var engine = this._scene.getEngine();
  43904. if (depthOnlySubMeshes.length) {
  43905. engine.setColorWrite(false);
  43906. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  43907. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  43908. }
  43909. engine.setColorWrite(true);
  43910. }
  43911. for (index = 0; index < opaqueSubMeshes.length; index++) {
  43912. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  43913. }
  43914. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  43915. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  43916. }
  43917. if (this._transparencyShadow) {
  43918. for (index = 0; index < transparentSubMeshes.length; index++) {
  43919. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  43920. }
  43921. }
  43922. };
  43923. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  43924. var _this = this;
  43925. var mesh = subMesh.getRenderingMesh();
  43926. var scene = this._scene;
  43927. var engine = scene.getEngine();
  43928. var material = subMesh.getMaterial();
  43929. if (!material || subMesh.verticesCount === 0) {
  43930. return;
  43931. }
  43932. // Culling
  43933. engine.setState(material.backFaceCulling);
  43934. // Managing instances
  43935. var batch = mesh._getInstancesRenderList(subMesh._id);
  43936. if (batch.mustReturn) {
  43937. return;
  43938. }
  43939. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  43940. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  43941. engine.enableEffect(this._effect);
  43942. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  43943. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  43944. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  43945. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  43946. this._effect.setVector3("lightData", this._cachedDirection);
  43947. }
  43948. else {
  43949. this._effect.setVector3("lightData", this._cachedPosition);
  43950. }
  43951. if (scene.activeCamera) {
  43952. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  43953. }
  43954. // Alpha test
  43955. if (material && material.needAlphaTesting()) {
  43956. var alphaTexture = material.getAlphaTestTexture();
  43957. if (alphaTexture) {
  43958. this._effect.setTexture("diffuseSampler", alphaTexture);
  43959. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  43960. }
  43961. }
  43962. // Bones
  43963. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  43964. var skeleton = mesh.skeleton;
  43965. if (skeleton.isUsingTextureForMatrices) {
  43966. var boneTexture = skeleton.getTransformMatrixTexture();
  43967. if (!boneTexture) {
  43968. return;
  43969. }
  43970. this._effect.setTexture("boneSampler", boneTexture);
  43971. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  43972. }
  43973. else {
  43974. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  43975. }
  43976. }
  43977. // Morph targets
  43978. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  43979. if (this.forceBackFacesOnly) {
  43980. engine.setState(true, 0, false, true);
  43981. }
  43982. // Draw
  43983. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  43984. if (this.forceBackFacesOnly) {
  43985. engine.setState(true, 0, false, false);
  43986. }
  43987. }
  43988. else {
  43989. // Need to reset refresh rate of the shadowMap
  43990. if (this._shadowMap) {
  43991. this._shadowMap.resetRefreshCounter();
  43992. }
  43993. }
  43994. };
  43995. ShadowGenerator.prototype._applyFilterValues = function () {
  43996. if (!this._shadowMap) {
  43997. return;
  43998. }
  43999. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  44000. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  44001. }
  44002. else {
  44003. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44004. }
  44005. };
  44006. /**
  44007. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44008. * @param onCompiled Callback triggered at the and of the effects compilation
  44009. * @param options Sets of optional options forcing the compilation with different modes
  44010. */
  44011. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  44012. var _this = this;
  44013. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  44014. var shadowMap = this.getShadowMap();
  44015. if (!shadowMap) {
  44016. if (onCompiled) {
  44017. onCompiled(this);
  44018. }
  44019. return;
  44020. }
  44021. var renderList = shadowMap.renderList;
  44022. if (!renderList) {
  44023. if (onCompiled) {
  44024. onCompiled(this);
  44025. }
  44026. return;
  44027. }
  44028. var subMeshes = new Array();
  44029. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  44030. var mesh = renderList_1[_i];
  44031. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  44032. }
  44033. if (subMeshes.length === 0) {
  44034. if (onCompiled) {
  44035. onCompiled(this);
  44036. }
  44037. return;
  44038. }
  44039. var currentIndex = 0;
  44040. var checkReady = function () {
  44041. if (!_this._scene || !_this._scene.getEngine()) {
  44042. return;
  44043. }
  44044. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  44045. currentIndex++;
  44046. if (currentIndex >= subMeshes.length) {
  44047. if (onCompiled) {
  44048. onCompiled(_this);
  44049. }
  44050. return;
  44051. }
  44052. }
  44053. setTimeout(checkReady, 16);
  44054. };
  44055. checkReady();
  44056. };
  44057. /**
  44058. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44059. * @param options Sets of optional options forcing the compilation with different modes
  44060. * @returns A promise that resolves when the compilation completes
  44061. */
  44062. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  44063. var _this = this;
  44064. return new Promise(function (resolve) {
  44065. _this.forceCompilation(function () {
  44066. resolve();
  44067. }, options);
  44068. });
  44069. };
  44070. /**
  44071. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44072. * @param subMesh The submesh we want to render in the shadow map
  44073. * @param useInstances Defines wether will draw in the map using instances
  44074. * @returns true if ready otherwise, false
  44075. */
  44076. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  44077. var defines = [];
  44078. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44079. defines.push("#define FLOAT");
  44080. }
  44081. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44082. defines.push("#define ESM");
  44083. }
  44084. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  44085. defines.push("#define DEPTHTEXTURE");
  44086. }
  44087. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  44088. var mesh = subMesh.getMesh();
  44089. var material = subMesh.getMaterial();
  44090. // Normal bias.
  44091. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  44092. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  44093. defines.push("#define NORMAL");
  44094. if (mesh.nonUniformScaling) {
  44095. defines.push("#define NONUNIFORMSCALING");
  44096. }
  44097. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44098. defines.push("#define DIRECTIONINLIGHTDATA");
  44099. }
  44100. }
  44101. // Alpha test
  44102. if (material && material.needAlphaTesting()) {
  44103. var alphaTexture = material.getAlphaTestTexture();
  44104. if (alphaTexture) {
  44105. defines.push("#define ALPHATEST");
  44106. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  44107. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  44108. defines.push("#define UV1");
  44109. }
  44110. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  44111. if (alphaTexture.coordinatesIndex === 1) {
  44112. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  44113. defines.push("#define UV2");
  44114. }
  44115. }
  44116. }
  44117. }
  44118. // Bones
  44119. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44120. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  44121. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  44122. if (mesh.numBoneInfluencers > 4) {
  44123. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  44124. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  44125. }
  44126. var skeleton = mesh.skeleton;
  44127. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  44128. if (skeleton.isUsingTextureForMatrices) {
  44129. defines.push("#define BONETEXTURE");
  44130. }
  44131. else {
  44132. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  44133. }
  44134. }
  44135. else {
  44136. defines.push("#define NUM_BONE_INFLUENCERS 0");
  44137. }
  44138. // Morph targets
  44139. var manager = mesh.morphTargetManager;
  44140. var morphInfluencers = 0;
  44141. if (manager) {
  44142. if (manager.numInfluencers > 0) {
  44143. defines.push("#define MORPHTARGETS");
  44144. morphInfluencers = manager.numInfluencers;
  44145. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  44146. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  44147. }
  44148. }
  44149. // Instances
  44150. if (useInstances) {
  44151. defines.push("#define INSTANCES");
  44152. attribs.push("world0");
  44153. attribs.push("world1");
  44154. attribs.push("world2");
  44155. attribs.push("world3");
  44156. }
  44157. // Get correct effect
  44158. var join = defines.join("\n");
  44159. if (this._cachedDefines !== join) {
  44160. this._cachedDefines = join;
  44161. this._effect = this._scene.getEngine().createEffect("shadowMap", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"], ["diffuseSampler", "boneSampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  44162. }
  44163. if (!this._effect.isReady()) {
  44164. return false;
  44165. }
  44166. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44167. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  44168. this._initializeBlurRTTAndPostProcesses();
  44169. }
  44170. }
  44171. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  44172. return false;
  44173. }
  44174. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  44175. return false;
  44176. }
  44177. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  44178. return false;
  44179. }
  44180. return true;
  44181. };
  44182. /**
  44183. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44184. * @param defines Defines of the material we want to update
  44185. * @param lightIndex Index of the light in the enabled light list of the material
  44186. */
  44187. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  44188. var scene = this._scene;
  44189. var light = this._light;
  44190. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44191. return;
  44192. }
  44193. defines["SHADOW" + lightIndex] = true;
  44194. if (this.useContactHardeningShadow) {
  44195. defines["SHADOWPCSS" + lightIndex] = true;
  44196. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44197. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44198. }
  44199. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44200. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44201. }
  44202. // else default to high.
  44203. }
  44204. if (this.usePercentageCloserFiltering) {
  44205. defines["SHADOWPCF" + lightIndex] = true;
  44206. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44207. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44208. }
  44209. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44210. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44211. }
  44212. // else default to high.
  44213. }
  44214. else if (this.usePoissonSampling) {
  44215. defines["SHADOWPOISSON" + lightIndex] = true;
  44216. }
  44217. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44218. defines["SHADOWESM" + lightIndex] = true;
  44219. }
  44220. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44221. defines["SHADOWCLOSEESM" + lightIndex] = true;
  44222. }
  44223. if (light.needCube()) {
  44224. defines["SHADOWCUBE" + lightIndex] = true;
  44225. }
  44226. };
  44227. /**
  44228. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44229. * defined in the generator but impacting the effect).
  44230. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44231. * @param effect The effect we are binfing the information for
  44232. */
  44233. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  44234. var light = this._light;
  44235. var scene = this._scene;
  44236. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44237. return;
  44238. }
  44239. var camera = scene.activeCamera;
  44240. if (!camera) {
  44241. return;
  44242. }
  44243. var shadowMap = this.getShadowMap();
  44244. if (!shadowMap) {
  44245. return;
  44246. }
  44247. if (!light.needCube()) {
  44248. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  44249. }
  44250. // Only PCF uses depth stencil texture.
  44251. if (this._filter === ShadowGenerator.FILTER_PCF) {
  44252. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44253. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44254. }
  44255. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  44256. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44257. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  44258. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44259. }
  44260. else {
  44261. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44262. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  44263. }
  44264. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  44265. };
  44266. /**
  44267. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44268. * (eq to shadow prjection matrix * light transform matrix)
  44269. * @returns The transform matrix used to create the shadow map
  44270. */
  44271. ShadowGenerator.prototype.getTransformMatrix = function () {
  44272. var scene = this._scene;
  44273. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  44274. return this._transformMatrix;
  44275. }
  44276. this._currentRenderID = scene.getRenderId();
  44277. this._currentFaceIndexCache = this._currentFaceIndex;
  44278. var lightPosition = this._light.position;
  44279. if (this._light.computeTransformedInformation()) {
  44280. lightPosition = this._light.transformedPosition;
  44281. }
  44282. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  44283. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  44284. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  44285. }
  44286. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  44287. this._cachedPosition.copyFrom(lightPosition);
  44288. this._cachedDirection.copyFrom(this._lightDirection);
  44289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  44290. var shadowMap = this.getShadowMap();
  44291. if (shadowMap) {
  44292. var renderList = shadowMap.renderList;
  44293. if (renderList) {
  44294. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  44295. }
  44296. }
  44297. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  44298. }
  44299. return this._transformMatrix;
  44300. };
  44301. /**
  44302. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44303. * Cube and 2D textures for instance.
  44304. */
  44305. ShadowGenerator.prototype.recreateShadowMap = function () {
  44306. var shadowMap = this._shadowMap;
  44307. if (!shadowMap) {
  44308. return;
  44309. }
  44310. // Track render list.
  44311. var renderList = shadowMap.renderList;
  44312. // Clean up existing data.
  44313. this._disposeRTTandPostProcesses();
  44314. // Reinitializes.
  44315. this._initializeGenerator();
  44316. // Reaffect the filter to ensure a correct fallback if necessary.
  44317. this.filter = this.filter;
  44318. // Reaffect the filter.
  44319. this._applyFilterValues();
  44320. // Reaffect Render List.
  44321. this._shadowMap.renderList = renderList;
  44322. };
  44323. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  44324. if (this._shadowMap2) {
  44325. this._shadowMap2.dispose();
  44326. this._shadowMap2 = null;
  44327. }
  44328. if (this._boxBlurPostprocess) {
  44329. this._boxBlurPostprocess.dispose();
  44330. this._boxBlurPostprocess = null;
  44331. }
  44332. if (this._kernelBlurXPostprocess) {
  44333. this._kernelBlurXPostprocess.dispose();
  44334. this._kernelBlurXPostprocess = null;
  44335. }
  44336. if (this._kernelBlurYPostprocess) {
  44337. this._kernelBlurYPostprocess.dispose();
  44338. this._kernelBlurYPostprocess = null;
  44339. }
  44340. this._blurPostProcesses = [];
  44341. };
  44342. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  44343. if (this._shadowMap) {
  44344. this._shadowMap.dispose();
  44345. this._shadowMap = null;
  44346. }
  44347. this._disposeBlurPostProcesses();
  44348. };
  44349. /**
  44350. * Disposes the ShadowGenerator.
  44351. * Returns nothing.
  44352. */
  44353. ShadowGenerator.prototype.dispose = function () {
  44354. this._disposeRTTandPostProcesses();
  44355. if (this._light) {
  44356. this._light._shadowGenerator = null;
  44357. this._light._markMeshesAsLightDirty();
  44358. }
  44359. };
  44360. /**
  44361. * Serializes the shadow generator setup to a json object.
  44362. * @returns The serialized JSON object
  44363. */
  44364. ShadowGenerator.prototype.serialize = function () {
  44365. var serializationObject = {};
  44366. var shadowMap = this.getShadowMap();
  44367. if (!shadowMap) {
  44368. return serializationObject;
  44369. }
  44370. serializationObject.lightId = this._light.id;
  44371. serializationObject.mapSize = shadowMap.getRenderSize();
  44372. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  44373. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  44374. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44375. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44376. serializationObject.usePoissonSampling = this.usePoissonSampling;
  44377. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  44378. serializationObject.depthScale = this.depthScale;
  44379. serializationObject.darkness = this.getDarkness();
  44380. serializationObject.blurBoxOffset = this.blurBoxOffset;
  44381. serializationObject.blurKernel = this.blurKernel;
  44382. serializationObject.blurScale = this.blurScale;
  44383. serializationObject.useKernelBlur = this.useKernelBlur;
  44384. serializationObject.transparencyShadow = this._transparencyShadow;
  44385. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  44386. serializationObject.bias = this.bias;
  44387. serializationObject.normalBias = this.normalBias;
  44388. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  44389. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  44390. serializationObject.filteringQuality = this.filteringQuality;
  44391. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  44392. serializationObject.renderList = [];
  44393. if (shadowMap.renderList) {
  44394. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  44395. var mesh = shadowMap.renderList[meshIndex];
  44396. serializationObject.renderList.push(mesh.id);
  44397. }
  44398. }
  44399. return serializationObject;
  44400. };
  44401. /**
  44402. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44403. * @param parsedShadowGenerator The JSON object to parse
  44404. * @param scene The scene to create the shadow map for
  44405. * @returns The parsed shadow generator
  44406. */
  44407. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  44408. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  44409. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  44410. var shadowMap = shadowGenerator.getShadowMap();
  44411. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  44412. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  44413. meshes.forEach(function (mesh) {
  44414. if (!shadowMap) {
  44415. return;
  44416. }
  44417. if (!shadowMap.renderList) {
  44418. shadowMap.renderList = [];
  44419. }
  44420. shadowMap.renderList.push(mesh);
  44421. });
  44422. }
  44423. if (parsedShadowGenerator.usePoissonSampling) {
  44424. shadowGenerator.usePoissonSampling = true;
  44425. }
  44426. else if (parsedShadowGenerator.useExponentialShadowMap) {
  44427. shadowGenerator.useExponentialShadowMap = true;
  44428. }
  44429. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  44430. shadowGenerator.useBlurExponentialShadowMap = true;
  44431. }
  44432. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  44433. shadowGenerator.useCloseExponentialShadowMap = true;
  44434. }
  44435. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  44436. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  44437. }
  44438. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  44439. shadowGenerator.usePercentageCloserFiltering = true;
  44440. }
  44441. else if (parsedShadowGenerator.useContactHardeningShadow) {
  44442. shadowGenerator.useContactHardeningShadow = true;
  44443. }
  44444. if (parsedShadowGenerator.filteringQuality) {
  44445. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  44446. }
  44447. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  44448. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  44449. }
  44450. // Backward compat
  44451. else if (parsedShadowGenerator.useVarianceShadowMap) {
  44452. shadowGenerator.useExponentialShadowMap = true;
  44453. }
  44454. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  44455. shadowGenerator.useBlurExponentialShadowMap = true;
  44456. }
  44457. if (parsedShadowGenerator.depthScale) {
  44458. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  44459. }
  44460. if (parsedShadowGenerator.blurScale) {
  44461. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  44462. }
  44463. if (parsedShadowGenerator.blurBoxOffset) {
  44464. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  44465. }
  44466. if (parsedShadowGenerator.useKernelBlur) {
  44467. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  44468. }
  44469. if (parsedShadowGenerator.blurKernel) {
  44470. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  44471. }
  44472. if (parsedShadowGenerator.bias !== undefined) {
  44473. shadowGenerator.bias = parsedShadowGenerator.bias;
  44474. }
  44475. if (parsedShadowGenerator.normalBias !== undefined) {
  44476. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  44477. }
  44478. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  44479. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  44480. }
  44481. if (parsedShadowGenerator.darkness) {
  44482. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  44483. }
  44484. if (parsedShadowGenerator.transparencyShadow) {
  44485. shadowGenerator.setTransparencyShadow(true);
  44486. }
  44487. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  44488. return shadowGenerator;
  44489. };
  44490. /**
  44491. * Shadow generator mode None: no filtering applied.
  44492. */
  44493. ShadowGenerator.FILTER_NONE = 0;
  44494. /**
  44495. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44497. */
  44498. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  44499. /**
  44500. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44501. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44502. */
  44503. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  44504. /**
  44505. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44506. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44507. */
  44508. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  44509. /**
  44510. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44511. * edge artifacts on steep falloff.
  44512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44513. */
  44514. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  44515. /**
  44516. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44517. * edge artifacts on steep falloff.
  44518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44519. */
  44520. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  44521. /**
  44522. * Shadow generator mode PCF: Percentage Closer Filtering
  44523. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44524. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44525. */
  44526. ShadowGenerator.FILTER_PCF = 6;
  44527. /**
  44528. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44530. * Contact Hardening
  44531. */
  44532. ShadowGenerator.FILTER_PCSS = 7;
  44533. /**
  44534. * Reserved for PCF and PCSS
  44535. * Highest Quality.
  44536. *
  44537. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44538. *
  44539. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44540. */
  44541. ShadowGenerator.QUALITY_HIGH = 0;
  44542. /**
  44543. * Reserved for PCF and PCSS
  44544. * Good tradeoff for quality/perf cross devices
  44545. *
  44546. * Execute PCF on a 3*3 kernel.
  44547. *
  44548. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44549. */
  44550. ShadowGenerator.QUALITY_MEDIUM = 1;
  44551. /**
  44552. * Reserved for PCF and PCSS
  44553. * The lowest quality but the fastest.
  44554. *
  44555. * Execute PCF on a 1*1 kernel.
  44556. *
  44557. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44558. */
  44559. ShadowGenerator.QUALITY_LOW = 2;
  44560. /** @hidden */
  44561. ShadowGenerator._SceneComponentInitialization = function (_) {
  44562. throw "Import ShadowGeneratorSceneComponent before creating ShadowGenerator.";
  44563. };
  44564. return ShadowGenerator;
  44565. }());
  44566. /***/ }),
  44567. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  44568. /*!*********************************************************!*\
  44569. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  44570. \*********************************************************/
  44571. /*! exports provided: ShadowGeneratorSceneComponent */
  44572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44573. "use strict";
  44574. __webpack_require__.r(__webpack_exports__);
  44575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  44576. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44577. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  44578. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  44579. // Adds the parser to the scene parsers.
  44580. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  44581. // Shadows
  44582. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  44583. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  44584. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  44585. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  44586. // SG would be available on their associated lights
  44587. }
  44588. }
  44589. });
  44590. /**
  44591. * Defines the shadow generator component responsible to manage any shadow generators
  44592. * in a given scene.
  44593. */
  44594. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  44595. /**
  44596. * Creates a new instance of the component for the given scene
  44597. * @param scene Defines the scene to register the component in
  44598. */
  44599. function ShadowGeneratorSceneComponent(scene) {
  44600. /**
  44601. * The component name helpfull to identify the component in the list of scene components.
  44602. */
  44603. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  44604. this.scene = scene;
  44605. }
  44606. /**
  44607. * Registers the component in a given scene
  44608. */
  44609. ShadowGeneratorSceneComponent.prototype.register = function () {
  44610. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  44611. };
  44612. /**
  44613. * Rebuilds the elements related to this component in case of
  44614. * context lost for instance.
  44615. */
  44616. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  44617. // Nothing To Do Here.
  44618. };
  44619. /**
  44620. * Serializes the component data to the specified json object
  44621. * @param serializationObject The object to serialize to
  44622. */
  44623. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  44624. // Shadows
  44625. serializationObject.shadowGenerators = [];
  44626. var lights = this.scene.lights;
  44627. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  44628. var light = lights_1[_i];
  44629. var shadowGenerator = light.getShadowGenerator();
  44630. if (shadowGenerator) {
  44631. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  44632. }
  44633. }
  44634. };
  44635. /**
  44636. * Adds all the element from the container to the scene
  44637. * @param container the container holding the elements
  44638. */
  44639. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  44640. // Nothing To Do Here. (directly attached to a light)
  44641. };
  44642. /**
  44643. * Removes all the elements in the container from the scene
  44644. * @param container contains the elements to remove
  44645. */
  44646. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  44647. // Nothing To Do Here. (directly attached to a light)
  44648. };
  44649. /**
  44650. * Rebuilds the elements related to this component in case of
  44651. * context lost for instance.
  44652. */
  44653. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  44654. // Nothing To Do Here.
  44655. };
  44656. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  44657. // Shadows
  44658. var scene = this.scene;
  44659. if (this.scene.shadowsEnabled) {
  44660. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  44661. var light = scene.lights[lightIndex];
  44662. var shadowGenerator = light.getShadowGenerator();
  44663. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  44664. var shadowMap = (shadowGenerator.getShadowMap());
  44665. if (scene.textures.indexOf(shadowMap) !== -1) {
  44666. renderTargets.push(shadowMap);
  44667. }
  44668. }
  44669. }
  44670. }
  44671. };
  44672. return ShadowGeneratorSceneComponent;
  44673. }());
  44674. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  44675. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  44676. if (!component) {
  44677. component = new ShadowGeneratorSceneComponent(scene);
  44678. scene._addComponent(component);
  44679. }
  44680. };
  44681. /***/ }),
  44682. /***/ "./Lights/directionalLight.ts":
  44683. /*!************************************!*\
  44684. !*** ./Lights/directionalLight.ts ***!
  44685. \************************************/
  44686. /*! exports provided: DirectionalLight */
  44687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44688. "use strict";
  44689. __webpack_require__.r(__webpack_exports__);
  44690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  44691. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44692. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  44693. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44694. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  44695. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  44696. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  44697. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  44698. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  44699. });
  44700. /**
  44701. * A directional light is defined by a direction (what a surprise!).
  44702. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44703. * 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.
  44704. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44705. */
  44706. var DirectionalLight = /** @class */ (function (_super) {
  44707. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  44708. /**
  44709. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44710. * The directional light is emitted from everywhere in the given direction.
  44711. * It can cast shadows.
  44712. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44713. * @param name The friendly name of the light
  44714. * @param direction The direction of the light
  44715. * @param scene The scene the light belongs to
  44716. */
  44717. function DirectionalLight(name, direction, scene) {
  44718. var _this = _super.call(this, name, scene) || this;
  44719. _this._shadowFrustumSize = 0;
  44720. _this._shadowOrthoScale = 0.1;
  44721. /**
  44722. * Automatically compute the projection matrix to best fit (including all the casters)
  44723. * on each frame.
  44724. */
  44725. _this.autoUpdateExtends = true;
  44726. // Cache
  44727. _this._orthoLeft = Number.MAX_VALUE;
  44728. _this._orthoRight = Number.MIN_VALUE;
  44729. _this._orthoTop = Number.MIN_VALUE;
  44730. _this._orthoBottom = Number.MAX_VALUE;
  44731. _this.position = direction.scale(-1.0);
  44732. _this.direction = direction;
  44733. return _this;
  44734. }
  44735. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  44736. /**
  44737. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44738. */
  44739. get: function () {
  44740. return this._shadowFrustumSize;
  44741. },
  44742. /**
  44743. * Specifies a fix frustum size for the shadow generation.
  44744. */
  44745. set: function (value) {
  44746. this._shadowFrustumSize = value;
  44747. this.forceProjectionMatrixCompute();
  44748. },
  44749. enumerable: true,
  44750. configurable: true
  44751. });
  44752. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  44753. /**
  44754. * Gets the shadow projection scale against the optimal computed one.
  44755. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44756. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44757. */
  44758. get: function () {
  44759. return this._shadowOrthoScale;
  44760. },
  44761. /**
  44762. * Sets the shadow projection scale against the optimal computed one.
  44763. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44764. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44765. */
  44766. set: function (value) {
  44767. this._shadowOrthoScale = value;
  44768. this.forceProjectionMatrixCompute();
  44769. },
  44770. enumerable: true,
  44771. configurable: true
  44772. });
  44773. /**
  44774. * Returns the string "DirectionalLight".
  44775. * @return The class name
  44776. */
  44777. DirectionalLight.prototype.getClassName = function () {
  44778. return "DirectionalLight";
  44779. };
  44780. /**
  44781. * Returns the integer 1.
  44782. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44783. */
  44784. DirectionalLight.prototype.getTypeID = function () {
  44785. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  44786. };
  44787. /**
  44788. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44789. * Returns the DirectionalLight Shadow projection matrix.
  44790. */
  44791. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  44792. if (this.shadowFrustumSize > 0) {
  44793. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  44794. }
  44795. else {
  44796. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  44797. }
  44798. };
  44799. /**
  44800. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44801. * Returns the DirectionalLight Shadow projection matrix.
  44802. */
  44803. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  44804. var activeCamera = this.getScene().activeCamera;
  44805. if (!activeCamera) {
  44806. return;
  44807. }
  44808. _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);
  44809. };
  44810. /**
  44811. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44812. * Returns the DirectionalLight Shadow projection matrix.
  44813. */
  44814. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  44815. var activeCamera = this.getScene().activeCamera;
  44816. if (!activeCamera) {
  44817. return;
  44818. }
  44819. // Check extends
  44820. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  44821. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  44822. this._orthoLeft = Number.MAX_VALUE;
  44823. this._orthoRight = Number.MIN_VALUE;
  44824. this._orthoTop = Number.MIN_VALUE;
  44825. this._orthoBottom = Number.MAX_VALUE;
  44826. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  44827. var mesh = renderList[meshIndex];
  44828. if (!mesh) {
  44829. continue;
  44830. }
  44831. var boundingInfo = mesh.getBoundingInfo();
  44832. var boundingBox = boundingInfo.boundingBox;
  44833. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  44834. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  44835. if (tempVector3.x < this._orthoLeft) {
  44836. this._orthoLeft = tempVector3.x;
  44837. }
  44838. if (tempVector3.y < this._orthoBottom) {
  44839. this._orthoBottom = tempVector3.y;
  44840. }
  44841. if (tempVector3.x > this._orthoRight) {
  44842. this._orthoRight = tempVector3.x;
  44843. }
  44844. if (tempVector3.y > this._orthoTop) {
  44845. this._orthoTop = tempVector3.y;
  44846. }
  44847. }
  44848. }
  44849. }
  44850. var xOffset = this._orthoRight - this._orthoLeft;
  44851. var yOffset = this._orthoTop - this._orthoBottom;
  44852. _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);
  44853. };
  44854. DirectionalLight.prototype._buildUniformLayout = function () {
  44855. this._uniformBuffer.addUniform("vLightData", 4);
  44856. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  44857. this._uniformBuffer.addUniform("vLightSpecular", 3);
  44858. this._uniformBuffer.addUniform("shadowsInfo", 3);
  44859. this._uniformBuffer.addUniform("depthValues", 2);
  44860. this._uniformBuffer.create();
  44861. };
  44862. /**
  44863. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44864. * @param effect The effect to update
  44865. * @param lightIndex The index of the light in the effect to update
  44866. * @returns The directional light
  44867. */
  44868. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  44869. if (this.computeTransformedInformation()) {
  44870. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  44871. return this;
  44872. }
  44873. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  44874. return this;
  44875. };
  44876. /**
  44877. * Gets the minZ used for shadow according to both the scene and the light.
  44878. *
  44879. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44880. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44881. * @param activeCamera The camera we are returning the min for
  44882. * @returns the depth min z
  44883. */
  44884. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  44885. return 1;
  44886. };
  44887. /**
  44888. * Gets the maxZ used for shadow according to both the scene and the light.
  44889. *
  44890. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44891. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44892. * @param activeCamera The camera we are returning the max for
  44893. * @returns the depth max z
  44894. */
  44895. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  44896. return 1;
  44897. };
  44898. /**
  44899. * Prepares the list of defines specific to the light type.
  44900. * @param defines the list of defines
  44901. * @param lightIndex defines the index of the light for the effect
  44902. */
  44903. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  44904. defines["DIRLIGHT" + lightIndex] = true;
  44905. };
  44906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44908. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  44909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44911. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  44912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  44913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  44914. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  44915. return DirectionalLight;
  44916. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  44917. /***/ }),
  44918. /***/ "./Lights/hemisphericLight.ts":
  44919. /*!************************************!*\
  44920. !*** ./Lights/hemisphericLight.ts ***!
  44921. \************************************/
  44922. /*! exports provided: HemisphericLight */
  44923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44924. "use strict";
  44925. __webpack_require__.r(__webpack_exports__);
  44926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  44927. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44928. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  44929. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44930. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  44931. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  44932. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  44933. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  44934. });
  44935. /**
  44936. * The HemisphericLight simulates the ambient environment light,
  44937. * so the passed direction is the light reflection direction, not the incoming direction.
  44938. */
  44939. var HemisphericLight = /** @class */ (function (_super) {
  44940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  44941. /**
  44942. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  44943. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  44944. * The HemisphericLight can't cast shadows.
  44945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44946. * @param name The friendly name of the light
  44947. * @param direction The direction of the light reflection
  44948. * @param scene The scene the light belongs to
  44949. */
  44950. function HemisphericLight(name, direction, scene) {
  44951. var _this = _super.call(this, name, scene) || this;
  44952. /**
  44953. * The groundColor is the light in the opposite direction to the one specified during creation.
  44954. * 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.
  44955. */
  44956. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  44957. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  44958. return _this;
  44959. }
  44960. HemisphericLight.prototype._buildUniformLayout = function () {
  44961. this._uniformBuffer.addUniform("vLightData", 4);
  44962. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  44963. this._uniformBuffer.addUniform("vLightSpecular", 3);
  44964. this._uniformBuffer.addUniform("vLightGround", 3);
  44965. this._uniformBuffer.addUniform("shadowsInfo", 3);
  44966. this._uniformBuffer.addUniform("depthValues", 2);
  44967. this._uniformBuffer.create();
  44968. };
  44969. /**
  44970. * Returns the string "HemisphericLight".
  44971. * @return The class name
  44972. */
  44973. HemisphericLight.prototype.getClassName = function () {
  44974. return "HemisphericLight";
  44975. };
  44976. /**
  44977. * Sets the HemisphericLight direction towards the passed target (Vector3).
  44978. * Returns the updated direction.
  44979. * @param target The target the direction should point to
  44980. * @return The computed direction
  44981. */
  44982. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  44983. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  44984. return this.direction;
  44985. };
  44986. /**
  44987. * Returns the shadow generator associated to the light.
  44988. * @returns Always null for hemispheric lights because it does not support shadows.
  44989. */
  44990. HemisphericLight.prototype.getShadowGenerator = function () {
  44991. return null;
  44992. };
  44993. /**
  44994. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  44995. * @param effect The effect to update
  44996. * @param lightIndex The index of the light in the effect to update
  44997. * @returns The hemispheric light
  44998. */
  44999. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  45000. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  45001. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  45002. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  45003. return this;
  45004. };
  45005. /**
  45006. * Computes the world matrix of the node
  45007. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  45008. * @param useWasUpdatedFlag defines a reserved property
  45009. * @returns the world matrix
  45010. */
  45011. HemisphericLight.prototype.computeWorldMatrix = function () {
  45012. if (!this._worldMatrix) {
  45013. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  45014. }
  45015. return this._worldMatrix;
  45016. };
  45017. /**
  45018. * Returns the integer 3.
  45019. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45020. */
  45021. HemisphericLight.prototype.getTypeID = function () {
  45022. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  45023. };
  45024. /**
  45025. * Prepares the list of defines specific to the light type.
  45026. * @param defines the list of defines
  45027. * @param lightIndex defines the index of the light for the effect
  45028. */
  45029. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45030. defines["HEMILIGHT" + lightIndex] = true;
  45031. };
  45032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45034. ], HemisphericLight.prototype, "groundColor", void 0);
  45035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  45037. ], HemisphericLight.prototype, "direction", void 0);
  45038. return HemisphericLight;
  45039. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  45040. /***/ }),
  45041. /***/ "./Lights/index.ts":
  45042. /*!*************************!*\
  45043. !*** ./Lights/index.ts ***!
  45044. \*************************/
  45045. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  45046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45047. "use strict";
  45048. __webpack_require__.r(__webpack_exports__);
  45049. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45051. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  45053. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  45054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  45055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  45056. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  45057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  45058. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  45059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  45060. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  45061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  45062. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  45063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  45064. /***/ }),
  45065. /***/ "./Lights/light.ts":
  45066. /*!*************************!*\
  45067. !*** ./Lights/light.ts ***!
  45068. \*************************/
  45069. /*! exports provided: Light */
  45070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45071. "use strict";
  45072. __webpack_require__.r(__webpack_exports__);
  45073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  45074. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45075. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45076. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45077. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45078. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  45079. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  45080. /**
  45081. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  45082. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  45083. * 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.
  45084. */
  45085. var Light = /** @class */ (function (_super) {
  45086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  45087. /**
  45088. * Creates a Light object in the scene.
  45089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45090. * @param name The firendly name of the light
  45091. * @param scene The scene the light belongs too
  45092. */
  45093. function Light(name, scene) {
  45094. var _this = _super.call(this, name, scene) || this;
  45095. /**
  45096. * Diffuse gives the basic color to an object.
  45097. */
  45098. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45099. /**
  45100. * Specular produces a highlight color on an object.
  45101. * Note: This is note affecting PBR materials.
  45102. */
  45103. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45104. /**
  45105. * Defines the falloff type for this light. This lets overrriding how punctual light are
  45106. * falling off base on range or angle.
  45107. * This can be set to any values in Light.FALLOFF_x.
  45108. *
  45109. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  45110. * other types of materials.
  45111. */
  45112. _this.falloffType = Light.FALLOFF_DEFAULT;
  45113. /**
  45114. * Strength of the light.
  45115. * Note: By default it is define in the framework own unit.
  45116. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  45117. */
  45118. _this.intensity = 1.0;
  45119. _this._range = Number.MAX_VALUE;
  45120. _this._inverseSquaredRange = 0;
  45121. /**
  45122. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  45123. * of light.
  45124. */
  45125. _this._photometricScale = 1.0;
  45126. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  45127. _this._radius = 0.00001;
  45128. /**
  45129. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  45130. * exceeding the number allowed of the materials.
  45131. */
  45132. _this.renderPriority = 0;
  45133. _this._shadowEnabled = true;
  45134. _this._excludeWithLayerMask = 0;
  45135. _this._includeOnlyWithLayerMask = 0;
  45136. _this._lightmapMode = 0;
  45137. /**
  45138. * @hidden Internal use only.
  45139. */
  45140. _this._excludedMeshesIds = new Array();
  45141. /**
  45142. * @hidden Internal use only.
  45143. */
  45144. _this._includedOnlyMeshesIds = new Array();
  45145. /** @hidden */
  45146. _this._isLight = true;
  45147. _this.getScene().addLight(_this);
  45148. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  45149. _this._buildUniformLayout();
  45150. _this.includedOnlyMeshes = new Array();
  45151. _this.excludedMeshes = new Array();
  45152. _this._resyncMeshes();
  45153. return _this;
  45154. }
  45155. Object.defineProperty(Light.prototype, "range", {
  45156. /**
  45157. * Defines how far from the source the light is impacting in scene units.
  45158. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45159. */
  45160. get: function () {
  45161. return this._range;
  45162. },
  45163. /**
  45164. * Defines how far from the source the light is impacting in scene units.
  45165. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45166. */
  45167. set: function (value) {
  45168. this._range = value;
  45169. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  45170. },
  45171. enumerable: true,
  45172. configurable: true
  45173. });
  45174. Object.defineProperty(Light.prototype, "intensityMode", {
  45175. /**
  45176. * Gets the photometric scale used to interpret the intensity.
  45177. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45178. */
  45179. get: function () {
  45180. return this._intensityMode;
  45181. },
  45182. /**
  45183. * Sets the photometric scale used to interpret the intensity.
  45184. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45185. */
  45186. set: function (value) {
  45187. this._intensityMode = value;
  45188. this._computePhotometricScale();
  45189. },
  45190. enumerable: true,
  45191. configurable: true
  45192. });
  45193. Object.defineProperty(Light.prototype, "radius", {
  45194. /**
  45195. * Gets the light radius used by PBR Materials to simulate soft area lights.
  45196. */
  45197. get: function () {
  45198. return this._radius;
  45199. },
  45200. /**
  45201. * sets the light radius used by PBR Materials to simulate soft area lights.
  45202. */
  45203. set: function (value) {
  45204. this._radius = value;
  45205. this._computePhotometricScale();
  45206. },
  45207. enumerable: true,
  45208. configurable: true
  45209. });
  45210. Object.defineProperty(Light.prototype, "shadowEnabled", {
  45211. /**
  45212. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45213. * the current shadow generator.
  45214. */
  45215. get: function () {
  45216. return this._shadowEnabled;
  45217. },
  45218. /**
  45219. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45220. * the current shadow generator.
  45221. */
  45222. set: function (value) {
  45223. if (this._shadowEnabled === value) {
  45224. return;
  45225. }
  45226. this._shadowEnabled = value;
  45227. this._markMeshesAsLightDirty();
  45228. },
  45229. enumerable: true,
  45230. configurable: true
  45231. });
  45232. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  45233. /**
  45234. * Gets the only meshes impacted by this light.
  45235. */
  45236. get: function () {
  45237. return this._includedOnlyMeshes;
  45238. },
  45239. /**
  45240. * Sets the only meshes impacted by this light.
  45241. */
  45242. set: function (value) {
  45243. this._includedOnlyMeshes = value;
  45244. this._hookArrayForIncludedOnly(value);
  45245. },
  45246. enumerable: true,
  45247. configurable: true
  45248. });
  45249. Object.defineProperty(Light.prototype, "excludedMeshes", {
  45250. /**
  45251. * Gets the meshes not impacted by this light.
  45252. */
  45253. get: function () {
  45254. return this._excludedMeshes;
  45255. },
  45256. /**
  45257. * Sets the meshes not impacted by this light.
  45258. */
  45259. set: function (value) {
  45260. this._excludedMeshes = value;
  45261. this._hookArrayForExcluded(value);
  45262. },
  45263. enumerable: true,
  45264. configurable: true
  45265. });
  45266. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  45267. /**
  45268. * Gets the layer id use to find what meshes are not impacted by the light.
  45269. * Inactive if 0
  45270. */
  45271. get: function () {
  45272. return this._excludeWithLayerMask;
  45273. },
  45274. /**
  45275. * Sets the layer id use to find what meshes are not impacted by the light.
  45276. * Inactive if 0
  45277. */
  45278. set: function (value) {
  45279. this._excludeWithLayerMask = value;
  45280. this._resyncMeshes();
  45281. },
  45282. enumerable: true,
  45283. configurable: true
  45284. });
  45285. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  45286. /**
  45287. * Gets the layer id use to find what meshes are impacted by the light.
  45288. * Inactive if 0
  45289. */
  45290. get: function () {
  45291. return this._includeOnlyWithLayerMask;
  45292. },
  45293. /**
  45294. * Sets the layer id use to find what meshes are impacted by the light.
  45295. * Inactive if 0
  45296. */
  45297. set: function (value) {
  45298. this._includeOnlyWithLayerMask = value;
  45299. this._resyncMeshes();
  45300. },
  45301. enumerable: true,
  45302. configurable: true
  45303. });
  45304. Object.defineProperty(Light.prototype, "lightmapMode", {
  45305. /**
  45306. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45307. */
  45308. get: function () {
  45309. return this._lightmapMode;
  45310. },
  45311. /**
  45312. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45313. */
  45314. set: function (value) {
  45315. if (this._lightmapMode === value) {
  45316. return;
  45317. }
  45318. this._lightmapMode = value;
  45319. this._markMeshesAsLightDirty();
  45320. },
  45321. enumerable: true,
  45322. configurable: true
  45323. });
  45324. /**
  45325. * Returns the string "Light".
  45326. * @returns the class name
  45327. */
  45328. Light.prototype.getClassName = function () {
  45329. return "Light";
  45330. };
  45331. /**
  45332. * Converts the light information to a readable string for debug purpose.
  45333. * @param fullDetails Supports for multiple levels of logging within scene loading
  45334. * @returns the human readable light info
  45335. */
  45336. Light.prototype.toString = function (fullDetails) {
  45337. var ret = "Name: " + this.name;
  45338. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  45339. if (this.animations) {
  45340. for (var i = 0; i < this.animations.length; i++) {
  45341. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  45342. }
  45343. }
  45344. if (fullDetails) {
  45345. }
  45346. return ret;
  45347. };
  45348. /** @hidden */
  45349. Light.prototype._syncParentEnabledState = function () {
  45350. _super.prototype._syncParentEnabledState.call(this);
  45351. this._resyncMeshes();
  45352. };
  45353. /**
  45354. * Set the enabled state of this node.
  45355. * @param value - the new enabled state
  45356. */
  45357. Light.prototype.setEnabled = function (value) {
  45358. _super.prototype.setEnabled.call(this, value);
  45359. this._resyncMeshes();
  45360. };
  45361. /**
  45362. * Returns the Light associated shadow generator if any.
  45363. * @return the associated shadow generator.
  45364. */
  45365. Light.prototype.getShadowGenerator = function () {
  45366. return this._shadowGenerator;
  45367. };
  45368. /**
  45369. * Returns a Vector3, the absolute light position in the World.
  45370. * @returns the world space position of the light
  45371. */
  45372. Light.prototype.getAbsolutePosition = function () {
  45373. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45374. };
  45375. /**
  45376. * Specifies if the light will affect the passed mesh.
  45377. * @param mesh The mesh to test against the light
  45378. * @return true the mesh is affected otherwise, false.
  45379. */
  45380. Light.prototype.canAffectMesh = function (mesh) {
  45381. if (!mesh) {
  45382. return true;
  45383. }
  45384. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  45385. return false;
  45386. }
  45387. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  45388. return false;
  45389. }
  45390. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  45391. return false;
  45392. }
  45393. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  45394. return false;
  45395. }
  45396. return true;
  45397. };
  45398. /**
  45399. * Sort function to order lights for rendering.
  45400. * @param a First Light object to compare to second.
  45401. * @param b Second Light object to compare first.
  45402. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  45403. */
  45404. Light.CompareLightsPriority = function (a, b) {
  45405. //shadow-casting lights have priority over non-shadow-casting lights
  45406. //the renderPrioirty is a secondary sort criterion
  45407. if (a.shadowEnabled !== b.shadowEnabled) {
  45408. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  45409. }
  45410. return b.renderPriority - a.renderPriority;
  45411. };
  45412. /**
  45413. * Releases resources associated with this node.
  45414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45416. */
  45417. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  45418. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  45419. if (this._shadowGenerator) {
  45420. this._shadowGenerator.dispose();
  45421. this._shadowGenerator = null;
  45422. }
  45423. // Animations
  45424. this.getScene().stopAnimation(this);
  45425. // Remove from meshes
  45426. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45427. var mesh = _a[_i];
  45428. mesh._removeLightSource(this);
  45429. }
  45430. this._uniformBuffer.dispose();
  45431. // Remove from scene
  45432. this.getScene().removeLight(this);
  45433. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  45434. };
  45435. /**
  45436. * Returns the light type ID (integer).
  45437. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45438. */
  45439. Light.prototype.getTypeID = function () {
  45440. return 0;
  45441. };
  45442. /**
  45443. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  45444. * @returns the scaled intensity in intensity mode unit
  45445. */
  45446. Light.prototype.getScaledIntensity = function () {
  45447. return this._photometricScale * this.intensity;
  45448. };
  45449. /**
  45450. * Returns a new Light object, named "name", from the current one.
  45451. * @param name The name of the cloned light
  45452. * @returns the new created light
  45453. */
  45454. Light.prototype.clone = function (name) {
  45455. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  45456. if (!constructor) {
  45457. return null;
  45458. }
  45459. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  45460. };
  45461. /**
  45462. * Serializes the current light into a Serialization object.
  45463. * @returns the serialized object.
  45464. */
  45465. Light.prototype.serialize = function () {
  45466. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  45467. // Type
  45468. serializationObject.type = this.getTypeID();
  45469. // Parent
  45470. if (this.parent) {
  45471. serializationObject.parentId = this.parent.id;
  45472. }
  45473. // Inclusion / exclusions
  45474. if (this.excludedMeshes.length > 0) {
  45475. serializationObject.excludedMeshesIds = [];
  45476. this.excludedMeshes.forEach(function (mesh) {
  45477. serializationObject.excludedMeshesIds.push(mesh.id);
  45478. });
  45479. }
  45480. if (this.includedOnlyMeshes.length > 0) {
  45481. serializationObject.includedOnlyMeshesIds = [];
  45482. this.includedOnlyMeshes.forEach(function (mesh) {
  45483. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  45484. });
  45485. }
  45486. // Animations
  45487. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  45488. serializationObject.ranges = this.serializeAnimationRanges();
  45489. return serializationObject;
  45490. };
  45491. /**
  45492. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  45493. * This new light is named "name" and added to the passed scene.
  45494. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  45495. * @param name The friendly name of the light
  45496. * @param scene The scene the new light will belong to
  45497. * @returns the constructor function
  45498. */
  45499. Light.GetConstructorFromName = function (type, name, scene) {
  45500. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  45501. if (constructorFunc) {
  45502. return constructorFunc;
  45503. }
  45504. // Default to no light for none present once.
  45505. return null;
  45506. };
  45507. /**
  45508. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  45509. * @param parsedLight The JSON representation of the light
  45510. * @param scene The scene to create the parsed light in
  45511. * @returns the created light after parsing
  45512. */
  45513. Light.Parse = function (parsedLight, scene) {
  45514. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  45515. if (!constructor) {
  45516. return null;
  45517. }
  45518. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  45519. // Inclusion / exclusions
  45520. if (parsedLight.excludedMeshesIds) {
  45521. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  45522. }
  45523. if (parsedLight.includedOnlyMeshesIds) {
  45524. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  45525. }
  45526. // Parent
  45527. if (parsedLight.parentId) {
  45528. light._waitingParentId = parsedLight.parentId;
  45529. }
  45530. // Animations
  45531. if (parsedLight.animations) {
  45532. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  45533. var parsedAnimation = parsedLight.animations[animationIndex];
  45534. light.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].Parse(parsedAnimation));
  45535. }
  45536. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  45537. }
  45538. if (parsedLight.autoAnimate) {
  45539. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  45540. }
  45541. return light;
  45542. };
  45543. Light.prototype._hookArrayForExcluded = function (array) {
  45544. var _this = this;
  45545. var oldPush = array.push;
  45546. array.push = function () {
  45547. var items = [];
  45548. for (var _i = 0; _i < arguments.length; _i++) {
  45549. items[_i] = arguments[_i];
  45550. }
  45551. var result = oldPush.apply(array, items);
  45552. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  45553. var item = items_1[_a];
  45554. item._resyncLighSource(_this);
  45555. }
  45556. return result;
  45557. };
  45558. var oldSplice = array.splice;
  45559. array.splice = function (index, deleteCount) {
  45560. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45561. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  45562. var item = deleted_1[_i];
  45563. item._resyncLighSource(_this);
  45564. }
  45565. return deleted;
  45566. };
  45567. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  45568. var item = array_1[_i];
  45569. item._resyncLighSource(this);
  45570. }
  45571. };
  45572. Light.prototype._hookArrayForIncludedOnly = function (array) {
  45573. var _this = this;
  45574. var oldPush = array.push;
  45575. array.push = function () {
  45576. var items = [];
  45577. for (var _i = 0; _i < arguments.length; _i++) {
  45578. items[_i] = arguments[_i];
  45579. }
  45580. var result = oldPush.apply(array, items);
  45581. _this._resyncMeshes();
  45582. return result;
  45583. };
  45584. var oldSplice = array.splice;
  45585. array.splice = function (index, deleteCount) {
  45586. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45587. _this._resyncMeshes();
  45588. return deleted;
  45589. };
  45590. this._resyncMeshes();
  45591. };
  45592. Light.prototype._resyncMeshes = function () {
  45593. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45594. var mesh = _a[_i];
  45595. mesh._resyncLighSource(this);
  45596. }
  45597. };
  45598. /**
  45599. * Forces the meshes to update their light related information in their rendering used effects
  45600. * @hidden Internal Use Only
  45601. */
  45602. Light.prototype._markMeshesAsLightDirty = function () {
  45603. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45604. var mesh = _a[_i];
  45605. if (mesh._lightSources.indexOf(this) !== -1) {
  45606. mesh._markSubMeshesAsLightDirty();
  45607. }
  45608. }
  45609. };
  45610. /**
  45611. * Recomputes the cached photometric scale if needed.
  45612. */
  45613. Light.prototype._computePhotometricScale = function () {
  45614. this._photometricScale = this._getPhotometricScale();
  45615. this.getScene().resetCachedMaterial();
  45616. };
  45617. /**
  45618. * Returns the Photometric Scale according to the light type and intensity mode.
  45619. */
  45620. Light.prototype._getPhotometricScale = function () {
  45621. var photometricScale = 0.0;
  45622. var lightTypeID = this.getTypeID();
  45623. //get photometric mode
  45624. var photometricMode = this.intensityMode;
  45625. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  45626. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  45627. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  45628. }
  45629. else {
  45630. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  45631. }
  45632. }
  45633. //compute photometric scale
  45634. switch (lightTypeID) {
  45635. case Light.LIGHTTYPEID_POINTLIGHT:
  45636. case Light.LIGHTTYPEID_SPOTLIGHT:
  45637. switch (photometricMode) {
  45638. case Light.INTENSITYMODE_LUMINOUSPOWER:
  45639. photometricScale = 1.0 / (4.0 * Math.PI);
  45640. break;
  45641. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  45642. photometricScale = 1.0;
  45643. break;
  45644. case Light.INTENSITYMODE_LUMINANCE:
  45645. photometricScale = this.radius * this.radius;
  45646. break;
  45647. }
  45648. break;
  45649. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  45650. switch (photometricMode) {
  45651. case Light.INTENSITYMODE_ILLUMINANCE:
  45652. photometricScale = 1.0;
  45653. break;
  45654. case Light.INTENSITYMODE_LUMINANCE:
  45655. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  45656. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  45657. var apexAngleRadians = this.radius;
  45658. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  45659. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  45660. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  45661. photometricScale = solidAngle;
  45662. break;
  45663. }
  45664. break;
  45665. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  45666. // No fall off in hemisperic light.
  45667. photometricScale = 1.0;
  45668. break;
  45669. }
  45670. return photometricScale;
  45671. };
  45672. /**
  45673. * Reorder the light in the scene according to their defined priority.
  45674. * @hidden Internal Use Only
  45675. */
  45676. Light.prototype._reorderLightsInScene = function () {
  45677. var scene = this.getScene();
  45678. if (this._renderPriority != 0) {
  45679. scene.requireLightSorting = true;
  45680. }
  45681. this.getScene().sortLightsByPriority();
  45682. };
  45683. /**
  45684. * Falloff Default: light is falling off following the material specification:
  45685. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  45686. */
  45687. Light.FALLOFF_DEFAULT = 0;
  45688. /**
  45689. * Falloff Physical: light is falling off following the inverse squared distance law.
  45690. */
  45691. Light.FALLOFF_PHYSICAL = 1;
  45692. /**
  45693. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  45694. * to enhance interoperability with other engines.
  45695. */
  45696. Light.FALLOFF_GLTF = 2;
  45697. /**
  45698. * Falloff Standard: light is falling off like in the standard material
  45699. * to enhance interoperability with other materials.
  45700. */
  45701. Light.FALLOFF_STANDARD = 3;
  45702. //lightmapMode Consts
  45703. /**
  45704. * If every light affecting the material is in this lightmapMode,
  45705. * material.lightmapTexture adds or multiplies
  45706. * (depends on material.useLightmapAsShadowmap)
  45707. * after every other light calculations.
  45708. */
  45709. Light.LIGHTMAP_DEFAULT = 0;
  45710. /**
  45711. * material.lightmapTexture as only diffuse lighting from this light
  45712. * adds only specular lighting from this light
  45713. * adds dynamic shadows
  45714. */
  45715. Light.LIGHTMAP_SPECULAR = 1;
  45716. /**
  45717. * material.lightmapTexture as only lighting
  45718. * no light calculation from this light
  45719. * only adds dynamic shadows from this light
  45720. */
  45721. Light.LIGHTMAP_SHADOWSONLY = 2;
  45722. // Intensity Mode Consts
  45723. /**
  45724. * Each light type uses the default quantity according to its type:
  45725. * point/spot lights use luminous intensity
  45726. * directional lights use illuminance
  45727. */
  45728. Light.INTENSITYMODE_AUTOMATIC = 0;
  45729. /**
  45730. * lumen (lm)
  45731. */
  45732. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  45733. /**
  45734. * candela (lm/sr)
  45735. */
  45736. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  45737. /**
  45738. * lux (lm/m^2)
  45739. */
  45740. Light.INTENSITYMODE_ILLUMINANCE = 3;
  45741. /**
  45742. * nit (cd/m^2)
  45743. */
  45744. Light.INTENSITYMODE_LUMINANCE = 4;
  45745. // Light types ids const.
  45746. /**
  45747. * Light type const id of the point light.
  45748. */
  45749. Light.LIGHTTYPEID_POINTLIGHT = 0;
  45750. /**
  45751. * Light type const id of the directional light.
  45752. */
  45753. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  45754. /**
  45755. * Light type const id of the spot light.
  45756. */
  45757. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  45758. /**
  45759. * Light type const id of the hemispheric light.
  45760. */
  45761. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  45762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45764. ], Light.prototype, "diffuse", void 0);
  45765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45767. ], Light.prototype, "specular", void 0);
  45768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45770. ], Light.prototype, "falloffType", void 0);
  45771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45773. ], Light.prototype, "intensity", void 0);
  45774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45776. ], Light.prototype, "range", null);
  45777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45779. ], Light.prototype, "intensityMode", null);
  45780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45782. ], Light.prototype, "radius", null);
  45783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45785. ], Light.prototype, "_renderPriority", void 0);
  45786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  45788. ], Light.prototype, "renderPriority", void 0);
  45789. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  45791. ], Light.prototype, "_shadowEnabled", void 0);
  45792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  45794. ], Light.prototype, "_excludeWithLayerMask", void 0);
  45795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  45797. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  45798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  45800. ], Light.prototype, "_lightmapMode", void 0);
  45801. return Light;
  45802. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  45803. /***/ }),
  45804. /***/ "./Lights/pointLight.ts":
  45805. /*!******************************!*\
  45806. !*** ./Lights/pointLight.ts ***!
  45807. \******************************/
  45808. /*! exports provided: PointLight */
  45809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45810. "use strict";
  45811. __webpack_require__.r(__webpack_exports__);
  45812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  45813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45814. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45815. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45816. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45817. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45818. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45819. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  45820. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45821. });
  45822. /**
  45823. * A point light is a light defined by an unique point in world space.
  45824. * The light is emitted in every direction from this point.
  45825. * A good example of a point light is a standard light bulb.
  45826. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45827. */
  45828. var PointLight = /** @class */ (function (_super) {
  45829. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  45830. /**
  45831. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45832. * A PointLight emits the light in every direction.
  45833. * It can cast shadows.
  45834. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45835. * ```javascript
  45836. * var pointLight = new PointLight("pl", camera.position, scene);
  45837. * ```
  45838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45839. * @param name The light friendly name
  45840. * @param position The position of the point light in the scene
  45841. * @param scene The scene the lights belongs to
  45842. */
  45843. function PointLight(name, position, scene) {
  45844. var _this = _super.call(this, name, scene) || this;
  45845. _this._shadowAngle = Math.PI / 2;
  45846. _this.position = position;
  45847. return _this;
  45848. }
  45849. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  45850. /**
  45851. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45852. * This specifies what angle the shadow will use to be created.
  45853. *
  45854. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45855. */
  45856. get: function () {
  45857. return this._shadowAngle;
  45858. },
  45859. /**
  45860. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45861. * This specifies what angle the shadow will use to be created.
  45862. *
  45863. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45864. */
  45865. set: function (value) {
  45866. this._shadowAngle = value;
  45867. this.forceProjectionMatrixCompute();
  45868. },
  45869. enumerable: true,
  45870. configurable: true
  45871. });
  45872. Object.defineProperty(PointLight.prototype, "direction", {
  45873. /**
  45874. * Gets the direction if it has been set.
  45875. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45876. */
  45877. get: function () {
  45878. return this._direction;
  45879. },
  45880. /**
  45881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45882. */
  45883. set: function (value) {
  45884. var previousNeedCube = this.needCube();
  45885. this._direction = value;
  45886. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  45887. this._shadowGenerator.recreateShadowMap();
  45888. }
  45889. },
  45890. enumerable: true,
  45891. configurable: true
  45892. });
  45893. /**
  45894. * Returns the string "PointLight"
  45895. * @returns the class name
  45896. */
  45897. PointLight.prototype.getClassName = function () {
  45898. return "PointLight";
  45899. };
  45900. /**
  45901. * Returns the integer 0.
  45902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45903. */
  45904. PointLight.prototype.getTypeID = function () {
  45905. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  45906. };
  45907. /**
  45908. * Specifies wether or not the shadowmap should be a cube texture.
  45909. * @returns true if the shadowmap needs to be a cube texture.
  45910. */
  45911. PointLight.prototype.needCube = function () {
  45912. return !this.direction;
  45913. };
  45914. /**
  45915. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  45916. * @param faceIndex The index of the face we are computed the direction to generate shadow
  45917. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  45918. */
  45919. PointLight.prototype.getShadowDirection = function (faceIndex) {
  45920. if (this.direction) {
  45921. return _super.prototype.getShadowDirection.call(this, faceIndex);
  45922. }
  45923. else {
  45924. switch (faceIndex) {
  45925. case 0:
  45926. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  45927. case 1:
  45928. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  45929. case 2:
  45930. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  45931. case 3:
  45932. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  45933. case 4:
  45934. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  45935. case 5:
  45936. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  45937. }
  45938. }
  45939. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45940. };
  45941. /**
  45942. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  45943. * - fov = PI / 2
  45944. * - aspect ratio : 1.0
  45945. * - z-near and far equal to the active camera minZ and maxZ.
  45946. * Returns the PointLight.
  45947. */
  45948. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45949. var activeCamera = this.getScene().activeCamera;
  45950. if (!activeCamera) {
  45951. return;
  45952. }
  45953. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  45954. };
  45955. PointLight.prototype._buildUniformLayout = function () {
  45956. this._uniformBuffer.addUniform("vLightData", 4);
  45957. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45958. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45959. this._uniformBuffer.addUniform("vLightFalloff", 4);
  45960. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45961. this._uniformBuffer.addUniform("depthValues", 2);
  45962. this._uniformBuffer.create();
  45963. };
  45964. /**
  45965. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  45966. * @param effect The effect to update
  45967. * @param lightIndex The index of the light in the effect to update
  45968. * @returns The point light
  45969. */
  45970. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  45971. if (this.computeTransformedInformation()) {
  45972. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  45973. }
  45974. else {
  45975. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  45976. }
  45977. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  45978. return this;
  45979. };
  45980. /**
  45981. * Prepares the list of defines specific to the light type.
  45982. * @param defines the list of defines
  45983. * @param lightIndex defines the index of the light for the effect
  45984. */
  45985. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45986. defines["POINTLIGHT" + lightIndex] = true;
  45987. };
  45988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45990. ], PointLight.prototype, "shadowAngle", null);
  45991. return PointLight;
  45992. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45993. /***/ }),
  45994. /***/ "./Lights/shadowLight.ts":
  45995. /*!*******************************!*\
  45996. !*** ./Lights/shadowLight.ts ***!
  45997. \*******************************/
  45998. /*! exports provided: ShadowLight */
  45999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46000. "use strict";
  46001. __webpack_require__.r(__webpack_exports__);
  46002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  46003. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46004. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46006. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46007. /**
  46008. * Base implementation IShadowLight
  46009. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  46010. */
  46011. var ShadowLight = /** @class */ (function (_super) {
  46012. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  46013. function ShadowLight() {
  46014. var _this = _super !== null && _super.apply(this, arguments) || this;
  46015. _this._needProjectionMatrixCompute = true;
  46016. return _this;
  46017. }
  46018. ShadowLight.prototype._setPosition = function (value) {
  46019. this._position = value;
  46020. };
  46021. Object.defineProperty(ShadowLight.prototype, "position", {
  46022. /**
  46023. * Sets the position the shadow will be casted from. Also use as the light position for both
  46024. * point and spot lights.
  46025. */
  46026. get: function () {
  46027. return this._position;
  46028. },
  46029. /**
  46030. * Sets the position the shadow will be casted from. Also use as the light position for both
  46031. * point and spot lights.
  46032. */
  46033. set: function (value) {
  46034. this._setPosition(value);
  46035. },
  46036. enumerable: true,
  46037. configurable: true
  46038. });
  46039. ShadowLight.prototype._setDirection = function (value) {
  46040. this._direction = value;
  46041. };
  46042. Object.defineProperty(ShadowLight.prototype, "direction", {
  46043. /**
  46044. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  46045. * Also use as the light direction on spot and directional lights.
  46046. */
  46047. get: function () {
  46048. return this._direction;
  46049. },
  46050. /**
  46051. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  46052. * Also use as the light direction on spot and directional lights.
  46053. */
  46054. set: function (value) {
  46055. this._setDirection(value);
  46056. },
  46057. enumerable: true,
  46058. configurable: true
  46059. });
  46060. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  46061. /**
  46062. * Gets the shadow projection clipping minimum z value.
  46063. */
  46064. get: function () {
  46065. return this._shadowMinZ;
  46066. },
  46067. /**
  46068. * Sets the shadow projection clipping minimum z value.
  46069. */
  46070. set: function (value) {
  46071. this._shadowMinZ = value;
  46072. this.forceProjectionMatrixCompute();
  46073. },
  46074. enumerable: true,
  46075. configurable: true
  46076. });
  46077. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  46078. /**
  46079. * Sets the shadow projection clipping maximum z value.
  46080. */
  46081. get: function () {
  46082. return this._shadowMaxZ;
  46083. },
  46084. /**
  46085. * Gets the shadow projection clipping maximum z value.
  46086. */
  46087. set: function (value) {
  46088. this._shadowMaxZ = value;
  46089. this.forceProjectionMatrixCompute();
  46090. },
  46091. enumerable: true,
  46092. configurable: true
  46093. });
  46094. /**
  46095. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  46096. * @returns true if the information has been computed, false if it does not need to (no parenting)
  46097. */
  46098. ShadowLight.prototype.computeTransformedInformation = function () {
  46099. if (this.parent && this.parent.getWorldMatrix) {
  46100. if (!this.transformedPosition) {
  46101. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46102. }
  46103. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  46104. // In case the direction is present.
  46105. if (this.direction) {
  46106. if (!this.transformedDirection) {
  46107. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46108. }
  46109. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  46110. }
  46111. return true;
  46112. }
  46113. return false;
  46114. };
  46115. /**
  46116. * Return the depth scale used for the shadow map.
  46117. * @returns the depth scale.
  46118. */
  46119. ShadowLight.prototype.getDepthScale = function () {
  46120. return 50.0;
  46121. };
  46122. /**
  46123. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  46124. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46125. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46126. */
  46127. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  46128. return this.transformedDirection ? this.transformedDirection : this.direction;
  46129. };
  46130. /**
  46131. * Returns the ShadowLight absolute position in the World.
  46132. * @returns the position vector in world space
  46133. */
  46134. ShadowLight.prototype.getAbsolutePosition = function () {
  46135. return this.transformedPosition ? this.transformedPosition : this.position;
  46136. };
  46137. /**
  46138. * Sets the ShadowLight direction toward the passed target.
  46139. * @param target The point tot target in local space
  46140. * @returns the updated ShadowLight direction
  46141. */
  46142. ShadowLight.prototype.setDirectionToTarget = function (target) {
  46143. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  46144. return this.direction;
  46145. };
  46146. /**
  46147. * Returns the light rotation in euler definition.
  46148. * @returns the x y z rotation in local space.
  46149. */
  46150. ShadowLight.prototype.getRotation = function () {
  46151. this.direction.normalize();
  46152. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  46153. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  46154. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  46155. };
  46156. /**
  46157. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  46158. * @returns true if a cube texture needs to be use
  46159. */
  46160. ShadowLight.prototype.needCube = function () {
  46161. return false;
  46162. };
  46163. /**
  46164. * Detects if the projection matrix requires to be recomputed this frame.
  46165. * @returns true if it requires to be recomputed otherwise, false.
  46166. */
  46167. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  46168. return this._needProjectionMatrixCompute;
  46169. };
  46170. /**
  46171. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  46172. */
  46173. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  46174. this._needProjectionMatrixCompute = true;
  46175. };
  46176. /** @hidden */
  46177. ShadowLight.prototype._initCache = function () {
  46178. _super.prototype._initCache.call(this);
  46179. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46180. };
  46181. /** @hidden */
  46182. ShadowLight.prototype._isSynchronized = function () {
  46183. if (!this._cache.position.equals(this.position)) {
  46184. return false;
  46185. }
  46186. return true;
  46187. };
  46188. /**
  46189. * Computes the world matrix of the node
  46190. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46191. * @returns the world matrix
  46192. */
  46193. ShadowLight.prototype.computeWorldMatrix = function (force) {
  46194. if (!force && this.isSynchronized()) {
  46195. this._currentRenderId = this.getScene().getRenderId();
  46196. return this._worldMatrix;
  46197. }
  46198. this._updateCache();
  46199. this._cache.position.copyFrom(this.position);
  46200. if (!this._worldMatrix) {
  46201. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46202. }
  46203. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  46204. if (this.parent && this.parent.getWorldMatrix) {
  46205. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  46206. this._markSyncedWithParent();
  46207. }
  46208. // Cache the determinant
  46209. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  46210. return this._worldMatrix;
  46211. };
  46212. /**
  46213. * Gets the minZ used for shadow according to both the scene and the light.
  46214. * @param activeCamera The camera we are returning the min for
  46215. * @returns the depth min z
  46216. */
  46217. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  46218. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  46219. };
  46220. /**
  46221. * Gets the maxZ used for shadow according to both the scene and the light.
  46222. * @param activeCamera The camera we are returning the max for
  46223. * @returns the depth max z
  46224. */
  46225. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  46226. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  46227. };
  46228. /**
  46229. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  46230. * @param matrix The materix to updated with the projection information
  46231. * @param viewMatrix The transform matrix of the light
  46232. * @param renderList The list of mesh to render in the map
  46233. * @returns The current light
  46234. */
  46235. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46236. if (this.customProjectionMatrixBuilder) {
  46237. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  46238. }
  46239. else {
  46240. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46241. }
  46242. return this;
  46243. };
  46244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46246. ], ShadowLight.prototype, "position", null);
  46247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46249. ], ShadowLight.prototype, "direction", null);
  46250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46252. ], ShadowLight.prototype, "shadowMinZ", null);
  46253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46255. ], ShadowLight.prototype, "shadowMaxZ", null);
  46256. return ShadowLight;
  46257. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  46258. /***/ }),
  46259. /***/ "./Lights/spotLight.ts":
  46260. /*!*****************************!*\
  46261. !*** ./Lights/spotLight.ts ***!
  46262. \*****************************/
  46263. /*! exports provided: SpotLight */
  46264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46265. "use strict";
  46266. __webpack_require__.r(__webpack_exports__);
  46267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  46268. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46269. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46270. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46271. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46272. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46273. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46274. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  46275. 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); };
  46276. });
  46277. /**
  46278. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46279. * These values define a cone of light starting from the position, emitting toward the direction.
  46280. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46281. * and the exponent defines the speed of the decay of the light with distance (reach).
  46282. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46283. */
  46284. var SpotLight = /** @class */ (function (_super) {
  46285. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  46286. /**
  46287. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46288. * It can cast shadows.
  46289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46290. * @param name The light friendly name
  46291. * @param position The position of the spot light in the scene
  46292. * @param direction The direction of the light in the scene
  46293. * @param angle The cone angle of the light in Radians
  46294. * @param exponent The light decay speed with the distance from the emission spot
  46295. * @param scene The scene the lights belongs to
  46296. */
  46297. function SpotLight(name, position, direction, angle, exponent, scene) {
  46298. var _this = _super.call(this, name, scene) || this;
  46299. _this._innerAngle = 0;
  46300. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46301. _this._projectionTextureLightNear = 1e-6;
  46302. _this._projectionTextureLightFar = 1000.0;
  46303. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46304. _this._projectionTextureViewLightDirty = true;
  46305. _this._projectionTextureProjectionLightDirty = true;
  46306. _this._projectionTextureDirty = true;
  46307. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46308. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46309. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46310. _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);
  46311. _this.position = position;
  46312. _this.direction = direction;
  46313. _this.angle = angle;
  46314. _this.exponent = exponent;
  46315. return _this;
  46316. }
  46317. Object.defineProperty(SpotLight.prototype, "angle", {
  46318. /**
  46319. * Gets the cone angle of the spot light in Radians.
  46320. */
  46321. get: function () {
  46322. return this._angle;
  46323. },
  46324. /**
  46325. * Sets the cone angle of the spot light in Radians.
  46326. */
  46327. set: function (value) {
  46328. this._angle = value;
  46329. this._cosHalfAngle = Math.cos(value * 0.5);
  46330. this._projectionTextureProjectionLightDirty = true;
  46331. this.forceProjectionMatrixCompute();
  46332. this._computeAngleValues();
  46333. },
  46334. enumerable: true,
  46335. configurable: true
  46336. });
  46337. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  46338. /**
  46339. * Only used in gltf falloff mode, this defines the angle where
  46340. * the directional falloff will start before cutting at angle which could be seen
  46341. * as outer angle.
  46342. */
  46343. get: function () {
  46344. return this._innerAngle;
  46345. },
  46346. /**
  46347. * Only used in gltf falloff mode, this defines the angle where
  46348. * the directional falloff will start before cutting at angle which could be seen
  46349. * as outer angle.
  46350. */
  46351. set: function (value) {
  46352. this._innerAngle = value;
  46353. this._computeAngleValues();
  46354. },
  46355. enumerable: true,
  46356. configurable: true
  46357. });
  46358. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  46359. /**
  46360. * Allows scaling the angle of the light for shadow generation only.
  46361. */
  46362. get: function () {
  46363. return this._shadowAngleScale;
  46364. },
  46365. /**
  46366. * Allows scaling the angle of the light for shadow generation only.
  46367. */
  46368. set: function (value) {
  46369. this._shadowAngleScale = value;
  46370. this.forceProjectionMatrixCompute();
  46371. },
  46372. enumerable: true,
  46373. configurable: true
  46374. });
  46375. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  46376. /**
  46377. * Allows reading the projecton texture
  46378. */
  46379. get: function () {
  46380. return this._projectionTextureMatrix;
  46381. },
  46382. enumerable: true,
  46383. configurable: true
  46384. });
  46385. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  46386. /**
  46387. * Gets the near clip of the Spotlight for texture projection.
  46388. */
  46389. get: function () {
  46390. return this._projectionTextureLightNear;
  46391. },
  46392. /**
  46393. * Sets the near clip of the Spotlight for texture projection.
  46394. */
  46395. set: function (value) {
  46396. this._projectionTextureLightNear = value;
  46397. this._projectionTextureProjectionLightDirty = true;
  46398. },
  46399. enumerable: true,
  46400. configurable: true
  46401. });
  46402. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  46403. /**
  46404. * Gets the far clip of the Spotlight for texture projection.
  46405. */
  46406. get: function () {
  46407. return this._projectionTextureLightFar;
  46408. },
  46409. /**
  46410. * Sets the far clip of the Spotlight for texture projection.
  46411. */
  46412. set: function (value) {
  46413. this._projectionTextureLightFar = value;
  46414. this._projectionTextureProjectionLightDirty = true;
  46415. },
  46416. enumerable: true,
  46417. configurable: true
  46418. });
  46419. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  46420. /**
  46421. * Gets the Up vector of the Spotlight for texture projection.
  46422. */
  46423. get: function () {
  46424. return this._projectionTextureUpDirection;
  46425. },
  46426. /**
  46427. * Sets the Up vector of the Spotlight for texture projection.
  46428. */
  46429. set: function (value) {
  46430. this._projectionTextureUpDirection = value;
  46431. this._projectionTextureProjectionLightDirty = true;
  46432. },
  46433. enumerable: true,
  46434. configurable: true
  46435. });
  46436. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  46437. /**
  46438. * Gets the projection texture of the light.
  46439. */
  46440. get: function () {
  46441. return this._projectionTexture;
  46442. },
  46443. /**
  46444. * Sets the projection texture of the light.
  46445. */
  46446. set: function (value) {
  46447. this._projectionTexture = value;
  46448. this._projectionTextureDirty = true;
  46449. },
  46450. enumerable: true,
  46451. configurable: true
  46452. });
  46453. /**
  46454. * Returns the string "SpotLight".
  46455. * @returns the class name
  46456. */
  46457. SpotLight.prototype.getClassName = function () {
  46458. return "SpotLight";
  46459. };
  46460. /**
  46461. * Returns the integer 2.
  46462. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46463. */
  46464. SpotLight.prototype.getTypeID = function () {
  46465. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  46466. };
  46467. /**
  46468. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46469. */
  46470. SpotLight.prototype._setDirection = function (value) {
  46471. _super.prototype._setDirection.call(this, value);
  46472. this._projectionTextureViewLightDirty = true;
  46473. };
  46474. /**
  46475. * Overrides the position setter to recompute the projection texture view light Matrix.
  46476. */
  46477. SpotLight.prototype._setPosition = function (value) {
  46478. _super.prototype._setPosition.call(this, value);
  46479. this._projectionTextureViewLightDirty = true;
  46480. };
  46481. /**
  46482. * 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.
  46483. * Returns the SpotLight.
  46484. */
  46485. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46486. var activeCamera = this.getScene().activeCamera;
  46487. if (!activeCamera) {
  46488. return;
  46489. }
  46490. this._shadowAngleScale = this._shadowAngleScale || 1;
  46491. var angle = this._shadowAngleScale * this._angle;
  46492. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46493. };
  46494. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  46495. this._projectionTextureViewLightDirty = false;
  46496. this._projectionTextureDirty = true;
  46497. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  46498. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  46499. };
  46500. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  46501. this._projectionTextureProjectionLightDirty = false;
  46502. this._projectionTextureDirty = true;
  46503. var light_far = this.projectionTextureLightFar;
  46504. var light_near = this.projectionTextureLightNear;
  46505. var P = light_far / (light_far - light_near);
  46506. var Q = -P * light_near;
  46507. var S = 1.0 / Math.tan(this._angle / 2.0);
  46508. var A = 1.0;
  46509. _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);
  46510. };
  46511. /**
  46512. * Main function for light texture projection matrix computing.
  46513. */
  46514. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  46515. this._projectionTextureDirty = false;
  46516. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  46517. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  46518. };
  46519. SpotLight.prototype._buildUniformLayout = function () {
  46520. this._uniformBuffer.addUniform("vLightData", 4);
  46521. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46522. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46523. this._uniformBuffer.addUniform("vLightDirection", 3);
  46524. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46525. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46526. this._uniformBuffer.addUniform("depthValues", 2);
  46527. this._uniformBuffer.create();
  46528. };
  46529. SpotLight.prototype._computeAngleValues = function () {
  46530. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  46531. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  46532. };
  46533. /**
  46534. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46535. * @param effect The effect to update
  46536. * @param lightIndex The index of the light in the effect to update
  46537. * @returns The spot light
  46538. */
  46539. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  46540. var normalizeDirection;
  46541. if (this.computeTransformedInformation()) {
  46542. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  46543. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  46544. }
  46545. else {
  46546. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  46547. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46548. }
  46549. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  46550. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  46551. if (this.projectionTexture && this.projectionTexture.isReady()) {
  46552. if (this._projectionTextureViewLightDirty) {
  46553. this._computeProjectionTextureViewLightMatrix();
  46554. }
  46555. if (this._projectionTextureProjectionLightDirty) {
  46556. this._computeProjectionTextureProjectionLightMatrix();
  46557. }
  46558. if (this._projectionTextureDirty) {
  46559. this._computeProjectionTextureMatrix();
  46560. }
  46561. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  46562. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  46563. }
  46564. return this;
  46565. };
  46566. /**
  46567. * Disposes the light and the associated resources.
  46568. */
  46569. SpotLight.prototype.dispose = function () {
  46570. _super.prototype.dispose.call(this);
  46571. if (this._projectionTexture) {
  46572. this._projectionTexture.dispose();
  46573. }
  46574. };
  46575. /**
  46576. * Prepares the list of defines specific to the light type.
  46577. * @param defines the list of defines
  46578. * @param lightIndex defines the index of the light for the effect
  46579. */
  46580. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46581. defines["SPOTLIGHT" + lightIndex] = true;
  46582. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  46583. };
  46584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46586. ], SpotLight.prototype, "angle", null);
  46587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46589. ], SpotLight.prototype, "innerAngle", null);
  46590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46592. ], SpotLight.prototype, "shadowAngleScale", null);
  46593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46595. ], SpotLight.prototype, "exponent", void 0);
  46596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46598. ], SpotLight.prototype, "projectionTextureLightNear", null);
  46599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46601. ], SpotLight.prototype, "projectionTextureLightFar", null);
  46602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46604. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  46605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  46607. ], SpotLight.prototype, "_projectionTexture", void 0);
  46608. return SpotLight;
  46609. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46610. /***/ }),
  46611. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  46612. /*!**********************************************!*\
  46613. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  46614. \**********************************************/
  46615. /*! exports provided: _BabylonLoaderRegistered */
  46616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46617. "use strict";
  46618. __webpack_require__.r(__webpack_exports__);
  46619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  46620. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  46621. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  46622. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  46623. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  46624. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  46625. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  46626. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  46627. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  46628. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  46629. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  46630. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  46631. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  46632. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  46633. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46634. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  46635. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46636. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  46637. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  46638. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  46639. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  46640. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  46641. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  46642. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  46643. /** @hidden */
  46644. var _BabylonLoaderRegistered = true;
  46645. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  46646. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  46647. var parsedMaterial = parsedData.materials[index];
  46648. if (parsedMaterial.id === id) {
  46649. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  46650. }
  46651. }
  46652. return null;
  46653. };
  46654. var isDescendantOf = function (mesh, names, hierarchyIds) {
  46655. for (var i in names) {
  46656. if (mesh.name === names[i]) {
  46657. hierarchyIds.push(mesh.id);
  46658. return true;
  46659. }
  46660. }
  46661. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  46662. hierarchyIds.push(mesh.id);
  46663. return true;
  46664. }
  46665. return false;
  46666. };
  46667. var logOperation = function (operation, producer) {
  46668. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  46669. };
  46670. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  46671. if (addToScene === void 0) { addToScene = false; }
  46672. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_16__["AssetContainer"](scene);
  46673. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  46674. // when SceneLoader.debugLogging = true (default), or exception encountered.
  46675. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  46676. // and avoid problems with multiple concurrent .babylon loads.
  46677. var log = "importScene has failed JSON parse";
  46678. try {
  46679. var parsedData = JSON.parse(data);
  46680. log = "";
  46681. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  46682. var index;
  46683. var cache;
  46684. // Lights
  46685. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  46686. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  46687. var parsedLight = parsedData.lights[index];
  46688. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_12__["Light"].Parse(parsedLight, scene);
  46689. if (light) {
  46690. container.lights.push(light);
  46691. log += (index === 0 ? "\n\tLights:" : "");
  46692. log += "\n\t\t" + light.toString(fullDetails);
  46693. }
  46694. }
  46695. }
  46696. // Reflection probes
  46697. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  46698. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  46699. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  46700. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  46701. if (reflectionProbe) {
  46702. container.reflectionProbes.push(reflectionProbe);
  46703. log += (index === 0 ? "\n\tReflection Probes:" : "");
  46704. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  46705. }
  46706. }
  46707. }
  46708. // Animations
  46709. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  46710. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  46711. var parsedAnimation = parsedData.animations[index];
  46712. var animation = _Animations_animation__WEBPACK_IMPORTED_MODULE_10__["Animation"].Parse(parsedAnimation);
  46713. scene.animations.push(animation);
  46714. container.animations.push(animation);
  46715. log += (index === 0 ? "\n\tAnimations:" : "");
  46716. log += "\n\t\t" + animation.toString(fullDetails);
  46717. }
  46718. }
  46719. // Materials
  46720. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  46721. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  46722. var parsedMaterial = parsedData.materials[index];
  46723. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  46724. container.materials.push(mat);
  46725. log += (index === 0 ? "\n\tMaterials:" : "");
  46726. log += "\n\t\t" + mat.toString(fullDetails);
  46727. }
  46728. }
  46729. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  46730. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  46731. var parsedMultiMaterial = parsedData.multiMaterials[index];
  46732. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  46733. container.multiMaterials.push(mmat);
  46734. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  46735. log += "\n\t\t" + mmat.toString(fullDetails);
  46736. }
  46737. }
  46738. // Morph targets
  46739. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  46740. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  46741. var managerData = _a[_i];
  46742. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene));
  46743. }
  46744. }
  46745. // Skeletons
  46746. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  46747. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  46748. var parsedSkeleton = parsedData.skeletons[index];
  46749. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  46750. container.skeletons.push(skeleton);
  46751. log += (index === 0 ? "\n\tSkeletons:" : "");
  46752. log += "\n\t\t" + skeleton.toString(fullDetails);
  46753. }
  46754. }
  46755. // Geometries
  46756. var geometries = parsedData.geometries;
  46757. if (geometries !== undefined && geometries !== null) {
  46758. var addedGeometry = new Array();
  46759. // Boxes
  46760. var boxes = geometries.boxes;
  46761. if (boxes !== undefined && boxes !== null) {
  46762. for (index = 0, cache = boxes.length; index < cache; index++) {
  46763. var parsedBox = boxes[index];
  46764. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedBox, scene));
  46765. }
  46766. }
  46767. // Spheres
  46768. var spheres = geometries.spheres;
  46769. if (spheres !== undefined && spheres !== null) {
  46770. for (index = 0, cache = spheres.length; index < cache; index++) {
  46771. var parsedSphere = spheres[index];
  46772. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedSphere, scene));
  46773. }
  46774. }
  46775. // Cylinders
  46776. var cylinders = geometries.cylinders;
  46777. if (cylinders !== undefined && cylinders !== null) {
  46778. for (index = 0, cache = cylinders.length; index < cache; index++) {
  46779. var parsedCylinder = cylinders[index];
  46780. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedCylinder, scene));
  46781. }
  46782. }
  46783. // Toruses
  46784. var toruses = geometries.toruses;
  46785. if (toruses !== undefined && toruses !== null) {
  46786. for (index = 0, cache = toruses.length; index < cache; index++) {
  46787. var parsedTorus = toruses[index];
  46788. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedTorus, scene));
  46789. }
  46790. }
  46791. // Grounds
  46792. var grounds = geometries.grounds;
  46793. if (grounds !== undefined && grounds !== null) {
  46794. for (index = 0, cache = grounds.length; index < cache; index++) {
  46795. var parsedGround = grounds[index];
  46796. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGround, scene));
  46797. }
  46798. }
  46799. // Planes
  46800. var planes = geometries.planes;
  46801. if (planes !== undefined && planes !== null) {
  46802. for (index = 0, cache = planes.length; index < cache; index++) {
  46803. var parsedPlane = planes[index];
  46804. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedPlane, scene));
  46805. }
  46806. }
  46807. // TorusKnots
  46808. var torusKnots = geometries.torusKnots;
  46809. if (torusKnots !== undefined && torusKnots !== null) {
  46810. for (index = 0, cache = torusKnots.length; index < cache; index++) {
  46811. var parsedTorusKnot = torusKnots[index];
  46812. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedTorusKnot, scene));
  46813. }
  46814. }
  46815. // VertexData
  46816. var vertexData = geometries.vertexData;
  46817. if (vertexData !== undefined && vertexData !== null) {
  46818. for (index = 0, cache = vertexData.length; index < cache; index++) {
  46819. var parsedVertexData = vertexData[index];
  46820. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  46821. }
  46822. }
  46823. addedGeometry.forEach(function (g) {
  46824. if (g) {
  46825. container.geometries.push(g);
  46826. }
  46827. });
  46828. }
  46829. // Transform nodes
  46830. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  46831. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  46832. var parsedTransformNode = parsedData.transformNodes[index];
  46833. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  46834. container.transformNodes.push(node);
  46835. }
  46836. }
  46837. // Meshes
  46838. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  46839. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  46840. var parsedMesh = parsedData.meshes[index];
  46841. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  46842. container.meshes.push(mesh);
  46843. log += (index === 0 ? "\n\tMeshes:" : "");
  46844. log += "\n\t\t" + mesh.toString(fullDetails);
  46845. }
  46846. }
  46847. // Cameras
  46848. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  46849. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  46850. var parsedCamera = parsedData.cameras[index];
  46851. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  46852. container.cameras.push(camera);
  46853. log += (index === 0 ? "\n\tCameras:" : "");
  46854. log += "\n\t\t" + camera.toString(fullDetails);
  46855. }
  46856. }
  46857. // Animation Groups
  46858. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  46859. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  46860. var parsedAnimationGroup = parsedData.animationGroups[index];
  46861. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  46862. container.animationGroups.push(animationGroup);
  46863. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  46864. log += "\n\t\t" + animationGroup.toString(fullDetails);
  46865. }
  46866. }
  46867. // Browsing all the graph to connect the dots
  46868. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  46869. var camera = scene.cameras[index];
  46870. if (camera._waitingParentId) {
  46871. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  46872. camera._waitingParentId = null;
  46873. }
  46874. }
  46875. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  46876. var light_1 = scene.lights[index];
  46877. if (light_1 && light_1._waitingParentId) {
  46878. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  46879. light_1._waitingParentId = null;
  46880. }
  46881. }
  46882. // Connect parents & children and parse actions
  46883. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  46884. var transformNode = scene.transformNodes[index];
  46885. if (transformNode._waitingParentId) {
  46886. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  46887. transformNode._waitingParentId = null;
  46888. }
  46889. }
  46890. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  46891. var mesh = scene.meshes[index];
  46892. if (mesh._waitingParentId) {
  46893. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  46894. mesh._waitingParentId = null;
  46895. }
  46896. }
  46897. // freeze world matrix application
  46898. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  46899. var currentMesh = scene.meshes[index];
  46900. if (currentMesh._waitingFreezeWorldMatrix) {
  46901. currentMesh.freezeWorldMatrix();
  46902. currentMesh._waitingFreezeWorldMatrix = null;
  46903. }
  46904. else {
  46905. currentMesh.computeWorldMatrix(true);
  46906. }
  46907. }
  46908. // Lights exclusions / inclusions
  46909. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  46910. var light_2 = scene.lights[index];
  46911. // Excluded check
  46912. if (light_2._excludedMeshesIds.length > 0) {
  46913. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  46914. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  46915. if (excludedMesh) {
  46916. light_2.excludedMeshes.push(excludedMesh);
  46917. }
  46918. }
  46919. light_2._excludedMeshesIds = [];
  46920. }
  46921. // Included check
  46922. if (light_2._includedOnlyMeshesIds.length > 0) {
  46923. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  46924. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  46925. if (includedOnlyMesh) {
  46926. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  46927. }
  46928. }
  46929. light_2._includedOnlyMeshesIds = [];
  46930. }
  46931. }
  46932. _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  46933. // Actions (scene) Done last as it can access other objects.
  46934. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  46935. var mesh = scene.meshes[index];
  46936. if (mesh._waitingActions) {
  46937. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  46938. mesh._waitingActions = null;
  46939. }
  46940. }
  46941. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  46942. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(parsedData.actions, null, scene);
  46943. }
  46944. if (!addToScene) {
  46945. container.removeAllFromScene();
  46946. }
  46947. }
  46948. catch (err) {
  46949. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  46950. if (onError) {
  46951. onError(msg, err);
  46952. }
  46953. else {
  46954. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  46955. throw err;
  46956. }
  46957. }
  46958. finally {
  46959. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  46960. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  46961. }
  46962. }
  46963. return container;
  46964. };
  46965. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].RegisterPlugin({
  46966. name: "babylon.js",
  46967. extensions: ".babylon",
  46968. canDirectLoad: function (data) {
  46969. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  46970. return true;
  46971. }
  46972. return false;
  46973. },
  46974. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  46975. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  46976. // when SceneLoader.debugLogging = true (default), or exception encountered.
  46977. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  46978. // and avoid problems with multiple concurrent .babylon loads.
  46979. var log = "importMesh has failed JSON parse";
  46980. try {
  46981. var parsedData = JSON.parse(data);
  46982. log = "";
  46983. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  46984. if (!meshesNames) {
  46985. meshesNames = null;
  46986. }
  46987. else if (!Array.isArray(meshesNames)) {
  46988. meshesNames = [meshesNames];
  46989. }
  46990. var hierarchyIds = new Array();
  46991. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  46992. var loadedSkeletonsIds = [];
  46993. var loadedMaterialsIds = [];
  46994. var index;
  46995. var cache;
  46996. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  46997. var parsedMesh = parsedData.meshes[index];
  46998. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  46999. if (meshesNames !== null) {
  47000. // Remove found mesh name from list.
  47001. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  47002. }
  47003. //Geometry?
  47004. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  47005. //does the file contain geometries?
  47006. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  47007. //find the correct geometry and add it to the scene
  47008. var found = false;
  47009. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  47010. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  47011. return;
  47012. }
  47013. else {
  47014. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  47015. if (parsedGeometryData.id === parsedMesh.geometryId) {
  47016. switch (geometryType) {
  47017. case "boxes":
  47018. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedGeometryData, scene);
  47019. break;
  47020. case "spheres":
  47021. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedGeometryData, scene);
  47022. break;
  47023. case "cylinders":
  47024. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedGeometryData, scene);
  47025. break;
  47026. case "toruses":
  47027. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedGeometryData, scene);
  47028. break;
  47029. case "grounds":
  47030. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGeometryData, scene);
  47031. break;
  47032. case "planes":
  47033. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedGeometryData, scene);
  47034. break;
  47035. case "torusKnots":
  47036. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedGeometryData, scene);
  47037. break;
  47038. case "vertexData":
  47039. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  47040. break;
  47041. }
  47042. found = true;
  47043. }
  47044. });
  47045. }
  47046. });
  47047. if (found === false) {
  47048. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  47049. }
  47050. }
  47051. }
  47052. // Material ?
  47053. if (parsedMesh.materialId) {
  47054. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  47055. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47056. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  47057. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  47058. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  47059. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  47060. var subMatId = parsedMultiMaterial.materials[matIndex];
  47061. loadedMaterialsIds.push(subMatId);
  47062. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  47063. if (mat) {
  47064. log += "\n\tMaterial " + mat.toString(fullDetails);
  47065. }
  47066. }
  47067. loadedMaterialsIds.push(parsedMultiMaterial.id);
  47068. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47069. if (mmat) {
  47070. materialFound = true;
  47071. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  47072. }
  47073. break;
  47074. }
  47075. }
  47076. }
  47077. if (materialFound === false) {
  47078. loadedMaterialsIds.push(parsedMesh.materialId);
  47079. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  47080. if (!mat) {
  47081. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  47082. }
  47083. else {
  47084. log += "\n\tMaterial " + mat.toString(fullDetails);
  47085. }
  47086. }
  47087. }
  47088. // Skeleton ?
  47089. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47090. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  47091. if (skeletonAlreadyLoaded === false) {
  47092. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  47093. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  47094. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  47095. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  47096. skeletons.push(skeleton);
  47097. loadedSkeletonsIds.push(parsedSkeleton.id);
  47098. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  47099. }
  47100. }
  47101. }
  47102. }
  47103. // Morph targets ?
  47104. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47105. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47106. var managerData = _a[_i];
  47107. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene);
  47108. }
  47109. }
  47110. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47111. meshes.push(mesh);
  47112. log += "\n\tMesh " + mesh.toString(fullDetails);
  47113. }
  47114. }
  47115. // Connecting parents
  47116. var currentMesh;
  47117. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47118. currentMesh = scene.meshes[index];
  47119. if (currentMesh._waitingParentId) {
  47120. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  47121. currentMesh._waitingParentId = null;
  47122. }
  47123. }
  47124. // freeze and compute world matrix application
  47125. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47126. currentMesh = scene.meshes[index];
  47127. if (currentMesh._waitingFreezeWorldMatrix) {
  47128. currentMesh.freezeWorldMatrix();
  47129. currentMesh._waitingFreezeWorldMatrix = null;
  47130. }
  47131. else {
  47132. currentMesh.computeWorldMatrix(true);
  47133. }
  47134. }
  47135. }
  47136. // Particles
  47137. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  47138. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_13__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  47139. if (parser) {
  47140. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  47141. var parsedParticleSystem = parsedData.particleSystems[index];
  47142. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  47143. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  47144. }
  47145. }
  47146. }
  47147. }
  47148. return true;
  47149. }
  47150. catch (err) {
  47151. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  47152. if (onError) {
  47153. onError(msg, err);
  47154. }
  47155. else {
  47156. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47157. throw err;
  47158. }
  47159. }
  47160. finally {
  47161. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47162. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47163. }
  47164. }
  47165. return false;
  47166. },
  47167. load: function (scene, data, rootUrl, onError) {
  47168. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47169. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47170. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47171. // and avoid problems with multiple concurrent .babylon loads.
  47172. var log = "importScene has failed JSON parse";
  47173. try {
  47174. var parsedData = JSON.parse(data);
  47175. log = "";
  47176. // Scene
  47177. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  47178. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  47179. }
  47180. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  47181. scene.autoClear = parsedData.autoClear;
  47182. }
  47183. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  47184. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  47185. }
  47186. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  47187. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  47188. }
  47189. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  47190. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  47191. }
  47192. // Fog
  47193. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  47194. scene.fogMode = parsedData.fogMode;
  47195. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  47196. scene.fogStart = parsedData.fogStart;
  47197. scene.fogEnd = parsedData.fogEnd;
  47198. scene.fogDensity = parsedData.fogDensity;
  47199. log += "\tFog mode for scene: ";
  47200. switch (scene.fogMode) {
  47201. // getters not compiling, so using hardcoded
  47202. case 1:
  47203. log += "exp\n";
  47204. break;
  47205. case 2:
  47206. log += "exp2\n";
  47207. break;
  47208. case 3:
  47209. log += "linear\n";
  47210. break;
  47211. }
  47212. }
  47213. //Physics
  47214. if (parsedData.physicsEnabled) {
  47215. var physicsPlugin;
  47216. if (parsedData.physicsEngine === "cannon") {
  47217. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__["CannonJSPlugin"]();
  47218. }
  47219. else if (parsedData.physicsEngine === "oimo") {
  47220. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["OimoJSPlugin"]();
  47221. }
  47222. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  47223. //else - default engine, which is currently oimo
  47224. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  47225. scene.enablePhysics(physicsGravity, physicsPlugin);
  47226. }
  47227. // Metadata
  47228. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  47229. scene.metadata = parsedData.metadata;
  47230. }
  47231. //collisions, if defined. otherwise, default is true
  47232. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  47233. scene.collisionsEnabled = parsedData.collisionsEnabled;
  47234. }
  47235. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  47236. if (!container) {
  47237. return false;
  47238. }
  47239. if (parsedData.autoAnimate) {
  47240. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  47241. }
  47242. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  47243. scene.setActiveCameraByID(parsedData.activeCameraID);
  47244. }
  47245. // Environment texture
  47246. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  47247. // PBR needed for both HDR texture (gamma space) & a sky box
  47248. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  47249. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  47250. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  47251. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  47252. if (parsedData.environmentTextureRotationY) {
  47253. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  47254. }
  47255. scene.environmentTexture = hdrTexture;
  47256. }
  47257. else {
  47258. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  47259. if (parsedData.environmentTextureRotationY) {
  47260. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  47261. }
  47262. scene.environmentTexture = cubeTexture;
  47263. }
  47264. if (parsedData.createDefaultSkybox === true) {
  47265. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  47266. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  47267. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  47268. }
  47269. }
  47270. // Finish
  47271. return true;
  47272. }
  47273. catch (err) {
  47274. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  47275. if (onError) {
  47276. onError(msg, err);
  47277. }
  47278. else {
  47279. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47280. throw err;
  47281. }
  47282. }
  47283. finally {
  47284. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47285. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47286. }
  47287. }
  47288. return false;
  47289. },
  47290. loadAssetContainer: function (scene, data, rootUrl, onError) {
  47291. var container = loadAssetContainer(scene, data, rootUrl, onError);
  47292. return container;
  47293. }
  47294. });
  47295. /***/ }),
  47296. /***/ "./Loading/Plugins/index.ts":
  47297. /*!**********************************!*\
  47298. !*** ./Loading/Plugins/index.ts ***!
  47299. \**********************************/
  47300. /*! exports provided: _BabylonLoaderRegistered */
  47301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47302. "use strict";
  47303. __webpack_require__.r(__webpack_exports__);
  47304. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  47305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  47306. /***/ }),
  47307. /***/ "./Loading/index.ts":
  47308. /*!**************************!*\
  47309. !*** ./Loading/index.ts ***!
  47310. \**************************/
  47311. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  47312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47313. "use strict";
  47314. __webpack_require__.r(__webpack_exports__);
  47315. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  47316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  47317. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  47318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  47319. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  47320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  47321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  47322. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  47324. /***/ }),
  47325. /***/ "./Loading/loadingScreen.ts":
  47326. /*!**********************************!*\
  47327. !*** ./Loading/loadingScreen.ts ***!
  47328. \**********************************/
  47329. /*! exports provided: DefaultLoadingScreen */
  47330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47331. "use strict";
  47332. __webpack_require__.r(__webpack_exports__);
  47333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  47334. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47335. /**
  47336. * Class used for the default loading screen
  47337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  47338. */
  47339. var DefaultLoadingScreen = /** @class */ (function () {
  47340. /**
  47341. * Creates a new default loading screen
  47342. * @param _renderingCanvas defines the canvas used to render the scene
  47343. * @param _loadingText defines the default text to display
  47344. * @param _loadingDivBackgroundColor defines the default background color
  47345. */
  47346. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  47347. if (_loadingText === void 0) { _loadingText = ""; }
  47348. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  47349. var _this = this;
  47350. this._renderingCanvas = _renderingCanvas;
  47351. this._loadingText = _loadingText;
  47352. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  47353. // Resize
  47354. this._resizeLoadingUI = function () {
  47355. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  47356. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  47357. if (!_this._loadingDiv) {
  47358. return;
  47359. }
  47360. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  47361. _this._loadingDiv.style.left = canvasRect.left + "px";
  47362. _this._loadingDiv.style.top = canvasRect.top + "px";
  47363. _this._loadingDiv.style.width = canvasRect.width + "px";
  47364. _this._loadingDiv.style.height = canvasRect.height + "px";
  47365. };
  47366. }
  47367. /**
  47368. * Function called to display the loading screen
  47369. */
  47370. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  47371. if (this._loadingDiv) {
  47372. // Do not add a loading screen if there is already one
  47373. return;
  47374. }
  47375. this._loadingDiv = document.createElement("div");
  47376. this._loadingDiv.id = "babylonjsLoadingDiv";
  47377. this._loadingDiv.style.opacity = "0";
  47378. this._loadingDiv.style.transition = "opacity 1.5s ease";
  47379. this._loadingDiv.style.pointerEvents = "none";
  47380. // Loading text
  47381. this._loadingTextDiv = document.createElement("div");
  47382. this._loadingTextDiv.style.position = "absolute";
  47383. this._loadingTextDiv.style.left = "0";
  47384. this._loadingTextDiv.style.top = "50%";
  47385. this._loadingTextDiv.style.marginTop = "80px";
  47386. this._loadingTextDiv.style.width = "100%";
  47387. this._loadingTextDiv.style.height = "20px";
  47388. this._loadingTextDiv.style.fontFamily = "Arial";
  47389. this._loadingTextDiv.style.fontSize = "14px";
  47390. this._loadingTextDiv.style.color = "white";
  47391. this._loadingTextDiv.style.textAlign = "center";
  47392. this._loadingTextDiv.innerHTML = "Loading";
  47393. this._loadingDiv.appendChild(this._loadingTextDiv);
  47394. //set the predefined text
  47395. this._loadingTextDiv.innerHTML = this._loadingText;
  47396. // Generating keyframes
  47397. var style = document.createElement('style');
  47398. style.type = 'text/css';
  47399. 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 }";
  47400. style.innerHTML = keyFrames;
  47401. document.getElementsByTagName('head')[0].appendChild(style);
  47402. // Loading img
  47403. var imgBack = new Image();
  47404. 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";
  47405. imgBack.style.position = "absolute";
  47406. imgBack.style.left = "50%";
  47407. imgBack.style.top = "50%";
  47408. imgBack.style.marginLeft = "-60px";
  47409. imgBack.style.marginTop = "-60px";
  47410. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  47411. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  47412. imgBack.style.transformOrigin = "50% 50%";
  47413. imgBack.style.webkitTransformOrigin = "50% 50%";
  47414. this._loadingDiv.appendChild(imgBack);
  47415. this._resizeLoadingUI();
  47416. window.addEventListener("resize", this._resizeLoadingUI);
  47417. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47418. document.body.appendChild(this._loadingDiv);
  47419. this._loadingDiv.style.opacity = "1";
  47420. };
  47421. /**
  47422. * Function called to hide the loading screen
  47423. */
  47424. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  47425. var _this = this;
  47426. if (!this._loadingDiv) {
  47427. return;
  47428. }
  47429. var onTransitionEnd = function () {
  47430. if (!_this._loadingDiv) {
  47431. return;
  47432. }
  47433. if (_this._loadingDiv.parentElement) {
  47434. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  47435. }
  47436. window.removeEventListener("resize", _this._resizeLoadingUI);
  47437. _this._loadingDiv = null;
  47438. };
  47439. this._loadingDiv.style.opacity = "0";
  47440. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  47441. };
  47442. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  47443. get: function () {
  47444. return this._loadingText;
  47445. },
  47446. /**
  47447. * Gets or sets the text to display while loading
  47448. */
  47449. set: function (text) {
  47450. this._loadingText = text;
  47451. if (this._loadingTextDiv) {
  47452. this._loadingTextDiv.innerHTML = this._loadingText;
  47453. }
  47454. },
  47455. enumerable: true,
  47456. configurable: true
  47457. });
  47458. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  47459. /**
  47460. * Gets or sets the color to use for the background
  47461. */
  47462. get: function () {
  47463. return this._loadingDivBackgroundColor;
  47464. },
  47465. set: function (color) {
  47466. this._loadingDivBackgroundColor = color;
  47467. if (!this._loadingDiv) {
  47468. return;
  47469. }
  47470. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47471. },
  47472. enumerable: true,
  47473. configurable: true
  47474. });
  47475. return DefaultLoadingScreen;
  47476. }());
  47477. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  47478. /***/ }),
  47479. /***/ "./Loading/sceneLoader.ts":
  47480. /*!********************************!*\
  47481. !*** ./Loading/sceneLoader.ts ***!
  47482. \********************************/
  47483. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  47484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47485. "use strict";
  47486. __webpack_require__.r(__webpack_exports__);
  47487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  47488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  47489. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  47490. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  47491. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  47492. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  47493. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47494. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  47495. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  47496. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  47497. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47498. /**
  47499. * Class used to represent data loading progression
  47500. */
  47501. var SceneLoaderProgressEvent = /** @class */ (function () {
  47502. /**
  47503. * Create a new progress event
  47504. * @param lengthComputable defines if data length to load can be evaluated
  47505. * @param loaded defines the loaded data length
  47506. * @param total defines the data length to load
  47507. */
  47508. function SceneLoaderProgressEvent(
  47509. /** defines if data length to load can be evaluated */
  47510. lengthComputable,
  47511. /** defines the loaded data length */
  47512. loaded,
  47513. /** defines the data length to load */
  47514. total) {
  47515. this.lengthComputable = lengthComputable;
  47516. this.loaded = loaded;
  47517. this.total = total;
  47518. }
  47519. /**
  47520. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  47521. * @param event defines the source event
  47522. * @returns a new SceneLoaderProgressEvent
  47523. */
  47524. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  47525. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  47526. };
  47527. return SceneLoaderProgressEvent;
  47528. }());
  47529. /**
  47530. * Class used to load scene from various file formats using registered plugins
  47531. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  47532. */
  47533. var SceneLoader = /** @class */ (function () {
  47534. function SceneLoader() {
  47535. }
  47536. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  47537. /**
  47538. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47539. */
  47540. get: function () {
  47541. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  47542. },
  47543. set: function (value) {
  47544. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  47545. },
  47546. enumerable: true,
  47547. configurable: true
  47548. });
  47549. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  47550. /**
  47551. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47552. */
  47553. get: function () {
  47554. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  47555. },
  47556. set: function (value) {
  47557. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  47558. },
  47559. enumerable: true,
  47560. configurable: true
  47561. });
  47562. Object.defineProperty(SceneLoader, "loggingLevel", {
  47563. /**
  47564. * Defines the current logging level (while loading the scene)
  47565. * @ignorenaming
  47566. */
  47567. get: function () {
  47568. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  47569. },
  47570. set: function (value) {
  47571. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  47572. },
  47573. enumerable: true,
  47574. configurable: true
  47575. });
  47576. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  47577. /**
  47578. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47579. */
  47580. get: function () {
  47581. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  47582. },
  47583. set: function (value) {
  47584. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  47585. },
  47586. enumerable: true,
  47587. configurable: true
  47588. });
  47589. SceneLoader._getDefaultPlugin = function () {
  47590. return SceneLoader._registeredPlugins[".babylon"];
  47591. };
  47592. SceneLoader._getPluginForExtension = function (extension) {
  47593. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  47594. if (registeredPlugin) {
  47595. return registeredPlugin;
  47596. }
  47597. _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");
  47598. return SceneLoader._getDefaultPlugin();
  47599. };
  47600. SceneLoader._getPluginForDirectLoad = function (data) {
  47601. for (var extension in SceneLoader._registeredPlugins) {
  47602. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  47603. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  47604. return SceneLoader._registeredPlugins[extension];
  47605. }
  47606. }
  47607. return SceneLoader._getDefaultPlugin();
  47608. };
  47609. SceneLoader._getPluginForFilename = function (sceneFilename) {
  47610. var queryStringPosition = sceneFilename.indexOf("?");
  47611. if (queryStringPosition !== -1) {
  47612. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  47613. }
  47614. var dotPosition = sceneFilename.lastIndexOf(".");
  47615. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  47616. return SceneLoader._getPluginForExtension(extension);
  47617. };
  47618. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  47619. SceneLoader._getDirectLoad = function (sceneFilename) {
  47620. if (sceneFilename.substr(0, 5) === "data:") {
  47621. return sceneFilename.substr(5);
  47622. }
  47623. return null;
  47624. };
  47625. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  47626. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  47627. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  47628. var plugin;
  47629. if (registeredPlugin.plugin.createPlugin) {
  47630. plugin = registeredPlugin.plugin.createPlugin();
  47631. }
  47632. else {
  47633. plugin = registeredPlugin.plugin;
  47634. }
  47635. var useArrayBuffer = registeredPlugin.isBinary;
  47636. var offlineProvider;
  47637. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  47638. var dataCallback = function (data, responseURL) {
  47639. if (scene.isDisposed) {
  47640. onError("Scene has been disposed");
  47641. return;
  47642. }
  47643. scene.offlineProvider = offlineProvider;
  47644. onSuccess(plugin, data, responseURL);
  47645. };
  47646. var request = null;
  47647. var pluginDisposed = false;
  47648. var onDisposeObservable = plugin.onDisposeObservable;
  47649. if (onDisposeObservable) {
  47650. onDisposeObservable.add(function () {
  47651. pluginDisposed = true;
  47652. if (request) {
  47653. request.abort();
  47654. request = null;
  47655. }
  47656. onDispose();
  47657. });
  47658. }
  47659. var manifestChecked = function () {
  47660. if (pluginDisposed) {
  47661. return;
  47662. }
  47663. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  47664. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  47665. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  47666. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  47667. });
  47668. };
  47669. if (directLoad) {
  47670. dataCallback(directLoad);
  47671. return plugin;
  47672. }
  47673. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  47674. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  47675. var engine = scene.getEngine();
  47676. var canUseOfflineSupport = engine.enableOfflineSupport;
  47677. if (canUseOfflineSupport) {
  47678. // Also check for exceptions
  47679. var exceptionFound = false;
  47680. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  47681. var regex = _a[_i];
  47682. if (regex.test(fileInfo.url)) {
  47683. exceptionFound = true;
  47684. break;
  47685. }
  47686. }
  47687. canUseOfflineSupport = !exceptionFound;
  47688. }
  47689. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  47690. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  47691. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  47692. }
  47693. else {
  47694. manifestChecked();
  47695. }
  47696. }
  47697. // Loading file from disk via input file or drag'n'drop
  47698. else {
  47699. if (file) {
  47700. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  47701. }
  47702. else {
  47703. onError("Unable to find file named " + fileInfo.name);
  47704. }
  47705. }
  47706. return plugin;
  47707. };
  47708. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  47709. var url;
  47710. var name;
  47711. var file = null;
  47712. if (!sceneFilename) {
  47713. url = rootUrl;
  47714. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  47715. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  47716. }
  47717. else if (sceneFilename.lastModified) {
  47718. var sceneFile = sceneFilename;
  47719. url = rootUrl + sceneFile.name;
  47720. name = sceneFile.name;
  47721. file = sceneFile;
  47722. }
  47723. else {
  47724. var filename = sceneFilename;
  47725. if (filename.substr(0, 1) === "/") {
  47726. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  47727. return null;
  47728. }
  47729. url = rootUrl + filename;
  47730. name = filename;
  47731. }
  47732. return {
  47733. url: url,
  47734. rootUrl: rootUrl,
  47735. name: name,
  47736. file: file
  47737. };
  47738. };
  47739. // Public functions
  47740. /**
  47741. * Gets a plugin that can load the given extension
  47742. * @param extension defines the extension to load
  47743. * @returns a plugin or null if none works
  47744. */
  47745. SceneLoader.GetPluginForExtension = function (extension) {
  47746. return SceneLoader._getPluginForExtension(extension).plugin;
  47747. };
  47748. /**
  47749. * Gets a boolean indicating that the given extension can be loaded
  47750. * @param extension defines the extension to load
  47751. * @returns true if the extension is supported
  47752. */
  47753. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  47754. return !!SceneLoader._registeredPlugins[extension];
  47755. };
  47756. /**
  47757. * Adds a new plugin to the list of registered plugins
  47758. * @param plugin defines the plugin to add
  47759. */
  47760. SceneLoader.RegisterPlugin = function (plugin) {
  47761. if (typeof plugin.extensions === "string") {
  47762. var extension = plugin.extensions;
  47763. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  47764. plugin: plugin,
  47765. isBinary: false
  47766. };
  47767. }
  47768. else {
  47769. var extensions = plugin.extensions;
  47770. Object.keys(extensions).forEach(function (extension) {
  47771. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  47772. plugin: plugin,
  47773. isBinary: extensions[extension].isBinary
  47774. };
  47775. });
  47776. }
  47777. };
  47778. /**
  47779. * Import meshes into a scene
  47780. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47781. * @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)
  47782. * @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)
  47783. * @param scene the instance of BABYLON.Scene to append to
  47784. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47785. * @param onProgress a callback with a progress event for each file being loaded
  47786. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47787. * @param pluginExtension the extension used to determine the plugin
  47788. * @returns The loaded plugin
  47789. */
  47790. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  47791. if (sceneFilename === void 0) { sceneFilename = ""; }
  47792. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  47793. if (onSuccess === void 0) { onSuccess = null; }
  47794. if (onProgress === void 0) { onProgress = null; }
  47795. if (onError === void 0) { onError = null; }
  47796. if (pluginExtension === void 0) { pluginExtension = null; }
  47797. if (!scene) {
  47798. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  47799. return null;
  47800. }
  47801. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  47802. if (!fileInfo) {
  47803. return null;
  47804. }
  47805. var loadingToken = {};
  47806. scene._addPendingData(loadingToken);
  47807. var disposeHandler = function () {
  47808. scene._removePendingData(loadingToken);
  47809. };
  47810. var errorHandler = function (message, exception) {
  47811. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  47812. if (onError) {
  47813. onError(scene, errorMessage, exception);
  47814. }
  47815. else {
  47816. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  47817. // should the exception be thrown?
  47818. }
  47819. disposeHandler();
  47820. };
  47821. var progressHandler = onProgress ? function (event) {
  47822. try {
  47823. onProgress(event);
  47824. }
  47825. catch (e) {
  47826. errorHandler("Error in onProgress callback", e);
  47827. }
  47828. } : undefined;
  47829. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  47830. scene.importedMeshesFiles.push(fileInfo.url);
  47831. if (onSuccess) {
  47832. try {
  47833. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  47834. }
  47835. catch (e) {
  47836. errorHandler("Error in onSuccess callback", e);
  47837. }
  47838. }
  47839. scene._removePendingData(loadingToken);
  47840. };
  47841. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  47842. if (plugin.rewriteRootURL) {
  47843. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  47844. }
  47845. if (plugin.importMesh) {
  47846. var syncedPlugin = plugin;
  47847. var meshes = new Array();
  47848. var particleSystems = new Array();
  47849. var skeletons = new Array();
  47850. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  47851. return;
  47852. }
  47853. scene.loadingPluginName = plugin.name;
  47854. successHandler(meshes, particleSystems, skeletons, []);
  47855. }
  47856. else {
  47857. var asyncedPlugin = plugin;
  47858. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  47859. scene.loadingPluginName = plugin.name;
  47860. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  47861. }).catch(function (error) {
  47862. errorHandler(error.message, error);
  47863. });
  47864. }
  47865. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  47866. };
  47867. /**
  47868. * Import meshes into a scene
  47869. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47870. * @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)
  47871. * @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)
  47872. * @param scene the instance of BABYLON.Scene to append to
  47873. * @param onProgress a callback with a progress event for each file being loaded
  47874. * @param pluginExtension the extension used to determine the plugin
  47875. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47876. */
  47877. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  47878. if (sceneFilename === void 0) { sceneFilename = ""; }
  47879. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  47880. if (onProgress === void 0) { onProgress = null; }
  47881. if (pluginExtension === void 0) { pluginExtension = null; }
  47882. return new Promise(function (resolve, reject) {
  47883. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  47884. resolve({
  47885. meshes: meshes,
  47886. particleSystems: particleSystems,
  47887. skeletons: skeletons,
  47888. animationGroups: animationGroups
  47889. });
  47890. }, onProgress, function (scene, message, exception) {
  47891. reject(exception || new Error(message));
  47892. }, pluginExtension);
  47893. });
  47894. };
  47895. /**
  47896. * Load a scene
  47897. * @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)
  47898. * @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)
  47899. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47900. * @param onSuccess a callback with the scene when import succeeds
  47901. * @param onProgress a callback with a progress event for each file being loaded
  47902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47903. * @param pluginExtension the extension used to determine the plugin
  47904. * @returns The loaded plugin
  47905. */
  47906. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  47907. if (sceneFilename === void 0) { sceneFilename = ""; }
  47908. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  47909. if (onSuccess === void 0) { onSuccess = null; }
  47910. if (onProgress === void 0) { onProgress = null; }
  47911. if (onError === void 0) { onError = null; }
  47912. if (pluginExtension === void 0) { pluginExtension = null; }
  47913. if (!engine) {
  47914. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  47915. return null;
  47916. }
  47917. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  47918. };
  47919. /**
  47920. * Load a scene
  47921. * @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)
  47922. * @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)
  47923. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47924. * @param onProgress a callback with a progress event for each file being loaded
  47925. * @param pluginExtension the extension used to determine the plugin
  47926. * @returns The loaded scene
  47927. */
  47928. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  47929. if (sceneFilename === void 0) { sceneFilename = ""; }
  47930. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  47931. if (onProgress === void 0) { onProgress = null; }
  47932. if (pluginExtension === void 0) { pluginExtension = null; }
  47933. return new Promise(function (resolve, reject) {
  47934. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  47935. resolve(scene);
  47936. }, onProgress, function (scene, message, exception) {
  47937. reject(exception || new Error(message));
  47938. }, pluginExtension);
  47939. });
  47940. };
  47941. /**
  47942. * Append a scene
  47943. * @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)
  47944. * @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)
  47945. * @param scene is the instance of BABYLON.Scene to append to
  47946. * @param onSuccess a callback with the scene when import succeeds
  47947. * @param onProgress a callback with a progress event for each file being loaded
  47948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47949. * @param pluginExtension the extension used to determine the plugin
  47950. * @returns The loaded plugin
  47951. */
  47952. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  47953. if (sceneFilename === void 0) { sceneFilename = ""; }
  47954. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  47955. if (onSuccess === void 0) { onSuccess = null; }
  47956. if (onProgress === void 0) { onProgress = null; }
  47957. if (onError === void 0) { onError = null; }
  47958. if (pluginExtension === void 0) { pluginExtension = null; }
  47959. if (!scene) {
  47960. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  47961. return null;
  47962. }
  47963. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  47964. if (!fileInfo) {
  47965. return null;
  47966. }
  47967. if (SceneLoader.ShowLoadingScreen) {
  47968. scene.getEngine().displayLoadingUI();
  47969. }
  47970. var loadingToken = {};
  47971. scene._addPendingData(loadingToken);
  47972. var disposeHandler = function () {
  47973. scene._removePendingData(loadingToken);
  47974. scene.getEngine().hideLoadingUI();
  47975. };
  47976. var errorHandler = function (message, exception) {
  47977. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  47978. if (onError) {
  47979. onError(scene, errorMessage, exception);
  47980. }
  47981. else {
  47982. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  47983. // should the exception be thrown?
  47984. }
  47985. disposeHandler();
  47986. };
  47987. var progressHandler = onProgress ? function (event) {
  47988. try {
  47989. onProgress(event);
  47990. }
  47991. catch (e) {
  47992. errorHandler("Error in onProgress callback", e);
  47993. }
  47994. } : undefined;
  47995. var successHandler = function () {
  47996. if (onSuccess) {
  47997. try {
  47998. onSuccess(scene);
  47999. }
  48000. catch (e) {
  48001. errorHandler("Error in onSuccess callback", e);
  48002. }
  48003. }
  48004. scene._removePendingData(loadingToken);
  48005. };
  48006. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48007. if (plugin.load) {
  48008. var syncedPlugin = plugin;
  48009. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  48010. return;
  48011. }
  48012. scene.loadingPluginName = plugin.name;
  48013. successHandler();
  48014. }
  48015. else {
  48016. var asyncedPlugin = plugin;
  48017. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  48018. scene.loadingPluginName = plugin.name;
  48019. successHandler();
  48020. }).catch(function (error) {
  48021. errorHandler(error.message, error);
  48022. });
  48023. }
  48024. if (SceneLoader.ShowLoadingScreen) {
  48025. scene.executeWhenReady(function () {
  48026. scene.getEngine().hideLoadingUI();
  48027. });
  48028. }
  48029. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48030. };
  48031. /**
  48032. * Append a scene
  48033. * @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)
  48034. * @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)
  48035. * @param scene is the instance of BABYLON.Scene to append to
  48036. * @param onProgress a callback with a progress event for each file being loaded
  48037. * @param pluginExtension the extension used to determine the plugin
  48038. * @returns The given scene
  48039. */
  48040. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48041. if (sceneFilename === void 0) { sceneFilename = ""; }
  48042. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48043. if (onProgress === void 0) { onProgress = null; }
  48044. if (pluginExtension === void 0) { pluginExtension = null; }
  48045. return new Promise(function (resolve, reject) {
  48046. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  48047. resolve(scene);
  48048. }, onProgress, function (scene, message, exception) {
  48049. reject(exception || new Error(message));
  48050. }, pluginExtension);
  48051. });
  48052. };
  48053. /**
  48054. * Load a scene into an asset container
  48055. * @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)
  48056. * @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)
  48057. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48058. * @param onSuccess a callback with the scene when import succeeds
  48059. * @param onProgress a callback with a progress event for each file being loaded
  48060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48061. * @param pluginExtension the extension used to determine the plugin
  48062. * @returns The loaded plugin
  48063. */
  48064. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48065. if (sceneFilename === void 0) { sceneFilename = ""; }
  48066. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48067. if (onSuccess === void 0) { onSuccess = null; }
  48068. if (onProgress === void 0) { onProgress = null; }
  48069. if (onError === void 0) { onError = null; }
  48070. if (pluginExtension === void 0) { pluginExtension = null; }
  48071. if (!scene) {
  48072. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  48073. return null;
  48074. }
  48075. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48076. if (!fileInfo) {
  48077. return null;
  48078. }
  48079. var loadingToken = {};
  48080. scene._addPendingData(loadingToken);
  48081. var disposeHandler = function () {
  48082. scene._removePendingData(loadingToken);
  48083. };
  48084. var errorHandler = function (message, exception) {
  48085. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  48086. if (onError) {
  48087. onError(scene, errorMessage, exception);
  48088. }
  48089. else {
  48090. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48091. // should the exception be thrown?
  48092. }
  48093. disposeHandler();
  48094. };
  48095. var progressHandler = onProgress ? function (event) {
  48096. try {
  48097. onProgress(event);
  48098. }
  48099. catch (e) {
  48100. errorHandler("Error in onProgress callback", e);
  48101. }
  48102. } : undefined;
  48103. var successHandler = function (assets) {
  48104. if (onSuccess) {
  48105. try {
  48106. onSuccess(assets);
  48107. }
  48108. catch (e) {
  48109. errorHandler("Error in onSuccess callback", e);
  48110. }
  48111. }
  48112. scene._removePendingData(loadingToken);
  48113. };
  48114. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48115. if (plugin.loadAssetContainer) {
  48116. var syncedPlugin = plugin;
  48117. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  48118. if (!assetContainer) {
  48119. return;
  48120. }
  48121. scene.loadingPluginName = plugin.name;
  48122. successHandler(assetContainer);
  48123. }
  48124. else if (plugin.loadAssetContainerAsync) {
  48125. var asyncedPlugin = plugin;
  48126. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  48127. scene.loadingPluginName = plugin.name;
  48128. successHandler(assetContainer);
  48129. }).catch(function (error) {
  48130. errorHandler(error.message, error);
  48131. });
  48132. }
  48133. else {
  48134. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  48135. }
  48136. if (SceneLoader.ShowLoadingScreen) {
  48137. scene.executeWhenReady(function () {
  48138. scene.getEngine().hideLoadingUI();
  48139. });
  48140. }
  48141. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48142. };
  48143. /**
  48144. * Load a scene into an asset container
  48145. * @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)
  48146. * @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)
  48147. * @param scene is the instance of Scene to append to
  48148. * @param onProgress a callback with a progress event for each file being loaded
  48149. * @param pluginExtension the extension used to determine the plugin
  48150. * @returns The loaded asset container
  48151. */
  48152. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48153. if (sceneFilename === void 0) { sceneFilename = ""; }
  48154. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48155. if (onProgress === void 0) { onProgress = null; }
  48156. if (pluginExtension === void 0) { pluginExtension = null; }
  48157. return new Promise(function (resolve, reject) {
  48158. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  48159. resolve(assetContainer);
  48160. }, onProgress, function (scene, message, exception) {
  48161. reject(exception || new Error(message));
  48162. }, pluginExtension);
  48163. });
  48164. };
  48165. /**
  48166. * No logging while loading
  48167. */
  48168. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  48169. /**
  48170. * Minimal logging while loading
  48171. */
  48172. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  48173. /**
  48174. * Summary logging while loading
  48175. */
  48176. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  48177. /**
  48178. * Detailled logging while loading
  48179. */
  48180. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  48181. // Members
  48182. /**
  48183. * Event raised when a plugin is used to load a scene
  48184. */
  48185. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  48186. SceneLoader._registeredPlugins = {};
  48187. return SceneLoader;
  48188. }());
  48189. /***/ }),
  48190. /***/ "./Loading/sceneLoaderFlags.ts":
  48191. /*!*************************************!*\
  48192. !*** ./Loading/sceneLoaderFlags.ts ***!
  48193. \*************************************/
  48194. /*! exports provided: SceneLoaderFlags */
  48195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48196. "use strict";
  48197. __webpack_require__.r(__webpack_exports__);
  48198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  48199. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48200. /**
  48201. * Class used to represent data loading progression
  48202. */
  48203. var SceneLoaderFlags = /** @class */ (function () {
  48204. function SceneLoaderFlags() {
  48205. }
  48206. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  48207. /**
  48208. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48209. */
  48210. get: function () {
  48211. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  48212. },
  48213. set: function (value) {
  48214. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  48215. },
  48216. enumerable: true,
  48217. configurable: true
  48218. });
  48219. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  48220. /**
  48221. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48222. */
  48223. get: function () {
  48224. return SceneLoaderFlags._ShowLoadingScreen;
  48225. },
  48226. set: function (value) {
  48227. SceneLoaderFlags._ShowLoadingScreen = value;
  48228. },
  48229. enumerable: true,
  48230. configurable: true
  48231. });
  48232. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  48233. /**
  48234. * Defines the current logging level (while loading the scene)
  48235. * @ignorenaming
  48236. */
  48237. get: function () {
  48238. return SceneLoaderFlags._loggingLevel;
  48239. },
  48240. set: function (value) {
  48241. SceneLoaderFlags._loggingLevel = value;
  48242. },
  48243. enumerable: true,
  48244. configurable: true
  48245. });
  48246. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  48247. /**
  48248. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48249. */
  48250. get: function () {
  48251. return SceneLoaderFlags._CleanBoneMatrixWeights;
  48252. },
  48253. set: function (value) {
  48254. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  48255. },
  48256. enumerable: true,
  48257. configurable: true
  48258. });
  48259. // Flags
  48260. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  48261. SceneLoaderFlags._ShowLoadingScreen = true;
  48262. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  48263. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  48264. return SceneLoaderFlags;
  48265. }());
  48266. /***/ }),
  48267. /***/ "./Materials/Background/backgroundMaterial.ts":
  48268. /*!****************************************************!*\
  48269. !*** ./Materials/Background/backgroundMaterial.ts ***!
  48270. \****************************************************/
  48271. /*! exports provided: BackgroundMaterial */
  48272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48273. "use strict";
  48274. __webpack_require__.r(__webpack_exports__);
  48275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  48276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48277. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  48278. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  48279. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48281. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  48282. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  48283. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  48284. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  48285. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  48286. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  48287. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48288. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  48289. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48290. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  48291. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  48292. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  48293. /**
  48294. * Background material defines definition.
  48295. * @hidden Mainly internal Use
  48296. */
  48297. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  48298. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  48299. /**
  48300. * Constructor of the defines.
  48301. */
  48302. function BackgroundMaterialDefines() {
  48303. var _this = _super.call(this) || this;
  48304. /**
  48305. * True if the diffuse texture is in use.
  48306. */
  48307. _this.DIFFUSE = false;
  48308. /**
  48309. * The direct UV channel to use.
  48310. */
  48311. _this.DIFFUSEDIRECTUV = 0;
  48312. /**
  48313. * True if the diffuse texture is in gamma space.
  48314. */
  48315. _this.GAMMADIFFUSE = false;
  48316. /**
  48317. * True if the diffuse texture has opacity in the alpha channel.
  48318. */
  48319. _this.DIFFUSEHASALPHA = false;
  48320. /**
  48321. * True if you want the material to fade to transparent at grazing angle.
  48322. */
  48323. _this.OPACITYFRESNEL = false;
  48324. /**
  48325. * True if an extra blur needs to be added in the reflection.
  48326. */
  48327. _this.REFLECTIONBLUR = false;
  48328. /**
  48329. * True if you want the material to fade to reflection at grazing angle.
  48330. */
  48331. _this.REFLECTIONFRESNEL = false;
  48332. /**
  48333. * True if you want the material to falloff as far as you move away from the scene center.
  48334. */
  48335. _this.REFLECTIONFALLOFF = false;
  48336. /**
  48337. * False if the current Webgl implementation does not support the texture lod extension.
  48338. */
  48339. _this.TEXTURELODSUPPORT = false;
  48340. /**
  48341. * True to ensure the data are premultiplied.
  48342. */
  48343. _this.PREMULTIPLYALPHA = false;
  48344. /**
  48345. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  48346. */
  48347. _this.USERGBCOLOR = false;
  48348. /**
  48349. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  48350. * stays aligned with the desired configuration.
  48351. */
  48352. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  48353. /**
  48354. * True to add noise in order to reduce the banding effect.
  48355. */
  48356. _this.NOISE = false;
  48357. /**
  48358. * is the reflection texture in BGR color scheme?
  48359. * Mainly used to solve a bug in ios10 video tag
  48360. */
  48361. _this.REFLECTIONBGR = false;
  48362. _this.IMAGEPROCESSING = false;
  48363. _this.VIGNETTE = false;
  48364. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  48365. _this.VIGNETTEBLENDMODEOPAQUE = false;
  48366. _this.TONEMAPPING = false;
  48367. _this.TONEMAPPING_ACES = false;
  48368. _this.CONTRAST = false;
  48369. _this.COLORCURVES = false;
  48370. _this.COLORGRADING = false;
  48371. _this.COLORGRADING3D = false;
  48372. _this.SAMPLER3DGREENDEPTH = false;
  48373. _this.SAMPLER3DBGRMAP = false;
  48374. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  48375. _this.EXPOSURE = false;
  48376. // Reflection.
  48377. _this.REFLECTION = false;
  48378. _this.REFLECTIONMAP_3D = false;
  48379. _this.REFLECTIONMAP_SPHERICAL = false;
  48380. _this.REFLECTIONMAP_PLANAR = false;
  48381. _this.REFLECTIONMAP_CUBIC = false;
  48382. _this.REFLECTIONMAP_PROJECTION = false;
  48383. _this.REFLECTIONMAP_SKYBOX = false;
  48384. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  48385. _this.REFLECTIONMAP_EXPLICIT = false;
  48386. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  48387. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  48388. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  48389. _this.INVERTCUBICMAP = false;
  48390. _this.REFLECTIONMAP_OPPOSITEZ = false;
  48391. _this.LODINREFLECTIONALPHA = false;
  48392. _this.GAMMAREFLECTION = false;
  48393. _this.RGBDREFLECTION = false;
  48394. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  48395. // Default BJS.
  48396. _this.MAINUV1 = false;
  48397. _this.MAINUV2 = false;
  48398. _this.UV1 = false;
  48399. _this.UV2 = false;
  48400. _this.CLIPPLANE = false;
  48401. _this.CLIPPLANE2 = false;
  48402. _this.CLIPPLANE3 = false;
  48403. _this.CLIPPLANE4 = false;
  48404. _this.POINTSIZE = false;
  48405. _this.FOG = false;
  48406. _this.NORMAL = false;
  48407. _this.NUM_BONE_INFLUENCERS = 0;
  48408. _this.BonesPerMesh = 0;
  48409. _this.INSTANCES = false;
  48410. _this.SHADOWFLOAT = false;
  48411. _this.rebuild();
  48412. return _this;
  48413. }
  48414. return BackgroundMaterialDefines;
  48415. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  48416. /**
  48417. * Background material used to create an efficient environement around your scene.
  48418. */
  48419. var BackgroundMaterial = /** @class */ (function (_super) {
  48420. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  48421. /**
  48422. * Instantiates a Background Material in the given scene
  48423. * @param name The friendly name of the material
  48424. * @param scene The scene to add the material to
  48425. */
  48426. function BackgroundMaterial(name, scene) {
  48427. var _this = _super.call(this, name, scene) || this;
  48428. /**
  48429. * Key light Color (multiply against the environement texture)
  48430. */
  48431. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48432. _this._primaryColorShadowLevel = 0;
  48433. _this._primaryColorHighlightLevel = 0;
  48434. /**
  48435. * Reflection Texture used in the material.
  48436. * Should be author in a specific way for the best result (refer to the documentation).
  48437. */
  48438. _this.reflectionTexture = null;
  48439. /**
  48440. * Reflection Texture level of blur.
  48441. *
  48442. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48443. * texture twice.
  48444. */
  48445. _this.reflectionBlur = 0;
  48446. /**
  48447. * Diffuse Texture used in the material.
  48448. * Should be author in a specific way for the best result (refer to the documentation).
  48449. */
  48450. _this.diffuseTexture = null;
  48451. _this._shadowLights = null;
  48452. /**
  48453. * Specify the list of lights casting shadow on the material.
  48454. * All scene shadow lights will be included if null.
  48455. */
  48456. _this.shadowLights = null;
  48457. /**
  48458. * Helps adjusting the shadow to a softer level if required.
  48459. * 0 means black shadows and 1 means no shadows.
  48460. */
  48461. _this.shadowLevel = 0;
  48462. /**
  48463. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48464. * It is usually zero but might be interesting to modify according to your setup.
  48465. */
  48466. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  48467. /**
  48468. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48469. * This helps ensuring a nice transition when the camera goes under the ground.
  48470. */
  48471. _this.opacityFresnel = true;
  48472. /**
  48473. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48474. * This helps adding a mirror texture on the ground.
  48475. */
  48476. _this.reflectionFresnel = false;
  48477. /**
  48478. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48479. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48480. */
  48481. _this.reflectionFalloffDistance = 0.0;
  48482. /**
  48483. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48484. */
  48485. _this.reflectionAmount = 1.0;
  48486. /**
  48487. * This specifies the weight of the reflection at grazing angle.
  48488. */
  48489. _this.reflectionReflectance0 = 0.05;
  48490. /**
  48491. * This specifies the weight of the reflection at a perpendicular point of view.
  48492. */
  48493. _this.reflectionReflectance90 = 0.5;
  48494. /**
  48495. * Helps to directly use the maps channels instead of their level.
  48496. */
  48497. _this.useRGBColor = true;
  48498. /**
  48499. * This helps reducing the banding effect that could occur on the background.
  48500. */
  48501. _this.enableNoise = false;
  48502. _this._fovMultiplier = 1.0;
  48503. /**
  48504. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48505. */
  48506. _this.useEquirectangularFOV = false;
  48507. _this._maxSimultaneousLights = 4;
  48508. /**
  48509. * Number of Simultaneous lights allowed on the material.
  48510. */
  48511. _this.maxSimultaneousLights = 4;
  48512. /**
  48513. * Keep track of the image processing observer to allow dispose and replace.
  48514. */
  48515. _this._imageProcessingObserver = null;
  48516. /**
  48517. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48518. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48519. */
  48520. _this.switchToBGR = false;
  48521. // Temp values kept as cache in the material.
  48522. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  48523. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  48524. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48525. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48526. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48527. // Setup the default processing configuration to the scene.
  48528. _this._attachImageProcessingConfiguration(null);
  48529. _this.getRenderTargetTextures = function () {
  48530. _this._renderTargets.reset();
  48531. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  48532. _this._renderTargets.push(_this._diffuseTexture);
  48533. }
  48534. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  48535. _this._renderTargets.push(_this._reflectionTexture);
  48536. }
  48537. return _this._renderTargets;
  48538. };
  48539. return _this;
  48540. }
  48541. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  48542. /**
  48543. * Experimental Internal Use Only.
  48544. *
  48545. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48546. * This acts as a helper to set the primary color to a more "human friendly" value.
  48547. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48548. * output color as close as possible from the chosen value.
  48549. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48550. * part of lighting setup.)
  48551. */
  48552. get: function () {
  48553. return this.__perceptualColor;
  48554. },
  48555. set: function (value) {
  48556. this.__perceptualColor = value;
  48557. this._computePrimaryColorFromPerceptualColor();
  48558. this._markAllSubMeshesAsLightsDirty();
  48559. },
  48560. enumerable: true,
  48561. configurable: true
  48562. });
  48563. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  48564. /**
  48565. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48566. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48567. */
  48568. get: function () {
  48569. return this._primaryColorShadowLevel;
  48570. },
  48571. set: function (value) {
  48572. this._primaryColorShadowLevel = value;
  48573. this._computePrimaryColors();
  48574. this._markAllSubMeshesAsLightsDirty();
  48575. },
  48576. enumerable: true,
  48577. configurable: true
  48578. });
  48579. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  48580. /**
  48581. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48582. * The primary color is used at the level chosen to define what the white area would look.
  48583. */
  48584. get: function () {
  48585. return this._primaryColorHighlightLevel;
  48586. },
  48587. set: function (value) {
  48588. this._primaryColorHighlightLevel = value;
  48589. this._computePrimaryColors();
  48590. this._markAllSubMeshesAsLightsDirty();
  48591. },
  48592. enumerable: true,
  48593. configurable: true
  48594. });
  48595. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  48596. /**
  48597. * Sets the reflection reflectance fresnel values according to the default standard
  48598. * empirically know to work well :-)
  48599. */
  48600. set: function (value) {
  48601. var reflectionWeight = value;
  48602. if (reflectionWeight < 0.5) {
  48603. reflectionWeight = reflectionWeight * 2.0;
  48604. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  48605. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  48606. }
  48607. else {
  48608. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  48609. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  48610. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  48611. }
  48612. },
  48613. enumerable: true,
  48614. configurable: true
  48615. });
  48616. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  48617. /**
  48618. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48619. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48620. * Recommended to be keep at 1.0 except for special cases.
  48621. */
  48622. get: function () {
  48623. return this._fovMultiplier;
  48624. },
  48625. set: function (value) {
  48626. if (isNaN(value)) {
  48627. value = 1.0;
  48628. }
  48629. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  48630. },
  48631. enumerable: true,
  48632. configurable: true
  48633. });
  48634. /**
  48635. * Attaches a new image processing configuration to the PBR Material.
  48636. * @param configuration (if null the scene configuration will be use)
  48637. */
  48638. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  48639. var _this = this;
  48640. if (configuration === this._imageProcessingConfiguration) {
  48641. return;
  48642. }
  48643. // Detaches observer.
  48644. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  48645. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  48646. }
  48647. // Pick the scene configuration if needed.
  48648. if (!configuration) {
  48649. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  48650. }
  48651. else {
  48652. this._imageProcessingConfiguration = configuration;
  48653. }
  48654. // Attaches observer.
  48655. if (this._imageProcessingConfiguration) {
  48656. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  48657. _this._computePrimaryColorFromPerceptualColor();
  48658. _this._markAllSubMeshesAsImageProcessingDirty();
  48659. });
  48660. }
  48661. };
  48662. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  48663. /**
  48664. * Gets the image processing configuration used either in this material.
  48665. */
  48666. get: function () {
  48667. return this._imageProcessingConfiguration;
  48668. },
  48669. /**
  48670. * Sets the Default image processing configuration used either in the this material.
  48671. *
  48672. * If sets to null, the scene one is in use.
  48673. */
  48674. set: function (value) {
  48675. this._attachImageProcessingConfiguration(value);
  48676. // Ensure the effect will be rebuilt.
  48677. this._markAllSubMeshesAsTexturesDirty();
  48678. },
  48679. enumerable: true,
  48680. configurable: true
  48681. });
  48682. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  48683. /**
  48684. * Gets wether the color curves effect is enabled.
  48685. */
  48686. get: function () {
  48687. return this.imageProcessingConfiguration.colorCurvesEnabled;
  48688. },
  48689. /**
  48690. * Sets wether the color curves effect is enabled.
  48691. */
  48692. set: function (value) {
  48693. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  48694. },
  48695. enumerable: true,
  48696. configurable: true
  48697. });
  48698. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  48699. /**
  48700. * Gets wether the color grading effect is enabled.
  48701. */
  48702. get: function () {
  48703. return this.imageProcessingConfiguration.colorGradingEnabled;
  48704. },
  48705. /**
  48706. * Gets wether the color grading effect is enabled.
  48707. */
  48708. set: function (value) {
  48709. this.imageProcessingConfiguration.colorGradingEnabled = value;
  48710. },
  48711. enumerable: true,
  48712. configurable: true
  48713. });
  48714. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  48715. /**
  48716. * Gets wether tonemapping is enabled or not.
  48717. */
  48718. get: function () {
  48719. return this._imageProcessingConfiguration.toneMappingEnabled;
  48720. },
  48721. /**
  48722. * Sets wether tonemapping is enabled or not
  48723. */
  48724. set: function (value) {
  48725. this._imageProcessingConfiguration.toneMappingEnabled = value;
  48726. },
  48727. enumerable: true,
  48728. configurable: true
  48729. });
  48730. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  48731. /**
  48732. * The camera exposure used on this material.
  48733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48734. * This corresponds to a photographic exposure.
  48735. */
  48736. get: function () {
  48737. return this._imageProcessingConfiguration.exposure;
  48738. },
  48739. /**
  48740. * The camera exposure used on this material.
  48741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48742. * This corresponds to a photographic exposure.
  48743. */
  48744. set: function (value) {
  48745. this._imageProcessingConfiguration.exposure = value;
  48746. },
  48747. enumerable: true,
  48748. configurable: true
  48749. });
  48750. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  48751. /**
  48752. * Gets The camera contrast used on this material.
  48753. */
  48754. get: function () {
  48755. return this._imageProcessingConfiguration.contrast;
  48756. },
  48757. /**
  48758. * Sets The camera contrast used on this material.
  48759. */
  48760. set: function (value) {
  48761. this._imageProcessingConfiguration.contrast = value;
  48762. },
  48763. enumerable: true,
  48764. configurable: true
  48765. });
  48766. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  48767. /**
  48768. * Gets the Color Grading 2D Lookup Texture.
  48769. */
  48770. get: function () {
  48771. return this._imageProcessingConfiguration.colorGradingTexture;
  48772. },
  48773. /**
  48774. * Sets the Color Grading 2D Lookup Texture.
  48775. */
  48776. set: function (value) {
  48777. this.imageProcessingConfiguration.colorGradingTexture = value;
  48778. },
  48779. enumerable: true,
  48780. configurable: true
  48781. });
  48782. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  48783. /**
  48784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48786. * 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;
  48787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48788. */
  48789. get: function () {
  48790. return this.imageProcessingConfiguration.colorCurves;
  48791. },
  48792. /**
  48793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48795. * 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;
  48796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48797. */
  48798. set: function (value) {
  48799. this.imageProcessingConfiguration.colorCurves = value;
  48800. },
  48801. enumerable: true,
  48802. configurable: true
  48803. });
  48804. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  48805. /**
  48806. * Gets a boolean indicating that current material needs to register RTT
  48807. */
  48808. get: function () {
  48809. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  48810. return true;
  48811. }
  48812. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  48813. return true;
  48814. }
  48815. return false;
  48816. },
  48817. enumerable: true,
  48818. configurable: true
  48819. });
  48820. /**
  48821. * The entire material has been created in order to prevent overdraw.
  48822. * @returns false
  48823. */
  48824. BackgroundMaterial.prototype.needAlphaTesting = function () {
  48825. return true;
  48826. };
  48827. /**
  48828. * The entire material has been created in order to prevent overdraw.
  48829. * @returns true if blending is enable
  48830. */
  48831. BackgroundMaterial.prototype.needAlphaBlending = function () {
  48832. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  48833. };
  48834. /**
  48835. * Checks wether the material is ready to be rendered for a given mesh.
  48836. * @param mesh The mesh to render
  48837. * @param subMesh The submesh to check against
  48838. * @param useInstances Specify wether or not the material is used with instances
  48839. * @returns true if all the dependencies are ready (Textures, Effects...)
  48840. */
  48841. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  48842. var _this = this;
  48843. if (useInstances === void 0) { useInstances = false; }
  48844. if (subMesh.effect && this.isFrozen) {
  48845. if (this._wasPreviouslyReady) {
  48846. return true;
  48847. }
  48848. }
  48849. if (!subMesh._materialDefines) {
  48850. subMesh._materialDefines = new BackgroundMaterialDefines();
  48851. }
  48852. var scene = this.getScene();
  48853. var defines = subMesh._materialDefines;
  48854. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  48855. if (defines._renderId === scene.getRenderId()) {
  48856. return true;
  48857. }
  48858. }
  48859. var engine = scene.getEngine();
  48860. // Lights
  48861. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  48862. defines._needNormals = true;
  48863. // Textures
  48864. if (defines._areTexturesDirty) {
  48865. defines._needUVs = false;
  48866. if (scene.texturesEnabled) {
  48867. if (scene.getEngine().getCaps().textureLOD) {
  48868. defines.TEXTURELODSUPPORT = true;
  48869. }
  48870. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  48871. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  48872. return false;
  48873. }
  48874. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  48875. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  48876. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  48877. defines.OPACITYFRESNEL = this._opacityFresnel;
  48878. }
  48879. else {
  48880. defines.DIFFUSE = false;
  48881. defines.DIFFUSEHASALPHA = false;
  48882. defines.GAMMADIFFUSE = false;
  48883. defines.OPACITYFRESNEL = false;
  48884. }
  48885. var reflectionTexture = this._reflectionTexture;
  48886. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  48887. if (!reflectionTexture.isReadyOrNotBlocking()) {
  48888. return false;
  48889. }
  48890. defines.REFLECTION = true;
  48891. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  48892. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  48893. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  48894. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  48895. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  48896. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  48897. defines.REFLECTIONBGR = this.switchToBGR;
  48898. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  48899. defines.INVERTCUBICMAP = true;
  48900. }
  48901. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  48902. switch (reflectionTexture.coordinatesMode) {
  48903. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  48904. defines.REFLECTIONMAP_EXPLICIT = true;
  48905. break;
  48906. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  48907. defines.REFLECTIONMAP_PLANAR = true;
  48908. break;
  48909. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  48910. defines.REFLECTIONMAP_PROJECTION = true;
  48911. break;
  48912. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  48913. defines.REFLECTIONMAP_SKYBOX = true;
  48914. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  48915. break;
  48916. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  48917. defines.REFLECTIONMAP_SPHERICAL = true;
  48918. break;
  48919. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  48920. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  48921. break;
  48922. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  48923. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  48924. break;
  48925. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  48926. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  48927. break;
  48928. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  48929. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  48930. default:
  48931. defines.REFLECTIONMAP_CUBIC = true;
  48932. break;
  48933. }
  48934. if (this.reflectionFresnel) {
  48935. defines.REFLECTIONFRESNEL = true;
  48936. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  48937. this._reflectionControls.x = this.reflectionAmount;
  48938. this._reflectionControls.y = this.reflectionReflectance0;
  48939. this._reflectionControls.z = this.reflectionReflectance90;
  48940. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  48941. }
  48942. else {
  48943. defines.REFLECTIONFRESNEL = false;
  48944. defines.REFLECTIONFALLOFF = false;
  48945. }
  48946. }
  48947. else {
  48948. defines.REFLECTION = false;
  48949. defines.REFLECTIONFRESNEL = false;
  48950. defines.REFLECTIONFALLOFF = false;
  48951. defines.REFLECTIONBLUR = false;
  48952. defines.REFLECTIONMAP_3D = false;
  48953. defines.REFLECTIONMAP_SPHERICAL = false;
  48954. defines.REFLECTIONMAP_PLANAR = false;
  48955. defines.REFLECTIONMAP_CUBIC = false;
  48956. defines.REFLECTIONMAP_PROJECTION = false;
  48957. defines.REFLECTIONMAP_SKYBOX = false;
  48958. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  48959. defines.REFLECTIONMAP_EXPLICIT = false;
  48960. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  48961. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  48962. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  48963. defines.INVERTCUBICMAP = false;
  48964. defines.REFLECTIONMAP_OPPOSITEZ = false;
  48965. defines.LODINREFLECTIONALPHA = false;
  48966. defines.GAMMAREFLECTION = false;
  48967. defines.RGBDREFLECTION = false;
  48968. }
  48969. }
  48970. 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);
  48971. defines.USERGBCOLOR = this._useRGBColor;
  48972. defines.NOISE = this._enableNoise;
  48973. }
  48974. if (defines._areLightsDirty) {
  48975. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  48976. }
  48977. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  48978. if (!this._imageProcessingConfiguration.isReady()) {
  48979. return false;
  48980. }
  48981. this._imageProcessingConfiguration.prepareDefines(defines);
  48982. }
  48983. // Misc.
  48984. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  48985. // Values that need to be evaluated on every frame
  48986. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  48987. // Attribs
  48988. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  48989. if (mesh) {
  48990. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  48991. mesh.createNormals(true);
  48992. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  48993. }
  48994. }
  48995. }
  48996. // Get correct effect
  48997. if (defines.isDirty) {
  48998. defines.markAsProcessed();
  48999. scene.resetCachedMaterial();
  49000. // Fallbacks
  49001. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49002. if (defines.FOG) {
  49003. fallbacks.addFallback(0, "FOG");
  49004. }
  49005. if (defines.POINTSIZE) {
  49006. fallbacks.addFallback(1, "POINTSIZE");
  49007. }
  49008. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  49009. if (defines.NUM_BONE_INFLUENCERS > 0) {
  49010. fallbacks.addCPUSkinningFallback(0, mesh);
  49011. }
  49012. //Attributes
  49013. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  49014. if (defines.NORMAL) {
  49015. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  49016. }
  49017. if (defines.UV1) {
  49018. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  49019. }
  49020. if (defines.UV2) {
  49021. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  49022. }
  49023. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  49024. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  49025. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  49026. "vFogInfos", "vFogColor", "pointSize",
  49027. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  49028. "vPrimaryColor", "vPrimaryColorShadow",
  49029. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  49030. "shadowLevel", "alpha",
  49031. "vBackgroundCenter", "vReflectionControl",
  49032. "vDiffuseInfos", "diffuseMatrix",
  49033. ];
  49034. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  49035. var uniformBuffers = ["Material", "Scene"];
  49036. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  49037. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  49038. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  49039. }
  49040. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  49041. uniformsNames: uniforms,
  49042. uniformBuffersNames: uniformBuffers,
  49043. samplers: samplers,
  49044. defines: defines,
  49045. maxSimultaneousLights: this._maxSimultaneousLights
  49046. });
  49047. var onCompiled = function (effect) {
  49048. if (_this.onCompiled) {
  49049. _this.onCompiled(effect);
  49050. }
  49051. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  49052. };
  49053. var join = defines.toString();
  49054. subMesh.setEffect(scene.getEngine().createEffect("background", {
  49055. attributes: attribs,
  49056. uniformsNames: uniforms,
  49057. uniformBuffersNames: uniformBuffers,
  49058. samplers: samplers,
  49059. defines: join,
  49060. fallbacks: fallbacks,
  49061. onCompiled: onCompiled,
  49062. onError: this.onError,
  49063. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  49064. }, engine), defines);
  49065. this.buildUniformLayout();
  49066. }
  49067. if (!subMesh.effect || !subMesh.effect.isReady()) {
  49068. return false;
  49069. }
  49070. defines._renderId = scene.getRenderId();
  49071. this._wasPreviouslyReady = true;
  49072. return true;
  49073. };
  49074. /**
  49075. * Compute the primary color according to the chosen perceptual color.
  49076. */
  49077. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  49078. if (!this.__perceptualColor) {
  49079. return;
  49080. }
  49081. this._primaryColor.copyFrom(this.__perceptualColor);
  49082. // Revert gamma space.
  49083. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  49084. // Revert image processing configuration.
  49085. if (this._imageProcessingConfiguration) {
  49086. // Revert Exposure.
  49087. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  49088. }
  49089. this._computePrimaryColors();
  49090. };
  49091. /**
  49092. * Compute the highlights and shadow colors according to their chosen levels.
  49093. */
  49094. BackgroundMaterial.prototype._computePrimaryColors = function () {
  49095. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  49096. return;
  49097. }
  49098. // Find the highlight color based on the configuration.
  49099. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  49100. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  49101. // Find the shadow color based on the configuration.
  49102. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  49103. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  49104. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  49105. };
  49106. /**
  49107. * Build the uniform buffer used in the material.
  49108. */
  49109. BackgroundMaterial.prototype.buildUniformLayout = function () {
  49110. // Order is important !
  49111. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  49112. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  49113. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  49114. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  49115. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  49116. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  49117. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  49118. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  49119. this._uniformBuffer.addUniform("pointSize", 1);
  49120. this._uniformBuffer.addUniform("shadowLevel", 1);
  49121. this._uniformBuffer.addUniform("alpha", 1);
  49122. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  49123. this._uniformBuffer.addUniform("vReflectionControl", 4);
  49124. this._uniformBuffer.create();
  49125. };
  49126. /**
  49127. * Unbind the material.
  49128. */
  49129. BackgroundMaterial.prototype.unbind = function () {
  49130. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49131. this._uniformBuffer.setTexture("diffuseSampler", null);
  49132. }
  49133. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49134. this._uniformBuffer.setTexture("reflectionSampler", null);
  49135. }
  49136. _super.prototype.unbind.call(this);
  49137. };
  49138. /**
  49139. * Bind only the world matrix to the material.
  49140. * @param world The world matrix to bind.
  49141. */
  49142. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  49143. this._activeEffect.setMatrix("world", world);
  49144. };
  49145. /**
  49146. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49147. * @param world The world matrix to bind.
  49148. * @param subMesh The submesh to bind for.
  49149. */
  49150. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  49151. var scene = this.getScene();
  49152. var defines = subMesh._materialDefines;
  49153. if (!defines) {
  49154. return;
  49155. }
  49156. var effect = subMesh.effect;
  49157. if (!effect) {
  49158. return;
  49159. }
  49160. this._activeEffect = effect;
  49161. // Matrices
  49162. this.bindOnlyWorldMatrix(world);
  49163. // Bones
  49164. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  49165. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  49166. if (mustRebind) {
  49167. this._uniformBuffer.bindToEffect(effect, "Material");
  49168. this.bindViewProjection(effect);
  49169. var reflectionTexture = this._reflectionTexture;
  49170. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  49171. // Texture uniforms
  49172. if (scene.texturesEnabled) {
  49173. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49174. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  49175. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  49176. }
  49177. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49178. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  49179. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  49180. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  49181. }
  49182. }
  49183. if (this.shadowLevel > 0) {
  49184. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  49185. }
  49186. this._uniformBuffer.updateFloat("alpha", this.alpha);
  49187. // Point size
  49188. if (this.pointsCloud) {
  49189. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  49190. }
  49191. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  49192. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  49193. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  49194. }
  49195. else {
  49196. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  49197. }
  49198. }
  49199. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  49200. // Textures
  49201. if (scene.texturesEnabled) {
  49202. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49203. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  49204. }
  49205. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49206. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  49207. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49208. }
  49209. else if (!defines.REFLECTIONBLUR) {
  49210. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49211. }
  49212. else {
  49213. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  49214. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  49215. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  49216. }
  49217. if (defines.REFLECTIONFRESNEL) {
  49218. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  49219. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  49220. }
  49221. }
  49222. }
  49223. // Clip plane
  49224. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  49225. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  49226. }
  49227. if (mustRebind || !this.isFrozen) {
  49228. if (scene.lightsEnabled) {
  49229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  49230. }
  49231. // View
  49232. this.bindView(effect);
  49233. // Fog
  49234. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  49235. // image processing
  49236. if (this._imageProcessingConfiguration) {
  49237. this._imageProcessingConfiguration.bind(this._activeEffect);
  49238. }
  49239. }
  49240. this._uniformBuffer.update();
  49241. this._afterBind(mesh, this._activeEffect);
  49242. };
  49243. /**
  49244. * Dispose the material.
  49245. * @param forceDisposeEffect Force disposal of the associated effect.
  49246. * @param forceDisposeTextures Force disposal of the associated textures.
  49247. */
  49248. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  49249. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  49250. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  49251. if (forceDisposeTextures) {
  49252. if (this.diffuseTexture) {
  49253. this.diffuseTexture.dispose();
  49254. }
  49255. if (this.reflectionTexture) {
  49256. this.reflectionTexture.dispose();
  49257. }
  49258. }
  49259. this._renderTargets.dispose();
  49260. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49261. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49262. }
  49263. _super.prototype.dispose.call(this, forceDisposeEffect);
  49264. };
  49265. /**
  49266. * Clones the material.
  49267. * @param name The cloned name.
  49268. * @returns The cloned material.
  49269. */
  49270. BackgroundMaterial.prototype.clone = function (name) {
  49271. var _this = this;
  49272. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  49273. };
  49274. /**
  49275. * Serializes the current material to its JSON representation.
  49276. * @returns The JSON representation.
  49277. */
  49278. BackgroundMaterial.prototype.serialize = function () {
  49279. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  49280. serializationObject.customType = "BABYLON.BackgroundMaterial";
  49281. return serializationObject;
  49282. };
  49283. /**
  49284. * Gets the class name of the material
  49285. * @returns "BackgroundMaterial"
  49286. */
  49287. BackgroundMaterial.prototype.getClassName = function () {
  49288. return "BackgroundMaterial";
  49289. };
  49290. /**
  49291. * Parse a JSON input to create back a background material.
  49292. * @param source The JSON data to parse
  49293. * @param scene The scene to create the parsed material in
  49294. * @param rootUrl The root url of the assets the material depends upon
  49295. * @returns the instantiated BackgroundMaterial.
  49296. */
  49297. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  49298. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  49299. };
  49300. /**
  49301. * Standard reflectance value at parallel view angle.
  49302. */
  49303. BackgroundMaterial.StandardReflectance0 = 0.05;
  49304. /**
  49305. * Standard reflectance value at grazing angle.
  49306. */
  49307. BackgroundMaterial.StandardReflectance90 = 0.5;
  49308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49310. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  49311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49313. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  49314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49316. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  49317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49319. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  49320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49322. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  49323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49325. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  49326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49328. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  49329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49331. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  49332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49334. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  49335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49337. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  49338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49340. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  49341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49343. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  49344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49346. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  49347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49349. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  49350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49352. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  49353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  49355. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  49356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49358. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  49359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49361. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  49362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49364. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  49365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49367. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  49368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49370. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  49371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49373. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  49374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49376. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  49377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49379. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  49380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49382. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  49383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49385. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  49386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49388. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  49389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49391. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  49392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49394. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  49395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49397. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  49398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49400. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  49401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49403. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  49404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49406. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  49407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49409. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  49410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49412. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  49413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  49415. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  49416. return BackgroundMaterial;
  49417. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  49418. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  49419. /***/ }),
  49420. /***/ "./Materials/Background/index.ts":
  49421. /*!***************************************!*\
  49422. !*** ./Materials/Background/index.ts ***!
  49423. \***************************************/
  49424. /*! exports provided: BackgroundMaterial */
  49425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49426. "use strict";
  49427. __webpack_require__.r(__webpack_exports__);
  49428. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  49429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  49430. /***/ }),
  49431. /***/ "./Materials/PBR/index.ts":
  49432. /*!********************************!*\
  49433. !*** ./Materials/PBR/index.ts ***!
  49434. \********************************/
  49435. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  49436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49437. "use strict";
  49438. __webpack_require__.r(__webpack_exports__);
  49439. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  49440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  49441. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  49442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  49443. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  49444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  49445. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  49446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  49447. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  49448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  49449. /***/ }),
  49450. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  49451. /*!******************************************!*\
  49452. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  49453. \******************************************/
  49454. /*! exports provided: PBRBaseMaterial */
  49455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49456. "use strict";
  49457. __webpack_require__.r(__webpack_exports__);
  49458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  49459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49460. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49461. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49462. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49463. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  49464. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  49465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49466. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49467. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49468. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49469. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49470. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49471. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49472. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49473. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49474. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49475. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  49476. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  49477. /**
  49478. * Manages the defines for the PBR Material.
  49479. * @hiddenChildren
  49480. */
  49481. var PBRMaterialDefines = /** @class */ (function (_super) {
  49482. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  49483. /**
  49484. * Initializes the PBR Material defines.
  49485. */
  49486. function PBRMaterialDefines() {
  49487. var _this = _super.call(this) || this;
  49488. _this.PBR = true;
  49489. _this.MAINUV1 = false;
  49490. _this.MAINUV2 = false;
  49491. _this.UV1 = false;
  49492. _this.UV2 = false;
  49493. _this.ALBEDO = false;
  49494. _this.ALBEDODIRECTUV = 0;
  49495. _this.VERTEXCOLOR = false;
  49496. _this.AMBIENT = false;
  49497. _this.AMBIENTDIRECTUV = 0;
  49498. _this.AMBIENTINGRAYSCALE = false;
  49499. _this.OPACITY = false;
  49500. _this.VERTEXALPHA = false;
  49501. _this.OPACITYDIRECTUV = 0;
  49502. _this.OPACITYRGB = false;
  49503. _this.ALPHATEST = false;
  49504. _this.DEPTHPREPASS = false;
  49505. _this.ALPHABLEND = false;
  49506. _this.ALPHAFROMALBEDO = false;
  49507. _this.ALPHATESTVALUE = "0.5";
  49508. _this.SPECULAROVERALPHA = false;
  49509. _this.RADIANCEOVERALPHA = false;
  49510. _this.ALPHAFRESNEL = false;
  49511. _this.LINEARALPHAFRESNEL = false;
  49512. _this.PREMULTIPLYALPHA = false;
  49513. _this.EMISSIVE = false;
  49514. _this.EMISSIVEDIRECTUV = 0;
  49515. _this.REFLECTIVITY = false;
  49516. _this.REFLECTIVITYDIRECTUV = 0;
  49517. _this.SPECULARTERM = false;
  49518. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  49519. _this.MICROSURFACEAUTOMATIC = false;
  49520. _this.LODBASEDMICROSFURACE = false;
  49521. _this.MICROSURFACEMAP = false;
  49522. _this.MICROSURFACEMAPDIRECTUV = 0;
  49523. _this.METALLICWORKFLOW = false;
  49524. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  49525. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  49526. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  49527. _this.AOSTOREINMETALMAPRED = false;
  49528. _this.ENVIRONMENTBRDF = false;
  49529. _this.NORMAL = false;
  49530. _this.TANGENT = false;
  49531. _this.BUMP = false;
  49532. _this.BUMPDIRECTUV = 0;
  49533. _this.OBJECTSPACE_NORMALMAP = false;
  49534. _this.PARALLAX = false;
  49535. _this.PARALLAXOCCLUSION = false;
  49536. _this.NORMALXYSCALE = true;
  49537. _this.LIGHTMAP = false;
  49538. _this.LIGHTMAPDIRECTUV = 0;
  49539. _this.USELIGHTMAPASSHADOWMAP = false;
  49540. _this.GAMMALIGHTMAP = false;
  49541. _this.REFLECTION = false;
  49542. _this.REFLECTIONMAP_3D = false;
  49543. _this.REFLECTIONMAP_SPHERICAL = false;
  49544. _this.REFLECTIONMAP_PLANAR = false;
  49545. _this.REFLECTIONMAP_CUBIC = false;
  49546. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  49547. _this.REFLECTIONMAP_PROJECTION = false;
  49548. _this.REFLECTIONMAP_SKYBOX = false;
  49549. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49550. _this.REFLECTIONMAP_EXPLICIT = false;
  49551. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49552. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49553. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49554. _this.INVERTCUBICMAP = false;
  49555. _this.USESPHERICALFROMREFLECTIONMAP = false;
  49556. _this.USESPHERICALINVERTEX = false;
  49557. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49558. _this.LODINREFLECTIONALPHA = false;
  49559. _this.GAMMAREFLECTION = false;
  49560. _this.RGBDREFLECTION = false;
  49561. _this.RADIANCEOCCLUSION = false;
  49562. _this.HORIZONOCCLUSION = false;
  49563. _this.REFRACTION = false;
  49564. _this.REFRACTIONMAP_3D = false;
  49565. _this.REFRACTIONMAP_OPPOSITEZ = false;
  49566. _this.LODINREFRACTIONALPHA = false;
  49567. _this.GAMMAREFRACTION = false;
  49568. _this.RGBDREFRACTION = false;
  49569. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  49570. _this.INSTANCES = false;
  49571. _this.NUM_BONE_INFLUENCERS = 0;
  49572. _this.BonesPerMesh = 0;
  49573. _this.BONETEXTURE = false;
  49574. _this.NONUNIFORMSCALING = false;
  49575. _this.MORPHTARGETS = false;
  49576. _this.MORPHTARGETS_NORMAL = false;
  49577. _this.MORPHTARGETS_TANGENT = false;
  49578. _this.NUM_MORPH_INFLUENCERS = 0;
  49579. _this.IMAGEPROCESSING = false;
  49580. _this.VIGNETTE = false;
  49581. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49582. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49583. _this.TONEMAPPING = false;
  49584. _this.TONEMAPPING_ACES = false;
  49585. _this.CONTRAST = false;
  49586. _this.COLORCURVES = false;
  49587. _this.COLORGRADING = false;
  49588. _this.COLORGRADING3D = false;
  49589. _this.SAMPLER3DGREENDEPTH = false;
  49590. _this.SAMPLER3DBGRMAP = false;
  49591. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49592. _this.EXPOSURE = false;
  49593. _this.USEPHYSICALLIGHTFALLOFF = false;
  49594. _this.USEGLTFLIGHTFALLOFF = false;
  49595. _this.TWOSIDEDLIGHTING = false;
  49596. _this.SHADOWFLOAT = false;
  49597. _this.CLIPPLANE = false;
  49598. _this.CLIPPLANE2 = false;
  49599. _this.CLIPPLANE3 = false;
  49600. _this.CLIPPLANE4 = false;
  49601. _this.POINTSIZE = false;
  49602. _this.FOG = false;
  49603. _this.LOGARITHMICDEPTH = false;
  49604. _this.FORCENORMALFORWARD = false;
  49605. _this.SPECULARAA = false;
  49606. _this.UNLIT = false;
  49607. _this.rebuild();
  49608. return _this;
  49609. }
  49610. /**
  49611. * Resets the PBR Material defines.
  49612. */
  49613. PBRMaterialDefines.prototype.reset = function () {
  49614. _super.prototype.reset.call(this);
  49615. this.ALPHATESTVALUE = "0.5";
  49616. this.PBR = true;
  49617. };
  49618. return PBRMaterialDefines;
  49619. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  49620. /**
  49621. * The Physically based material base class of BJS.
  49622. *
  49623. * This offers the main features of a standard PBR material.
  49624. * For more information, please refer to the documentation :
  49625. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  49626. */
  49627. var PBRBaseMaterial = /** @class */ (function (_super) {
  49628. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  49629. /**
  49630. * Instantiates a new PBRMaterial instance.
  49631. *
  49632. * @param name The material name
  49633. * @param scene The scene the material will be use in.
  49634. */
  49635. function PBRBaseMaterial(name, scene) {
  49636. var _this = _super.call(this, name, scene) || this;
  49637. /**
  49638. * Intensity of the direct lights e.g. the four lights available in your scene.
  49639. * This impacts both the direct diffuse and specular highlights.
  49640. */
  49641. _this._directIntensity = 1.0;
  49642. /**
  49643. * Intensity of the emissive part of the material.
  49644. * This helps controlling the emissive effect without modifying the emissive color.
  49645. */
  49646. _this._emissiveIntensity = 1.0;
  49647. /**
  49648. * Intensity of the environment e.g. how much the environment will light the object
  49649. * either through harmonics for rough material or through the refelction for shiny ones.
  49650. */
  49651. _this._environmentIntensity = 1.0;
  49652. /**
  49653. * This is a special control allowing the reduction of the specular highlights coming from the
  49654. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49655. */
  49656. _this._specularIntensity = 1.0;
  49657. /**
  49658. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49659. */
  49660. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  49661. /**
  49662. * Debug Control allowing disabling the bump map on this material.
  49663. */
  49664. _this._disableBumpMap = false;
  49665. /**
  49666. * AKA Occlusion Texture Intensity in other nomenclature.
  49667. */
  49668. _this._ambientTextureStrength = 1.0;
  49669. /**
  49670. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49671. * 1 means it completely occludes it
  49672. * 0 mean it has no impact
  49673. */
  49674. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  49675. /**
  49676. * The color of a material in ambient lighting.
  49677. */
  49678. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49679. /**
  49680. * AKA Diffuse Color in other nomenclature.
  49681. */
  49682. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49683. /**
  49684. * AKA Specular Color in other nomenclature.
  49685. */
  49686. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49687. /**
  49688. * The color applied when light is reflected from a material.
  49689. */
  49690. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49691. /**
  49692. * The color applied when light is emitted from a material.
  49693. */
  49694. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49695. /**
  49696. * AKA Glossiness in other nomenclature.
  49697. */
  49698. _this._microSurface = 0.9;
  49699. /**
  49700. * source material index of refraction (IOR)' / 'destination material IOR.
  49701. */
  49702. _this._indexOfRefraction = 0.66;
  49703. /**
  49704. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49705. */
  49706. _this._invertRefractionY = false;
  49707. /**
  49708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49709. * Materials half opaque for instance using refraction could benefit from this control.
  49710. */
  49711. _this._linkRefractionWithTransparency = false;
  49712. /**
  49713. * Specifies that the material will use the light map as a show map.
  49714. */
  49715. _this._useLightmapAsShadowmap = false;
  49716. /**
  49717. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49718. * makes the reflect vector face the model (under horizon).
  49719. */
  49720. _this._useHorizonOcclusion = true;
  49721. /**
  49722. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49723. * too much the area relying on ambient texture to define their ambient occlusion.
  49724. */
  49725. _this._useRadianceOcclusion = true;
  49726. /**
  49727. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49728. */
  49729. _this._useAlphaFromAlbedoTexture = false;
  49730. /**
  49731. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49732. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49733. */
  49734. _this._useSpecularOverAlpha = true;
  49735. /**
  49736. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49737. */
  49738. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  49739. /**
  49740. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49741. */
  49742. _this._useRoughnessFromMetallicTextureAlpha = true;
  49743. /**
  49744. * Specifies if the metallic texture contains the roughness information in its green channel.
  49745. */
  49746. _this._useRoughnessFromMetallicTextureGreen = false;
  49747. /**
  49748. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49749. */
  49750. _this._useMetallnessFromMetallicTextureBlue = false;
  49751. /**
  49752. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49753. */
  49754. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  49755. /**
  49756. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49757. */
  49758. _this._useAmbientInGrayScale = false;
  49759. /**
  49760. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49761. * The material will try to infer what glossiness each pixel should be.
  49762. */
  49763. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  49764. /**
  49765. * Defines the falloff type used in this material.
  49766. * It by default is Physical.
  49767. */
  49768. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  49769. /**
  49770. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49771. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49772. */
  49773. _this._useRadianceOverAlpha = true;
  49774. /**
  49775. * Allows using an object space normal map (instead of tangent space).
  49776. */
  49777. _this._useObjectSpaceNormalMap = false;
  49778. /**
  49779. * Allows using the bump map in parallax mode.
  49780. */
  49781. _this._useParallax = false;
  49782. /**
  49783. * Allows using the bump map in parallax occlusion mode.
  49784. */
  49785. _this._useParallaxOcclusion = false;
  49786. /**
  49787. * Controls the scale bias of the parallax mode.
  49788. */
  49789. _this._parallaxScaleBias = 0.05;
  49790. /**
  49791. * If sets to true, disables all the lights affecting the material.
  49792. */
  49793. _this._disableLighting = false;
  49794. /**
  49795. * Number of Simultaneous lights allowed on the material.
  49796. */
  49797. _this._maxSimultaneousLights = 4;
  49798. /**
  49799. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49800. */
  49801. _this._invertNormalMapX = false;
  49802. /**
  49803. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49804. */
  49805. _this._invertNormalMapY = false;
  49806. /**
  49807. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49808. */
  49809. _this._twoSidedLighting = false;
  49810. /**
  49811. * Defines the alpha limits in alpha test mode.
  49812. */
  49813. _this._alphaCutOff = 0.4;
  49814. /**
  49815. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49816. */
  49817. _this._forceAlphaTest = false;
  49818. /**
  49819. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49820. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49821. */
  49822. _this._useAlphaFresnel = false;
  49823. /**
  49824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49825. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49826. */
  49827. _this._useLinearAlphaFresnel = false;
  49828. /**
  49829. * The transparency mode of the material.
  49830. */
  49831. _this._transparencyMode = null;
  49832. /**
  49833. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49834. * from cos thetav and roughness:
  49835. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49836. */
  49837. _this._environmentBRDFTexture = null;
  49838. /**
  49839. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49840. */
  49841. _this._forceIrradianceInFragment = false;
  49842. /**
  49843. * Force normal to face away from face.
  49844. */
  49845. _this._forceNormalForward = false;
  49846. /**
  49847. * Enables specular anti aliasing in the PBR shader.
  49848. * It will both interacts on the Geometry for analytical and IBL lighting.
  49849. * It also prefilter the roughness map based on the bump values.
  49850. */
  49851. _this._enableSpecularAntiAliasing = false;
  49852. /**
  49853. * Stores the available render targets.
  49854. */
  49855. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  49856. /**
  49857. * Sets the global ambient color for the material used in lighting calculations.
  49858. */
  49859. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49860. /**
  49861. * If set to true, no lighting calculations will be applied.
  49862. */
  49863. _this._unlit = false;
  49864. // Setup the default processing configuration to the scene.
  49865. _this._attachImageProcessingConfiguration(null);
  49866. _this.getRenderTargetTextures = function () {
  49867. _this._renderTargets.reset();
  49868. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49869. _this._renderTargets.push(_this._reflectionTexture);
  49870. }
  49871. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  49872. _this._renderTargets.push(_this._refractionTexture);
  49873. }
  49874. return _this._renderTargets;
  49875. };
  49876. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  49877. return _this;
  49878. }
  49879. /**
  49880. * Attaches a new image processing configuration to the PBR Material.
  49881. * @param configuration
  49882. */
  49883. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49884. var _this = this;
  49885. if (configuration === this._imageProcessingConfiguration) {
  49886. return;
  49887. }
  49888. // Detaches observer.
  49889. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49890. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49891. }
  49892. // Pick the scene configuration if needed.
  49893. if (!configuration) {
  49894. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49895. }
  49896. else {
  49897. this._imageProcessingConfiguration = configuration;
  49898. }
  49899. // Attaches observer.
  49900. if (this._imageProcessingConfiguration) {
  49901. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49902. _this._markAllSubMeshesAsImageProcessingDirty();
  49903. });
  49904. }
  49905. };
  49906. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  49907. /**
  49908. * Gets a boolean indicating that current material needs to register RTT
  49909. */
  49910. get: function () {
  49911. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49912. return true;
  49913. }
  49914. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  49915. return true;
  49916. }
  49917. return false;
  49918. },
  49919. enumerable: true,
  49920. configurable: true
  49921. });
  49922. /**
  49923. * Gets the name of the material class.
  49924. */
  49925. PBRBaseMaterial.prototype.getClassName = function () {
  49926. return "PBRBaseMaterial";
  49927. };
  49928. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  49929. /**
  49930. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49931. */
  49932. get: function () {
  49933. return this._useLogarithmicDepth;
  49934. },
  49935. /**
  49936. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49937. */
  49938. set: function (value) {
  49939. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  49940. },
  49941. enumerable: true,
  49942. configurable: true
  49943. });
  49944. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  49945. /**
  49946. * Gets the current transparency mode.
  49947. */
  49948. get: function () {
  49949. return this._transparencyMode;
  49950. },
  49951. /**
  49952. * Sets the transparency mode of the material.
  49953. *
  49954. * | Value | Type | Description |
  49955. * | ----- | ----------------------------------- | ----------- |
  49956. * | 0 | OPAQUE | |
  49957. * | 1 | ALPHATEST | |
  49958. * | 2 | ALPHABLEND | |
  49959. * | 3 | ALPHATESTANDBLEND | |
  49960. *
  49961. */
  49962. set: function (value) {
  49963. if (this._transparencyMode === value) {
  49964. return;
  49965. }
  49966. this._transparencyMode = value;
  49967. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  49968. this._markAllSubMeshesAsTexturesAndMiscDirty();
  49969. },
  49970. enumerable: true,
  49971. configurable: true
  49972. });
  49973. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  49974. /**
  49975. * Returns true if alpha blending should be disabled.
  49976. */
  49977. get: function () {
  49978. return (this._linkRefractionWithTransparency ||
  49979. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  49980. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  49981. },
  49982. enumerable: true,
  49983. configurable: true
  49984. });
  49985. /**
  49986. * Specifies whether or not this material should be rendered in alpha blend mode.
  49987. */
  49988. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  49989. if (this._disableAlphaBlending) {
  49990. return false;
  49991. }
  49992. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  49993. };
  49994. /**
  49995. * Specifies if the mesh will require alpha blending.
  49996. * @param mesh - BJS mesh.
  49997. */
  49998. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  49999. if (this._disableAlphaBlending) {
  50000. return false;
  50001. }
  50002. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50003. };
  50004. /**
  50005. * Specifies whether or not this material should be rendered in alpha test mode.
  50006. */
  50007. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50008. if (this._forceAlphaTest) {
  50009. return true;
  50010. }
  50011. if (this._linkRefractionWithTransparency) {
  50012. return false;
  50013. }
  50014. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50015. };
  50016. /**
  50017. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50018. */
  50019. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  50020. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  50021. };
  50022. /**
  50023. * Gets the texture used for the alpha test.
  50024. */
  50025. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  50026. return this._albedoTexture;
  50027. };
  50028. /**
  50029. * Specifies that the submesh is ready to be used.
  50030. * @param mesh - BJS mesh.
  50031. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50032. * @param useInstances - Specifies that instances should be used.
  50033. * @returns - boolean indicating that the submesh is ready or not.
  50034. */
  50035. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50036. if (subMesh.effect && this.isFrozen) {
  50037. if (this._wasPreviouslyReady) {
  50038. return true;
  50039. }
  50040. }
  50041. if (!subMesh._materialDefines) {
  50042. subMesh._materialDefines = new PBRMaterialDefines();
  50043. }
  50044. var defines = subMesh._materialDefines;
  50045. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50046. if (defines._renderId === this.getScene().getRenderId()) {
  50047. return true;
  50048. }
  50049. }
  50050. var scene = this.getScene();
  50051. var engine = scene.getEngine();
  50052. if (defines._areTexturesDirty) {
  50053. if (scene.texturesEnabled) {
  50054. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50055. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  50056. return false;
  50057. }
  50058. }
  50059. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50060. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  50061. return false;
  50062. }
  50063. }
  50064. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50065. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  50066. return false;
  50067. }
  50068. }
  50069. var reflectionTexture = this._getReflectionTexture();
  50070. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50071. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50072. return false;
  50073. }
  50074. }
  50075. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50076. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  50077. return false;
  50078. }
  50079. }
  50080. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50081. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  50082. return false;
  50083. }
  50084. }
  50085. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50086. if (this._metallicTexture) {
  50087. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  50088. return false;
  50089. }
  50090. }
  50091. else if (this._reflectivityTexture) {
  50092. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  50093. return false;
  50094. }
  50095. }
  50096. if (this._microSurfaceTexture) {
  50097. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  50098. return false;
  50099. }
  50100. }
  50101. }
  50102. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50103. // Bump texture cannot be not blocking.
  50104. if (!this._bumpTexture.isReady()) {
  50105. return false;
  50106. }
  50107. }
  50108. var refractionTexture = this._getRefractionTexture();
  50109. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50110. if (!refractionTexture.isReadyOrNotBlocking()) {
  50111. return false;
  50112. }
  50113. }
  50114. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50115. // This is blocking.
  50116. if (!this._environmentBRDFTexture.isReady()) {
  50117. return false;
  50118. }
  50119. }
  50120. }
  50121. }
  50122. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50123. if (!this._imageProcessingConfiguration.isReady()) {
  50124. return false;
  50125. }
  50126. }
  50127. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  50128. mesh.createNormals(true);
  50129. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  50130. }
  50131. var previousEffect = subMesh.effect;
  50132. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  50133. if (effect) {
  50134. // Use previous effect while new one is compiling
  50135. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  50136. effect = previousEffect;
  50137. defines.markAsUnprocessed();
  50138. }
  50139. else {
  50140. scene.resetCachedMaterial();
  50141. subMesh.setEffect(effect, defines);
  50142. this.buildUniformLayout();
  50143. }
  50144. }
  50145. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50146. return false;
  50147. }
  50148. defines._renderId = scene.getRenderId();
  50149. this._wasPreviouslyReady = true;
  50150. return true;
  50151. };
  50152. /**
  50153. * Specifies if the material uses metallic roughness workflow.
  50154. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50155. */
  50156. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  50157. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  50158. return true;
  50159. }
  50160. return false;
  50161. };
  50162. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  50163. if (onCompiled === void 0) { onCompiled = null; }
  50164. if (onError === void 0) { onError = null; }
  50165. if (useInstances === void 0) { useInstances = null; }
  50166. if (useClipPlane === void 0) { useClipPlane = null; }
  50167. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  50168. if (!defines.isDirty) {
  50169. return null;
  50170. }
  50171. defines.markAsProcessed();
  50172. var scene = this.getScene();
  50173. var engine = scene.getEngine();
  50174. // Fallbacks
  50175. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  50176. var fallbackRank = 0;
  50177. if (defines.USESPHERICALINVERTEX) {
  50178. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  50179. }
  50180. if (defines.FOG) {
  50181. fallbacks.addFallback(fallbackRank, "FOG");
  50182. }
  50183. if (defines.SPECULARAA) {
  50184. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  50185. }
  50186. if (defines.POINTSIZE) {
  50187. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  50188. }
  50189. if (defines.LOGARITHMICDEPTH) {
  50190. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  50191. }
  50192. if (defines.PARALLAX) {
  50193. fallbacks.addFallback(fallbackRank, "PARALLAX");
  50194. }
  50195. if (defines.PARALLAXOCCLUSION) {
  50196. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  50197. }
  50198. if (defines.ENVIRONMENTBRDF) {
  50199. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  50200. }
  50201. if (defines.TANGENT) {
  50202. fallbacks.addFallback(fallbackRank++, "TANGENT");
  50203. }
  50204. if (defines.BUMP) {
  50205. fallbacks.addFallback(fallbackRank++, "BUMP");
  50206. }
  50207. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  50208. if (defines.SPECULARTERM) {
  50209. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  50210. }
  50211. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  50212. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  50213. }
  50214. if (defines.LIGHTMAP) {
  50215. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  50216. }
  50217. if (defines.NORMAL) {
  50218. fallbacks.addFallback(fallbackRank++, "NORMAL");
  50219. }
  50220. if (defines.AMBIENT) {
  50221. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  50222. }
  50223. if (defines.EMISSIVE) {
  50224. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  50225. }
  50226. if (defines.VERTEXCOLOR) {
  50227. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  50228. }
  50229. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50230. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  50231. }
  50232. if (defines.MORPHTARGETS) {
  50233. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  50234. }
  50235. //Attributes
  50236. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  50237. if (defines.NORMAL) {
  50238. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  50239. }
  50240. if (defines.TANGENT) {
  50241. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  50242. }
  50243. if (defines.UV1) {
  50244. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  50245. }
  50246. if (defines.UV2) {
  50247. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  50248. }
  50249. if (defines.VERTEXCOLOR) {
  50250. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  50251. }
  50252. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50253. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50254. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  50255. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  50256. "vFogInfos", "vFogColor", "pointSize",
  50257. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  50258. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  50259. "mBones",
  50260. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  50261. "vLightingIntensity",
  50262. "logarithmicDepthConstant",
  50263. "vSphericalX", "vSphericalY", "vSphericalZ",
  50264. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  50265. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  50266. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  50267. "vTangentSpaceParams", "boneTextureWidth"
  50268. ];
  50269. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  50270. "bumpSampler", "lightmapSampler", "opacitySampler",
  50271. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  50272. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  50273. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  50274. var uniformBuffers = ["Material", "Scene"];
  50275. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  50276. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50277. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50278. }
  50279. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50280. uniformsNames: uniforms,
  50281. uniformBuffersNames: uniformBuffers,
  50282. samplers: samplers,
  50283. defines: defines,
  50284. maxSimultaneousLights: this._maxSimultaneousLights
  50285. });
  50286. var join = defines.toString();
  50287. return engine.createEffect("pbr", {
  50288. attributes: attribs,
  50289. uniformsNames: uniforms,
  50290. uniformBuffersNames: uniformBuffers,
  50291. samplers: samplers,
  50292. defines: join,
  50293. fallbacks: fallbacks,
  50294. onCompiled: onCompiled,
  50295. onError: onError,
  50296. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  50297. }, engine);
  50298. };
  50299. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  50300. if (useInstances === void 0) { useInstances = null; }
  50301. if (useClipPlane === void 0) { useClipPlane = null; }
  50302. var scene = this.getScene();
  50303. var engine = scene.getEngine();
  50304. // Lights
  50305. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  50306. defines._needNormals = true;
  50307. // Textures
  50308. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  50309. if (defines._areTexturesDirty) {
  50310. defines._needUVs = false;
  50311. if (scene.texturesEnabled) {
  50312. if (scene.getEngine().getCaps().textureLOD) {
  50313. defines.LODBASEDMICROSFURACE = true;
  50314. }
  50315. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50316. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  50317. }
  50318. else {
  50319. defines.ALBEDO = false;
  50320. }
  50321. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  50323. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  50324. }
  50325. else {
  50326. defines.AMBIENT = false;
  50327. }
  50328. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50329. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  50330. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  50331. }
  50332. else {
  50333. defines.OPACITY = false;
  50334. }
  50335. var reflectionTexture = this._getReflectionTexture();
  50336. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50337. defines.REFLECTION = true;
  50338. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50339. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50340. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50341. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50342. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  50343. defines.INVERTCUBICMAP = true;
  50344. }
  50345. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50346. defines.REFLECTIONMAP_CUBIC = false;
  50347. defines.REFLECTIONMAP_EXPLICIT = false;
  50348. defines.REFLECTIONMAP_PLANAR = false;
  50349. defines.REFLECTIONMAP_PROJECTION = false;
  50350. defines.REFLECTIONMAP_SKYBOX = false;
  50351. defines.REFLECTIONMAP_SPHERICAL = false;
  50352. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50353. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50354. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50355. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50356. switch (reflectionTexture.coordinatesMode) {
  50357. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  50358. defines.REFLECTIONMAP_EXPLICIT = true;
  50359. break;
  50360. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  50361. defines.REFLECTIONMAP_PLANAR = true;
  50362. break;
  50363. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  50364. defines.REFLECTIONMAP_PROJECTION = true;
  50365. break;
  50366. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  50367. defines.REFLECTIONMAP_SKYBOX = true;
  50368. break;
  50369. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  50370. defines.REFLECTIONMAP_SPHERICAL = true;
  50371. break;
  50372. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  50373. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50374. break;
  50375. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50376. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50377. break;
  50378. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50379. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50380. break;
  50381. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  50382. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  50383. default:
  50384. defines.REFLECTIONMAP_CUBIC = true;
  50385. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  50386. break;
  50387. }
  50388. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  50389. if (reflectionTexture.sphericalPolynomial) {
  50390. defines.USESPHERICALFROMREFLECTIONMAP = true;
  50391. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  50392. defines.USESPHERICALINVERTEX = false;
  50393. }
  50394. else {
  50395. defines.USESPHERICALINVERTEX = true;
  50396. }
  50397. }
  50398. }
  50399. else {
  50400. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50401. }
  50402. }
  50403. else {
  50404. defines.REFLECTION = false;
  50405. defines.REFLECTIONMAP_3D = false;
  50406. defines.REFLECTIONMAP_SPHERICAL = false;
  50407. defines.REFLECTIONMAP_PLANAR = false;
  50408. defines.REFLECTIONMAP_CUBIC = false;
  50409. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50410. defines.REFLECTIONMAP_PROJECTION = false;
  50411. defines.REFLECTIONMAP_SKYBOX = false;
  50412. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50413. defines.REFLECTIONMAP_EXPLICIT = false;
  50414. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50415. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50416. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50417. defines.INVERTCUBICMAP = false;
  50418. defines.USESPHERICALFROMREFLECTIONMAP = false;
  50419. defines.USESPHERICALINVERTEX = false;
  50420. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50421. defines.LODINREFLECTIONALPHA = false;
  50422. defines.GAMMAREFLECTION = false;
  50423. defines.RGBDREFLECTION = false;
  50424. }
  50425. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50426. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  50427. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  50428. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  50429. }
  50430. else {
  50431. defines.LIGHTMAP = false;
  50432. }
  50433. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50434. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  50435. }
  50436. else {
  50437. defines.EMISSIVE = false;
  50438. }
  50439. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50440. if (this._metallicTexture) {
  50441. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  50442. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  50443. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  50444. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  50445. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  50446. }
  50447. else if (this._reflectivityTexture) {
  50448. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  50449. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  50450. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  50451. }
  50452. else {
  50453. defines.REFLECTIVITY = false;
  50454. }
  50455. if (this._microSurfaceTexture) {
  50456. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  50457. }
  50458. else {
  50459. defines.MICROSURFACEMAP = false;
  50460. }
  50461. }
  50462. else {
  50463. defines.REFLECTIVITY = false;
  50464. defines.MICROSURFACEMAP = false;
  50465. }
  50466. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50467. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  50468. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50469. defines.PARALLAX = true;
  50470. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  50471. }
  50472. else {
  50473. defines.PARALLAX = false;
  50474. }
  50475. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  50476. }
  50477. else {
  50478. defines.BUMP = false;
  50479. }
  50480. var refractionTexture = this._getRefractionTexture();
  50481. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50482. defines.REFRACTION = true;
  50483. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  50484. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  50485. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  50486. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  50487. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  50488. if (this._linkRefractionWithTransparency) {
  50489. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  50490. }
  50491. }
  50492. else {
  50493. defines.REFRACTION = false;
  50494. }
  50495. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50496. defines.ENVIRONMENTBRDF = true;
  50497. }
  50498. else {
  50499. defines.ENVIRONMENTBRDF = false;
  50500. }
  50501. if (this._shouldUseAlphaFromAlbedoTexture()) {
  50502. defines.ALPHAFROMALBEDO = true;
  50503. }
  50504. else {
  50505. defines.ALPHAFROMALBEDO = false;
  50506. }
  50507. }
  50508. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  50509. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  50510. defines.USEPHYSICALLIGHTFALLOFF = false;
  50511. defines.USEGLTFLIGHTFALLOFF = false;
  50512. }
  50513. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  50514. defines.USEPHYSICALLIGHTFALLOFF = false;
  50515. defines.USEGLTFLIGHTFALLOFF = true;
  50516. }
  50517. else {
  50518. defines.USEPHYSICALLIGHTFALLOFF = true;
  50519. defines.USEGLTFLIGHTFALLOFF = false;
  50520. }
  50521. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  50522. if (!this.backFaceCulling && this._twoSidedLighting) {
  50523. defines.TWOSIDEDLIGHTING = true;
  50524. }
  50525. else {
  50526. defines.TWOSIDEDLIGHTING = false;
  50527. }
  50528. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  50529. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  50530. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  50531. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  50532. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  50533. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  50534. }
  50535. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50536. this._imageProcessingConfiguration.prepareDefines(defines);
  50537. }
  50538. defines.FORCENORMALFORWARD = this._forceNormalForward;
  50539. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  50540. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  50541. // Misc.
  50542. if (defines._areMiscDirty) {
  50543. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  50544. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  50545. }
  50546. // Values that need to be evaluated on every frame
  50547. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  50548. // Attribs
  50549. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  50550. };
  50551. /**
  50552. * Force shader compilation
  50553. */
  50554. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  50555. var _this = this;
  50556. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  50557. var defines = new PBRMaterialDefines();
  50558. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  50559. if (effect.isReady()) {
  50560. if (onCompiled) {
  50561. onCompiled(this);
  50562. }
  50563. }
  50564. else {
  50565. effect.onCompileObservable.add(function () {
  50566. if (onCompiled) {
  50567. onCompiled(_this);
  50568. }
  50569. });
  50570. }
  50571. };
  50572. /**
  50573. * Initializes the uniform buffer layout for the shader.
  50574. */
  50575. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  50576. // Order is important !
  50577. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  50578. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  50579. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  50580. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  50581. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  50582. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  50583. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  50584. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  50585. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50586. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  50587. this._uniformBuffer.addUniform("vReflectionSize", 3);
  50588. this._uniformBuffer.addUniform("vBumpInfos", 3);
  50589. this._uniformBuffer.addUniform("albedoMatrix", 16);
  50590. this._uniformBuffer.addUniform("ambientMatrix", 16);
  50591. this._uniformBuffer.addUniform("opacityMatrix", 16);
  50592. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  50593. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  50594. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  50595. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  50596. this._uniformBuffer.addUniform("bumpMatrix", 16);
  50597. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  50598. this._uniformBuffer.addUniform("refractionMatrix", 16);
  50599. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50600. this._uniformBuffer.addUniform("vReflectionColor", 3);
  50601. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  50602. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  50603. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  50604. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50605. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  50606. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  50607. this._uniformBuffer.addUniform("pointSize", 1);
  50608. this._uniformBuffer.create();
  50609. };
  50610. /**
  50611. * Unbinds the textures.
  50612. */
  50613. PBRBaseMaterial.prototype.unbind = function () {
  50614. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50615. this._uniformBuffer.setTexture("reflectionSampler", null);
  50616. }
  50617. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50618. this._uniformBuffer.setTexture("refractionSampler", null);
  50619. }
  50620. _super.prototype.unbind.call(this);
  50621. };
  50622. /**
  50623. * Binds the submesh data.
  50624. * @param world - The world matrix.
  50625. * @param mesh - The BJS mesh.
  50626. * @param subMesh - A submesh of the BJS mesh.
  50627. */
  50628. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50629. var scene = this.getScene();
  50630. var defines = subMesh._materialDefines;
  50631. if (!defines) {
  50632. return;
  50633. }
  50634. var effect = subMesh.effect;
  50635. if (!effect) {
  50636. return;
  50637. }
  50638. this._activeEffect = effect;
  50639. // Matrices
  50640. this.bindOnlyWorldMatrix(world);
  50641. // Normal Matrix
  50642. if (defines.OBJECTSPACE_NORMALMAP) {
  50643. world.toNormalMatrix(this._normalMatrix);
  50644. this.bindOnlyNormalMatrix(this._normalMatrix);
  50645. }
  50646. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50647. // Bones
  50648. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50649. var reflectionTexture = null;
  50650. if (mustRebind) {
  50651. this._uniformBuffer.bindToEffect(effect, "Material");
  50652. this.bindViewProjection(effect);
  50653. reflectionTexture = this._getReflectionTexture();
  50654. var refractionTexture = this._getRefractionTexture();
  50655. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50656. // Texture uniforms
  50657. if (scene.texturesEnabled) {
  50658. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50659. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  50660. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  50661. }
  50662. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50663. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  50664. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  50665. }
  50666. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50667. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  50668. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  50669. }
  50670. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50671. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50672. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  50673. if (reflectionTexture.boundingBoxSize) {
  50674. var cubeTexture = reflectionTexture;
  50675. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  50676. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  50677. }
  50678. var polynomials = reflectionTexture.sphericalPolynomial;
  50679. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  50680. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  50681. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  50682. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  50683. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  50684. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  50685. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  50686. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  50687. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  50688. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  50689. }
  50690. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50691. }
  50692. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50693. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  50694. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  50695. }
  50696. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50697. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  50698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  50699. }
  50700. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50701. if (this._metallicTexture) {
  50702. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  50703. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  50704. }
  50705. else if (this._reflectivityTexture) {
  50706. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  50707. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  50708. }
  50709. if (this._microSurfaceTexture) {
  50710. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  50711. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  50712. }
  50713. }
  50714. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50715. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  50716. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  50717. if (scene._mirroredCameraPosition) {
  50718. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  50719. }
  50720. else {
  50721. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  50722. }
  50723. }
  50724. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50725. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  50726. var depth = 1.0;
  50727. if (!refractionTexture.isCube) {
  50728. if (refractionTexture.depth) {
  50729. depth = refractionTexture.depth;
  50730. }
  50731. }
  50732. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  50733. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  50734. }
  50735. }
  50736. // Point size
  50737. if (this.pointsCloud) {
  50738. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50739. }
  50740. // Colors
  50741. if (defines.METALLICWORKFLOW) {
  50742. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  50743. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  50744. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  50745. }
  50746. else {
  50747. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  50748. }
  50749. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  50750. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  50751. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  50752. // Misc
  50753. this._lightingInfos.x = this._directIntensity;
  50754. this._lightingInfos.y = this._emissiveIntensity;
  50755. this._lightingInfos.z = this._environmentIntensity;
  50756. this._lightingInfos.w = this._specularIntensity;
  50757. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  50758. }
  50759. // Textures
  50760. if (scene.texturesEnabled) {
  50761. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50762. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  50763. }
  50764. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50765. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  50766. }
  50767. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50768. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  50769. }
  50770. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50771. if (defines.LODBASEDMICROSFURACE) {
  50772. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50773. }
  50774. else {
  50775. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50776. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50777. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50778. }
  50779. }
  50780. if (defines.ENVIRONMENTBRDF) {
  50781. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  50782. }
  50783. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50784. if (defines.LODBASEDMICROSFURACE) {
  50785. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  50786. }
  50787. else {
  50788. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  50789. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  50790. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  50791. }
  50792. }
  50793. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50794. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  50795. }
  50796. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50797. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  50798. }
  50799. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50800. if (this._metallicTexture) {
  50801. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  50802. }
  50803. else if (this._reflectivityTexture) {
  50804. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  50805. }
  50806. if (this._microSurfaceTexture) {
  50807. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  50808. }
  50809. }
  50810. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50811. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  50812. }
  50813. }
  50814. // Clip plane
  50815. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50816. // Colors
  50817. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  50818. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  50819. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  50820. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  50821. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  50822. }
  50823. if (mustRebind || !this.isFrozen) {
  50824. // Lights
  50825. if (scene.lightsEnabled && !this._disableLighting) {
  50826. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  50827. }
  50828. // View
  50829. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  50830. this.bindView(effect);
  50831. }
  50832. // Fog
  50833. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50834. // Morph targets
  50835. if (defines.NUM_MORPH_INFLUENCERS) {
  50836. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  50837. }
  50838. // image processing
  50839. this._imageProcessingConfiguration.bind(this._activeEffect);
  50840. // Log. depth
  50841. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  50842. }
  50843. this._uniformBuffer.update();
  50844. this._afterBind(mesh, this._activeEffect);
  50845. };
  50846. /**
  50847. * Returns the animatable textures.
  50848. * @returns - Array of animatable textures.
  50849. */
  50850. PBRBaseMaterial.prototype.getAnimatables = function () {
  50851. var results = [];
  50852. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  50853. results.push(this._albedoTexture);
  50854. }
  50855. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  50856. results.push(this._ambientTexture);
  50857. }
  50858. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  50859. results.push(this._opacityTexture);
  50860. }
  50861. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  50862. results.push(this._reflectionTexture);
  50863. }
  50864. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  50865. results.push(this._emissiveTexture);
  50866. }
  50867. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  50868. results.push(this._metallicTexture);
  50869. }
  50870. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  50871. results.push(this._reflectivityTexture);
  50872. }
  50873. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  50874. results.push(this._bumpTexture);
  50875. }
  50876. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  50877. results.push(this._lightmapTexture);
  50878. }
  50879. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  50880. results.push(this._refractionTexture);
  50881. }
  50882. return results;
  50883. };
  50884. /**
  50885. * Returns the texture used for reflections.
  50886. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50887. */
  50888. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  50889. if (this._reflectionTexture) {
  50890. return this._reflectionTexture;
  50891. }
  50892. return this.getScene().environmentTexture;
  50893. };
  50894. /**
  50895. * Returns the texture used for refraction or null if none is used.
  50896. * @returns - Refection texture if present. If no refraction texture and refraction
  50897. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50898. */
  50899. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  50900. if (this._refractionTexture) {
  50901. return this._refractionTexture;
  50902. }
  50903. if (this._linkRefractionWithTransparency) {
  50904. return this.getScene().environmentTexture;
  50905. }
  50906. return null;
  50907. };
  50908. /**
  50909. * Disposes the resources of the material.
  50910. * @param forceDisposeEffect - Forces the disposal of effects.
  50911. * @param forceDisposeTextures - Forces the disposal of all textures.
  50912. */
  50913. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50914. if (forceDisposeTextures) {
  50915. if (this._albedoTexture) {
  50916. this._albedoTexture.dispose();
  50917. }
  50918. if (this._ambientTexture) {
  50919. this._ambientTexture.dispose();
  50920. }
  50921. if (this._opacityTexture) {
  50922. this._opacityTexture.dispose();
  50923. }
  50924. if (this._reflectionTexture) {
  50925. this._reflectionTexture.dispose();
  50926. }
  50927. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  50928. this._environmentBRDFTexture.dispose();
  50929. }
  50930. if (this._emissiveTexture) {
  50931. this._emissiveTexture.dispose();
  50932. }
  50933. if (this._metallicTexture) {
  50934. this._metallicTexture.dispose();
  50935. }
  50936. if (this._reflectivityTexture) {
  50937. this._reflectivityTexture.dispose();
  50938. }
  50939. if (this._bumpTexture) {
  50940. this._bumpTexture.dispose();
  50941. }
  50942. if (this._lightmapTexture) {
  50943. this._lightmapTexture.dispose();
  50944. }
  50945. if (this._refractionTexture) {
  50946. this._refractionTexture.dispose();
  50947. }
  50948. }
  50949. this._renderTargets.dispose();
  50950. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50951. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50952. }
  50953. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  50954. };
  50955. /**
  50956. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50957. */
  50958. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  50959. /**
  50960. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50961. */
  50962. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  50963. /**
  50964. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50965. */
  50966. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  50967. /**
  50968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50969. * They are also discarded below the alpha cutoff threshold to improve performances.
  50970. */
  50971. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  50972. /**
  50973. * Defines the default value of how much AO map is occluding the analytical lights
  50974. * (point spot...).
  50975. */
  50976. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  50977. /**
  50978. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50979. */
  50980. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  50981. /**
  50982. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50983. * to enhance interoperability with other engines.
  50984. */
  50985. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  50986. /**
  50987. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50988. * to enhance interoperability with other materials.
  50989. */
  50990. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  50991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50993. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50996. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  50997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50999. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51000. return PBRBaseMaterial;
  51001. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51002. /***/ }),
  51003. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51004. /*!************************************************!*\
  51005. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51006. \************************************************/
  51007. /*! exports provided: PBRBaseSimpleMaterial */
  51008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51009. "use strict";
  51010. __webpack_require__.r(__webpack_exports__);
  51011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  51012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51013. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51014. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51015. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51016. /**
  51017. * The Physically based simple base material of BJS.
  51018. *
  51019. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51020. * It is used as the base class for both the specGloss and metalRough conventions.
  51021. */
  51022. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  51023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  51024. /**
  51025. * Instantiates a new PBRMaterial instance.
  51026. *
  51027. * @param name The material name
  51028. * @param scene The scene the material will be use in.
  51029. */
  51030. function PBRBaseSimpleMaterial(name, scene) {
  51031. var _this = _super.call(this, name, scene) || this;
  51032. /**
  51033. * Number of Simultaneous lights allowed on the material.
  51034. */
  51035. _this.maxSimultaneousLights = 4;
  51036. /**
  51037. * If sets to true, disables all the lights affecting the material.
  51038. */
  51039. _this.disableLighting = false;
  51040. /**
  51041. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51042. */
  51043. _this.invertNormalMapX = false;
  51044. /**
  51045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51046. */
  51047. _this.invertNormalMapY = false;
  51048. /**
  51049. * Emissivie color used to self-illuminate the model.
  51050. */
  51051. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  51052. /**
  51053. * Occlusion Channel Strenght.
  51054. */
  51055. _this.occlusionStrength = 1.0;
  51056. /**
  51057. * If true, the light map contains occlusion information instead of lighting info.
  51058. */
  51059. _this.useLightmapAsShadowmap = false;
  51060. _this._useAlphaFromAlbedoTexture = true;
  51061. _this._useAmbientInGrayScale = true;
  51062. return _this;
  51063. }
  51064. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  51065. /**
  51066. * Gets the current double sided mode.
  51067. */
  51068. get: function () {
  51069. return this._twoSidedLighting;
  51070. },
  51071. /**
  51072. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51073. */
  51074. set: function (value) {
  51075. if (this._twoSidedLighting === value) {
  51076. return;
  51077. }
  51078. this._twoSidedLighting = value;
  51079. this.backFaceCulling = !value;
  51080. this._markAllSubMeshesAsTexturesDirty();
  51081. },
  51082. enumerable: true,
  51083. configurable: true
  51084. });
  51085. /**
  51086. * Return the active textures of the material.
  51087. */
  51088. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  51089. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51090. if (this.environmentTexture) {
  51091. activeTextures.push(this.environmentTexture);
  51092. }
  51093. if (this.normalTexture) {
  51094. activeTextures.push(this.normalTexture);
  51095. }
  51096. if (this.emissiveTexture) {
  51097. activeTextures.push(this.emissiveTexture);
  51098. }
  51099. if (this.occlusionTexture) {
  51100. activeTextures.push(this.occlusionTexture);
  51101. }
  51102. if (this.lightmapTexture) {
  51103. activeTextures.push(this.lightmapTexture);
  51104. }
  51105. return activeTextures;
  51106. };
  51107. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  51108. if (_super.prototype.hasTexture.call(this, texture)) {
  51109. return true;
  51110. }
  51111. if (this.lightmapTexture === texture) {
  51112. return true;
  51113. }
  51114. return false;
  51115. };
  51116. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  51117. return "PBRBaseSimpleMaterial";
  51118. };
  51119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51122. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  51123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51126. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  51127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  51130. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  51131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51134. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  51135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51138. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  51139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  51142. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  51143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  51145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51146. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  51147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51150. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  51151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  51154. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  51155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  51158. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  51159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  51162. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  51163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51165. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  51166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51169. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  51170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51173. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  51174. return PBRBaseSimpleMaterial;
  51175. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  51176. /***/ }),
  51177. /***/ "./Materials/PBR/pbrMaterial.ts":
  51178. /*!**************************************!*\
  51179. !*** ./Materials/PBR/pbrMaterial.ts ***!
  51180. \**************************************/
  51181. /*! exports provided: PBRMaterial */
  51182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51183. "use strict";
  51184. __webpack_require__.r(__webpack_exports__);
  51185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  51186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51187. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51188. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51189. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51190. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51191. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  51192. /**
  51193. * The Physically based material of BJS.
  51194. *
  51195. * This offers the main features of a standard PBR material.
  51196. * For more information, please refer to the documentation :
  51197. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51198. */
  51199. var PBRMaterial = /** @class */ (function (_super) {
  51200. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  51201. /**
  51202. * Instantiates a new PBRMaterial instance.
  51203. *
  51204. * @param name The material name
  51205. * @param scene The scene the material will be use in.
  51206. */
  51207. function PBRMaterial(name, scene) {
  51208. var _this = _super.call(this, name, scene) || this;
  51209. /**
  51210. * Intensity of the direct lights e.g. the four lights available in your scene.
  51211. * This impacts both the direct diffuse and specular highlights.
  51212. */
  51213. _this.directIntensity = 1.0;
  51214. /**
  51215. * Intensity of the emissive part of the material.
  51216. * This helps controlling the emissive effect without modifying the emissive color.
  51217. */
  51218. _this.emissiveIntensity = 1.0;
  51219. /**
  51220. * Intensity of the environment e.g. how much the environment will light the object
  51221. * either through harmonics for rough material or through the refelction for shiny ones.
  51222. */
  51223. _this.environmentIntensity = 1.0;
  51224. /**
  51225. * This is a special control allowing the reduction of the specular highlights coming from the
  51226. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51227. */
  51228. _this.specularIntensity = 1.0;
  51229. /**
  51230. * Debug Control allowing disabling the bump map on this material.
  51231. */
  51232. _this.disableBumpMap = false;
  51233. /**
  51234. * AKA Occlusion Texture Intensity in other nomenclature.
  51235. */
  51236. _this.ambientTextureStrength = 1.0;
  51237. /**
  51238. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51239. * 1 means it completely occludes it
  51240. * 0 mean it has no impact
  51241. */
  51242. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51243. /**
  51244. * The color of a material in ambient lighting.
  51245. */
  51246. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51247. /**
  51248. * AKA Diffuse Color in other nomenclature.
  51249. */
  51250. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51251. /**
  51252. * AKA Specular Color in other nomenclature.
  51253. */
  51254. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51255. /**
  51256. * The color reflected from the material.
  51257. */
  51258. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  51259. /**
  51260. * The color emitted from the material.
  51261. */
  51262. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51263. /**
  51264. * AKA Glossiness in other nomenclature.
  51265. */
  51266. _this.microSurface = 1.0;
  51267. /**
  51268. * source material index of refraction (IOR)' / 'destination material IOR.
  51269. */
  51270. _this.indexOfRefraction = 0.66;
  51271. /**
  51272. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51273. */
  51274. _this.invertRefractionY = false;
  51275. /**
  51276. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51277. * Materials half opaque for instance using refraction could benefit from this control.
  51278. */
  51279. _this.linkRefractionWithTransparency = false;
  51280. /**
  51281. * If true, the light map contains occlusion information instead of lighting info.
  51282. */
  51283. _this.useLightmapAsShadowmap = false;
  51284. /**
  51285. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51286. */
  51287. _this.useAlphaFromAlbedoTexture = false;
  51288. /**
  51289. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51290. */
  51291. _this.forceAlphaTest = false;
  51292. /**
  51293. * Defines the alpha limits in alpha test mode.
  51294. */
  51295. _this.alphaCutOff = 0.4;
  51296. /**
  51297. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51298. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51299. */
  51300. _this.useSpecularOverAlpha = true;
  51301. /**
  51302. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51303. */
  51304. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  51305. /**
  51306. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51307. */
  51308. _this.useRoughnessFromMetallicTextureAlpha = true;
  51309. /**
  51310. * Specifies if the metallic texture contains the roughness information in its green channel.
  51311. */
  51312. _this.useRoughnessFromMetallicTextureGreen = false;
  51313. /**
  51314. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51315. */
  51316. _this.useMetallnessFromMetallicTextureBlue = false;
  51317. /**
  51318. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51319. */
  51320. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  51321. /**
  51322. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51323. */
  51324. _this.useAmbientInGrayScale = false;
  51325. /**
  51326. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51327. * The material will try to infer what glossiness each pixel should be.
  51328. */
  51329. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  51330. /**
  51331. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51332. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51333. */
  51334. _this.useRadianceOverAlpha = true;
  51335. /**
  51336. * Allows using an object space normal map (instead of tangent space).
  51337. */
  51338. _this.useObjectSpaceNormalMap = false;
  51339. /**
  51340. * Allows using the bump map in parallax mode.
  51341. */
  51342. _this.useParallax = false;
  51343. /**
  51344. * Allows using the bump map in parallax occlusion mode.
  51345. */
  51346. _this.useParallaxOcclusion = false;
  51347. /**
  51348. * Controls the scale bias of the parallax mode.
  51349. */
  51350. _this.parallaxScaleBias = 0.05;
  51351. /**
  51352. * If sets to true, disables all the lights affecting the material.
  51353. */
  51354. _this.disableLighting = false;
  51355. /**
  51356. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51357. */
  51358. _this.forceIrradianceInFragment = false;
  51359. /**
  51360. * Number of Simultaneous lights allowed on the material.
  51361. */
  51362. _this.maxSimultaneousLights = 4;
  51363. /**
  51364. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51365. */
  51366. _this.invertNormalMapX = false;
  51367. /**
  51368. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51369. */
  51370. _this.invertNormalMapY = false;
  51371. /**
  51372. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51373. */
  51374. _this.twoSidedLighting = false;
  51375. /**
  51376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51377. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51378. */
  51379. _this.useAlphaFresnel = false;
  51380. /**
  51381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51382. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51383. */
  51384. _this.useLinearAlphaFresnel = false;
  51385. /**
  51386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51387. * And/Or occlude the blended part.
  51388. */
  51389. _this.environmentBRDFTexture = null;
  51390. /**
  51391. * Force normal to face away from face.
  51392. */
  51393. _this.forceNormalForward = false;
  51394. /**
  51395. * Enables specular anti aliasing in the PBR shader.
  51396. * It will both interacts on the Geometry for analytical and IBL lighting.
  51397. * It also prefilter the roughness map based on the bump values.
  51398. */
  51399. _this.enableSpecularAntiAliasing = false;
  51400. /**
  51401. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51402. * makes the reflect vector face the model (under horizon).
  51403. */
  51404. _this.useHorizonOcclusion = true;
  51405. /**
  51406. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51407. * too much the area relying on ambient texture to define their ambient occlusion.
  51408. */
  51409. _this.useRadianceOcclusion = true;
  51410. /**
  51411. * If set to true, no lighting calculations will be applied.
  51412. */
  51413. _this.unlit = false;
  51414. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51415. return _this;
  51416. }
  51417. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  51418. /**
  51419. * BJS is using an harcoded light falloff based on a manually sets up range.
  51420. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51421. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51422. */
  51423. get: function () {
  51424. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51425. },
  51426. /**
  51427. * BJS is using an harcoded light falloff based on a manually sets up range.
  51428. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51429. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51430. */
  51431. set: function (value) {
  51432. if (value !== this.usePhysicalLightFalloff) {
  51433. // Ensure the effect will be rebuilt.
  51434. this._markAllSubMeshesAsTexturesDirty();
  51435. if (value) {
  51436. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51437. }
  51438. else {
  51439. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51440. }
  51441. }
  51442. },
  51443. enumerable: true,
  51444. configurable: true
  51445. });
  51446. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  51447. /**
  51448. * In order to support the falloff compatibility with gltf, a special mode has been added
  51449. * to reproduce the gltf light falloff.
  51450. */
  51451. get: function () {
  51452. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51453. },
  51454. /**
  51455. * In order to support the falloff compatibility with gltf, a special mode has been added
  51456. * to reproduce the gltf light falloff.
  51457. */
  51458. set: function (value) {
  51459. if (value !== this.useGLTFLightFalloff) {
  51460. // Ensure the effect will be rebuilt.
  51461. this._markAllSubMeshesAsTexturesDirty();
  51462. if (value) {
  51463. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51464. }
  51465. else {
  51466. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51467. }
  51468. }
  51469. },
  51470. enumerable: true,
  51471. configurable: true
  51472. });
  51473. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  51474. /**
  51475. * Gets the image processing configuration used either in this material.
  51476. */
  51477. get: function () {
  51478. return this._imageProcessingConfiguration;
  51479. },
  51480. /**
  51481. * Sets the Default image processing configuration used either in the this material.
  51482. *
  51483. * If sets to null, the scene one is in use.
  51484. */
  51485. set: function (value) {
  51486. this._attachImageProcessingConfiguration(value);
  51487. // Ensure the effect will be rebuilt.
  51488. this._markAllSubMeshesAsTexturesDirty();
  51489. },
  51490. enumerable: true,
  51491. configurable: true
  51492. });
  51493. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  51494. /**
  51495. * Gets wether the color curves effect is enabled.
  51496. */
  51497. get: function () {
  51498. return this.imageProcessingConfiguration.colorCurvesEnabled;
  51499. },
  51500. /**
  51501. * Sets wether the color curves effect is enabled.
  51502. */
  51503. set: function (value) {
  51504. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  51505. },
  51506. enumerable: true,
  51507. configurable: true
  51508. });
  51509. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  51510. /**
  51511. * Gets wether the color grading effect is enabled.
  51512. */
  51513. get: function () {
  51514. return this.imageProcessingConfiguration.colorGradingEnabled;
  51515. },
  51516. /**
  51517. * Gets wether the color grading effect is enabled.
  51518. */
  51519. set: function (value) {
  51520. this.imageProcessingConfiguration.colorGradingEnabled = value;
  51521. },
  51522. enumerable: true,
  51523. configurable: true
  51524. });
  51525. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  51526. /**
  51527. * Gets wether tonemapping is enabled or not.
  51528. */
  51529. get: function () {
  51530. return this._imageProcessingConfiguration.toneMappingEnabled;
  51531. },
  51532. /**
  51533. * Sets wether tonemapping is enabled or not
  51534. */
  51535. set: function (value) {
  51536. this._imageProcessingConfiguration.toneMappingEnabled = value;
  51537. },
  51538. enumerable: true,
  51539. configurable: true
  51540. });
  51541. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  51542. /**
  51543. * The camera exposure used on this material.
  51544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51545. * This corresponds to a photographic exposure.
  51546. */
  51547. get: function () {
  51548. return this._imageProcessingConfiguration.exposure;
  51549. },
  51550. /**
  51551. * The camera exposure used on this material.
  51552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51553. * This corresponds to a photographic exposure.
  51554. */
  51555. set: function (value) {
  51556. this._imageProcessingConfiguration.exposure = value;
  51557. },
  51558. enumerable: true,
  51559. configurable: true
  51560. });
  51561. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  51562. /**
  51563. * Gets The camera contrast used on this material.
  51564. */
  51565. get: function () {
  51566. return this._imageProcessingConfiguration.contrast;
  51567. },
  51568. /**
  51569. * Sets The camera contrast used on this material.
  51570. */
  51571. set: function (value) {
  51572. this._imageProcessingConfiguration.contrast = value;
  51573. },
  51574. enumerable: true,
  51575. configurable: true
  51576. });
  51577. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  51578. /**
  51579. * Gets the Color Grading 2D Lookup Texture.
  51580. */
  51581. get: function () {
  51582. return this._imageProcessingConfiguration.colorGradingTexture;
  51583. },
  51584. /**
  51585. * Sets the Color Grading 2D Lookup Texture.
  51586. */
  51587. set: function (value) {
  51588. this._imageProcessingConfiguration.colorGradingTexture = value;
  51589. },
  51590. enumerable: true,
  51591. configurable: true
  51592. });
  51593. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  51594. /**
  51595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51597. * 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;
  51598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51599. */
  51600. get: function () {
  51601. return this._imageProcessingConfiguration.colorCurves;
  51602. },
  51603. /**
  51604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51606. * 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;
  51607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51608. */
  51609. set: function (value) {
  51610. this._imageProcessingConfiguration.colorCurves = value;
  51611. },
  51612. enumerable: true,
  51613. configurable: true
  51614. });
  51615. /**
  51616. * Returns the name of this material class.
  51617. */
  51618. PBRMaterial.prototype.getClassName = function () {
  51619. return "PBRMaterial";
  51620. };
  51621. /**
  51622. * Returns an array of the actively used textures.
  51623. * @returns - Array of BaseTextures
  51624. */
  51625. PBRMaterial.prototype.getActiveTextures = function () {
  51626. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51627. if (this._albedoTexture) {
  51628. activeTextures.push(this._albedoTexture);
  51629. }
  51630. if (this._ambientTexture) {
  51631. activeTextures.push(this._ambientTexture);
  51632. }
  51633. if (this._opacityTexture) {
  51634. activeTextures.push(this._opacityTexture);
  51635. }
  51636. if (this._reflectionTexture) {
  51637. activeTextures.push(this._reflectionTexture);
  51638. }
  51639. if (this._emissiveTexture) {
  51640. activeTextures.push(this._emissiveTexture);
  51641. }
  51642. if (this._reflectivityTexture) {
  51643. activeTextures.push(this._reflectivityTexture);
  51644. }
  51645. if (this._metallicTexture) {
  51646. activeTextures.push(this._metallicTexture);
  51647. }
  51648. if (this._microSurfaceTexture) {
  51649. activeTextures.push(this._microSurfaceTexture);
  51650. }
  51651. if (this._bumpTexture) {
  51652. activeTextures.push(this._bumpTexture);
  51653. }
  51654. if (this._lightmapTexture) {
  51655. activeTextures.push(this._lightmapTexture);
  51656. }
  51657. if (this._refractionTexture) {
  51658. activeTextures.push(this._refractionTexture);
  51659. }
  51660. return activeTextures;
  51661. };
  51662. /**
  51663. * Checks to see if a texture is used in the material.
  51664. * @param texture - Base texture to use.
  51665. * @returns - Boolean specifying if a texture is used in the material.
  51666. */
  51667. PBRMaterial.prototype.hasTexture = function (texture) {
  51668. if (_super.prototype.hasTexture.call(this, texture)) {
  51669. return true;
  51670. }
  51671. if (this._albedoTexture === texture) {
  51672. return true;
  51673. }
  51674. if (this._ambientTexture === texture) {
  51675. return true;
  51676. }
  51677. if (this._opacityTexture === texture) {
  51678. return true;
  51679. }
  51680. if (this._reflectionTexture === texture) {
  51681. return true;
  51682. }
  51683. if (this._reflectivityTexture === texture) {
  51684. return true;
  51685. }
  51686. if (this._metallicTexture === texture) {
  51687. return true;
  51688. }
  51689. if (this._microSurfaceTexture === texture) {
  51690. return true;
  51691. }
  51692. if (this._bumpTexture === texture) {
  51693. return true;
  51694. }
  51695. if (this._lightmapTexture === texture) {
  51696. return true;
  51697. }
  51698. if (this._refractionTexture === texture) {
  51699. return true;
  51700. }
  51701. return false;
  51702. };
  51703. /**
  51704. * Makes a duplicate of the current material.
  51705. * @param name - name to use for the new material.
  51706. */
  51707. PBRMaterial.prototype.clone = function (name) {
  51708. var _this = this;
  51709. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  51710. clone.id = name;
  51711. clone.name = name;
  51712. return clone;
  51713. };
  51714. /**
  51715. * Serializes this PBR Material.
  51716. * @returns - An object with the serialized material.
  51717. */
  51718. PBRMaterial.prototype.serialize = function () {
  51719. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51720. serializationObject.customType = "BABYLON.PBRMaterial";
  51721. return serializationObject;
  51722. };
  51723. // Statics
  51724. /**
  51725. * Parses a PBR Material from a serialized object.
  51726. * @param source - Serialized object.
  51727. * @param scene - BJS scene instance.
  51728. * @param rootUrl - url for the scene object
  51729. * @returns - PBRMaterial
  51730. */
  51731. PBRMaterial.Parse = function (source, scene, rootUrl) {
  51732. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  51733. };
  51734. /**
  51735. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51736. */
  51737. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  51738. /**
  51739. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51740. */
  51741. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  51742. /**
  51743. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51744. */
  51745. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  51746. /**
  51747. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51748. * They are also discarded below the alpha cutoff threshold to improve performances.
  51749. */
  51750. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  51751. /**
  51752. * Defines the default value of how much AO map is occluding the analytical lights
  51753. * (point spot...).
  51754. */
  51755. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51759. ], PBRMaterial.prototype, "directIntensity", void 0);
  51760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51762. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51763. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  51764. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51767. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  51768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51771. ], PBRMaterial.prototype, "specularIntensity", void 0);
  51772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51774. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51775. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  51776. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51779. ], PBRMaterial.prototype, "albedoTexture", void 0);
  51780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51783. ], PBRMaterial.prototype, "ambientTexture", void 0);
  51784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51786. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51787. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  51788. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51791. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  51792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  51795. ], PBRMaterial.prototype, "opacityTexture", void 0);
  51796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51798. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51799. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  51800. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51803. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  51804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51807. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  51808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51811. ], PBRMaterial.prototype, "metallicTexture", void 0);
  51812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51815. ], PBRMaterial.prototype, "metallic", void 0);
  51816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51819. ], PBRMaterial.prototype, "roughness", void 0);
  51820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51823. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  51824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51827. ], PBRMaterial.prototype, "bumpTexture", void 0);
  51828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51831. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  51832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51835. ], PBRMaterial.prototype, "refractionTexture", void 0);
  51836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  51838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51839. ], PBRMaterial.prototype, "ambientColor", void 0);
  51840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  51842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51843. ], PBRMaterial.prototype, "albedoColor", void 0);
  51844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  51846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51847. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  51848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  51850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51851. ], PBRMaterial.prototype, "reflectionColor", void 0);
  51852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  51854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51855. ], PBRMaterial.prototype, "emissiveColor", void 0);
  51856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51859. ], PBRMaterial.prototype, "microSurface", void 0);
  51860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51863. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  51864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51867. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  51868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51871. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  51872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51875. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  51876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  51879. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  51880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  51883. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  51884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  51887. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  51888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51891. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  51892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51895. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  51896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51899. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  51900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51903. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  51904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51907. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  51908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51911. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  51912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51915. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  51916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51919. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  51920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51922. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  51923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51925. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  51926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51929. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  51930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51933. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  51934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51937. ], PBRMaterial.prototype, "useParallax", void 0);
  51938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51941. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  51942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51945. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  51946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51949. ], PBRMaterial.prototype, "disableLighting", void 0);
  51950. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51953. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  51954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51957. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  51958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51960. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51961. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  51962. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51965. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  51966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51969. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  51970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51973. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  51974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51977. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  51978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51981. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  51982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51985. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  51986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51989. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  51990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51993. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  51994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51997. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  51998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52001. ], PBRMaterial.prototype, "unlit", void 0);
  52002. return PBRMaterial;
  52003. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52004. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52005. /***/ }),
  52006. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52007. /*!*******************************************************!*\
  52008. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  52009. \*******************************************************/
  52010. /*! exports provided: PBRMetallicRoughnessMaterial */
  52011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52012. "use strict";
  52013. __webpack_require__.r(__webpack_exports__);
  52014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  52015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52017. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52018. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52019. /**
  52020. * The PBR material of BJS following the metal roughness convention.
  52021. *
  52022. * This fits to the PBR convention in the GLTF definition:
  52023. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52024. */
  52025. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  52026. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  52027. /**
  52028. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52029. *
  52030. * @param name The material name
  52031. * @param scene The scene the material will be use in.
  52032. */
  52033. function PBRMetallicRoughnessMaterial(name, scene) {
  52034. var _this = _super.call(this, name, scene) || this;
  52035. _this._useRoughnessFromMetallicTextureAlpha = false;
  52036. _this._useRoughnessFromMetallicTextureGreen = true;
  52037. _this._useMetallnessFromMetallicTextureBlue = true;
  52038. _this.metallic = 1.0;
  52039. _this.roughness = 1.0;
  52040. return _this;
  52041. }
  52042. /**
  52043. * Return the currrent class name of the material.
  52044. */
  52045. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  52046. return "PBRMetallicRoughnessMaterial";
  52047. };
  52048. /**
  52049. * Return the active textures of the material.
  52050. */
  52051. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  52052. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52053. if (this.baseTexture) {
  52054. activeTextures.push(this.baseTexture);
  52055. }
  52056. if (this.metallicRoughnessTexture) {
  52057. activeTextures.push(this.metallicRoughnessTexture);
  52058. }
  52059. return activeTextures;
  52060. };
  52061. /**
  52062. * Checks to see if a texture is used in the material.
  52063. * @param texture - Base texture to use.
  52064. * @returns - Boolean specifying if a texture is used in the material.
  52065. */
  52066. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  52067. if (_super.prototype.hasTexture.call(this, texture)) {
  52068. return true;
  52069. }
  52070. if (this.baseTexture === texture) {
  52071. return true;
  52072. }
  52073. if (this.metallicRoughnessTexture === texture) {
  52074. return true;
  52075. }
  52076. return false;
  52077. };
  52078. /**
  52079. * Makes a duplicate of the current material.
  52080. * @param name - name to use for the new material.
  52081. */
  52082. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  52083. var _this = this;
  52084. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  52085. clone.id = name;
  52086. clone.name = name;
  52087. return clone;
  52088. };
  52089. /**
  52090. * Serialize the material to a parsable JSON object.
  52091. */
  52092. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  52093. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52094. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  52095. return serializationObject;
  52096. };
  52097. /**
  52098. * Parses a JSON object correponding to the serialize function.
  52099. */
  52100. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  52101. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  52102. };
  52103. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  52105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52106. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  52107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52110. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  52111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52114. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  52115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52118. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  52119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  52122. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  52123. return PBRMetallicRoughnessMaterial;
  52124. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52125. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  52126. /***/ }),
  52127. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  52128. /*!********************************************************!*\
  52129. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  52130. \********************************************************/
  52131. /*! exports provided: PBRSpecularGlossinessMaterial */
  52132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52133. "use strict";
  52134. __webpack_require__.r(__webpack_exports__);
  52135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  52136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52137. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52138. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52139. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52140. /**
  52141. * The PBR material of BJS following the specular glossiness convention.
  52142. *
  52143. * This fits to the PBR convention in the GLTF definition:
  52144. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52145. */
  52146. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  52147. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  52148. /**
  52149. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52150. *
  52151. * @param name The material name
  52152. * @param scene The scene the material will be use in.
  52153. */
  52154. function PBRSpecularGlossinessMaterial(name, scene) {
  52155. var _this = _super.call(this, name, scene) || this;
  52156. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  52157. return _this;
  52158. }
  52159. /**
  52160. * Return the currrent class name of the material.
  52161. */
  52162. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  52163. return "PBRSpecularGlossinessMaterial";
  52164. };
  52165. /**
  52166. * Return the active textures of the material.
  52167. */
  52168. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  52169. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52170. if (this.diffuseTexture) {
  52171. activeTextures.push(this.diffuseTexture);
  52172. }
  52173. if (this.specularGlossinessTexture) {
  52174. activeTextures.push(this.specularGlossinessTexture);
  52175. }
  52176. return activeTextures;
  52177. };
  52178. /**
  52179. * Checks to see if a texture is used in the material.
  52180. * @param texture - Base texture to use.
  52181. * @returns - Boolean specifying if a texture is used in the material.
  52182. */
  52183. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  52184. if (_super.prototype.hasTexture.call(this, texture)) {
  52185. return true;
  52186. }
  52187. if (this.diffuseTexture === texture) {
  52188. return true;
  52189. }
  52190. if (this.specularGlossinessTexture === texture) {
  52191. return true;
  52192. }
  52193. return false;
  52194. };
  52195. /**
  52196. * Makes a duplicate of the current material.
  52197. * @param name - name to use for the new material.
  52198. */
  52199. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  52200. var _this = this;
  52201. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  52202. clone.id = name;
  52203. clone.name = name;
  52204. return clone;
  52205. };
  52206. /**
  52207. * Serialize the material to a parsable JSON object.
  52208. */
  52209. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  52210. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52211. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  52212. return serializationObject;
  52213. };
  52214. /**
  52215. * Parses a JSON object correponding to the serialize function.
  52216. */
  52217. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  52218. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  52219. };
  52220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  52222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52223. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  52224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52227. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  52228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  52230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  52231. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  52232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  52235. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  52236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  52239. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  52240. return PBRSpecularGlossinessMaterial;
  52241. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52242. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  52243. /***/ }),
  52244. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  52245. /*!********************************************************!*\
  52246. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  52247. \********************************************************/
  52248. /*! exports provided: _DDSTextureLoader */
  52249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52250. "use strict";
  52251. __webpack_require__.r(__webpack_exports__);
  52252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  52253. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  52254. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52255. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  52256. /**
  52257. * Implementation of the DDS Texture Loader.
  52258. * @hidden
  52259. */
  52260. var _DDSTextureLoader = /** @class */ (function () {
  52261. function _DDSTextureLoader() {
  52262. /**
  52263. * Defines wether the loader supports cascade loading the different faces.
  52264. */
  52265. this.supportCascades = true;
  52266. }
  52267. /**
  52268. * This returns if the loader support the current file information.
  52269. * @param extension defines the file extension of the file being loaded
  52270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52271. * @param fallback defines the fallback internal texture if any
  52272. * @param isBase64 defines whether the texture is encoded as a base64
  52273. * @param isBuffer defines whether the texture data are stored as a buffer
  52274. * @returns true if the loader can load the specified file
  52275. */
  52276. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52277. return extension.indexOf(".dds") === 0;
  52278. };
  52279. /**
  52280. * Transform the url before loading if required.
  52281. * @param rootUrl the url of the texture
  52282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52283. * @returns the transformed texture
  52284. */
  52285. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52286. return rootUrl;
  52287. };
  52288. /**
  52289. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52290. * @param rootUrl the url of the texture
  52291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52292. * @returns the fallback texture
  52293. */
  52294. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52295. return null;
  52296. };
  52297. /**
  52298. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52299. * @param data contains the texture data
  52300. * @param texture defines the BabylonJS internal texture
  52301. * @param createPolynomials will be true if polynomials have been requested
  52302. * @param onLoad defines the callback to trigger once the texture is ready
  52303. * @param onError defines the callback to trigger in case of error
  52304. */
  52305. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  52306. var engine = texture.getEngine();
  52307. var info;
  52308. var loadMipmap = false;
  52309. if (Array.isArray(imgs)) {
  52310. for (var index = 0; index < imgs.length; index++) {
  52311. var data_1 = imgs[index];
  52312. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  52313. texture.width = info.width;
  52314. texture.height = info.height;
  52315. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52316. engine._unpackFlipY(info.isCompressed);
  52317. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  52318. if (!info.isFourCC && info.mipmapCount === 1) {
  52319. engine.generateMipMapsForCubemap(texture);
  52320. }
  52321. }
  52322. }
  52323. else {
  52324. var data = imgs;
  52325. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52326. texture.width = info.width;
  52327. texture.height = info.height;
  52328. if (createPolynomials) {
  52329. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  52330. }
  52331. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52332. engine._unpackFlipY(info.isCompressed);
  52333. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  52334. if (!info.isFourCC && info.mipmapCount === 1) {
  52335. engine.generateMipMapsForCubemap(texture);
  52336. }
  52337. }
  52338. engine._setCubeMapTextureParams(loadMipmap);
  52339. texture.isReady = true;
  52340. if (onLoad) {
  52341. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  52342. }
  52343. };
  52344. /**
  52345. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52346. * @param data contains the texture data
  52347. * @param texture defines the BabylonJS internal texture
  52348. * @param callback defines the method to call once ready to upload
  52349. */
  52350. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  52351. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52352. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  52353. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  52354. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  52355. });
  52356. };
  52357. return _DDSTextureLoader;
  52358. }());
  52359. // Register the loader.
  52360. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  52361. /***/ }),
  52362. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  52363. /*!********************************************************!*\
  52364. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  52365. \********************************************************/
  52366. /*! exports provided: _ENVTextureLoader */
  52367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52368. "use strict";
  52369. __webpack_require__.r(__webpack_exports__);
  52370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  52371. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  52372. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52373. /**
  52374. * Implementation of the ENV Texture Loader.
  52375. * @hidden
  52376. */
  52377. var _ENVTextureLoader = /** @class */ (function () {
  52378. function _ENVTextureLoader() {
  52379. /**
  52380. * Defines wether the loader supports cascade loading the different faces.
  52381. */
  52382. this.supportCascades = false;
  52383. }
  52384. /**
  52385. * This returns if the loader support the current file information.
  52386. * @param extension defines the file extension of the file being loaded
  52387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52388. * @param fallback defines the fallback internal texture if any
  52389. * @param isBase64 defines whether the texture is encoded as a base64
  52390. * @param isBuffer defines whether the texture data are stored as a buffer
  52391. * @returns true if the loader can load the specified file
  52392. */
  52393. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52394. return extension.indexOf(".env") === 0;
  52395. };
  52396. /**
  52397. * Transform the url before loading if required.
  52398. * @param rootUrl the url of the texture
  52399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52400. * @returns the transformed texture
  52401. */
  52402. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52403. return rootUrl;
  52404. };
  52405. /**
  52406. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52407. * @param rootUrl the url of the texture
  52408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52409. * @returns the fallback texture
  52410. */
  52411. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52412. return null;
  52413. };
  52414. /**
  52415. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52416. * @param data contains the texture data
  52417. * @param texture defines the BabylonJS internal texture
  52418. * @param createPolynomials will be true if polynomials have been requested
  52419. * @param onLoad defines the callback to trigger once the texture is ready
  52420. * @param onError defines the callback to trigger in case of error
  52421. */
  52422. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52423. if (Array.isArray(data)) {
  52424. return;
  52425. }
  52426. data = data;
  52427. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  52428. if (info) {
  52429. texture.width = info.width;
  52430. texture.height = info.width;
  52431. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  52432. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  52433. texture.isReady = true;
  52434. if (onLoad) {
  52435. onLoad();
  52436. }
  52437. });
  52438. }
  52439. else if (onError) {
  52440. onError("Can not parse the environment file", null);
  52441. }
  52442. };
  52443. /**
  52444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52445. * @param data contains the texture data
  52446. * @param texture defines the BabylonJS internal texture
  52447. * @param callback defines the method to call once ready to upload
  52448. */
  52449. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  52450. throw ".env not supported in 2d.";
  52451. };
  52452. return _ENVTextureLoader;
  52453. }());
  52454. // Register the loader.
  52455. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  52456. /***/ }),
  52457. /***/ "./Materials/Textures/Loaders/index.ts":
  52458. /*!*********************************************!*\
  52459. !*** ./Materials/Textures/Loaders/index.ts ***!
  52460. \*********************************************/
  52461. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  52462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52463. "use strict";
  52464. __webpack_require__.r(__webpack_exports__);
  52465. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  52466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  52467. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  52468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  52469. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  52470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  52471. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  52472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  52473. /***/ }),
  52474. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  52475. /*!********************************************************!*\
  52476. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  52477. \********************************************************/
  52478. /*! exports provided: _KTXTextureLoader */
  52479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52480. "use strict";
  52481. __webpack_require__.r(__webpack_exports__);
  52482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  52483. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  52484. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52485. /**
  52486. * Implementation of the KTX Texture Loader.
  52487. * @hidden
  52488. */
  52489. var _KTXTextureLoader = /** @class */ (function () {
  52490. function _KTXTextureLoader() {
  52491. /**
  52492. * Defines wether the loader supports cascade loading the different faces.
  52493. */
  52494. this.supportCascades = false;
  52495. }
  52496. /**
  52497. * This returns if the loader support the current file information.
  52498. * @param extension defines the file extension of the file being loaded
  52499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52500. * @param fallback defines the fallback internal texture if any
  52501. * @param isBase64 defines whether the texture is encoded as a base64
  52502. * @param isBuffer defines whether the texture data are stored as a buffer
  52503. * @returns true if the loader can load the specified file
  52504. */
  52505. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52506. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  52507. return true;
  52508. }
  52509. return false;
  52510. };
  52511. /**
  52512. * Transform the url before loading if required.
  52513. * @param rootUrl the url of the texture
  52514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52515. * @returns the transformed texture
  52516. */
  52517. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52518. var lastDot = rootUrl.lastIndexOf('.');
  52519. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  52520. // Already transformed
  52521. return rootUrl;
  52522. }
  52523. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  52524. };
  52525. /**
  52526. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52527. * @param rootUrl the url of the texture
  52528. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52529. * @returns the fallback texture
  52530. */
  52531. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52532. // remove the format appended to the rootUrl in the original createCubeTexture call.
  52533. var exp = new RegExp("" + textureFormatInUse + "$");
  52534. return rootUrl.replace(exp, "");
  52535. };
  52536. /**
  52537. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52538. * @param data contains the texture data
  52539. * @param texture defines the BabylonJS internal texture
  52540. * @param createPolynomials will be true if polynomials have been requested
  52541. * @param onLoad defines the callback to trigger once the texture is ready
  52542. * @param onError defines the callback to trigger in case of error
  52543. */
  52544. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52545. if (Array.isArray(data)) {
  52546. return;
  52547. }
  52548. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52549. texture._invertVScale = !texture.invertY;
  52550. var engine = texture.getEngine();
  52551. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  52552. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  52553. engine._unpackFlipY(true);
  52554. ktx.uploadLevels(texture, texture.generateMipMaps);
  52555. texture.width = ktx.pixelWidth;
  52556. texture.height = ktx.pixelHeight;
  52557. engine._setCubeMapTextureParams(loadMipmap);
  52558. texture.isReady = true;
  52559. };
  52560. /**
  52561. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52562. * @param data contains the texture data
  52563. * @param texture defines the BabylonJS internal texture
  52564. * @param callback defines the method to call once ready to upload
  52565. */
  52566. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  52567. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52568. texture._invertVScale = !texture.invertY;
  52569. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  52570. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  52571. ktx.uploadLevels(texture, texture.generateMipMaps);
  52572. }, ktx.isInvalid);
  52573. };
  52574. return _KTXTextureLoader;
  52575. }());
  52576. // Register the loader.
  52577. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  52578. /***/ }),
  52579. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  52580. /*!********************************************************!*\
  52581. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  52582. \********************************************************/
  52583. /*! exports provided: _TGATextureLoader */
  52584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52585. "use strict";
  52586. __webpack_require__.r(__webpack_exports__);
  52587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  52588. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  52589. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52590. /**
  52591. * Implementation of the TGA Texture Loader.
  52592. * @hidden
  52593. */
  52594. var _TGATextureLoader = /** @class */ (function () {
  52595. function _TGATextureLoader() {
  52596. /**
  52597. * Defines wether the loader supports cascade loading the different faces.
  52598. */
  52599. this.supportCascades = false;
  52600. }
  52601. /**
  52602. * This returns if the loader support the current file information.
  52603. * @param extension defines the file extension of the file being loaded
  52604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52605. * @param fallback defines the fallback internal texture if any
  52606. * @param isBase64 defines whether the texture is encoded as a base64
  52607. * @param isBuffer defines whether the texture data are stored as a buffer
  52608. * @returns true if the loader can load the specified file
  52609. */
  52610. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52611. return extension.indexOf(".tga") === 0;
  52612. };
  52613. /**
  52614. * Transform the url before loading if required.
  52615. * @param rootUrl the url of the texture
  52616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52617. * @returns the transformed texture
  52618. */
  52619. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52620. return rootUrl;
  52621. };
  52622. /**
  52623. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52624. * @param rootUrl the url of the texture
  52625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52626. * @returns the fallback texture
  52627. */
  52628. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52629. return null;
  52630. };
  52631. /**
  52632. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52633. * @param data contains the texture data
  52634. * @param texture defines the BabylonJS internal texture
  52635. * @param createPolynomials will be true if polynomials have been requested
  52636. * @param onLoad defines the callback to trigger once the texture is ready
  52637. * @param onError defines the callback to trigger in case of error
  52638. */
  52639. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52640. throw ".env not supported in Cube.";
  52641. };
  52642. /**
  52643. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52644. * @param data contains the texture data
  52645. * @param texture defines the BabylonJS internal texture
  52646. * @param callback defines the method to call once ready to upload
  52647. */
  52648. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  52649. var uintData = new Uint8Array(data);
  52650. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  52651. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  52652. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  52653. });
  52654. };
  52655. return _TGATextureLoader;
  52656. }());
  52657. // Register the loader.
  52658. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  52659. /***/ }),
  52660. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  52661. /*!*******************************************************************!*\
  52662. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  52663. \*******************************************************************/
  52664. /*! exports provided: CustomProceduralTexture */
  52665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52666. "use strict";
  52667. __webpack_require__.r(__webpack_exports__);
  52668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  52669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52670. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  52671. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  52672. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  52673. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52674. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52675. /**
  52676. * 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.
  52677. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52678. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52679. */
  52680. var CustomProceduralTexture = /** @class */ (function (_super) {
  52681. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  52682. /**
  52683. * Instantiates a new Custom Procedural Texture.
  52684. * 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.
  52685. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52686. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52687. * @param name Define the name of the texture
  52688. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52689. * @param size Define the size of the texture to create
  52690. * @param scene Define the scene the texture belongs to
  52691. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52692. * @param generateMipMaps Define if the texture should creates mip maps or not
  52693. */
  52694. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  52695. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  52696. _this._animate = true;
  52697. _this._time = 0;
  52698. _this._texturePath = texturePath;
  52699. //Try to load json
  52700. _this._loadJson(texturePath);
  52701. _this.refreshRate = 1;
  52702. return _this;
  52703. }
  52704. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  52705. var _this = this;
  52706. var noConfigFile = function () {
  52707. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  52708. try {
  52709. _this.setFragment(_this._texturePath);
  52710. }
  52711. catch (ex) {
  52712. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  52713. }
  52714. };
  52715. var configFileUrl = jsonUrl + "/config.json";
  52716. var xhr = new XMLHttpRequest();
  52717. xhr.open("GET", configFileUrl, true);
  52718. xhr.addEventListener("load", function () {
  52719. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  52720. try {
  52721. _this._config = JSON.parse(xhr.response);
  52722. _this.updateShaderUniforms();
  52723. _this.updateTextures();
  52724. _this.setFragment(_this._texturePath + "/custom");
  52725. _this._animate = _this._config.animate;
  52726. _this.refreshRate = _this._config.refreshrate;
  52727. }
  52728. catch (ex) {
  52729. noConfigFile();
  52730. }
  52731. }
  52732. else {
  52733. noConfigFile();
  52734. }
  52735. }, false);
  52736. xhr.addEventListener("error", function () {
  52737. noConfigFile();
  52738. }, false);
  52739. try {
  52740. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  52741. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  52742. }
  52743. xhr.send();
  52744. }
  52745. catch (ex) {
  52746. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  52747. }
  52748. };
  52749. /**
  52750. * Is the texture ready to be used ? (rendered at least once)
  52751. * @returns true if ready, otherwise, false.
  52752. */
  52753. CustomProceduralTexture.prototype.isReady = function () {
  52754. if (!_super.prototype.isReady.call(this)) {
  52755. return false;
  52756. }
  52757. for (var name in this._textures) {
  52758. var texture = this._textures[name];
  52759. if (!texture.isReady()) {
  52760. return false;
  52761. }
  52762. }
  52763. return true;
  52764. };
  52765. /**
  52766. * Render the texture to its associated render target.
  52767. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52768. */
  52769. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  52770. var scene = this.getScene();
  52771. if (this._animate && scene) {
  52772. this._time += scene.getAnimationRatio() * 0.03;
  52773. this.updateShaderUniforms();
  52774. }
  52775. _super.prototype.render.call(this, useCameraPostProcess);
  52776. };
  52777. /**
  52778. * Update the list of dependant textures samplers in the shader.
  52779. */
  52780. CustomProceduralTexture.prototype.updateTextures = function () {
  52781. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  52782. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  52783. }
  52784. };
  52785. /**
  52786. * Update the uniform values of the procedural texture in the shader.
  52787. */
  52788. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  52789. if (this._config) {
  52790. for (var j = 0; j < this._config.uniforms.length; j++) {
  52791. var uniform = this._config.uniforms[j];
  52792. switch (uniform.type) {
  52793. case "float":
  52794. this.setFloat(uniform.name, uniform.value);
  52795. break;
  52796. case "color3":
  52797. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  52798. break;
  52799. case "color4":
  52800. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  52801. break;
  52802. case "vector2":
  52803. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  52804. break;
  52805. case "vector3":
  52806. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  52807. break;
  52808. }
  52809. }
  52810. }
  52811. this.setFloat("time", this._time);
  52812. };
  52813. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  52814. /**
  52815. * Define if the texture animates or not.
  52816. */
  52817. get: function () {
  52818. return this._animate;
  52819. },
  52820. set: function (value) {
  52821. this._animate = value;
  52822. },
  52823. enumerable: true,
  52824. configurable: true
  52825. });
  52826. return CustomProceduralTexture;
  52827. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  52828. /***/ }),
  52829. /***/ "./Materials/Textures/Procedurals/index.ts":
  52830. /*!*************************************************!*\
  52831. !*** ./Materials/Textures/Procedurals/index.ts ***!
  52832. \*************************************************/
  52833. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  52834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52835. "use strict";
  52836. __webpack_require__.r(__webpack_exports__);
  52837. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  52838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  52839. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  52840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  52841. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  52843. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  52844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  52845. /***/ }),
  52846. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  52847. /*!******************************************************************!*\
  52848. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  52849. \******************************************************************/
  52850. /*! exports provided: NoiseProceduralTexture */
  52851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52852. "use strict";
  52853. __webpack_require__.r(__webpack_exports__);
  52854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  52855. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52856. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  52857. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52858. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  52859. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  52860. /**
  52861. * Class used to generate noise procedural textures
  52862. */
  52863. var NoiseProceduralTexture = /** @class */ (function (_super) {
  52864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  52865. /**
  52866. * Creates a new NoiseProceduralTexture
  52867. * @param name defines the name fo the texture
  52868. * @param size defines the size of the texture (default is 256)
  52869. * @param scene defines the hosting scene
  52870. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52871. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52872. */
  52873. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  52874. if (size === void 0) { size = 256; }
  52875. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  52876. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  52877. _this._time = 0;
  52878. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52879. _this.brightness = 0.2;
  52880. /** Defines the number of octaves to process */
  52881. _this.octaves = 3;
  52882. /** Defines the level of persistence (0.8 by default) */
  52883. _this.persistence = 0.8;
  52884. /** Gets or sets animation speed factor (default is 1) */
  52885. _this.animationSpeedFactor = 1;
  52886. _this.autoClear = false;
  52887. _this._updateShaderUniforms();
  52888. return _this;
  52889. }
  52890. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  52891. var scene = this.getScene();
  52892. if (!scene) {
  52893. return;
  52894. }
  52895. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  52896. this.setFloat("brightness", this.brightness);
  52897. this.setFloat("persistence", this.persistence);
  52898. this.setFloat("timeScale", this._time);
  52899. };
  52900. NoiseProceduralTexture.prototype._getDefines = function () {
  52901. return "#define OCTAVES " + (this.octaves | 0);
  52902. };
  52903. /** Generate the current state of the procedural texture */
  52904. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  52905. this._updateShaderUniforms();
  52906. _super.prototype.render.call(this, useCameraPostProcess);
  52907. };
  52908. /**
  52909. * Serializes this noise procedural texture
  52910. * @returns a serialized noise procedural texture object
  52911. */
  52912. NoiseProceduralTexture.prototype.serialize = function () {
  52913. var serializationObject = {};
  52914. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  52915. serializationObject.brightness = this.brightness;
  52916. serializationObject.octaves = this.octaves;
  52917. serializationObject.persistence = this.persistence;
  52918. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  52919. serializationObject.size = this.getSize().width;
  52920. serializationObject.generateMipMaps = this._generateMipMaps;
  52921. return serializationObject;
  52922. };
  52923. /**
  52924. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52925. * @param parsedTexture defines parsed texture data
  52926. * @param scene defines the current scene
  52927. * @param rootUrl defines the root URL containing noise procedural texture information
  52928. * @returns a parsed NoiseProceduralTexture
  52929. */
  52930. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  52931. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  52932. texture.brightness = parsedTexture.brightness;
  52933. texture.octaves = parsedTexture.octaves;
  52934. texture.persistence = parsedTexture.persistence;
  52935. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  52936. return texture;
  52937. };
  52938. return NoiseProceduralTexture;
  52939. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  52940. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  52941. /***/ }),
  52942. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  52943. /*!*************************************************************!*\
  52944. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  52945. \*************************************************************/
  52946. /*! exports provided: ProceduralTexture */
  52947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52948. "use strict";
  52949. __webpack_require__.r(__webpack_exports__);
  52950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  52951. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52952. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  52953. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  52954. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  52955. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  52956. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  52957. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52958. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  52959. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  52960. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  52961. /**
  52962. * 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.
  52963. * This is the base class of any Procedural texture and contains most of the shareable code.
  52964. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  52965. */
  52966. var ProceduralTexture = /** @class */ (function (_super) {
  52967. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  52968. /**
  52969. * Instantiates a new procedural texture.
  52970. * 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.
  52971. * This is the base class of any Procedural texture and contains most of the shareable code.
  52972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  52973. * @param name Define the name of the texture
  52974. * @param size Define the size of the texture to create
  52975. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  52976. * @param scene Define the scene the texture belongs to
  52977. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52978. * @param generateMipMaps Define if the texture should creates mip maps or not
  52979. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  52980. */
  52981. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  52982. if (fallbackTexture === void 0) { fallbackTexture = null; }
  52983. if (generateMipMaps === void 0) { generateMipMaps = true; }
  52984. if (isCube === void 0) { isCube = false; }
  52985. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  52986. _this.isCube = isCube;
  52987. /**
  52988. * Define if the texture is enabled or not (disabled texture will not render)
  52989. */
  52990. _this.isEnabled = true;
  52991. /**
  52992. * Define if the texture must be cleared before rendering (default is true)
  52993. */
  52994. _this.autoClear = true;
  52995. /**
  52996. * Event raised when the texture is generated
  52997. */
  52998. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  52999. /** @hidden */
  53000. _this._textures = {};
  53001. _this._currentRefreshId = -1;
  53002. _this._refreshRate = 1;
  53003. _this._vertexBuffers = {};
  53004. _this._uniforms = new Array();
  53005. _this._samplers = new Array();
  53006. _this._floats = {};
  53007. _this._ints = {};
  53008. _this._floatsArrays = {};
  53009. _this._colors3 = {};
  53010. _this._colors4 = {};
  53011. _this._vectors2 = {};
  53012. _this._vectors3 = {};
  53013. _this._matrices = {};
  53014. _this._fallbackTextureUsed = false;
  53015. _this._cachedDefines = "";
  53016. _this._contentUpdateId = -1;
  53017. scene = _this.getScene();
  53018. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  53019. if (!component) {
  53020. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  53021. scene._addComponent(component);
  53022. }
  53023. scene.proceduralTextures.push(_this);
  53024. _this._engine = scene.getEngine();
  53025. _this.name = name;
  53026. _this.isRenderTarget = true;
  53027. _this._size = size;
  53028. _this._generateMipMaps = generateMipMaps;
  53029. _this.setFragment(fragment);
  53030. _this._fallbackTexture = fallbackTexture;
  53031. if (isCube) {
  53032. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53033. _this.setFloat("face", 0);
  53034. }
  53035. else {
  53036. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53037. }
  53038. // VBO
  53039. var vertices = [];
  53040. vertices.push(1, 1);
  53041. vertices.push(-1, 1);
  53042. vertices.push(-1, -1);
  53043. vertices.push(1, -1);
  53044. _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);
  53045. _this._createIndexBuffer();
  53046. return _this;
  53047. }
  53048. /**
  53049. * The effect that is created when initializing the post process.
  53050. * @returns The created effect corrisponding the the postprocess.
  53051. */
  53052. ProceduralTexture.prototype.getEffect = function () {
  53053. return this._effect;
  53054. };
  53055. /**
  53056. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  53057. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  53058. */
  53059. ProceduralTexture.prototype.getContent = function () {
  53060. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  53061. return this._contentData;
  53062. }
  53063. this._contentData = this.readPixels(0, 0, this._contentData);
  53064. this._contentUpdateId = this._currentRefreshId;
  53065. return this._contentData;
  53066. };
  53067. ProceduralTexture.prototype._createIndexBuffer = function () {
  53068. var engine = this._engine;
  53069. // Indices
  53070. var indices = [];
  53071. indices.push(0);
  53072. indices.push(1);
  53073. indices.push(2);
  53074. indices.push(0);
  53075. indices.push(2);
  53076. indices.push(3);
  53077. this._indexBuffer = engine.createIndexBuffer(indices);
  53078. };
  53079. /** @hidden */
  53080. ProceduralTexture.prototype._rebuild = function () {
  53081. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53082. if (vb) {
  53083. vb._rebuild();
  53084. }
  53085. this._createIndexBuffer();
  53086. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  53087. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  53088. }
  53089. };
  53090. /**
  53091. * Resets the texture in order to recreate its associated resources.
  53092. * This can be called in case of context loss
  53093. */
  53094. ProceduralTexture.prototype.reset = function () {
  53095. if (this._effect === undefined) {
  53096. return;
  53097. }
  53098. var engine = this._engine;
  53099. engine._releaseEffect(this._effect);
  53100. };
  53101. ProceduralTexture.prototype._getDefines = function () {
  53102. return "";
  53103. };
  53104. /**
  53105. * Is the texture ready to be used ? (rendered at least once)
  53106. * @returns true if ready, otherwise, false.
  53107. */
  53108. ProceduralTexture.prototype.isReady = function () {
  53109. var _this = this;
  53110. var engine = this._engine;
  53111. var shaders;
  53112. if (!this._fragment) {
  53113. return false;
  53114. }
  53115. if (this._fallbackTextureUsed) {
  53116. return true;
  53117. }
  53118. var defines = this._getDefines();
  53119. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  53120. return true;
  53121. }
  53122. if (this._fragment.fragmentElement !== undefined) {
  53123. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  53124. }
  53125. else {
  53126. shaders = { vertex: "procedural", fragment: this._fragment };
  53127. }
  53128. this._cachedDefines = defines;
  53129. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  53130. _this.releaseInternalTexture();
  53131. if (_this._fallbackTexture) {
  53132. _this._texture = _this._fallbackTexture._texture;
  53133. if (_this._texture) {
  53134. _this._texture.incrementReferences();
  53135. }
  53136. }
  53137. _this._fallbackTextureUsed = true;
  53138. });
  53139. return this._effect.isReady();
  53140. };
  53141. /**
  53142. * Resets the refresh counter of the texture and start bak from scratch.
  53143. * Could be useful to regenerate the texture if it is setup to render only once.
  53144. */
  53145. ProceduralTexture.prototype.resetRefreshCounter = function () {
  53146. this._currentRefreshId = -1;
  53147. };
  53148. /**
  53149. * Set the fragment shader to use in order to render the texture.
  53150. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  53151. */
  53152. ProceduralTexture.prototype.setFragment = function (fragment) {
  53153. this._fragment = fragment;
  53154. };
  53155. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  53156. /**
  53157. * Define the refresh rate of the texture or the rendering frequency.
  53158. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  53159. */
  53160. get: function () {
  53161. return this._refreshRate;
  53162. },
  53163. set: function (value) {
  53164. this._refreshRate = value;
  53165. this.resetRefreshCounter();
  53166. },
  53167. enumerable: true,
  53168. configurable: true
  53169. });
  53170. /** @hidden */
  53171. ProceduralTexture.prototype._shouldRender = function () {
  53172. if (!this.isEnabled || !this.isReady() || !this._texture) {
  53173. if (this._texture) {
  53174. this._texture.isReady = false;
  53175. }
  53176. return false;
  53177. }
  53178. if (this._fallbackTextureUsed) {
  53179. return false;
  53180. }
  53181. if (this._currentRefreshId === -1) { // At least render once
  53182. this._currentRefreshId = 1;
  53183. return true;
  53184. }
  53185. if (this.refreshRate === this._currentRefreshId) {
  53186. this._currentRefreshId = 1;
  53187. return true;
  53188. }
  53189. this._currentRefreshId++;
  53190. return false;
  53191. };
  53192. /**
  53193. * Get the size the texture is rendering at.
  53194. * @returns the size (texture is always squared)
  53195. */
  53196. ProceduralTexture.prototype.getRenderSize = function () {
  53197. return this._size;
  53198. };
  53199. /**
  53200. * Resize the texture to new value.
  53201. * @param size Define the new size the texture should have
  53202. * @param generateMipMaps Define whether the new texture should create mip maps
  53203. */
  53204. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  53205. if (this._fallbackTextureUsed) {
  53206. return;
  53207. }
  53208. this.releaseInternalTexture();
  53209. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  53210. // Update properties
  53211. this._size = size;
  53212. this._generateMipMaps = generateMipMaps;
  53213. };
  53214. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  53215. if (this._uniforms.indexOf(uniformName) === -1) {
  53216. this._uniforms.push(uniformName);
  53217. }
  53218. };
  53219. /**
  53220. * Set a texture in the shader program used to render.
  53221. * @param name Define the name of the uniform samplers as defined in the shader
  53222. * @param texture Define the texture to bind to this sampler
  53223. * @return the texture itself allowing "fluent" like uniform updates
  53224. */
  53225. ProceduralTexture.prototype.setTexture = function (name, texture) {
  53226. if (this._samplers.indexOf(name) === -1) {
  53227. this._samplers.push(name);
  53228. }
  53229. this._textures[name] = texture;
  53230. return this;
  53231. };
  53232. /**
  53233. * Set a float in the shader.
  53234. * @param name Define the name of the uniform as defined in the shader
  53235. * @param value Define the value to give to the uniform
  53236. * @return the texture itself allowing "fluent" like uniform updates
  53237. */
  53238. ProceduralTexture.prototype.setFloat = function (name, value) {
  53239. this._checkUniform(name);
  53240. this._floats[name] = value;
  53241. return this;
  53242. };
  53243. /**
  53244. * Set a int in the shader.
  53245. * @param name Define the name of the uniform as defined in the shader
  53246. * @param value Define the value to give to the uniform
  53247. * @return the texture itself allowing "fluent" like uniform updates
  53248. */
  53249. ProceduralTexture.prototype.setInt = function (name, value) {
  53250. this._checkUniform(name);
  53251. this._ints[name] = value;
  53252. return this;
  53253. };
  53254. /**
  53255. * Set an array of floats in the shader.
  53256. * @param name Define the name of the uniform as defined in the shader
  53257. * @param value Define the value to give to the uniform
  53258. * @return the texture itself allowing "fluent" like uniform updates
  53259. */
  53260. ProceduralTexture.prototype.setFloats = function (name, value) {
  53261. this._checkUniform(name);
  53262. this._floatsArrays[name] = value;
  53263. return this;
  53264. };
  53265. /**
  53266. * Set a vec3 in the shader from a Color3.
  53267. * @param name Define the name of the uniform as defined in the shader
  53268. * @param value Define the value to give to the uniform
  53269. * @return the texture itself allowing "fluent" like uniform updates
  53270. */
  53271. ProceduralTexture.prototype.setColor3 = function (name, value) {
  53272. this._checkUniform(name);
  53273. this._colors3[name] = value;
  53274. return this;
  53275. };
  53276. /**
  53277. * Set a vec4 in the shader from a Color4.
  53278. * @param name Define the name of the uniform as defined in the shader
  53279. * @param value Define the value to give to the uniform
  53280. * @return the texture itself allowing "fluent" like uniform updates
  53281. */
  53282. ProceduralTexture.prototype.setColor4 = function (name, value) {
  53283. this._checkUniform(name);
  53284. this._colors4[name] = value;
  53285. return this;
  53286. };
  53287. /**
  53288. * Set a vec2 in the shader from a Vector2.
  53289. * @param name Define the name of the uniform as defined in the shader
  53290. * @param value Define the value to give to the uniform
  53291. * @return the texture itself allowing "fluent" like uniform updates
  53292. */
  53293. ProceduralTexture.prototype.setVector2 = function (name, value) {
  53294. this._checkUniform(name);
  53295. this._vectors2[name] = value;
  53296. return this;
  53297. };
  53298. /**
  53299. * Set a vec3 in the shader from a Vector3.
  53300. * @param name Define the name of the uniform as defined in the shader
  53301. * @param value Define the value to give to the uniform
  53302. * @return the texture itself allowing "fluent" like uniform updates
  53303. */
  53304. ProceduralTexture.prototype.setVector3 = function (name, value) {
  53305. this._checkUniform(name);
  53306. this._vectors3[name] = value;
  53307. return this;
  53308. };
  53309. /**
  53310. * Set a mat4 in the shader from a MAtrix.
  53311. * @param name Define the name of the uniform as defined in the shader
  53312. * @param value Define the value to give to the uniform
  53313. * @return the texture itself allowing "fluent" like uniform updates
  53314. */
  53315. ProceduralTexture.prototype.setMatrix = function (name, value) {
  53316. this._checkUniform(name);
  53317. this._matrices[name] = value;
  53318. return this;
  53319. };
  53320. /**
  53321. * Render the texture to its associated render target.
  53322. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53323. */
  53324. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53325. var scene = this.getScene();
  53326. if (!scene) {
  53327. return;
  53328. }
  53329. var engine = this._engine;
  53330. // Render
  53331. engine.enableEffect(this._effect);
  53332. engine.setState(false);
  53333. // Texture
  53334. for (var name in this._textures) {
  53335. this._effect.setTexture(name, this._textures[name]);
  53336. }
  53337. // Float
  53338. for (name in this._ints) {
  53339. this._effect.setInt(name, this._ints[name]);
  53340. }
  53341. // Float
  53342. for (name in this._floats) {
  53343. this._effect.setFloat(name, this._floats[name]);
  53344. }
  53345. // Floats
  53346. for (name in this._floatsArrays) {
  53347. this._effect.setArray(name, this._floatsArrays[name]);
  53348. }
  53349. // Color3
  53350. for (name in this._colors3) {
  53351. this._effect.setColor3(name, this._colors3[name]);
  53352. }
  53353. // Color4
  53354. for (name in this._colors4) {
  53355. var color = this._colors4[name];
  53356. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  53357. }
  53358. // Vector2
  53359. for (name in this._vectors2) {
  53360. this._effect.setVector2(name, this._vectors2[name]);
  53361. }
  53362. // Vector3
  53363. for (name in this._vectors3) {
  53364. this._effect.setVector3(name, this._vectors3[name]);
  53365. }
  53366. // Matrix
  53367. for (name in this._matrices) {
  53368. this._effect.setMatrix(name, this._matrices[name]);
  53369. }
  53370. if (!this._texture) {
  53371. return;
  53372. }
  53373. if (this.isCube) {
  53374. for (var face = 0; face < 6; face++) {
  53375. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  53376. // VBOs
  53377. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53378. this._effect.setFloat("face", face);
  53379. // Clear
  53380. if (this.autoClear) {
  53381. engine.clear(scene.clearColor, true, false, false);
  53382. }
  53383. // Draw order
  53384. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53385. // Mipmaps
  53386. if (face === 5) {
  53387. engine.generateMipMapsForCubemap(this._texture);
  53388. }
  53389. }
  53390. }
  53391. else {
  53392. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  53393. // VBOs
  53394. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53395. // Clear
  53396. if (this.autoClear) {
  53397. engine.clear(scene.clearColor, true, false, false);
  53398. }
  53399. // Draw order
  53400. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53401. }
  53402. // Unbind
  53403. engine.unBindFramebuffer(this._texture, this.isCube);
  53404. if (this.onGenerated) {
  53405. this.onGenerated();
  53406. }
  53407. this.onGeneratedObservable.notifyObservers(this);
  53408. };
  53409. /**
  53410. * Clone the texture.
  53411. * @returns the cloned texture
  53412. */
  53413. ProceduralTexture.prototype.clone = function () {
  53414. var textureSize = this.getSize();
  53415. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  53416. // Base texture
  53417. newTexture.hasAlpha = this.hasAlpha;
  53418. newTexture.level = this.level;
  53419. // RenderTarget Texture
  53420. newTexture.coordinatesMode = this.coordinatesMode;
  53421. return newTexture;
  53422. };
  53423. /**
  53424. * Dispose the texture and release its asoociated resources.
  53425. */
  53426. ProceduralTexture.prototype.dispose = function () {
  53427. var scene = this.getScene();
  53428. if (!scene) {
  53429. return;
  53430. }
  53431. var index = scene.proceduralTextures.indexOf(this);
  53432. if (index >= 0) {
  53433. scene.proceduralTextures.splice(index, 1);
  53434. }
  53435. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53436. if (vertexBuffer) {
  53437. vertexBuffer.dispose();
  53438. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  53439. }
  53440. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  53441. this._indexBuffer = null;
  53442. }
  53443. _super.prototype.dispose.call(this);
  53444. };
  53445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53447. ], ProceduralTexture.prototype, "isEnabled", void 0);
  53448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53450. ], ProceduralTexture.prototype, "autoClear", void 0);
  53451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53453. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  53454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53456. ], ProceduralTexture.prototype, "_size", void 0);
  53457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53459. ], ProceduralTexture.prototype, "refreshRate", null);
  53460. return ProceduralTexture;
  53461. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  53462. /***/ }),
  53463. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  53464. /*!***************************************************************************!*\
  53465. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  53466. \***************************************************************************/
  53467. /*! exports provided: ProceduralTextureSceneComponent */
  53468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53469. "use strict";
  53470. __webpack_require__.r(__webpack_exports__);
  53471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  53472. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53473. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53474. /**
  53475. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  53476. * in a given scene.
  53477. */
  53478. var ProceduralTextureSceneComponent = /** @class */ (function () {
  53479. /**
  53480. * Creates a new instance of the component for the given scene
  53481. * @param scene Defines the scene to register the component in
  53482. */
  53483. function ProceduralTextureSceneComponent(scene) {
  53484. /**
  53485. * The component name helpfull to identify the component in the list of scene components.
  53486. */
  53487. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  53488. this.scene = scene;
  53489. this.scene.proceduralTextures = new Array();
  53490. scene.layers = new Array();
  53491. }
  53492. /**
  53493. * Registers the component in a given scene
  53494. */
  53495. ProceduralTextureSceneComponent.prototype.register = function () {
  53496. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  53497. };
  53498. /**
  53499. * Rebuilds the elements related to this component in case of
  53500. * context lost for instance.
  53501. */
  53502. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  53503. // Nothing to do here.
  53504. };
  53505. /**
  53506. * Disposes the component and the associated ressources.
  53507. */
  53508. ProceduralTextureSceneComponent.prototype.dispose = function () {
  53509. // Nothing to do here.
  53510. };
  53511. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  53512. if (this.scene.proceduralTexturesEnabled) {
  53513. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53514. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  53515. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  53516. if (proceduralTexture._shouldRender()) {
  53517. proceduralTexture.render();
  53518. }
  53519. }
  53520. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53521. }
  53522. };
  53523. return ProceduralTextureSceneComponent;
  53524. }());
  53525. /***/ }),
  53526. /***/ "./Materials/Textures/baseTexture.ts":
  53527. /*!*******************************************!*\
  53528. !*** ./Materials/Textures/baseTexture.ts ***!
  53529. \*******************************************/
  53530. /*! exports provided: BaseTexture */
  53531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53532. "use strict";
  53533. __webpack_require__.r(__webpack_exports__);
  53534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  53535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53536. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53537. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  53538. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  53539. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  53540. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53541. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  53542. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  53543. /**
  53544. * Base class of all the textures in babylon.
  53545. * It groups all the common properties the materials, post process, lights... might need
  53546. * in order to make a correct use of the texture.
  53547. */
  53548. var BaseTexture = /** @class */ (function () {
  53549. /**
  53550. * Instantiates a new BaseTexture.
  53551. * Base class of all the textures in babylon.
  53552. * It groups all the common properties the materials, post process, lights... might need
  53553. * in order to make a correct use of the texture.
  53554. * @param scene Define the scene the texture blongs to
  53555. */
  53556. function BaseTexture(scene) {
  53557. /**
  53558. * Gets or sets an object used to store user defined information.
  53559. */
  53560. this.metadata = null;
  53561. /**
  53562. * For internal use only. Please do not use.
  53563. */
  53564. this.reservedDataStore = null;
  53565. this._hasAlpha = false;
  53566. /**
  53567. * Defines if the alpha value should be determined via the rgb values.
  53568. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  53569. */
  53570. this.getAlphaFromRGB = false;
  53571. /**
  53572. * Intensity or strength of the texture.
  53573. * It is commonly used by materials to fine tune the intensity of the texture
  53574. */
  53575. this.level = 1;
  53576. /**
  53577. * Define the UV chanel to use starting from 0 and defaulting to 0.
  53578. * This is part of the texture as textures usually maps to one uv set.
  53579. */
  53580. this.coordinatesIndex = 0;
  53581. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  53582. /**
  53583. * | Value | Type | Description |
  53584. * | ----- | ------------------ | ----------- |
  53585. * | 0 | CLAMP_ADDRESSMODE | |
  53586. * | 1 | WRAP_ADDRESSMODE | |
  53587. * | 2 | MIRROR_ADDRESSMODE | |
  53588. */
  53589. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53590. /**
  53591. * | Value | Type | Description |
  53592. * | ----- | ------------------ | ----------- |
  53593. * | 0 | CLAMP_ADDRESSMODE | |
  53594. * | 1 | WRAP_ADDRESSMODE | |
  53595. * | 2 | MIRROR_ADDRESSMODE | |
  53596. */
  53597. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53598. /**
  53599. * | Value | Type | Description |
  53600. * | ----- | ------------------ | ----------- |
  53601. * | 0 | CLAMP_ADDRESSMODE | |
  53602. * | 1 | WRAP_ADDRESSMODE | |
  53603. * | 2 | MIRROR_ADDRESSMODE | |
  53604. */
  53605. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53606. /**
  53607. * With compliant hardware and browser (supporting anisotropic filtering)
  53608. * this defines the level of anisotropic filtering in the texture.
  53609. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  53610. */
  53611. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  53612. /**
  53613. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  53614. * HDR texture are usually stored in linear space.
  53615. * This only impacts the PBR and Background materials
  53616. */
  53617. this.gammaSpace = true;
  53618. /**
  53619. * Is Z inverted in the texture (useful in a cube texture).
  53620. */
  53621. this.invertZ = false;
  53622. /**
  53623. * @hidden
  53624. */
  53625. this.lodLevelInAlpha = false;
  53626. /**
  53627. * Define if the texture is a render target.
  53628. */
  53629. this.isRenderTarget = false;
  53630. /**
  53631. * Define the list of animation attached to the texture.
  53632. */
  53633. this.animations = new Array();
  53634. /**
  53635. * An event triggered when the texture is disposed.
  53636. */
  53637. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53638. /**
  53639. * Define the current state of the loading sequence when in delayed load mode.
  53640. */
  53641. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  53642. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  53643. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  53644. if (this._scene) {
  53645. this.uniqueId = this._scene.getUniqueId();
  53646. this._scene.addTexture(this);
  53647. }
  53648. this._uid = null;
  53649. }
  53650. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  53651. get: function () {
  53652. return this._hasAlpha;
  53653. },
  53654. /**
  53655. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  53656. */
  53657. set: function (value) {
  53658. if (this._hasAlpha === value) {
  53659. return;
  53660. }
  53661. this._hasAlpha = value;
  53662. if (this._scene) {
  53663. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  53664. }
  53665. },
  53666. enumerable: true,
  53667. configurable: true
  53668. });
  53669. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  53670. get: function () {
  53671. return this._coordinatesMode;
  53672. },
  53673. /**
  53674. * How a texture is mapped.
  53675. *
  53676. * | Value | Type | Description |
  53677. * | ----- | ----------------------------------- | ----------- |
  53678. * | 0 | EXPLICIT_MODE | |
  53679. * | 1 | SPHERICAL_MODE | |
  53680. * | 2 | PLANAR_MODE | |
  53681. * | 3 | CUBIC_MODE | |
  53682. * | 4 | PROJECTION_MODE | |
  53683. * | 5 | SKYBOX_MODE | |
  53684. * | 6 | INVCUBIC_MODE | |
  53685. * | 7 | EQUIRECTANGULAR_MODE | |
  53686. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  53687. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  53688. */
  53689. set: function (value) {
  53690. if (this._coordinatesMode === value) {
  53691. return;
  53692. }
  53693. this._coordinatesMode = value;
  53694. if (this._scene) {
  53695. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  53696. }
  53697. },
  53698. enumerable: true,
  53699. configurable: true
  53700. });
  53701. Object.defineProperty(BaseTexture.prototype, "isCube", {
  53702. /**
  53703. * Define if the texture is a cube texture or if false a 2d texture.
  53704. */
  53705. get: function () {
  53706. if (!this._texture) {
  53707. return false;
  53708. }
  53709. return this._texture.isCube;
  53710. },
  53711. set: function (value) {
  53712. if (!this._texture) {
  53713. return;
  53714. }
  53715. this._texture.isCube = value;
  53716. },
  53717. enumerable: true,
  53718. configurable: true
  53719. });
  53720. Object.defineProperty(BaseTexture.prototype, "is3D", {
  53721. /**
  53722. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  53723. */
  53724. get: function () {
  53725. if (!this._texture) {
  53726. return false;
  53727. }
  53728. return this._texture.is3D;
  53729. },
  53730. set: function (value) {
  53731. if (!this._texture) {
  53732. return;
  53733. }
  53734. this._texture.is3D = value;
  53735. },
  53736. enumerable: true,
  53737. configurable: true
  53738. });
  53739. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  53740. /**
  53741. * Gets whether or not the texture contains RGBD data.
  53742. */
  53743. get: function () {
  53744. return this._texture != null && this._texture._isRGBD;
  53745. },
  53746. enumerable: true,
  53747. configurable: true
  53748. });
  53749. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  53750. /**
  53751. * Are mip maps generated for this texture or not.
  53752. */
  53753. get: function () {
  53754. return false;
  53755. },
  53756. enumerable: true,
  53757. configurable: true
  53758. });
  53759. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  53760. /**
  53761. * With prefiltered texture, defined the offset used during the prefiltering steps.
  53762. */
  53763. get: function () {
  53764. if (this._texture) {
  53765. return this._texture._lodGenerationOffset;
  53766. }
  53767. return 0.0;
  53768. },
  53769. set: function (value) {
  53770. if (this._texture) {
  53771. this._texture._lodGenerationOffset = value;
  53772. }
  53773. },
  53774. enumerable: true,
  53775. configurable: true
  53776. });
  53777. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  53778. /**
  53779. * With prefiltered texture, defined the scale used during the prefiltering steps.
  53780. */
  53781. get: function () {
  53782. if (this._texture) {
  53783. return this._texture._lodGenerationScale;
  53784. }
  53785. return 0.0;
  53786. },
  53787. set: function (value) {
  53788. if (this._texture) {
  53789. this._texture._lodGenerationScale = value;
  53790. }
  53791. },
  53792. enumerable: true,
  53793. configurable: true
  53794. });
  53795. Object.defineProperty(BaseTexture.prototype, "uid", {
  53796. /**
  53797. * Define the unique id of the texture in the scene.
  53798. */
  53799. get: function () {
  53800. if (!this._uid) {
  53801. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  53802. }
  53803. return this._uid;
  53804. },
  53805. enumerable: true,
  53806. configurable: true
  53807. });
  53808. /**
  53809. * Return a string representation of the texture.
  53810. * @returns the texture as a string
  53811. */
  53812. BaseTexture.prototype.toString = function () {
  53813. return this.name;
  53814. };
  53815. /**
  53816. * Get the class name of the texture.
  53817. * @returns "BaseTexture"
  53818. */
  53819. BaseTexture.prototype.getClassName = function () {
  53820. return "BaseTexture";
  53821. };
  53822. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  53823. /**
  53824. * Callback triggered when the texture has been disposed.
  53825. * Kept for back compatibility, you can use the onDisposeObservable instead.
  53826. */
  53827. set: function (callback) {
  53828. if (this._onDisposeObserver) {
  53829. this.onDisposeObservable.remove(this._onDisposeObserver);
  53830. }
  53831. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  53832. },
  53833. enumerable: true,
  53834. configurable: true
  53835. });
  53836. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  53837. /**
  53838. * Define if the texture is preventinga material to render or not.
  53839. * If not and the texture is not ready, the engine will use a default black texture instead.
  53840. */
  53841. get: function () {
  53842. return true;
  53843. },
  53844. enumerable: true,
  53845. configurable: true
  53846. });
  53847. /**
  53848. * Get the scene the texture belongs to.
  53849. * @returns the scene or null if undefined
  53850. */
  53851. BaseTexture.prototype.getScene = function () {
  53852. return this._scene;
  53853. };
  53854. /**
  53855. * Get the texture transform matrix used to offset tile the texture for istance.
  53856. * @returns the transformation matrix
  53857. */
  53858. BaseTexture.prototype.getTextureMatrix = function () {
  53859. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  53860. };
  53861. /**
  53862. * Get the texture reflection matrix used to rotate/transform the reflection.
  53863. * @returns the reflection matrix
  53864. */
  53865. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  53866. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  53867. };
  53868. /**
  53869. * Get the underlying lower level texture from Babylon.
  53870. * @returns the insternal texture
  53871. */
  53872. BaseTexture.prototype.getInternalTexture = function () {
  53873. return this._texture;
  53874. };
  53875. /**
  53876. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  53877. * @returns true if ready or not blocking
  53878. */
  53879. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  53880. return !this.isBlocking || this.isReady();
  53881. };
  53882. /**
  53883. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  53884. * @returns true if fully ready
  53885. */
  53886. BaseTexture.prototype.isReady = function () {
  53887. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  53888. this.delayLoad();
  53889. return false;
  53890. }
  53891. if (this._texture) {
  53892. return this._texture.isReady;
  53893. }
  53894. return false;
  53895. };
  53896. /**
  53897. * Get the size of the texture.
  53898. * @returns the texture size.
  53899. */
  53900. BaseTexture.prototype.getSize = function () {
  53901. if (this._texture) {
  53902. if (this._texture.width) {
  53903. this._cachedSize.width = this._texture.width;
  53904. this._cachedSize.height = this._texture.height;
  53905. return this._cachedSize;
  53906. }
  53907. if (this._texture._size) {
  53908. this._cachedSize.width = this._texture._size;
  53909. this._cachedSize.height = this._texture._size;
  53910. return this._cachedSize;
  53911. }
  53912. }
  53913. return this._cachedSize;
  53914. };
  53915. /**
  53916. * Get the base size of the texture.
  53917. * It can be different from the size if the texture has been resized for POT for instance
  53918. * @returns the base size
  53919. */
  53920. BaseTexture.prototype.getBaseSize = function () {
  53921. if (!this.isReady() || !this._texture) {
  53922. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  53923. }
  53924. if (this._texture._size) {
  53925. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  53926. }
  53927. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  53928. };
  53929. /**
  53930. * Update the sampling mode of the texture.
  53931. * Default is Trilinear mode.
  53932. *
  53933. * | Value | Type | Description |
  53934. * | ----- | ------------------ | ----------- |
  53935. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  53936. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  53937. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  53938. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  53939. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  53940. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  53941. * | 7 | NEAREST_LINEAR | |
  53942. * | 8 | NEAREST_NEAREST | |
  53943. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  53944. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  53945. * | 11 | LINEAR_LINEAR | |
  53946. * | 12 | LINEAR_NEAREST | |
  53947. *
  53948. * > _mag_: magnification filter (close to the viewer)
  53949. * > _min_: minification filter (far from the viewer)
  53950. * > _mip_: filter used between mip map levels
  53951. *@param samplingMode Define the new sampling mode of the texture
  53952. */
  53953. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  53954. if (!this._texture) {
  53955. return;
  53956. }
  53957. var scene = this.getScene();
  53958. if (!scene) {
  53959. return;
  53960. }
  53961. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  53962. };
  53963. /**
  53964. * Scales the texture if is `canRescale()`
  53965. * @param ratio the resize factor we want to use to rescale
  53966. */
  53967. BaseTexture.prototype.scale = function (ratio) {
  53968. };
  53969. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  53970. /**
  53971. * Get if the texture can rescale.
  53972. */
  53973. get: function () {
  53974. return false;
  53975. },
  53976. enumerable: true,
  53977. configurable: true
  53978. });
  53979. /** @hidden */
  53980. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  53981. if (!this._scene) {
  53982. return null;
  53983. }
  53984. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  53985. for (var index = 0; index < texturesCache.length; index++) {
  53986. var texturesCacheEntry = texturesCache[index];
  53987. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  53988. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  53989. texturesCacheEntry.incrementReferences();
  53990. return texturesCacheEntry;
  53991. }
  53992. }
  53993. }
  53994. return null;
  53995. };
  53996. /** @hidden */
  53997. BaseTexture.prototype._rebuild = function () {
  53998. };
  53999. /**
  54000. * Triggers the load sequence in delayed load mode.
  54001. */
  54002. BaseTexture.prototype.delayLoad = function () {
  54003. };
  54004. /**
  54005. * Clones the texture.
  54006. * @returns the cloned texture
  54007. */
  54008. BaseTexture.prototype.clone = function () {
  54009. return null;
  54010. };
  54011. Object.defineProperty(BaseTexture.prototype, "textureType", {
  54012. /**
  54013. * Get the texture underlying type (INT, FLOAT...)
  54014. */
  54015. get: function () {
  54016. if (!this._texture) {
  54017. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54018. }
  54019. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54020. },
  54021. enumerable: true,
  54022. configurable: true
  54023. });
  54024. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  54025. /**
  54026. * Get the texture underlying format (RGB, RGBA...)
  54027. */
  54028. get: function () {
  54029. if (!this._texture) {
  54030. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54031. }
  54032. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54033. },
  54034. enumerable: true,
  54035. configurable: true
  54036. });
  54037. /**
  54038. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  54039. * This will returns an RGBA array buffer containing either in values (0-255) or
  54040. * float values (0-1) depending of the underlying buffer type.
  54041. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  54042. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  54043. * @param buffer defines a user defined buffer to fill with data (can be null)
  54044. * @returns The Array buffer containing the pixels data.
  54045. */
  54046. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  54047. if (faceIndex === void 0) { faceIndex = 0; }
  54048. if (level === void 0) { level = 0; }
  54049. if (buffer === void 0) { buffer = null; }
  54050. if (!this._texture) {
  54051. return null;
  54052. }
  54053. var size = this.getSize();
  54054. var width = size.width;
  54055. var height = size.height;
  54056. var scene = this.getScene();
  54057. if (!scene) {
  54058. return null;
  54059. }
  54060. var engine = scene.getEngine();
  54061. if (level != 0) {
  54062. width = width / Math.pow(2, level);
  54063. height = height / Math.pow(2, level);
  54064. width = Math.round(width);
  54065. height = Math.round(height);
  54066. }
  54067. if (this._texture.isCube) {
  54068. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  54069. }
  54070. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  54071. };
  54072. /**
  54073. * Release and destroy the underlying lower level texture aka internalTexture.
  54074. */
  54075. BaseTexture.prototype.releaseInternalTexture = function () {
  54076. if (this._texture) {
  54077. this._texture.dispose();
  54078. this._texture = null;
  54079. }
  54080. };
  54081. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  54082. /**
  54083. * Get the polynomial representation of the texture data.
  54084. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54085. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54086. */
  54087. get: function () {
  54088. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  54089. return null;
  54090. }
  54091. if (!this._texture._sphericalPolynomial) {
  54092. this._texture._sphericalPolynomial =
  54093. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  54094. }
  54095. return this._texture._sphericalPolynomial;
  54096. },
  54097. set: function (value) {
  54098. if (this._texture) {
  54099. this._texture._sphericalPolynomial = value;
  54100. }
  54101. },
  54102. enumerable: true,
  54103. configurable: true
  54104. });
  54105. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  54106. /** @hidden */
  54107. get: function () {
  54108. if (this._texture) {
  54109. return this._texture._lodTextureHigh;
  54110. }
  54111. return null;
  54112. },
  54113. enumerable: true,
  54114. configurable: true
  54115. });
  54116. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  54117. /** @hidden */
  54118. get: function () {
  54119. if (this._texture) {
  54120. return this._texture._lodTextureMid;
  54121. }
  54122. return null;
  54123. },
  54124. enumerable: true,
  54125. configurable: true
  54126. });
  54127. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  54128. /** @hidden */
  54129. get: function () {
  54130. if (this._texture) {
  54131. return this._texture._lodTextureLow;
  54132. }
  54133. return null;
  54134. },
  54135. enumerable: true,
  54136. configurable: true
  54137. });
  54138. /**
  54139. * Dispose the texture and release its associated resources.
  54140. */
  54141. BaseTexture.prototype.dispose = function () {
  54142. if (!this._scene) {
  54143. return;
  54144. }
  54145. // Animations
  54146. this._scene.stopAnimation(this);
  54147. // Remove from scene
  54148. this._scene._removePendingData(this);
  54149. var index = this._scene.textures.indexOf(this);
  54150. if (index >= 0) {
  54151. this._scene.textures.splice(index, 1);
  54152. }
  54153. this._scene.onTextureRemovedObservable.notifyObservers(this);
  54154. if (this._texture === undefined) {
  54155. return;
  54156. }
  54157. // Release
  54158. this.releaseInternalTexture();
  54159. // Callback
  54160. this.onDisposeObservable.notifyObservers(this);
  54161. this.onDisposeObservable.clear();
  54162. };
  54163. /**
  54164. * Serialize the texture into a JSON representation that can be parsed later on.
  54165. * @returns the JSON representation of the texture
  54166. */
  54167. BaseTexture.prototype.serialize = function () {
  54168. if (!this.name) {
  54169. return null;
  54170. }
  54171. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54172. // Animations
  54173. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  54174. return serializationObject;
  54175. };
  54176. /**
  54177. * Helper function to be called back once a list of texture contains only ready textures.
  54178. * @param textures Define the list of textures to wait for
  54179. * @param callback Define the callback triggered once the entire list will be ready
  54180. */
  54181. BaseTexture.WhenAllReady = function (textures, callback) {
  54182. var numRemaining = textures.length;
  54183. if (numRemaining === 0) {
  54184. callback();
  54185. return;
  54186. }
  54187. var _loop_1 = function () {
  54188. texture = textures[i];
  54189. if (texture.isReady()) {
  54190. if (--numRemaining === 0) {
  54191. callback();
  54192. }
  54193. }
  54194. else {
  54195. onLoadObservable = texture.onLoadObservable;
  54196. var onLoadCallback_1 = function () {
  54197. onLoadObservable.removeCallback(onLoadCallback_1);
  54198. if (--numRemaining === 0) {
  54199. callback();
  54200. }
  54201. };
  54202. onLoadObservable.add(onLoadCallback_1);
  54203. }
  54204. };
  54205. var texture, onLoadObservable;
  54206. for (var i = 0; i < textures.length; i++) {
  54207. _loop_1();
  54208. }
  54209. };
  54210. /**
  54211. * Default anisotropic filtering level for the application.
  54212. * It is set to 4 as a good tradeoff between perf and quality.
  54213. */
  54214. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  54215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54217. ], BaseTexture.prototype, "uniqueId", void 0);
  54218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54220. ], BaseTexture.prototype, "name", void 0);
  54221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54223. ], BaseTexture.prototype, "metadata", void 0);
  54224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  54226. ], BaseTexture.prototype, "_hasAlpha", void 0);
  54227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54229. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  54230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54232. ], BaseTexture.prototype, "level", void 0);
  54233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54235. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  54236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  54238. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  54239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54241. ], BaseTexture.prototype, "wrapU", void 0);
  54242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54244. ], BaseTexture.prototype, "wrapV", void 0);
  54245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54247. ], BaseTexture.prototype, "wrapR", void 0);
  54248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54250. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  54251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54253. ], BaseTexture.prototype, "isCube", null);
  54254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54256. ], BaseTexture.prototype, "is3D", null);
  54257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54259. ], BaseTexture.prototype, "gammaSpace", void 0);
  54260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54262. ], BaseTexture.prototype, "invertZ", void 0);
  54263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54265. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  54266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54268. ], BaseTexture.prototype, "lodGenerationOffset", null);
  54269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54271. ], BaseTexture.prototype, "lodGenerationScale", null);
  54272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54274. ], BaseTexture.prototype, "isRenderTarget", void 0);
  54275. return BaseTexture;
  54276. }());
  54277. /***/ }),
  54278. /***/ "./Materials/Textures/colorGradingTexture.ts":
  54279. /*!***************************************************!*\
  54280. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  54281. \***************************************************/
  54282. /*! exports provided: ColorGradingTexture */
  54283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54284. "use strict";
  54285. __webpack_require__.r(__webpack_exports__);
  54286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  54287. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54288. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54289. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54290. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54291. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54292. /**
  54293. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54294. * It can help converting any input color in a desired output one. This can then be used to create effects
  54295. * from sepia, black and white to sixties or futuristic rendering...
  54296. *
  54297. * The only supported format is currently 3dl.
  54298. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54299. */
  54300. var ColorGradingTexture = /** @class */ (function (_super) {
  54301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  54302. /**
  54303. * Instantiates a ColorGradingTexture from the following parameters.
  54304. *
  54305. * @param url The location of the color gradind data (currently only supporting 3dl)
  54306. * @param scene The scene the texture will be used in
  54307. */
  54308. function ColorGradingTexture(url, scene) {
  54309. var _this = _super.call(this, scene) || this;
  54310. if (!url) {
  54311. return _this;
  54312. }
  54313. _this._engine = scene.getEngine();
  54314. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  54315. _this.name = url;
  54316. _this.url = url;
  54317. _this.hasAlpha = false;
  54318. _this.isCube = false;
  54319. _this.is3D = _this._engine.webGLVersion > 1;
  54320. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54321. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54322. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54323. _this.anisotropicFilteringLevel = 1;
  54324. _this._texture = _this._getFromCache(url, true);
  54325. if (!_this._texture) {
  54326. if (!scene.useDelayedTextureLoading) {
  54327. _this.loadTexture();
  54328. }
  54329. else {
  54330. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54331. }
  54332. }
  54333. return _this;
  54334. }
  54335. /**
  54336. * Returns the texture matrix used in most of the material.
  54337. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54338. */
  54339. ColorGradingTexture.prototype.getTextureMatrix = function () {
  54340. return this._textureMatrix;
  54341. };
  54342. /**
  54343. * Occurs when the file being loaded is a .3dl LUT file.
  54344. */
  54345. ColorGradingTexture.prototype.load3dlTexture = function () {
  54346. var engine = this._engine;
  54347. var texture;
  54348. if (engine.webGLVersion === 1) {
  54349. 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);
  54350. }
  54351. else {
  54352. 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);
  54353. }
  54354. this._texture = texture;
  54355. var callback = function (text) {
  54356. if (typeof text !== "string") {
  54357. return;
  54358. }
  54359. var data = null;
  54360. var tempData = null;
  54361. var line;
  54362. var lines = text.split('\n');
  54363. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  54364. var maxColor = 0;
  54365. for (var i = 0; i < lines.length; i++) {
  54366. line = lines[i];
  54367. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  54368. continue;
  54369. }
  54370. if (line.indexOf('#') === 0) {
  54371. continue;
  54372. }
  54373. var words = line.split(" ");
  54374. if (size === 0) {
  54375. // Number of space + one
  54376. size = words.length;
  54377. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  54378. tempData = new Float32Array(size * size * size * 4);
  54379. continue;
  54380. }
  54381. if (size != 0) {
  54382. var r = Math.max(parseInt(words[0]), 0);
  54383. var g = Math.max(parseInt(words[1]), 0);
  54384. var b = Math.max(parseInt(words[2]), 0);
  54385. maxColor = Math.max(r, maxColor);
  54386. maxColor = Math.max(g, maxColor);
  54387. maxColor = Math.max(b, maxColor);
  54388. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  54389. if (tempData) {
  54390. tempData[pixelStorageIndex + 0] = r;
  54391. tempData[pixelStorageIndex + 1] = g;
  54392. tempData[pixelStorageIndex + 2] = b;
  54393. }
  54394. // Keep for reference in case of back compat problems.
  54395. // pixelIndexSlice++;
  54396. // if (pixelIndexSlice % size == 0) {
  54397. // pixelIndexH++;
  54398. // pixelIndexSlice = 0;
  54399. // if (pixelIndexH % size == 0) {
  54400. // pixelIndexW++;
  54401. // pixelIndexH = 0;
  54402. // }
  54403. // }
  54404. pixelIndexH++;
  54405. if (pixelIndexH % size == 0) {
  54406. pixelIndexSlice++;
  54407. pixelIndexH = 0;
  54408. if (pixelIndexSlice % size == 0) {
  54409. pixelIndexW++;
  54410. pixelIndexSlice = 0;
  54411. }
  54412. }
  54413. }
  54414. }
  54415. if (tempData && data) {
  54416. for (var i = 0; i < tempData.length; i++) {
  54417. if (i > 0 && (i + 1) % 4 === 0) {
  54418. data[i] = 255;
  54419. }
  54420. else {
  54421. var value = tempData[i];
  54422. data[i] = (value / maxColor * 255);
  54423. }
  54424. }
  54425. }
  54426. if (texture.is3D) {
  54427. texture.updateSize(size, size, size);
  54428. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54429. }
  54430. else {
  54431. texture.updateSize(size * size, size);
  54432. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54433. }
  54434. };
  54435. var scene = this.getScene();
  54436. if (scene) {
  54437. scene._loadFile(this.url, callback);
  54438. }
  54439. else {
  54440. this._engine._loadFile(this.url, callback);
  54441. }
  54442. return this._texture;
  54443. };
  54444. /**
  54445. * Starts the loading process of the texture.
  54446. */
  54447. ColorGradingTexture.prototype.loadTexture = function () {
  54448. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  54449. this.load3dlTexture();
  54450. }
  54451. };
  54452. /**
  54453. * Clones the color gradind texture.
  54454. */
  54455. ColorGradingTexture.prototype.clone = function () {
  54456. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  54457. // Base texture
  54458. newTexture.level = this.level;
  54459. return newTexture;
  54460. };
  54461. /**
  54462. * Called during delayed load for textures.
  54463. */
  54464. ColorGradingTexture.prototype.delayLoad = function () {
  54465. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54466. return;
  54467. }
  54468. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  54469. this._texture = this._getFromCache(this.url, true);
  54470. if (!this._texture) {
  54471. this.loadTexture();
  54472. }
  54473. };
  54474. /**
  54475. * Parses a color grading texture serialized by Babylon.
  54476. * @param parsedTexture The texture information being parsedTexture
  54477. * @param scene The scene to load the texture in
  54478. * @param rootUrl The root url of the data assets to load
  54479. * @return A color gradind texture
  54480. */
  54481. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  54482. var texture = null;
  54483. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  54484. texture = new ColorGradingTexture(parsedTexture.name, scene);
  54485. texture.name = parsedTexture.name;
  54486. texture.level = parsedTexture.level;
  54487. }
  54488. return texture;
  54489. };
  54490. /**
  54491. * Serializes the LUT texture to json format.
  54492. */
  54493. ColorGradingTexture.prototype.serialize = function () {
  54494. if (!this.name) {
  54495. return null;
  54496. }
  54497. var serializationObject = {};
  54498. serializationObject.name = this.name;
  54499. serializationObject.level = this.level;
  54500. serializationObject.customType = "BABYLON.ColorGradingTexture";
  54501. return serializationObject;
  54502. };
  54503. /**
  54504. * Empty line regex stored for GC.
  54505. */
  54506. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  54507. return ColorGradingTexture;
  54508. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  54509. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  54510. /***/ }),
  54511. /***/ "./Materials/Textures/cubeTexture.ts":
  54512. /*!*******************************************!*\
  54513. !*** ./Materials/Textures/cubeTexture.ts ***!
  54514. \*******************************************/
  54515. /*! exports provided: CubeTexture */
  54516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54517. "use strict";
  54518. __webpack_require__.r(__webpack_exports__);
  54519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  54520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54521. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54522. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54523. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54524. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54525. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54526. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  54527. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54528. /**
  54529. * Class for creating a cube texture
  54530. */
  54531. var CubeTexture = /** @class */ (function (_super) {
  54532. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  54533. /**
  54534. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  54535. * as prefiltered data.
  54536. * @param rootUrl defines the url of the texture or the root name of the six images
  54537. * @param scene defines the scene the texture is attached to
  54538. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  54539. * @param noMipmap defines if mipmaps should be created or not
  54540. * @param files defines the six files to load for the different faces
  54541. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  54542. * @param onError defines a callback triggered in case of error during load
  54543. * @param format defines the internal format to use for the texture once loaded
  54544. * @param prefiltered defines whether or not the texture is created from prefiltered data
  54545. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  54546. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  54547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54549. * @return the cube texture
  54550. */
  54551. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  54552. if (extensions === void 0) { extensions = null; }
  54553. if (noMipmap === void 0) { noMipmap = false; }
  54554. if (files === void 0) { files = null; }
  54555. if (onLoad === void 0) { onLoad = null; }
  54556. if (onError === void 0) { onError = null; }
  54557. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  54558. if (prefiltered === void 0) { prefiltered = false; }
  54559. if (forcedExtension === void 0) { forcedExtension = null; }
  54560. if (createPolynomials === void 0) { createPolynomials = false; }
  54561. if (lodScale === void 0) { lodScale = 0.8; }
  54562. if (lodOffset === void 0) { lodOffset = 0; }
  54563. var _this = _super.call(this, scene) || this;
  54564. /**
  54565. * Gets or sets the center of the bounding box associated with the cube texture.
  54566. * It must define where the camera used to render the texture was set
  54567. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54568. */
  54569. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  54570. _this._rotationY = 0;
  54571. /** @hidden */
  54572. _this._prefiltered = false;
  54573. _this.name = rootUrl;
  54574. _this.url = rootUrl;
  54575. _this._noMipmap = noMipmap;
  54576. _this.hasAlpha = false;
  54577. _this._format = format;
  54578. _this.isCube = true;
  54579. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  54580. _this._createPolynomials = createPolynomials;
  54581. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  54582. if (!rootUrl && !files) {
  54583. return _this;
  54584. }
  54585. var lastDot = rootUrl.lastIndexOf(".");
  54586. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  54587. var isDDS = (extension === ".dds");
  54588. var isEnv = (extension === ".env");
  54589. if (isEnv) {
  54590. _this.gammaSpace = false;
  54591. _this._prefiltered = false;
  54592. }
  54593. else {
  54594. _this._prefiltered = prefiltered;
  54595. if (prefiltered) {
  54596. _this.gammaSpace = false;
  54597. }
  54598. }
  54599. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  54600. if (!files) {
  54601. if (!isEnv && !isDDS && !extensions) {
  54602. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  54603. }
  54604. files = [];
  54605. if (extensions) {
  54606. for (var index = 0; index < extensions.length; index++) {
  54607. files.push(rootUrl + extensions[index]);
  54608. }
  54609. }
  54610. }
  54611. _this._files = files;
  54612. if (!_this._texture) {
  54613. if (!scene.useDelayedTextureLoading) {
  54614. if (prefiltered) {
  54615. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  54616. }
  54617. else {
  54618. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  54619. }
  54620. }
  54621. else {
  54622. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54623. }
  54624. }
  54625. else if (onLoad) {
  54626. if (_this._texture.isReady) {
  54627. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  54628. }
  54629. else {
  54630. _this._texture.onLoadedObservable.add(onLoad);
  54631. }
  54632. }
  54633. return _this;
  54634. }
  54635. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  54636. /**
  54637. * Returns the bounding box size
  54638. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54639. */
  54640. get: function () {
  54641. return this._boundingBoxSize;
  54642. },
  54643. /**
  54644. * Gets or sets the size of the bounding box associated with the cube texture
  54645. * When defined, the cubemap will switch to local mode
  54646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54647. * @example https://www.babylonjs-playground.com/#RNASML
  54648. */
  54649. set: function (value) {
  54650. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  54651. return;
  54652. }
  54653. this._boundingBoxSize = value;
  54654. var scene = this.getScene();
  54655. if (scene) {
  54656. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54657. }
  54658. },
  54659. enumerable: true,
  54660. configurable: true
  54661. });
  54662. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  54663. /**
  54664. * Gets texture matrix rotation angle around Y axis radians.
  54665. */
  54666. get: function () {
  54667. return this._rotationY;
  54668. },
  54669. /**
  54670. * Sets texture matrix rotation angle around Y axis in radians.
  54671. */
  54672. set: function (value) {
  54673. this._rotationY = value;
  54674. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  54675. },
  54676. enumerable: true,
  54677. configurable: true
  54678. });
  54679. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  54680. /**
  54681. * Are mip maps generated for this texture or not.
  54682. */
  54683. get: function () {
  54684. return this._noMipmap;
  54685. },
  54686. enumerable: true,
  54687. configurable: true
  54688. });
  54689. /**
  54690. * Creates a cube texture from an array of image urls
  54691. * @param files defines an array of image urls
  54692. * @param scene defines the hosting scene
  54693. * @param noMipmap specifies if mip maps are not used
  54694. * @returns a cube texture
  54695. */
  54696. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  54697. var rootUrlKey = "";
  54698. files.forEach(function (url) { return rootUrlKey += url; });
  54699. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  54700. };
  54701. /**
  54702. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  54703. * @param url defines the url of the prefiltered texture
  54704. * @param scene defines the scene the texture is attached to
  54705. * @param forcedExtension defines the extension of the file if different from the url
  54706. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  54707. * @return the prefiltered texture
  54708. */
  54709. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  54710. if (forcedExtension === void 0) { forcedExtension = null; }
  54711. if (createPolynomials === void 0) { createPolynomials = true; }
  54712. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  54713. };
  54714. /**
  54715. * Get the current class name of the texture useful for serialization or dynamic coding.
  54716. * @returns "CubeTexture"
  54717. */
  54718. CubeTexture.prototype.getClassName = function () {
  54719. return "CubeTexture";
  54720. };
  54721. /**
  54722. * Update the url (and optional buffer) of this texture if url was null during construction.
  54723. * @param url the url of the texture
  54724. * @param forcedExtension defines the extension to use
  54725. * @param onLoad callback called when the texture is loaded (defaults to null)
  54726. */
  54727. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  54728. if (this.url) {
  54729. this.releaseInternalTexture();
  54730. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54731. }
  54732. this.url = url;
  54733. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54734. this._prefiltered = false;
  54735. if (onLoad) {
  54736. this._delayedOnLoad = onLoad;
  54737. }
  54738. this.delayLoad(forcedExtension);
  54739. };
  54740. /**
  54741. * Delays loading of the cube texture
  54742. * @param forcedExtension defines the extension to use
  54743. */
  54744. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  54745. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54746. return;
  54747. }
  54748. var scene = this.getScene();
  54749. if (!scene) {
  54750. return;
  54751. }
  54752. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  54753. this._texture = this._getFromCache(this.url, this._noMipmap);
  54754. if (!this._texture) {
  54755. if (this._prefiltered) {
  54756. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  54757. }
  54758. else {
  54759. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  54760. }
  54761. }
  54762. };
  54763. /**
  54764. * Returns the reflection texture matrix
  54765. * @returns the reflection texture matrix
  54766. */
  54767. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  54768. return this._textureMatrix;
  54769. };
  54770. /**
  54771. * Sets the reflection texture matrix
  54772. * @param value Reflection texture matrix
  54773. */
  54774. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  54775. var _this = this;
  54776. if (value.updateFlag === this._textureMatrix.updateFlag) {
  54777. return;
  54778. }
  54779. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  54780. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  54781. }
  54782. this._textureMatrix = value;
  54783. };
  54784. /**
  54785. * Parses text to create a cube texture
  54786. * @param parsedTexture define the serialized text to read from
  54787. * @param scene defines the hosting scene
  54788. * @param rootUrl defines the root url of the cube texture
  54789. * @returns a cube texture
  54790. */
  54791. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  54792. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  54793. var prefiltered = false;
  54794. if (parsedTexture.prefiltered) {
  54795. prefiltered = parsedTexture.prefiltered;
  54796. }
  54797. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  54798. }, parsedTexture, scene);
  54799. // Local Cubemaps
  54800. if (parsedTexture.boundingBoxPosition) {
  54801. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  54802. }
  54803. if (parsedTexture.boundingBoxSize) {
  54804. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  54805. }
  54806. // Animations
  54807. if (parsedTexture.animations) {
  54808. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  54809. var parsedAnimation = parsedTexture.animations[animationIndex];
  54810. texture.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].Parse(parsedAnimation));
  54811. }
  54812. }
  54813. return texture;
  54814. };
  54815. /**
  54816. * Makes a clone, or deep copy, of the cube texture
  54817. * @returns a new cube texture
  54818. */
  54819. CubeTexture.prototype.clone = function () {
  54820. var _this = this;
  54821. var scene = this.getScene();
  54822. var uniqueId = 0;
  54823. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  54824. if (!scene) {
  54825. return _this;
  54826. }
  54827. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  54828. uniqueId = cubeTexture.uniqueId;
  54829. return cubeTexture;
  54830. }, this);
  54831. newCubeTexture.uniqueId = uniqueId;
  54832. return newCubeTexture;
  54833. };
  54834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  54836. ], CubeTexture.prototype, "rotationY", null);
  54837. return CubeTexture;
  54838. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  54839. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  54840. /***/ }),
  54841. /***/ "./Materials/Textures/dynamicTexture.ts":
  54842. /*!**********************************************!*\
  54843. !*** ./Materials/Textures/dynamicTexture.ts ***!
  54844. \**********************************************/
  54845. /*! exports provided: DynamicTexture */
  54846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54847. "use strict";
  54848. __webpack_require__.r(__webpack_exports__);
  54849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  54850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54851. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  54852. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54853. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54854. /**
  54855. * A class extending Texture allowing drawing on a texture
  54856. * @see http://doc.babylonjs.com/how_to/dynamictexture
  54857. */
  54858. var DynamicTexture = /** @class */ (function (_super) {
  54859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  54860. /**
  54861. * Creates a DynamicTexture
  54862. * @param name defines the name of the texture
  54863. * @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
  54864. * @param scene defines the scene where you want the texture
  54865. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54866. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54867. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54868. */
  54869. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  54870. if (scene === void 0) { scene = null; }
  54871. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  54872. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  54873. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  54874. _this.name = name;
  54875. _this._engine = _this.getScene().getEngine();
  54876. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  54877. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  54878. _this._generateMipMaps = generateMipMaps;
  54879. if (options.getContext) {
  54880. _this._canvas = options;
  54881. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  54882. }
  54883. else {
  54884. _this._canvas = document.createElement("canvas");
  54885. if (options.width || options.width === 0) {
  54886. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  54887. }
  54888. else {
  54889. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  54890. }
  54891. }
  54892. var textureSize = _this.getSize();
  54893. _this._canvas.width = textureSize.width;
  54894. _this._canvas.height = textureSize.height;
  54895. _this._context = _this._canvas.getContext("2d");
  54896. return _this;
  54897. }
  54898. /**
  54899. * Get the current class name of the texture useful for serialization or dynamic coding.
  54900. * @returns "DynamicTexture"
  54901. */
  54902. DynamicTexture.prototype.getClassName = function () {
  54903. return "DynamicTexture";
  54904. };
  54905. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  54906. /**
  54907. * Gets the current state of canRescale
  54908. */
  54909. get: function () {
  54910. return true;
  54911. },
  54912. enumerable: true,
  54913. configurable: true
  54914. });
  54915. DynamicTexture.prototype._recreate = function (textureSize) {
  54916. this._canvas.width = textureSize.width;
  54917. this._canvas.height = textureSize.height;
  54918. this.releaseInternalTexture();
  54919. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  54920. };
  54921. /**
  54922. * Scales the texture
  54923. * @param ratio the scale factor to apply to both width and height
  54924. */
  54925. DynamicTexture.prototype.scale = function (ratio) {
  54926. var textureSize = this.getSize();
  54927. textureSize.width *= ratio;
  54928. textureSize.height *= ratio;
  54929. this._recreate(textureSize);
  54930. };
  54931. /**
  54932. * Resizes the texture
  54933. * @param width the new width
  54934. * @param height the new height
  54935. */
  54936. DynamicTexture.prototype.scaleTo = function (width, height) {
  54937. var textureSize = this.getSize();
  54938. textureSize.width = width;
  54939. textureSize.height = height;
  54940. this._recreate(textureSize);
  54941. };
  54942. /**
  54943. * Gets the context of the canvas used by the texture
  54944. * @returns the canvas context of the dynamic texture
  54945. */
  54946. DynamicTexture.prototype.getContext = function () {
  54947. return this._context;
  54948. };
  54949. /**
  54950. * Clears the texture
  54951. */
  54952. DynamicTexture.prototype.clear = function () {
  54953. var size = this.getSize();
  54954. this._context.fillRect(0, 0, size.width, size.height);
  54955. };
  54956. /**
  54957. * Updates the texture
  54958. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54959. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54960. */
  54961. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  54962. if (premulAlpha === void 0) { premulAlpha = false; }
  54963. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  54964. };
  54965. /**
  54966. * Draws text onto the texture
  54967. * @param text defines the text to be drawn
  54968. * @param x defines the placement of the text from the left
  54969. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54970. * @param font defines the font to be used with font-style, font-size, font-name
  54971. * @param color defines the color used for the text
  54972. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54973. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54974. * @param update defines whether texture is immediately update (default is true)
  54975. */
  54976. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  54977. if (update === void 0) { update = true; }
  54978. var size = this.getSize();
  54979. if (clearColor) {
  54980. this._context.fillStyle = clearColor;
  54981. this._context.fillRect(0, 0, size.width, size.height);
  54982. }
  54983. this._context.font = font;
  54984. if (x === null || x === undefined) {
  54985. var textSize = this._context.measureText(text);
  54986. x = (size.width - textSize.width) / 2;
  54987. }
  54988. if (y === null || y === undefined) {
  54989. var fontSize = parseInt((font.replace(/\D/g, '')));
  54990. y = (size.height / 2) + (fontSize / 3.65);
  54991. }
  54992. this._context.fillStyle = color;
  54993. this._context.fillText(text, x, y);
  54994. if (update) {
  54995. this.update(invertY);
  54996. }
  54997. };
  54998. /**
  54999. * Clones the texture
  55000. * @returns the clone of the texture.
  55001. */
  55002. DynamicTexture.prototype.clone = function () {
  55003. var scene = this.getScene();
  55004. if (!scene) {
  55005. return this;
  55006. }
  55007. var textureSize = this.getSize();
  55008. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  55009. // Base texture
  55010. newTexture.hasAlpha = this.hasAlpha;
  55011. newTexture.level = this.level;
  55012. // Dynamic Texture
  55013. newTexture.wrapU = this.wrapU;
  55014. newTexture.wrapV = this.wrapV;
  55015. return newTexture;
  55016. };
  55017. /**
  55018. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55019. * @returns a serialized dynamic texture object
  55020. */
  55021. DynamicTexture.prototype.serialize = function () {
  55022. var scene = this.getScene();
  55023. if (scene && !scene.isReady()) {
  55024. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  55025. }
  55026. var serializationObject = _super.prototype.serialize.call(this);
  55027. serializationObject.base64String = this._canvas.toDataURL();
  55028. serializationObject.invertY = this._invertY;
  55029. serializationObject.samplingMode = this.samplingMode;
  55030. return serializationObject;
  55031. };
  55032. /** @hidden */
  55033. DynamicTexture.prototype._rebuild = function () {
  55034. this.update();
  55035. };
  55036. return DynamicTexture;
  55037. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  55038. /***/ }),
  55039. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  55040. /*!**********************************************!*\
  55041. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  55042. \**********************************************/
  55043. /*! exports provided: HDRCubeTexture */
  55044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55045. "use strict";
  55046. __webpack_require__.r(__webpack_exports__);
  55047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  55048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55049. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55050. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  55051. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55052. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55053. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55054. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  55055. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55056. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55057. /**
  55058. * This represents a texture coming from an HDR input.
  55059. *
  55060. * The only supported format is currently panorama picture stored in RGBE format.
  55061. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55062. */
  55063. var HDRCubeTexture = /** @class */ (function (_super) {
  55064. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  55065. /**
  55066. * Instantiates an HDRTexture from the following parameters.
  55067. *
  55068. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55069. * @param scene The scene the texture will be used in
  55070. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55071. * @param noMipmap Forces to not generate the mipmap if true
  55072. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55073. * @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)
  55074. * @param reserved Reserved flag for internal use.
  55075. */
  55076. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  55077. if (noMipmap === void 0) { noMipmap = false; }
  55078. if (generateHarmonics === void 0) { generateHarmonics = true; }
  55079. if (gammaSpace === void 0) { gammaSpace = false; }
  55080. if (reserved === void 0) { reserved = false; }
  55081. if (onLoad === void 0) { onLoad = null; }
  55082. if (onError === void 0) { onError = null; }
  55083. var _this = _super.call(this, scene) || this;
  55084. _this._generateHarmonics = true;
  55085. _this._onLoad = null;
  55086. _this._onError = null;
  55087. /**
  55088. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55089. */
  55090. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  55091. _this._isBlocking = true;
  55092. _this._rotationY = 0;
  55093. /**
  55094. * Gets or sets the center of the bounding box associated with the cube texture
  55095. * It must define where the camera used to render the texture was set
  55096. */
  55097. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  55098. if (!url) {
  55099. return _this;
  55100. }
  55101. _this.name = url;
  55102. _this.url = url;
  55103. _this.hasAlpha = false;
  55104. _this.isCube = true;
  55105. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55106. _this._onLoad = onLoad;
  55107. _this._onError = onError;
  55108. _this.gammaSpace = gammaSpace;
  55109. _this._noMipmap = noMipmap;
  55110. _this._size = size;
  55111. _this._texture = _this._getFromCache(url, _this._noMipmap);
  55112. if (!_this._texture) {
  55113. if (!scene.useDelayedTextureLoading) {
  55114. _this.loadTexture();
  55115. }
  55116. else {
  55117. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  55118. }
  55119. }
  55120. return _this;
  55121. }
  55122. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  55123. /**
  55124. * Gets wether or not the texture is blocking during loading.
  55125. */
  55126. get: function () {
  55127. return this._isBlocking;
  55128. },
  55129. /**
  55130. * Sets wether or not the texture is blocking during loading.
  55131. */
  55132. set: function (value) {
  55133. this._isBlocking = value;
  55134. },
  55135. enumerable: true,
  55136. configurable: true
  55137. });
  55138. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  55139. /**
  55140. * Gets texture matrix rotation angle around Y axis radians.
  55141. */
  55142. get: function () {
  55143. return this._rotationY;
  55144. },
  55145. /**
  55146. * Sets texture matrix rotation angle around Y axis in radians.
  55147. */
  55148. set: function (value) {
  55149. this._rotationY = value;
  55150. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  55151. },
  55152. enumerable: true,
  55153. configurable: true
  55154. });
  55155. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  55156. get: function () {
  55157. return this._boundingBoxSize;
  55158. },
  55159. /**
  55160. * Gets or sets the size of the bounding box associated with the cube texture
  55161. * When defined, the cubemap will switch to local mode
  55162. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55163. * @example https://www.babylonjs-playground.com/#RNASML
  55164. */
  55165. set: function (value) {
  55166. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55167. return;
  55168. }
  55169. this._boundingBoxSize = value;
  55170. var scene = this.getScene();
  55171. if (scene) {
  55172. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  55173. }
  55174. },
  55175. enumerable: true,
  55176. configurable: true
  55177. });
  55178. /**
  55179. * Get the current class name of the texture useful for serialization or dynamic coding.
  55180. * @returns "HDRCubeTexture"
  55181. */
  55182. HDRCubeTexture.prototype.getClassName = function () {
  55183. return "HDRCubeTexture";
  55184. };
  55185. /**
  55186. * Occurs when the file is raw .hdr file.
  55187. */
  55188. HDRCubeTexture.prototype.loadTexture = function () {
  55189. var _this = this;
  55190. var callback = function (buffer) {
  55191. _this.lodGenerationOffset = 0.0;
  55192. _this.lodGenerationScale = 0.8;
  55193. var scene = _this.getScene();
  55194. if (!scene) {
  55195. return null;
  55196. }
  55197. // Extract the raw linear data.
  55198. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  55199. // Generate harmonics if needed.
  55200. if (_this._generateHarmonics) {
  55201. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  55202. _this.sphericalPolynomial = sphericalPolynomial;
  55203. }
  55204. var results = [];
  55205. var byteArray = null;
  55206. // Push each faces.
  55207. for (var j = 0; j < 6; j++) {
  55208. // Create uintarray fallback.
  55209. if (!scene.getEngine().getCaps().textureFloat) {
  55210. // 3 channels of 1 bytes per pixel in bytes.
  55211. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  55212. byteArray = new Uint8Array(byteBuffer);
  55213. }
  55214. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  55215. // If special cases.
  55216. if (_this.gammaSpace || byteArray) {
  55217. for (var i = 0; i < _this._size * _this._size; i++) {
  55218. // Put in gamma space if requested.
  55219. if (_this.gammaSpace) {
  55220. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55221. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55222. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55223. }
  55224. // Convert to int texture for fallback.
  55225. if (byteArray) {
  55226. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  55227. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  55228. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  55229. // May use luminance instead if the result is not accurate.
  55230. var max = Math.max(Math.max(r, g), b);
  55231. if (max > 255) {
  55232. var scale = 255 / max;
  55233. r *= scale;
  55234. g *= scale;
  55235. b *= scale;
  55236. }
  55237. byteArray[(i * 3) + 0] = r;
  55238. byteArray[(i * 3) + 1] = g;
  55239. byteArray[(i * 3) + 2] = b;
  55240. }
  55241. }
  55242. }
  55243. if (byteArray) {
  55244. results.push(byteArray);
  55245. }
  55246. else {
  55247. results.push(dataFace);
  55248. }
  55249. }
  55250. return results;
  55251. };
  55252. var scene = this.getScene();
  55253. if (scene) {
  55254. 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);
  55255. }
  55256. };
  55257. HDRCubeTexture.prototype.clone = function () {
  55258. var scene = this.getScene();
  55259. if (!scene) {
  55260. return this;
  55261. }
  55262. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  55263. // Base texture
  55264. newTexture.level = this.level;
  55265. newTexture.wrapU = this.wrapU;
  55266. newTexture.wrapV = this.wrapV;
  55267. newTexture.coordinatesIndex = this.coordinatesIndex;
  55268. newTexture.coordinatesMode = this.coordinatesMode;
  55269. return newTexture;
  55270. };
  55271. // Methods
  55272. HDRCubeTexture.prototype.delayLoad = function () {
  55273. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  55274. return;
  55275. }
  55276. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  55277. this._texture = this._getFromCache(this.url, this._noMipmap);
  55278. if (!this._texture) {
  55279. this.loadTexture();
  55280. }
  55281. };
  55282. /**
  55283. * Get the texture reflection matrix used to rotate/transform the reflection.
  55284. * @returns the reflection matrix
  55285. */
  55286. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  55287. return this._textureMatrix;
  55288. };
  55289. /**
  55290. * Set the texture reflection matrix used to rotate/transform the reflection.
  55291. * @param value Define the reflection matrix to set
  55292. */
  55293. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55294. var _this = this;
  55295. this._textureMatrix = value;
  55296. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55297. return;
  55298. }
  55299. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55300. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55301. }
  55302. };
  55303. /**
  55304. * Parses a JSON representation of an HDR Texture in order to create the texture
  55305. * @param parsedTexture Define the JSON representation
  55306. * @param scene Define the scene the texture should be created in
  55307. * @param rootUrl Define the root url in case we need to load relative dependencies
  55308. * @returns the newly created texture after parsing
  55309. */
  55310. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55311. var texture = null;
  55312. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55313. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  55314. texture.name = parsedTexture.name;
  55315. texture.hasAlpha = parsedTexture.hasAlpha;
  55316. texture.level = parsedTexture.level;
  55317. texture.coordinatesMode = parsedTexture.coordinatesMode;
  55318. texture.isBlocking = parsedTexture.isBlocking;
  55319. }
  55320. if (texture) {
  55321. if (parsedTexture.boundingBoxPosition) {
  55322. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55323. }
  55324. if (parsedTexture.boundingBoxSize) {
  55325. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55326. }
  55327. if (parsedTexture.rotationY) {
  55328. texture.rotationY = parsedTexture.rotationY;
  55329. }
  55330. }
  55331. return texture;
  55332. };
  55333. HDRCubeTexture.prototype.serialize = function () {
  55334. if (!this.name) {
  55335. return null;
  55336. }
  55337. var serializationObject = {};
  55338. serializationObject.name = this.name;
  55339. serializationObject.hasAlpha = this.hasAlpha;
  55340. serializationObject.isCube = true;
  55341. serializationObject.level = this.level;
  55342. serializationObject.size = this._size;
  55343. serializationObject.coordinatesMode = this.coordinatesMode;
  55344. serializationObject.useInGammaSpace = this.gammaSpace;
  55345. serializationObject.generateHarmonics = this._generateHarmonics;
  55346. serializationObject.customType = "BABYLON.HDRCubeTexture";
  55347. serializationObject.noMipmap = this._noMipmap;
  55348. serializationObject.isBlocking = this._isBlocking;
  55349. serializationObject.rotationY = this._rotationY;
  55350. return serializationObject;
  55351. };
  55352. HDRCubeTexture._facesMapping = [
  55353. "right",
  55354. "left",
  55355. "up",
  55356. "down",
  55357. "front",
  55358. "back"
  55359. ];
  55360. return HDRCubeTexture;
  55361. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  55362. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  55363. /***/ }),
  55364. /***/ "./Materials/Textures/index.ts":
  55365. /*!*************************************!*\
  55366. !*** ./Materials/Textures/index.ts ***!
  55367. \*************************************/
  55368. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  55369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55370. "use strict";
  55371. __webpack_require__.r(__webpack_exports__);
  55372. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  55373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  55374. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  55375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  55376. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  55377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  55378. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  55379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  55380. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  55381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  55382. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  55383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  55384. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  55385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  55386. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  55387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  55388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  55389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  55390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  55391. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  55392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  55393. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  55394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  55395. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  55396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  55397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  55398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  55399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  55400. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  55401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  55402. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  55403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  55404. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  55405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  55406. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  55407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  55408. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  55410. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  55411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  55412. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  55413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  55414. /***/ }),
  55415. /***/ "./Materials/Textures/internalTexture.ts":
  55416. /*!***********************************************!*\
  55417. !*** ./Materials/Textures/internalTexture.ts ***!
  55418. \***********************************************/
  55419. /*! exports provided: InternalTexture */
  55420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55421. "use strict";
  55422. __webpack_require__.r(__webpack_exports__);
  55423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  55424. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  55425. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  55426. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55427. /**
  55428. * Class used to store data associated with WebGL texture data for the engine
  55429. * This class should not be used directly
  55430. */
  55431. var InternalTexture = /** @class */ (function () {
  55432. /**
  55433. * Creates a new InternalTexture
  55434. * @param engine defines the engine to use
  55435. * @param dataSource defines the type of data that will be used
  55436. * @param delayAllocation if the texture allocation should be delayed (default: false)
  55437. */
  55438. function InternalTexture(engine, dataSource, delayAllocation) {
  55439. if (delayAllocation === void 0) { delayAllocation = false; }
  55440. /**
  55441. * Observable called when the texture is loaded
  55442. */
  55443. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  55444. /**
  55445. * Gets or set the previous tracker in the list
  55446. */
  55447. this.previous = null;
  55448. /**
  55449. * Gets or set the next tracker in the list
  55450. */
  55451. this.next = null;
  55452. // Private
  55453. /** @hidden */
  55454. this._invertVScale = false;
  55455. /** @hidden */
  55456. this._initialSlot = -1;
  55457. /** @hidden */
  55458. this._designatedSlot = -1;
  55459. /** @hidden */
  55460. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  55461. /** @hidden */
  55462. this._comparisonFunction = 0;
  55463. /** @hidden */
  55464. this._sphericalPolynomial = null;
  55465. /** @hidden */
  55466. this._lodGenerationScale = 0;
  55467. /** @hidden */
  55468. this._lodGenerationOffset = 0;
  55469. /** @hidden */
  55470. this._isRGBD = false;
  55471. /** @hidden */
  55472. this._references = 1;
  55473. this._engine = engine;
  55474. this._dataSource = dataSource;
  55475. if (!delayAllocation) {
  55476. this._webGLTexture = engine._createTexture();
  55477. }
  55478. }
  55479. /**
  55480. * Gets the Engine the texture belongs to.
  55481. * @returns The babylon engine
  55482. */
  55483. InternalTexture.prototype.getEngine = function () {
  55484. return this._engine;
  55485. };
  55486. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  55487. /**
  55488. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  55489. */
  55490. get: function () {
  55491. return this._dataSource;
  55492. },
  55493. enumerable: true,
  55494. configurable: true
  55495. });
  55496. /**
  55497. * Increments the number of references (ie. the number of Texture that point to it)
  55498. */
  55499. InternalTexture.prototype.incrementReferences = function () {
  55500. this._references++;
  55501. };
  55502. /**
  55503. * Change the size of the texture (not the size of the content)
  55504. * @param width defines the new width
  55505. * @param height defines the new height
  55506. * @param depth defines the new depth (1 by default)
  55507. */
  55508. InternalTexture.prototype.updateSize = function (width, height, depth) {
  55509. if (depth === void 0) { depth = 1; }
  55510. this.width = width;
  55511. this.height = height;
  55512. this.depth = depth;
  55513. this.baseWidth = width;
  55514. this.baseHeight = height;
  55515. this.baseDepth = depth;
  55516. this._size = width * height * depth;
  55517. };
  55518. /** @hidden */
  55519. InternalTexture.prototype._rebuild = function () {
  55520. var _this = this;
  55521. var proxy;
  55522. this.isReady = false;
  55523. this._cachedCoordinatesMode = null;
  55524. this._cachedWrapU = null;
  55525. this._cachedWrapV = null;
  55526. this._cachedAnisotropicFilteringLevel = null;
  55527. switch (this._dataSource) {
  55528. case InternalTexture.DATASOURCE_TEMP:
  55529. return;
  55530. case InternalTexture.DATASOURCE_URL:
  55531. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  55532. proxy._swapAndDie(_this);
  55533. _this.isReady = true;
  55534. }, null, this._buffer, undefined, this.format);
  55535. return;
  55536. case InternalTexture.DATASOURCE_RAW:
  55537. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55538. proxy._swapAndDie(this);
  55539. this.isReady = true;
  55540. return;
  55541. case InternalTexture.DATASOURCE_RAW3D:
  55542. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55543. proxy._swapAndDie(this);
  55544. this.isReady = true;
  55545. return;
  55546. case InternalTexture.DATASOURCE_DYNAMIC:
  55547. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  55548. proxy._swapAndDie(this);
  55549. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  55550. // The engine will make sure to update content so no need to flag it as isReady = true
  55551. return;
  55552. case InternalTexture.DATASOURCE_RENDERTARGET:
  55553. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  55554. options.generateDepthBuffer = this._generateDepthBuffer;
  55555. options.generateMipMaps = this.generateMipMaps;
  55556. options.generateStencilBuffer = this._generateStencilBuffer;
  55557. options.samplingMode = this.samplingMode;
  55558. options.type = this.type;
  55559. if (this.isCube) {
  55560. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  55561. }
  55562. else {
  55563. var size = {
  55564. width: this.width,
  55565. height: this.height
  55566. };
  55567. proxy = this._engine.createRenderTargetTexture(size, options);
  55568. }
  55569. proxy._swapAndDie(this);
  55570. this.isReady = true;
  55571. return;
  55572. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  55573. var depthTextureOptions = {
  55574. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  55575. comparisonFunction: this._comparisonFunction,
  55576. generateStencil: this._generateStencilBuffer,
  55577. isCube: this.isCube
  55578. };
  55579. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  55580. proxy._swapAndDie(this);
  55581. this.isReady = true;
  55582. return;
  55583. case InternalTexture.DATASOURCE_CUBE:
  55584. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  55585. proxy._swapAndDie(_this);
  55586. _this.isReady = true;
  55587. }, null, this.format, this._extension);
  55588. return;
  55589. case InternalTexture.DATASOURCE_CUBERAW:
  55590. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55591. proxy._swapAndDie(this);
  55592. this.isReady = true;
  55593. return;
  55594. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  55595. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55596. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  55597. proxy._swapAndDie(_this);
  55598. _this.isReady = true;
  55599. });
  55600. return;
  55601. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  55602. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  55603. if (proxy) {
  55604. proxy._swapAndDie(_this);
  55605. }
  55606. _this.isReady = true;
  55607. }, null, this.format, this._extension);
  55608. proxy._sphericalPolynomial = this._sphericalPolynomial;
  55609. return;
  55610. }
  55611. };
  55612. /** @hidden */
  55613. InternalTexture.prototype._swapAndDie = function (target) {
  55614. target._webGLTexture = this._webGLTexture;
  55615. if (this._framebuffer) {
  55616. target._framebuffer = this._framebuffer;
  55617. }
  55618. if (this._depthStencilBuffer) {
  55619. target._depthStencilBuffer = this._depthStencilBuffer;
  55620. }
  55621. if (this._lodTextureHigh) {
  55622. if (target._lodTextureHigh) {
  55623. target._lodTextureHigh.dispose();
  55624. }
  55625. target._lodTextureHigh = this._lodTextureHigh;
  55626. }
  55627. if (this._lodTextureMid) {
  55628. if (target._lodTextureMid) {
  55629. target._lodTextureMid.dispose();
  55630. }
  55631. target._lodTextureMid = this._lodTextureMid;
  55632. }
  55633. if (this._lodTextureLow) {
  55634. if (target._lodTextureLow) {
  55635. target._lodTextureLow.dispose();
  55636. }
  55637. target._lodTextureLow = this._lodTextureLow;
  55638. }
  55639. var cache = this._engine.getLoadedTexturesCache();
  55640. var index = cache.indexOf(this);
  55641. if (index !== -1) {
  55642. cache.splice(index, 1);
  55643. }
  55644. };
  55645. /**
  55646. * Dispose the current allocated resources
  55647. */
  55648. InternalTexture.prototype.dispose = function () {
  55649. if (!this._webGLTexture) {
  55650. return;
  55651. }
  55652. this._references--;
  55653. if (this._references === 0) {
  55654. this._engine._releaseTexture(this);
  55655. this._webGLTexture = null;
  55656. this.previous = null;
  55657. this.next = null;
  55658. }
  55659. };
  55660. /** hidden */
  55661. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  55662. throw "environmentTextureTools needs to be imported before rebuilding RGBD textures.";
  55663. };
  55664. /**
  55665. * The source of the texture data is unknown
  55666. */
  55667. InternalTexture.DATASOURCE_UNKNOWN = 0;
  55668. /**
  55669. * Texture data comes from an URL
  55670. */
  55671. InternalTexture.DATASOURCE_URL = 1;
  55672. /**
  55673. * Texture data is only used for temporary storage
  55674. */
  55675. InternalTexture.DATASOURCE_TEMP = 2;
  55676. /**
  55677. * Texture data comes from raw data (ArrayBuffer)
  55678. */
  55679. InternalTexture.DATASOURCE_RAW = 3;
  55680. /**
  55681. * Texture content is dynamic (video or dynamic texture)
  55682. */
  55683. InternalTexture.DATASOURCE_DYNAMIC = 4;
  55684. /**
  55685. * Texture content is generated by rendering to it
  55686. */
  55687. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  55688. /**
  55689. * Texture content is part of a multi render target process
  55690. */
  55691. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  55692. /**
  55693. * Texture data comes from a cube data file
  55694. */
  55695. InternalTexture.DATASOURCE_CUBE = 7;
  55696. /**
  55697. * Texture data comes from a raw cube data
  55698. */
  55699. InternalTexture.DATASOURCE_CUBERAW = 8;
  55700. /**
  55701. * Texture data come from a prefiltered cube data file
  55702. */
  55703. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  55704. /**
  55705. * Texture content is raw 3D data
  55706. */
  55707. InternalTexture.DATASOURCE_RAW3D = 10;
  55708. /**
  55709. * Texture content is a depth texture
  55710. */
  55711. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  55712. /**
  55713. * Texture data comes from a raw cube data encoded with RGBD
  55714. */
  55715. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  55716. return InternalTexture;
  55717. }());
  55718. /***/ }),
  55719. /***/ "./Materials/Textures/internalTextureTracker.ts":
  55720. /*!******************************************************!*\
  55721. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  55722. \******************************************************/
  55723. /*! exports provided: DummyInternalTextureTracker */
  55724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55725. "use strict";
  55726. __webpack_require__.r(__webpack_exports__);
  55727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  55728. /**
  55729. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  55730. */
  55731. var DummyInternalTextureTracker = /** @class */ (function () {
  55732. function DummyInternalTextureTracker() {
  55733. /**
  55734. * Gets or set the previous tracker in the list
  55735. */
  55736. this.previous = null;
  55737. /**
  55738. * Gets or set the next tracker in the list
  55739. */
  55740. this.next = null;
  55741. }
  55742. return DummyInternalTextureTracker;
  55743. }());
  55744. /***/ }),
  55745. /***/ "./Materials/Textures/mirrorTexture.ts":
  55746. /*!*********************************************!*\
  55747. !*** ./Materials/Textures/mirrorTexture.ts ***!
  55748. \*********************************************/
  55749. /*! exports provided: MirrorTexture */
  55750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55751. "use strict";
  55752. __webpack_require__.r(__webpack_exports__);
  55753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  55754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55755. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55756. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55757. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55758. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  55759. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55760. /**
  55761. * Mirror texture can be used to simulate the view from a mirror in a scene.
  55762. * It will dynamically be rendered every frame to adapt to the camera point of view.
  55763. * You can then easily use it as a reflectionTexture on a flat surface.
  55764. * In case the surface is not a plane, please consider relying on reflection probes.
  55765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55766. */
  55767. var MirrorTexture = /** @class */ (function (_super) {
  55768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  55769. /**
  55770. * Instantiates a Mirror Texture.
  55771. * Mirror texture can be used to simulate the view from a mirror in a scene.
  55772. * It will dynamically be rendered every frame to adapt to the camera point of view.
  55773. * You can then easily use it as a reflectionTexture on a flat surface.
  55774. * In case the surface is not a plane, please consider relying on reflection probes.
  55775. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55776. * @param name
  55777. * @param size
  55778. * @param scene
  55779. * @param generateMipMaps
  55780. * @param type
  55781. * @param samplingMode
  55782. * @param generateDepthBuffer
  55783. */
  55784. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  55785. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  55786. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  55787. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  55788. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  55789. _this.scene = scene;
  55790. /**
  55791. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  55792. * 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.
  55793. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55794. */
  55795. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  55796. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  55797. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  55798. _this._adaptiveBlurKernel = 0;
  55799. _this._blurKernelX = 0;
  55800. _this._blurKernelY = 0;
  55801. _this._blurRatio = 1.0;
  55802. _this.ignoreCameraViewport = true;
  55803. _this._updateGammaSpace();
  55804. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  55805. _this._updateGammaSpace;
  55806. });
  55807. _this.onBeforeRenderObservable.add(function () {
  55808. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  55809. _this._savedViewMatrix = scene.getViewMatrix();
  55810. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  55811. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  55812. scene.clipPlane = _this.mirrorPlane;
  55813. scene.getEngine().cullBackFaces = false;
  55814. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  55815. });
  55816. _this.onAfterRenderObservable.add(function () {
  55817. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  55818. scene.getEngine().cullBackFaces = true;
  55819. scene._mirroredCameraPosition = null;
  55820. delete scene.clipPlane;
  55821. });
  55822. return _this;
  55823. }
  55824. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  55825. get: function () {
  55826. return this._blurRatio;
  55827. },
  55828. /**
  55829. * Define the blur ratio used to blur the reflection if needed.
  55830. */
  55831. set: function (value) {
  55832. if (this._blurRatio === value) {
  55833. return;
  55834. }
  55835. this._blurRatio = value;
  55836. this._preparePostProcesses();
  55837. },
  55838. enumerable: true,
  55839. configurable: true
  55840. });
  55841. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  55842. /**
  55843. * Define the adaptive blur kernel used to blur the reflection if needed.
  55844. * This will autocompute the closest best match for the `blurKernel`
  55845. */
  55846. set: function (value) {
  55847. this._adaptiveBlurKernel = value;
  55848. this._autoComputeBlurKernel();
  55849. },
  55850. enumerable: true,
  55851. configurable: true
  55852. });
  55853. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  55854. /**
  55855. * Define the blur kernel used to blur the reflection if needed.
  55856. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  55857. */
  55858. set: function (value) {
  55859. this.blurKernelX = value;
  55860. this.blurKernelY = value;
  55861. },
  55862. enumerable: true,
  55863. configurable: true
  55864. });
  55865. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  55866. get: function () {
  55867. return this._blurKernelX;
  55868. },
  55869. /**
  55870. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  55871. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  55872. */
  55873. set: function (value) {
  55874. if (this._blurKernelX === value) {
  55875. return;
  55876. }
  55877. this._blurKernelX = value;
  55878. this._preparePostProcesses();
  55879. },
  55880. enumerable: true,
  55881. configurable: true
  55882. });
  55883. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  55884. get: function () {
  55885. return this._blurKernelY;
  55886. },
  55887. /**
  55888. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  55889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  55890. */
  55891. set: function (value) {
  55892. if (this._blurKernelY === value) {
  55893. return;
  55894. }
  55895. this._blurKernelY = value;
  55896. this._preparePostProcesses();
  55897. },
  55898. enumerable: true,
  55899. configurable: true
  55900. });
  55901. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  55902. var engine = this.getScene().getEngine();
  55903. var dw = this.getRenderWidth() / engine.getRenderWidth();
  55904. var dh = this.getRenderHeight() / engine.getRenderHeight();
  55905. this.blurKernelX = this._adaptiveBlurKernel * dw;
  55906. this.blurKernelY = this._adaptiveBlurKernel * dh;
  55907. };
  55908. MirrorTexture.prototype._onRatioRescale = function () {
  55909. if (this._sizeRatio) {
  55910. this.resize(this._initialSizeParameter);
  55911. if (!this._adaptiveBlurKernel) {
  55912. this._preparePostProcesses();
  55913. }
  55914. }
  55915. if (this._adaptiveBlurKernel) {
  55916. this._autoComputeBlurKernel();
  55917. }
  55918. };
  55919. MirrorTexture.prototype._updateGammaSpace = function () {
  55920. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  55921. };
  55922. MirrorTexture.prototype._preparePostProcesses = function () {
  55923. this.clearPostProcesses(true);
  55924. if (this._blurKernelX && this._blurKernelY) {
  55925. var engine = this.getScene().getEngine();
  55926. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  55927. 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);
  55928. this._blurX.autoClear = false;
  55929. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  55930. this._blurX.inputTexture = this._texture;
  55931. }
  55932. else {
  55933. this._blurX.alwaysForcePOT = true;
  55934. }
  55935. 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);
  55936. this._blurY.autoClear = false;
  55937. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  55938. this.addPostProcess(this._blurX);
  55939. this.addPostProcess(this._blurY);
  55940. }
  55941. else {
  55942. if (this._blurY) {
  55943. this.removePostProcess(this._blurY);
  55944. this._blurY.dispose();
  55945. this._blurY = null;
  55946. }
  55947. if (this._blurX) {
  55948. this.removePostProcess(this._blurX);
  55949. this._blurX.dispose();
  55950. this._blurX = null;
  55951. }
  55952. }
  55953. };
  55954. /**
  55955. * Clone the mirror texture.
  55956. * @returns the cloned texture
  55957. */
  55958. MirrorTexture.prototype.clone = function () {
  55959. var scene = this.getScene();
  55960. if (!scene) {
  55961. return this;
  55962. }
  55963. var textureSize = this.getSize();
  55964. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  55965. // Base texture
  55966. newTexture.hasAlpha = this.hasAlpha;
  55967. newTexture.level = this.level;
  55968. // Mirror Texture
  55969. newTexture.mirrorPlane = this.mirrorPlane.clone();
  55970. if (this.renderList) {
  55971. newTexture.renderList = this.renderList.slice(0);
  55972. }
  55973. return newTexture;
  55974. };
  55975. /**
  55976. * Serialize the texture to a JSON representation you could use in Parse later on
  55977. * @returns the serialized JSON representation
  55978. */
  55979. MirrorTexture.prototype.serialize = function () {
  55980. if (!this.name) {
  55981. return null;
  55982. }
  55983. var serializationObject = _super.prototype.serialize.call(this);
  55984. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  55985. return serializationObject;
  55986. };
  55987. /**
  55988. * Dispose the texture and release its associated resources.
  55989. */
  55990. MirrorTexture.prototype.dispose = function () {
  55991. _super.prototype.dispose.call(this);
  55992. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  55993. };
  55994. return MirrorTexture;
  55995. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  55996. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  55997. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  55998. };
  55999. /***/ }),
  56000. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56001. /*!*************************************************!*\
  56002. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56003. \*************************************************/
  56004. /*! exports provided: MultiRenderTarget */
  56005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56006. "use strict";
  56007. __webpack_require__.r(__webpack_exports__);
  56008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  56009. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56010. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56011. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56013. /**
  56014. * A multi render target, like a render target provides the ability to render to a texture.
  56015. * Unlike the render target, it can render to several draw buffers in one draw.
  56016. * This is specially interesting in deferred rendering or for any effects requiring more than
  56017. * just one color from a single pass.
  56018. */
  56019. var MultiRenderTarget = /** @class */ (function (_super) {
  56020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  56021. /**
  56022. * Instantiate a new multi render target texture.
  56023. * A multi render target, like a render target provides the ability to render to a texture.
  56024. * Unlike the render target, it can render to several draw buffers in one draw.
  56025. * This is specially interesting in deferred rendering or for any effects requiring more than
  56026. * just one color from a single pass.
  56027. * @param name Define the name of the texture
  56028. * @param size Define the size of the buffers to render to
  56029. * @param count Define the number of target we are rendering into
  56030. * @param scene Define the scene the texture belongs to
  56031. * @param options Define the options used to create the multi render target
  56032. */
  56033. function MultiRenderTarget(name, size, count, scene, options) {
  56034. var _this = this;
  56035. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  56036. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  56037. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  56038. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  56039. _this._engine = scene.getEngine();
  56040. if (!_this.isSupported) {
  56041. _this.dispose();
  56042. return;
  56043. }
  56044. var types = [];
  56045. var samplingModes = [];
  56046. for (var i = 0; i < count; i++) {
  56047. if (options && options.types && options.types[i] !== undefined) {
  56048. types.push(options.types[i]);
  56049. }
  56050. else {
  56051. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  56052. }
  56053. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  56054. samplingModes.push(options.samplingModes[i]);
  56055. }
  56056. else {
  56057. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  56058. }
  56059. }
  56060. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  56061. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  56062. _this._size = size;
  56063. _this._multiRenderTargetOptions = {
  56064. samplingModes: samplingModes,
  56065. generateMipMaps: generateMipMaps,
  56066. generateDepthBuffer: generateDepthBuffer,
  56067. generateStencilBuffer: generateStencilBuffer,
  56068. generateDepthTexture: generateDepthTexture,
  56069. types: types,
  56070. textureCount: count
  56071. };
  56072. _this._createInternalTextures();
  56073. _this._createTextures();
  56074. return _this;
  56075. }
  56076. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  56077. /**
  56078. * Get if draw buffers are currently supported by the used hardware and browser.
  56079. */
  56080. get: function () {
  56081. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  56082. },
  56083. enumerable: true,
  56084. configurable: true
  56085. });
  56086. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  56087. /**
  56088. * Get the list of textures generated by the multi render target.
  56089. */
  56090. get: function () {
  56091. return this._textures;
  56092. },
  56093. enumerable: true,
  56094. configurable: true
  56095. });
  56096. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  56097. /**
  56098. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  56099. */
  56100. get: function () {
  56101. return this._textures[this._textures.length - 1];
  56102. },
  56103. enumerable: true,
  56104. configurable: true
  56105. });
  56106. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  56107. /**
  56108. * Set the wrapping mode on U of all the textures we are rendering to.
  56109. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56110. */
  56111. set: function (wrap) {
  56112. if (this._textures) {
  56113. for (var i = 0; i < this._textures.length; i++) {
  56114. this._textures[i].wrapU = wrap;
  56115. }
  56116. }
  56117. },
  56118. enumerable: true,
  56119. configurable: true
  56120. });
  56121. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  56122. /**
  56123. * Set the wrapping mode on V of all the textures we are rendering to.
  56124. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56125. */
  56126. set: function (wrap) {
  56127. if (this._textures) {
  56128. for (var i = 0; i < this._textures.length; i++) {
  56129. this._textures[i].wrapV = wrap;
  56130. }
  56131. }
  56132. },
  56133. enumerable: true,
  56134. configurable: true
  56135. });
  56136. /** @hidden */
  56137. MultiRenderTarget.prototype._rebuild = function () {
  56138. this.releaseInternalTextures();
  56139. this._createInternalTextures();
  56140. for (var i = 0; i < this._internalTextures.length; i++) {
  56141. var texture = this._textures[i];
  56142. texture._texture = this._internalTextures[i];
  56143. }
  56144. // Keeps references to frame buffer and stencil/depth buffer
  56145. this._texture = this._internalTextures[0];
  56146. };
  56147. MultiRenderTarget.prototype._createInternalTextures = function () {
  56148. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  56149. };
  56150. MultiRenderTarget.prototype._createTextures = function () {
  56151. this._textures = [];
  56152. for (var i = 0; i < this._internalTextures.length; i++) {
  56153. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  56154. texture._texture = this._internalTextures[i];
  56155. this._textures.push(texture);
  56156. }
  56157. // Keeps references to frame buffer and stencil/depth buffer
  56158. this._texture = this._internalTextures[0];
  56159. };
  56160. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  56161. /**
  56162. * Define the number of samples used if MSAA is enabled.
  56163. */
  56164. get: function () {
  56165. return this._samples;
  56166. },
  56167. set: function (value) {
  56168. if (this._samples === value) {
  56169. return;
  56170. }
  56171. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  56172. },
  56173. enumerable: true,
  56174. configurable: true
  56175. });
  56176. /**
  56177. * Resize all the textures in the multi render target.
  56178. * Be carrefull as it will recreate all the data in the new texture.
  56179. * @param size Define the new size
  56180. */
  56181. MultiRenderTarget.prototype.resize = function (size) {
  56182. this.releaseInternalTextures();
  56183. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  56184. this._createInternalTextures();
  56185. };
  56186. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  56187. var _this = this;
  56188. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  56189. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  56190. });
  56191. };
  56192. /**
  56193. * Dispose the render targets and their associated resources
  56194. */
  56195. MultiRenderTarget.prototype.dispose = function () {
  56196. this.releaseInternalTextures();
  56197. _super.prototype.dispose.call(this);
  56198. };
  56199. /**
  56200. * Release all the underlying texture used as draw buffers.
  56201. */
  56202. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  56203. if (!this._internalTextures) {
  56204. return;
  56205. }
  56206. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  56207. if (this._internalTextures[i] !== undefined) {
  56208. this._internalTextures[i].dispose();
  56209. this._internalTextures.splice(i, 1);
  56210. }
  56211. }
  56212. };
  56213. return MultiRenderTarget;
  56214. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56215. /***/ }),
  56216. /***/ "./Materials/Textures/rawCubeTexture.ts":
  56217. /*!**********************************************!*\
  56218. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  56219. \**********************************************/
  56220. /*! exports provided: RawCubeTexture */
  56221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56222. "use strict";
  56223. __webpack_require__.r(__webpack_exports__);
  56224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  56225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56226. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56227. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56228. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56229. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56230. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56231. /**
  56232. * Raw cube texture where the raw buffers are passed in
  56233. */
  56234. var RawCubeTexture = /** @class */ (function (_super) {
  56235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  56236. /**
  56237. * Creates a cube texture where the raw buffers are passed in.
  56238. * @param scene defines the scene the texture is attached to
  56239. * @param data defines the array of data to use to create each face
  56240. * @param size defines the size of the textures
  56241. * @param format defines the format of the data
  56242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56243. * @param generateMipMaps defines if the engine should generate the mip levels
  56244. * @param invertY defines if data must be stored with Y axis inverted
  56245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56246. * @param compression defines the compression used (null by default)
  56247. */
  56248. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  56249. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  56250. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56251. if (generateMipMaps === void 0) { generateMipMaps = false; }
  56252. if (invertY === void 0) { invertY = false; }
  56253. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56254. if (compression === void 0) { compression = null; }
  56255. var _this = _super.call(this, "", scene) || this;
  56256. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  56257. return _this;
  56258. }
  56259. /**
  56260. * Updates the raw cube texture.
  56261. * @param data defines the data to store
  56262. * @param format defines the data format
  56263. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56264. * @param invertY defines if data must be stored with Y axis inverted
  56265. * @param compression defines the compression used (null by default)
  56266. * @param level defines which level of the texture to update
  56267. */
  56268. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  56269. if (compression === void 0) { compression = null; }
  56270. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  56271. };
  56272. /**
  56273. * Updates a raw cube texture with RGBD encoded data.
  56274. * @param data defines the array of data [mipmap][face] to use to create each face
  56275. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56276. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56277. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56278. * @returns a promsie that resolves when the operation is complete
  56279. */
  56280. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  56281. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  56282. if (lodScale === void 0) { lodScale = 0.8; }
  56283. if (lodOffset === void 0) { lodOffset = 0; }
  56284. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  56285. };
  56286. /**
  56287. * Clones the raw cube texture.
  56288. * @return a new cube texture
  56289. */
  56290. RawCubeTexture.prototype.clone = function () {
  56291. var _this = this;
  56292. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  56293. var scene = _this.getScene();
  56294. var internalTexture = _this._texture;
  56295. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  56296. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  56297. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  56298. }
  56299. return texture;
  56300. }, this);
  56301. };
  56302. /** @hidden */
  56303. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56304. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  56305. internalTexture._bufferViewArrayArray = data;
  56306. internalTexture._lodGenerationScale = lodScale;
  56307. internalTexture._lodGenerationOffset = lodOffset;
  56308. internalTexture._sphericalPolynomial = sphericalPolynomial;
  56309. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  56310. internalTexture.isReady = true;
  56311. });
  56312. };
  56313. return RawCubeTexture;
  56314. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  56315. /***/ }),
  56316. /***/ "./Materials/Textures/rawTexture.ts":
  56317. /*!******************************************!*\
  56318. !*** ./Materials/Textures/rawTexture.ts ***!
  56319. \******************************************/
  56320. /*! exports provided: RawTexture */
  56321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56322. "use strict";
  56323. __webpack_require__.r(__webpack_exports__);
  56324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  56325. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56326. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56327. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56328. /**
  56329. * Raw texture can help creating a texture directly from an array of data.
  56330. * This can be super useful if you either get the data from an uncompressed source or
  56331. * if you wish to create your texture pixel by pixel.
  56332. */
  56333. var RawTexture = /** @class */ (function (_super) {
  56334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  56335. /**
  56336. * Instantiates a new RawTexture.
  56337. * Raw texture can help creating a texture directly from an array of data.
  56338. * This can be super useful if you either get the data from an uncompressed source or
  56339. * if you wish to create your texture pixel by pixel.
  56340. * @param data define the array of data to use to create the texture
  56341. * @param width define the width of the texture
  56342. * @param height define the height of the texture
  56343. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56344. * @param scene define the scene the texture belongs to
  56345. * @param generateMipMaps define whether mip maps should be generated or not
  56346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56348. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56349. */
  56350. function RawTexture(data, width, height,
  56351. /**
  56352. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56353. */
  56354. format, scene, generateMipMaps, invertY, samplingMode, type) {
  56355. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56356. if (invertY === void 0) { invertY = false; }
  56357. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56358. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56359. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56360. _this.format = format;
  56361. _this._engine = scene.getEngine();
  56362. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  56363. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56364. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56365. return _this;
  56366. }
  56367. /**
  56368. * Updates the texture underlying data.
  56369. * @param data Define the new data of the texture
  56370. */
  56371. RawTexture.prototype.update = function (data) {
  56372. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56373. };
  56374. /**
  56375. * Creates a luminance texture from some data.
  56376. * @param data Define the texture data
  56377. * @param width Define the width of the texture
  56378. * @param height Define the height of the texture
  56379. * @param scene Define the scene the texture belongs to
  56380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56383. * @returns the luminance texture
  56384. */
  56385. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56386. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56387. if (invertY === void 0) { invertY = false; }
  56388. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56389. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  56390. };
  56391. /**
  56392. * Creates a luminance alpha texture from some data.
  56393. * @param data Define the texture data
  56394. * @param width Define the width of the texture
  56395. * @param height Define the height of the texture
  56396. * @param scene Define the scene the texture belongs to
  56397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56400. * @returns the luminance alpha texture
  56401. */
  56402. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56403. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56404. if (invertY === void 0) { invertY = false; }
  56405. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56406. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56407. };
  56408. /**
  56409. * Creates an alpha texture from some data.
  56410. * @param data Define the texture data
  56411. * @param width Define the width of the texture
  56412. * @param height Define the height of the texture
  56413. * @param scene Define the scene the texture belongs to
  56414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56417. * @returns the alpha texture
  56418. */
  56419. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56420. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56421. if (invertY === void 0) { invertY = false; }
  56422. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56423. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56424. };
  56425. /**
  56426. * Creates a RGB texture from some data.
  56427. * @param data Define the texture data
  56428. * @param width Define the width of the texture
  56429. * @param height Define the height of the texture
  56430. * @param scene Define the scene the texture belongs to
  56431. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56432. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56433. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56434. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56435. * @returns the RGB alpha texture
  56436. */
  56437. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56438. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56439. if (invertY === void 0) { invertY = false; }
  56440. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56441. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56442. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  56443. };
  56444. /**
  56445. * Creates a RGBA texture from some data.
  56446. * @param data Define the texture data
  56447. * @param width Define the width of the texture
  56448. * @param height Define the height of the texture
  56449. * @param scene Define the scene the texture belongs to
  56450. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56451. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56452. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56453. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56454. * @returns the RGBA texture
  56455. */
  56456. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56457. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56458. if (invertY === void 0) { invertY = false; }
  56459. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56460. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56461. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  56462. };
  56463. /**
  56464. * Creates a R texture from some data.
  56465. * @param data Define the texture data
  56466. * @param width Define the width of the texture
  56467. * @param height Define the height of the texture
  56468. * @param scene Define the scene the texture belongs to
  56469. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56470. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56471. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56472. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56473. * @returns the R texture
  56474. */
  56475. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56476. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56477. if (invertY === void 0) { invertY = false; }
  56478. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56479. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  56480. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  56481. };
  56482. return RawTexture;
  56483. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56484. /***/ }),
  56485. /***/ "./Materials/Textures/rawTexture3D.ts":
  56486. /*!********************************************!*\
  56487. !*** ./Materials/Textures/rawTexture3D.ts ***!
  56488. \********************************************/
  56489. /*! exports provided: RawTexture3D */
  56490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56491. "use strict";
  56492. __webpack_require__.r(__webpack_exports__);
  56493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  56494. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56495. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56496. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56497. /**
  56498. * Class used to store 3D textures containing user data
  56499. */
  56500. var RawTexture3D = /** @class */ (function (_super) {
  56501. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  56502. /**
  56503. * Create a new RawTexture3D
  56504. * @param data defines the data of the texture
  56505. * @param width defines the width of the texture
  56506. * @param height defines the height of the texture
  56507. * @param depth defines the depth of the texture
  56508. * @param format defines the texture format to use
  56509. * @param scene defines the hosting scene
  56510. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56511. * @param invertY defines if texture must be stored with Y axis inverted
  56512. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56513. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56514. */
  56515. function RawTexture3D(data, width, height, depth,
  56516. /** Gets or sets the texture format to use */
  56517. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  56518. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56519. if (invertY === void 0) { invertY = false; }
  56520. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56521. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56522. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56523. _this.format = format;
  56524. _this._engine = scene.getEngine();
  56525. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  56526. _this.is3D = true;
  56527. return _this;
  56528. }
  56529. /**
  56530. * Update the texture with new data
  56531. * @param data defines the data to store in the texture
  56532. */
  56533. RawTexture3D.prototype.update = function (data) {
  56534. if (!this._texture) {
  56535. return;
  56536. }
  56537. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56538. };
  56539. return RawTexture3D;
  56540. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56541. /***/ }),
  56542. /***/ "./Materials/Textures/refractionTexture.ts":
  56543. /*!*************************************************!*\
  56544. !*** ./Materials/Textures/refractionTexture.ts ***!
  56545. \*************************************************/
  56546. /*! exports provided: RefractionTexture */
  56547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56548. "use strict";
  56549. __webpack_require__.r(__webpack_exports__);
  56550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  56551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56552. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56553. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56554. /**
  56555. * Creates a refraction texture used by refraction channel of the standard material.
  56556. * It is like a mirror but to see through a material.
  56557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56558. */
  56559. var RefractionTexture = /** @class */ (function (_super) {
  56560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  56561. /**
  56562. * Creates a refraction texture used by refraction channel of the standard material.
  56563. * It is like a mirror but to see through a material.
  56564. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56565. * @param name Define the texture name
  56566. * @param size Define the size of the underlying texture
  56567. * @param scene Define the scene the refraction belongs to
  56568. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56569. */
  56570. function RefractionTexture(name, size, scene, generateMipMaps) {
  56571. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  56572. /**
  56573. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56574. * 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.
  56575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56576. */
  56577. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56578. /**
  56579. * Define how deep under the surface we should see.
  56580. */
  56581. _this.depth = 2.0;
  56582. _this.onBeforeRenderObservable.add(function () {
  56583. scene.clipPlane = _this.refractionPlane;
  56584. });
  56585. _this.onAfterRenderObservable.add(function () {
  56586. delete scene.clipPlane;
  56587. });
  56588. return _this;
  56589. }
  56590. /**
  56591. * Clone the refraction texture.
  56592. * @returns the cloned texture
  56593. */
  56594. RefractionTexture.prototype.clone = function () {
  56595. var scene = this.getScene();
  56596. if (!scene) {
  56597. return this;
  56598. }
  56599. var textureSize = this.getSize();
  56600. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  56601. // Base texture
  56602. newTexture.hasAlpha = this.hasAlpha;
  56603. newTexture.level = this.level;
  56604. // Refraction Texture
  56605. newTexture.refractionPlane = this.refractionPlane.clone();
  56606. if (this.renderList) {
  56607. newTexture.renderList = this.renderList.slice(0);
  56608. }
  56609. newTexture.depth = this.depth;
  56610. return newTexture;
  56611. };
  56612. /**
  56613. * Serialize the texture to a JSON representation you could use in Parse later on
  56614. * @returns the serialized JSON representation
  56615. */
  56616. RefractionTexture.prototype.serialize = function () {
  56617. if (!this.name) {
  56618. return null;
  56619. }
  56620. var serializationObject = _super.prototype.serialize.call(this);
  56621. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  56622. serializationObject.depth = this.depth;
  56623. return serializationObject;
  56624. };
  56625. return RefractionTexture;
  56626. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56627. /***/ }),
  56628. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  56629. /*!***********************************************************!*\
  56630. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  56631. \***********************************************************/
  56632. /*! exports provided: RenderTargetCreationOptions */
  56633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56634. "use strict";
  56635. __webpack_require__.r(__webpack_exports__);
  56636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  56637. /**
  56638. * Define options used to create a render target texture
  56639. */
  56640. var RenderTargetCreationOptions = /** @class */ (function () {
  56641. function RenderTargetCreationOptions() {
  56642. }
  56643. return RenderTargetCreationOptions;
  56644. }());
  56645. /***/ }),
  56646. /***/ "./Materials/Textures/renderTargetTexture.ts":
  56647. /*!***************************************************!*\
  56648. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  56649. \***************************************************/
  56650. /*! exports provided: RenderTargetTexture */
  56651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56652. "use strict";
  56653. __webpack_require__.r(__webpack_exports__);
  56654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  56655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56656. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56657. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56659. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56660. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  56661. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  56662. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56663. /**
  56664. * This Helps creating a texture that will be created from a camera in your scene.
  56665. * It is basically a dynamic texture that could be used to create special effects for instance.
  56666. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  56667. */
  56668. var RenderTargetTexture = /** @class */ (function (_super) {
  56669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  56670. /**
  56671. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  56672. * or used a shadow, depth texture...
  56673. * @param name The friendly name of the texture
  56674. * @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)
  56675. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  56676. * @param generateMipMaps True if mip maps need to be generated after render.
  56677. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  56678. * @param type The type of the buffer in the RTT (int, half float, float...)
  56679. * @param isCube True if a cube texture needs to be created
  56680. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  56681. * @param generateDepthBuffer True to generate a depth buffer
  56682. * @param generateStencilBuffer True to generate a stencil buffer
  56683. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  56684. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  56685. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56686. */
  56687. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  56688. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  56689. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56690. if (isCube === void 0) { isCube = false; }
  56691. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56692. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56693. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  56694. if (isMulti === void 0) { isMulti = false; }
  56695. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  56696. if (delayAllocation === void 0) { delayAllocation = false; }
  56697. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56698. _this.isCube = isCube;
  56699. /**
  56700. * Define if particles should be rendered in your texture.
  56701. */
  56702. _this.renderParticles = true;
  56703. /**
  56704. * Define if sprites should be rendered in your texture.
  56705. */
  56706. _this.renderSprites = false;
  56707. /**
  56708. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  56709. */
  56710. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  56711. /**
  56712. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  56713. */
  56714. _this.ignoreCameraViewport = false;
  56715. /**
  56716. * An event triggered when the texture is unbind.
  56717. */
  56718. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56719. /**
  56720. * An event triggered when the texture is unbind.
  56721. */
  56722. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56723. /**
  56724. * An event triggered before rendering the texture
  56725. */
  56726. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56727. /**
  56728. * An event triggered after rendering the texture
  56729. */
  56730. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56731. /**
  56732. * An event triggered after the texture clear
  56733. */
  56734. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56735. _this._currentRefreshId = -1;
  56736. _this._refreshRate = 1;
  56737. _this._samples = 1;
  56738. /**
  56739. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  56740. * It must define where the camera used to render the texture is set
  56741. */
  56742. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  56743. scene = _this.getScene();
  56744. if (!scene) {
  56745. return _this;
  56746. }
  56747. _this.renderList = new Array();
  56748. _this._engine = scene.getEngine();
  56749. _this.name = name;
  56750. _this.isRenderTarget = true;
  56751. _this._initialSizeParameter = size;
  56752. _this._processSizeParameter(size);
  56753. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  56754. });
  56755. _this._generateMipMaps = generateMipMaps ? true : false;
  56756. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  56757. // Rendering groups
  56758. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  56759. _this._renderingManager._useSceneAutoClearSetup = true;
  56760. if (isMulti) {
  56761. return _this;
  56762. }
  56763. _this._renderTargetOptions = {
  56764. generateMipMaps: generateMipMaps,
  56765. type: type,
  56766. format: format,
  56767. samplingMode: samplingMode,
  56768. generateDepthBuffer: generateDepthBuffer,
  56769. generateStencilBuffer: generateStencilBuffer
  56770. };
  56771. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  56772. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  56773. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  56774. }
  56775. if (!delayAllocation) {
  56776. if (isCube) {
  56777. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  56778. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  56779. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  56780. }
  56781. else {
  56782. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  56783. }
  56784. }
  56785. return _this;
  56786. }
  56787. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  56788. /**
  56789. * Use this list to define the list of mesh you want to render.
  56790. */
  56791. get: function () {
  56792. return this._renderList;
  56793. },
  56794. set: function (value) {
  56795. this._renderList = value;
  56796. if (this._renderList) {
  56797. this._hookArray(this._renderList);
  56798. }
  56799. },
  56800. enumerable: true,
  56801. configurable: true
  56802. });
  56803. RenderTargetTexture.prototype._hookArray = function (array) {
  56804. var _this = this;
  56805. var oldPush = array.push;
  56806. array.push = function () {
  56807. var items = [];
  56808. for (var _i = 0; _i < arguments.length; _i++) {
  56809. items[_i] = arguments[_i];
  56810. }
  56811. var wasEmpty = array.length === 0;
  56812. var result = oldPush.apply(array, items);
  56813. if (wasEmpty) {
  56814. _this.getScene().meshes.forEach(function (mesh) {
  56815. mesh._markSubMeshesAsLightDirty();
  56816. });
  56817. }
  56818. return result;
  56819. };
  56820. var oldSplice = array.splice;
  56821. array.splice = function (index, deleteCount) {
  56822. var deleted = oldSplice.apply(array, [index, deleteCount]);
  56823. if (array.length === 0) {
  56824. _this.getScene().meshes.forEach(function (mesh) {
  56825. mesh._markSubMeshesAsLightDirty();
  56826. });
  56827. }
  56828. return deleted;
  56829. };
  56830. };
  56831. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  56832. /**
  56833. * Set a after unbind callback in the texture.
  56834. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  56835. */
  56836. set: function (callback) {
  56837. if (this._onAfterUnbindObserver) {
  56838. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  56839. }
  56840. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  56841. },
  56842. enumerable: true,
  56843. configurable: true
  56844. });
  56845. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  56846. /**
  56847. * Set a before render callback in the texture.
  56848. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  56849. */
  56850. set: function (callback) {
  56851. if (this._onBeforeRenderObserver) {
  56852. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  56853. }
  56854. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  56855. },
  56856. enumerable: true,
  56857. configurable: true
  56858. });
  56859. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  56860. /**
  56861. * Set a after render callback in the texture.
  56862. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  56863. */
  56864. set: function (callback) {
  56865. if (this._onAfterRenderObserver) {
  56866. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  56867. }
  56868. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  56869. },
  56870. enumerable: true,
  56871. configurable: true
  56872. });
  56873. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  56874. /**
  56875. * Set a clear callback in the texture.
  56876. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  56877. */
  56878. set: function (callback) {
  56879. if (this._onClearObserver) {
  56880. this.onClearObservable.remove(this._onClearObserver);
  56881. }
  56882. this._onClearObserver = this.onClearObservable.add(callback);
  56883. },
  56884. enumerable: true,
  56885. configurable: true
  56886. });
  56887. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  56888. /**
  56889. * Gets render target creation options that were used.
  56890. */
  56891. get: function () {
  56892. return this._renderTargetOptions;
  56893. },
  56894. enumerable: true,
  56895. configurable: true
  56896. });
  56897. RenderTargetTexture.prototype._onRatioRescale = function () {
  56898. if (this._sizeRatio) {
  56899. this.resize(this._initialSizeParameter);
  56900. }
  56901. };
  56902. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  56903. get: function () {
  56904. return this._boundingBoxSize;
  56905. },
  56906. /**
  56907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  56908. * When defined, the cubemap will switch to local mode
  56909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56910. * @example https://www.babylonjs-playground.com/#RNASML
  56911. */
  56912. set: function (value) {
  56913. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56914. return;
  56915. }
  56916. this._boundingBoxSize = value;
  56917. var scene = this.getScene();
  56918. if (scene) {
  56919. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  56920. }
  56921. },
  56922. enumerable: true,
  56923. configurable: true
  56924. });
  56925. /**
  56926. * Creates a depth stencil texture.
  56927. * This is only available in WebGL 2 or with the depth texture extension available.
  56928. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  56929. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  56930. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  56931. */
  56932. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  56933. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  56934. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  56935. if (generateStencil === void 0) { generateStencil = false; }
  56936. if (!this.getScene()) {
  56937. return;
  56938. }
  56939. var engine = this.getScene().getEngine();
  56940. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  56941. bilinearFiltering: bilinearFiltering,
  56942. comparisonFunction: comparisonFunction,
  56943. generateStencil: generateStencil,
  56944. isCube: this.isCube
  56945. });
  56946. engine.setFrameBufferDepthStencilTexture(this);
  56947. };
  56948. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  56949. if (size.ratio) {
  56950. this._sizeRatio = size.ratio;
  56951. this._size = {
  56952. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  56953. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  56954. };
  56955. }
  56956. else {
  56957. this._size = size;
  56958. }
  56959. };
  56960. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  56961. /**
  56962. * Define the number of samples to use in case of MSAA.
  56963. * It defaults to one meaning no MSAA has been enabled.
  56964. */
  56965. get: function () {
  56966. return this._samples;
  56967. },
  56968. set: function (value) {
  56969. if (this._samples === value) {
  56970. return;
  56971. }
  56972. var scene = this.getScene();
  56973. if (!scene) {
  56974. return;
  56975. }
  56976. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  56977. },
  56978. enumerable: true,
  56979. configurable: true
  56980. });
  56981. /**
  56982. * Resets the refresh counter of the texture and start bak from scratch.
  56983. * Could be useful to regenerate the texture if it is setup to render only once.
  56984. */
  56985. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  56986. this._currentRefreshId = -1;
  56987. };
  56988. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  56989. /**
  56990. * Define the refresh rate of the texture or the rendering frequency.
  56991. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  56992. */
  56993. get: function () {
  56994. return this._refreshRate;
  56995. },
  56996. set: function (value) {
  56997. this._refreshRate = value;
  56998. this.resetRefreshCounter();
  56999. },
  57000. enumerable: true,
  57001. configurable: true
  57002. });
  57003. /**
  57004. * Adds a post process to the render target rendering passes.
  57005. * @param postProcess define the post process to add
  57006. */
  57007. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  57008. if (!this._postProcessManager) {
  57009. var scene = this.getScene();
  57010. if (!scene) {
  57011. return;
  57012. }
  57013. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  57014. this._postProcesses = new Array();
  57015. }
  57016. this._postProcesses.push(postProcess);
  57017. this._postProcesses[0].autoClear = false;
  57018. };
  57019. /**
  57020. * Clear all the post processes attached to the render target
  57021. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  57022. */
  57023. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  57024. if (dispose === void 0) { dispose = false; }
  57025. if (!this._postProcesses) {
  57026. return;
  57027. }
  57028. if (dispose) {
  57029. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  57030. var postProcess = _a[_i];
  57031. postProcess.dispose();
  57032. }
  57033. }
  57034. this._postProcesses = [];
  57035. };
  57036. /**
  57037. * Remove one of the post process from the list of attached post processes to the texture
  57038. * @param postProcess define the post process to remove from the list
  57039. */
  57040. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  57041. if (!this._postProcesses) {
  57042. return;
  57043. }
  57044. var index = this._postProcesses.indexOf(postProcess);
  57045. if (index === -1) {
  57046. return;
  57047. }
  57048. this._postProcesses.splice(index, 1);
  57049. if (this._postProcesses.length > 0) {
  57050. this._postProcesses[0].autoClear = false;
  57051. }
  57052. };
  57053. /** @hidden */
  57054. RenderTargetTexture.prototype._shouldRender = function () {
  57055. if (this._currentRefreshId === -1) { // At least render once
  57056. this._currentRefreshId = 1;
  57057. return true;
  57058. }
  57059. if (this.refreshRate === this._currentRefreshId) {
  57060. this._currentRefreshId = 1;
  57061. return true;
  57062. }
  57063. this._currentRefreshId++;
  57064. return false;
  57065. };
  57066. /**
  57067. * Gets the actual render size of the texture.
  57068. * @returns the width of the render size
  57069. */
  57070. RenderTargetTexture.prototype.getRenderSize = function () {
  57071. return this.getRenderWidth();
  57072. };
  57073. /**
  57074. * Gets the actual render width of the texture.
  57075. * @returns the width of the render size
  57076. */
  57077. RenderTargetTexture.prototype.getRenderWidth = function () {
  57078. if (this._size.width) {
  57079. return this._size.width;
  57080. }
  57081. return this._size;
  57082. };
  57083. /**
  57084. * Gets the actual render height of the texture.
  57085. * @returns the height of the render size
  57086. */
  57087. RenderTargetTexture.prototype.getRenderHeight = function () {
  57088. if (this._size.width) {
  57089. return this._size.height;
  57090. }
  57091. return this._size;
  57092. };
  57093. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  57094. /**
  57095. * Get if the texture can be rescaled or not.
  57096. */
  57097. get: function () {
  57098. return true;
  57099. },
  57100. enumerable: true,
  57101. configurable: true
  57102. });
  57103. /**
  57104. * Resize the texture using a ratio.
  57105. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  57106. */
  57107. RenderTargetTexture.prototype.scale = function (ratio) {
  57108. var newSize = this.getRenderSize() * ratio;
  57109. this.resize(newSize);
  57110. };
  57111. /**
  57112. * Get the texture reflection matrix used to rotate/transform the reflection.
  57113. * @returns the reflection matrix
  57114. */
  57115. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  57116. if (this.isCube) {
  57117. return this._textureMatrix;
  57118. }
  57119. return _super.prototype.getReflectionTextureMatrix.call(this);
  57120. };
  57121. /**
  57122. * Resize the texture to a new desired size.
  57123. * Be carrefull as it will recreate all the data in the new texture.
  57124. * @param size Define the new size. It can be:
  57125. * - a number for squared texture,
  57126. * - an object containing { width: number, height: number }
  57127. * - or an object containing a ratio { ratio: number }
  57128. */
  57129. RenderTargetTexture.prototype.resize = function (size) {
  57130. this.releaseInternalTexture();
  57131. var scene = this.getScene();
  57132. if (!scene) {
  57133. return;
  57134. }
  57135. this._processSizeParameter(size);
  57136. if (this.isCube) {
  57137. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  57138. }
  57139. else {
  57140. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  57141. }
  57142. };
  57143. /**
  57144. * Renders all the objects from the render list into the texture.
  57145. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  57146. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  57147. */
  57148. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  57149. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  57150. if (dumpForDebug === void 0) { dumpForDebug = false; }
  57151. var scene = this.getScene();
  57152. if (!scene) {
  57153. return;
  57154. }
  57155. var engine = scene.getEngine();
  57156. if (this.useCameraPostProcesses !== undefined) {
  57157. useCameraPostProcess = this.useCameraPostProcesses;
  57158. }
  57159. if (this._waitingRenderList) {
  57160. this.renderList = [];
  57161. for (var index = 0; index < this._waitingRenderList.length; index++) {
  57162. var id = this._waitingRenderList[index];
  57163. var mesh_1 = scene.getMeshByID(id);
  57164. if (mesh_1) {
  57165. this.renderList.push(mesh_1);
  57166. }
  57167. }
  57168. delete this._waitingRenderList;
  57169. }
  57170. // Is predicate defined?
  57171. if (this.renderListPredicate) {
  57172. if (this.renderList) {
  57173. this.renderList.length = 0; // Clear previous renderList
  57174. }
  57175. else {
  57176. this.renderList = [];
  57177. }
  57178. var scene = this.getScene();
  57179. if (!scene) {
  57180. return;
  57181. }
  57182. var sceneMeshes = scene.meshes;
  57183. for (var index = 0; index < sceneMeshes.length; index++) {
  57184. var mesh = sceneMeshes[index];
  57185. if (this.renderListPredicate(mesh)) {
  57186. this.renderList.push(mesh);
  57187. }
  57188. }
  57189. }
  57190. this.onBeforeBindObservable.notifyObservers(this);
  57191. // Set custom projection.
  57192. // Needs to be before binding to prevent changing the aspect ratio.
  57193. var camera;
  57194. if (this.activeCamera) {
  57195. camera = this.activeCamera;
  57196. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57197. if (this.activeCamera !== scene.activeCamera) {
  57198. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  57199. }
  57200. }
  57201. else {
  57202. camera = scene.activeCamera;
  57203. if (camera) {
  57204. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57205. }
  57206. }
  57207. // Prepare renderingManager
  57208. this._renderingManager.reset();
  57209. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  57210. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  57211. var sceneRenderId = scene.getRenderId();
  57212. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  57213. var mesh = currentRenderList[meshIndex];
  57214. if (mesh) {
  57215. if (!mesh.isReady(this.refreshRate === 0)) {
  57216. this.resetRefreshCounter();
  57217. continue;
  57218. }
  57219. mesh._preActivateForIntermediateRendering(sceneRenderId);
  57220. var isMasked = void 0;
  57221. if (!this.renderList && camera) {
  57222. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  57223. }
  57224. else {
  57225. isMasked = false;
  57226. }
  57227. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  57228. mesh._activate(sceneRenderId);
  57229. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  57230. var subMesh = mesh.subMeshes[subIndex];
  57231. scene._activeIndices.addCount(subMesh.indexCount, false);
  57232. this._renderingManager.dispatch(subMesh, mesh);
  57233. }
  57234. }
  57235. }
  57236. }
  57237. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  57238. var particleSystem = scene.particleSystems[particleIndex];
  57239. var emitter = particleSystem.emitter;
  57240. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  57241. continue;
  57242. }
  57243. if (currentRenderList.indexOf(emitter) >= 0) {
  57244. this._renderingManager.dispatchParticles(particleSystem);
  57245. }
  57246. }
  57247. if (this.isCube) {
  57248. for (var face = 0; face < 6; face++) {
  57249. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  57250. scene.incrementRenderId();
  57251. scene.resetCachedMaterial();
  57252. }
  57253. }
  57254. else {
  57255. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  57256. }
  57257. this.onAfterUnbindObservable.notifyObservers(this);
  57258. if (scene.activeCamera) {
  57259. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  57260. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  57261. }
  57262. engine.setViewport(scene.activeCamera.viewport);
  57263. }
  57264. scene.resetCachedMaterial();
  57265. };
  57266. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  57267. var minimum = 128;
  57268. var x = renderDimension * scale;
  57269. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  57270. // Ensure we don't exceed the render dimension (while staying POT)
  57271. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  57272. };
  57273. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57274. var _this = this;
  57275. if (!this._texture) {
  57276. return;
  57277. }
  57278. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  57279. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57280. });
  57281. };
  57282. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  57283. var scene = this.getScene();
  57284. if (!scene) {
  57285. return;
  57286. }
  57287. var engine = scene.getEngine();
  57288. if (!this._texture) {
  57289. return;
  57290. }
  57291. // Bind
  57292. if (this._postProcessManager) {
  57293. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  57294. }
  57295. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  57296. if (this._texture) {
  57297. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  57298. }
  57299. }
  57300. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  57301. // Clear
  57302. if (this.onClearObservable.hasObservers()) {
  57303. this.onClearObservable.notifyObservers(engine);
  57304. }
  57305. else {
  57306. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  57307. }
  57308. if (!this._doNotChangeAspectRatio) {
  57309. scene.updateTransformMatrix(true);
  57310. }
  57311. // Before Camera Draw
  57312. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  57313. var step = _a[_i];
  57314. step.action(this);
  57315. }
  57316. // Render
  57317. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  57318. // After Camera Draw
  57319. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  57320. var step = _c[_b];
  57321. step.action(this);
  57322. }
  57323. if (this._postProcessManager) {
  57324. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  57325. }
  57326. else if (useCameraPostProcess) {
  57327. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  57328. }
  57329. if (!this._doNotChangeAspectRatio) {
  57330. scene.updateTransformMatrix(true);
  57331. }
  57332. // Dump ?
  57333. if (dumpForDebug) {
  57334. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  57335. }
  57336. // Unbind
  57337. if (!this.isCube || faceIndex === 5) {
  57338. if (this.isCube) {
  57339. if (faceIndex === 5) {
  57340. engine.generateMipMapsForCubemap(this._texture);
  57341. }
  57342. }
  57343. this.unbindFrameBuffer(engine, faceIndex);
  57344. }
  57345. else {
  57346. this.onAfterRenderObservable.notifyObservers(faceIndex);
  57347. }
  57348. };
  57349. /**
  57350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  57351. * This allowed control for front to back rendering or reversly depending of the special needs.
  57352. *
  57353. * @param renderingGroupId The rendering group id corresponding to its index
  57354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  57355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  57356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  57357. */
  57358. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  57359. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  57360. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  57361. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  57362. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  57363. };
  57364. /**
  57365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  57366. *
  57367. * @param renderingGroupId The rendering group id corresponding to its index
  57368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57369. */
  57370. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  57371. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  57372. this._renderingManager._useSceneAutoClearSetup = false;
  57373. };
  57374. /**
  57375. * Clones the texture.
  57376. * @returns the cloned texture
  57377. */
  57378. RenderTargetTexture.prototype.clone = function () {
  57379. var textureSize = this.getSize();
  57380. 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);
  57381. // Base texture
  57382. newTexture.hasAlpha = this.hasAlpha;
  57383. newTexture.level = this.level;
  57384. // RenderTarget Texture
  57385. newTexture.coordinatesMode = this.coordinatesMode;
  57386. if (this.renderList) {
  57387. newTexture.renderList = this.renderList.slice(0);
  57388. }
  57389. return newTexture;
  57390. };
  57391. /**
  57392. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  57393. * @returns The JSON representation of the texture
  57394. */
  57395. RenderTargetTexture.prototype.serialize = function () {
  57396. if (!this.name) {
  57397. return null;
  57398. }
  57399. var serializationObject = _super.prototype.serialize.call(this);
  57400. serializationObject.renderTargetSize = this.getRenderSize();
  57401. serializationObject.renderList = [];
  57402. if (this.renderList) {
  57403. for (var index = 0; index < this.renderList.length; index++) {
  57404. serializationObject.renderList.push(this.renderList[index].id);
  57405. }
  57406. }
  57407. return serializationObject;
  57408. };
  57409. /**
  57410. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  57411. */
  57412. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  57413. var objBuffer = this.getInternalTexture();
  57414. var scene = this.getScene();
  57415. if (objBuffer && scene) {
  57416. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  57417. }
  57418. };
  57419. /**
  57420. * Dispose the texture and release its associated resources.
  57421. */
  57422. RenderTargetTexture.prototype.dispose = function () {
  57423. if (this._postProcessManager) {
  57424. this._postProcessManager.dispose();
  57425. this._postProcessManager = null;
  57426. }
  57427. this.clearPostProcesses(true);
  57428. if (this._resizeObserver) {
  57429. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  57430. this._resizeObserver = null;
  57431. }
  57432. this.renderList = null;
  57433. // Remove from custom render targets
  57434. var scene = this.getScene();
  57435. if (!scene) {
  57436. return;
  57437. }
  57438. var index = scene.customRenderTargets.indexOf(this);
  57439. if (index >= 0) {
  57440. scene.customRenderTargets.splice(index, 1);
  57441. }
  57442. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  57443. var camera = _a[_i];
  57444. index = camera.customRenderTargets.indexOf(this);
  57445. if (index >= 0) {
  57446. camera.customRenderTargets.splice(index, 1);
  57447. }
  57448. }
  57449. _super.prototype.dispose.call(this);
  57450. };
  57451. /** @hidden */
  57452. RenderTargetTexture.prototype._rebuild = function () {
  57453. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  57454. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  57455. }
  57456. if (this._postProcessManager) {
  57457. this._postProcessManager._rebuild();
  57458. }
  57459. };
  57460. /**
  57461. * Clear the info related to rendering groups preventing retention point in material dispose.
  57462. */
  57463. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  57464. if (this._renderingManager) {
  57465. this._renderingManager.freeRenderingGroups();
  57466. }
  57467. };
  57468. /**
  57469. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  57470. */
  57471. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  57472. /**
  57473. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  57474. */
  57475. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  57476. /**
  57477. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  57478. * the central point of your effect and can save a lot of performances.
  57479. */
  57480. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  57481. return RenderTargetTexture;
  57482. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  57483. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  57484. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  57485. };
  57486. /***/ }),
  57487. /***/ "./Materials/Textures/texture.ts":
  57488. /*!***************************************!*\
  57489. !*** ./Materials/Textures/texture.ts ***!
  57490. \***************************************/
  57491. /*! exports provided: Texture */
  57492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57493. "use strict";
  57494. __webpack_require__.r(__webpack_exports__);
  57495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  57496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57497. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57498. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57499. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57501. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57502. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57503. /**
  57504. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57505. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57506. */
  57507. var Texture = /** @class */ (function (_super) {
  57508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  57509. /**
  57510. * Instantiates a new texture.
  57511. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57512. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57513. * @param url define the url of the picture to load as a texture
  57514. * @param scene define the scene the texture will belong to
  57515. * @param noMipmap define if the texture will require mip maps or not
  57516. * @param invertY define if the texture needs to be inverted on the y axis during loading
  57517. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  57518. * @param onLoad define a callback triggered when the texture has been loaded
  57519. * @param onError define a callback triggered when an error occurred during the loading session
  57520. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  57521. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  57522. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  57523. */
  57524. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  57525. if (noMipmap === void 0) { noMipmap = false; }
  57526. if (invertY === void 0) { invertY = true; }
  57527. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  57528. if (onLoad === void 0) { onLoad = null; }
  57529. if (onError === void 0) { onError = null; }
  57530. if (buffer === void 0) { buffer = null; }
  57531. if (deleteBuffer === void 0) { deleteBuffer = false; }
  57532. var _this = _super.call(this, scene) || this;
  57533. /**
  57534. * Define an offset on the texture to offset the u coordinates of the UVs
  57535. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57536. */
  57537. _this.uOffset = 0;
  57538. /**
  57539. * Define an offset on the texture to offset the v coordinates of the UVs
  57540. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57541. */
  57542. _this.vOffset = 0;
  57543. /**
  57544. * Define an offset on the texture to scale the u coordinates of the UVs
  57545. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57546. */
  57547. _this.uScale = 1.0;
  57548. /**
  57549. * Define an offset on the texture to scale the v coordinates of the UVs
  57550. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57551. */
  57552. _this.vScale = 1.0;
  57553. /**
  57554. * Define an offset on the texture to rotate around the u coordinates of the UVs
  57555. * @see http://doc.babylonjs.com/how_to/more_materials
  57556. */
  57557. _this.uAng = 0;
  57558. /**
  57559. * Define an offset on the texture to rotate around the v coordinates of the UVs
  57560. * @see http://doc.babylonjs.com/how_to/more_materials
  57561. */
  57562. _this.vAng = 0;
  57563. /**
  57564. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  57565. * @see http://doc.babylonjs.com/how_to/more_materials
  57566. */
  57567. _this.wAng = 0;
  57568. /**
  57569. * Defines the center of rotation (U)
  57570. */
  57571. _this.uRotationCenter = 0.5;
  57572. /**
  57573. * Defines the center of rotation (V)
  57574. */
  57575. _this.vRotationCenter = 0.5;
  57576. /**
  57577. * Defines the center of rotation (W)
  57578. */
  57579. _this.wRotationCenter = 0.5;
  57580. /** @hidden */
  57581. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  57582. /**
  57583. * Observable triggered once the texture has been loaded.
  57584. */
  57585. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57586. _this._isBlocking = true;
  57587. _this.name = url || "";
  57588. _this.url = url;
  57589. _this._noMipmap = noMipmap;
  57590. _this._invertY = invertY;
  57591. _this._initialSamplingMode = samplingMode;
  57592. _this._buffer = buffer;
  57593. _this._deleteBuffer = deleteBuffer;
  57594. if (format) {
  57595. _this._format = format;
  57596. }
  57597. scene = _this.getScene();
  57598. if (!scene) {
  57599. return _this;
  57600. }
  57601. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  57602. var load = function () {
  57603. if (_this._texture && _this._texture._invertVScale) {
  57604. _this.vScale = -1;
  57605. }
  57606. if (_this.onLoadObservable.hasObservers()) {
  57607. _this.onLoadObservable.notifyObservers(_this);
  57608. }
  57609. if (onLoad) {
  57610. onLoad();
  57611. }
  57612. if (!_this.isBlocking && scene) {
  57613. scene.resetCachedMaterial();
  57614. }
  57615. };
  57616. if (!_this.url) {
  57617. _this._delayedOnLoad = load;
  57618. _this._delayedOnError = onError;
  57619. return _this;
  57620. }
  57621. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  57622. if (!_this._texture) {
  57623. if (!scene.useDelayedTextureLoading) {
  57624. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  57625. if (deleteBuffer) {
  57626. delete _this._buffer;
  57627. }
  57628. }
  57629. else {
  57630. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57631. _this._delayedOnLoad = load;
  57632. _this._delayedOnError = onError;
  57633. }
  57634. }
  57635. else {
  57636. if (_this._texture.isReady) {
  57637. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  57638. }
  57639. else {
  57640. _this._texture.onLoadedObservable.add(load);
  57641. }
  57642. }
  57643. return _this;
  57644. }
  57645. Object.defineProperty(Texture.prototype, "noMipmap", {
  57646. /**
  57647. * Are mip maps generated for this texture or not.
  57648. */
  57649. get: function () {
  57650. return this._noMipmap;
  57651. },
  57652. enumerable: true,
  57653. configurable: true
  57654. });
  57655. Object.defineProperty(Texture.prototype, "isBlocking", {
  57656. get: function () {
  57657. return this._isBlocking;
  57658. },
  57659. /**
  57660. * Is the texture preventing material to render while loading.
  57661. * If false, a default texture will be used instead of the loading one during the preparation step.
  57662. */
  57663. set: function (value) {
  57664. this._isBlocking = value;
  57665. },
  57666. enumerable: true,
  57667. configurable: true
  57668. });
  57669. Object.defineProperty(Texture.prototype, "samplingMode", {
  57670. /**
  57671. * Get the current sampling mode associated with the texture.
  57672. */
  57673. get: function () {
  57674. if (!this._texture) {
  57675. return this._initialSamplingMode;
  57676. }
  57677. return this._texture.samplingMode;
  57678. },
  57679. enumerable: true,
  57680. configurable: true
  57681. });
  57682. Object.defineProperty(Texture.prototype, "invertY", {
  57683. /**
  57684. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  57685. */
  57686. get: function () {
  57687. return this._invertY;
  57688. },
  57689. enumerable: true,
  57690. configurable: true
  57691. });
  57692. /**
  57693. * Update the url (and optional buffer) of this texture if url was null during construction.
  57694. * @param url the url of the texture
  57695. * @param buffer the buffer of the texture (defaults to null)
  57696. * @param onLoad callback called when the texture is loaded (defaults to null)
  57697. */
  57698. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  57699. if (buffer === void 0) { buffer = null; }
  57700. if (this.url) {
  57701. this.releaseInternalTexture();
  57702. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57703. }
  57704. this.url = url;
  57705. this._buffer = buffer;
  57706. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57707. if (onLoad) {
  57708. this._delayedOnLoad = onLoad;
  57709. }
  57710. this.delayLoad();
  57711. };
  57712. /**
  57713. * Finish the loading sequence of a texture flagged as delayed load.
  57714. * @hidden
  57715. */
  57716. Texture.prototype.delayLoad = function () {
  57717. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57718. return;
  57719. }
  57720. var scene = this.getScene();
  57721. if (!scene) {
  57722. return;
  57723. }
  57724. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57725. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  57726. if (!this._texture) {
  57727. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  57728. if (this._deleteBuffer) {
  57729. delete this._buffer;
  57730. }
  57731. }
  57732. else {
  57733. if (this._delayedOnLoad) {
  57734. if (this._texture.isReady) {
  57735. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  57736. }
  57737. else {
  57738. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  57739. }
  57740. }
  57741. }
  57742. this._delayedOnLoad = null;
  57743. this._delayedOnError = null;
  57744. };
  57745. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  57746. x *= this.uScale;
  57747. y *= this.vScale;
  57748. x -= this.uRotationCenter * this.uScale;
  57749. y -= this.vRotationCenter * this.vScale;
  57750. z -= this.wRotationCenter;
  57751. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  57752. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  57753. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  57754. t.z += this.wRotationCenter;
  57755. };
  57756. /**
  57757. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  57758. * @returns the transform matrix of the texture.
  57759. */
  57760. Texture.prototype.getTextureMatrix = function () {
  57761. var _this = this;
  57762. if (this.uOffset === this._cachedUOffset &&
  57763. this.vOffset === this._cachedVOffset &&
  57764. this.uScale === this._cachedUScale &&
  57765. this.vScale === this._cachedVScale &&
  57766. this.uAng === this._cachedUAng &&
  57767. this.vAng === this._cachedVAng &&
  57768. this.wAng === this._cachedWAng) {
  57769. return this._cachedTextureMatrix;
  57770. }
  57771. this._cachedUOffset = this.uOffset;
  57772. this._cachedVOffset = this.vOffset;
  57773. this._cachedUScale = this.uScale;
  57774. this._cachedVScale = this.vScale;
  57775. this._cachedUAng = this.uAng;
  57776. this._cachedVAng = this.vAng;
  57777. this._cachedWAng = this.wAng;
  57778. if (!this._cachedTextureMatrix) {
  57779. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57780. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  57781. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57782. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57783. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57784. }
  57785. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  57786. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  57787. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  57788. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  57789. this._t1.subtractInPlace(this._t0);
  57790. this._t2.subtractInPlace(this._t0);
  57791. _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);
  57792. var scene = this.getScene();
  57793. if (!scene) {
  57794. return this._cachedTextureMatrix;
  57795. }
  57796. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  57797. return mat.hasTexture(_this);
  57798. });
  57799. return this._cachedTextureMatrix;
  57800. };
  57801. /**
  57802. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  57803. * @returns The reflection texture transform
  57804. */
  57805. Texture.prototype.getReflectionTextureMatrix = function () {
  57806. var _this = this;
  57807. var scene = this.getScene();
  57808. if (!scene) {
  57809. return this._cachedTextureMatrix;
  57810. }
  57811. if (this.uOffset === this._cachedUOffset &&
  57812. this.vOffset === this._cachedVOffset &&
  57813. this.uScale === this._cachedUScale &&
  57814. this.vScale === this._cachedVScale &&
  57815. this.coordinatesMode === this._cachedCoordinatesMode) {
  57816. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  57817. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  57818. return this._cachedTextureMatrix;
  57819. }
  57820. }
  57821. else {
  57822. return this._cachedTextureMatrix;
  57823. }
  57824. }
  57825. if (!this._cachedTextureMatrix) {
  57826. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57827. }
  57828. if (!this._projectionModeMatrix) {
  57829. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57830. }
  57831. this._cachedUOffset = this.uOffset;
  57832. this._cachedVOffset = this.vOffset;
  57833. this._cachedUScale = this.uScale;
  57834. this._cachedVScale = this.vScale;
  57835. this._cachedCoordinatesMode = this.coordinatesMode;
  57836. switch (this.coordinatesMode) {
  57837. case Texture.PLANAR_MODE:
  57838. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  57839. this._cachedTextureMatrix[0] = this.uScale;
  57840. this._cachedTextureMatrix[5] = this.vScale;
  57841. this._cachedTextureMatrix[12] = this.uOffset;
  57842. this._cachedTextureMatrix[13] = this.vOffset;
  57843. break;
  57844. case Texture.PROJECTION_MODE:
  57845. _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);
  57846. var projectionMatrix = scene.getProjectionMatrix();
  57847. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  57848. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  57849. break;
  57850. default:
  57851. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  57852. break;
  57853. }
  57854. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  57855. return (mat.getActiveTextures().indexOf(_this) !== -1);
  57856. });
  57857. return this._cachedTextureMatrix;
  57858. };
  57859. /**
  57860. * Clones the texture.
  57861. * @returns the cloned texture
  57862. */
  57863. Texture.prototype.clone = function () {
  57864. var _this = this;
  57865. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57866. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  57867. }, this);
  57868. };
  57869. /**
  57870. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  57871. * @returns The JSON representation of the texture
  57872. */
  57873. Texture.prototype.serialize = function () {
  57874. var serializationObject = _super.prototype.serialize.call(this);
  57875. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  57876. serializationObject.base64String = this._buffer;
  57877. serializationObject.name = serializationObject.name.replace("data:", "");
  57878. }
  57879. serializationObject.invertY = this._invertY;
  57880. serializationObject.samplingMode = this.samplingMode;
  57881. return serializationObject;
  57882. };
  57883. /**
  57884. * Get the current class name of the texture useful for serialization or dynamic coding.
  57885. * @returns "Texture"
  57886. */
  57887. Texture.prototype.getClassName = function () {
  57888. return "Texture";
  57889. };
  57890. /**
  57891. * Dispose the texture and release its associated resources.
  57892. */
  57893. Texture.prototype.dispose = function () {
  57894. _super.prototype.dispose.call(this);
  57895. this.onLoadObservable.clear();
  57896. this._delayedOnLoad = null;
  57897. this._delayedOnError = null;
  57898. };
  57899. /**
  57900. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  57901. * @param parsedTexture Define the JSON representation of the texture
  57902. * @param scene Define the scene the parsed texture should be instantiated in
  57903. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57904. * @returns The parsed texture if successful
  57905. */
  57906. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  57907. if (parsedTexture.customType) {
  57908. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  57909. // Update Sampling Mode
  57910. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  57911. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  57912. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  57913. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  57914. }
  57915. }
  57916. return parsedCustomTexture;
  57917. }
  57918. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  57919. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  57920. }
  57921. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  57922. return null;
  57923. }
  57924. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  57925. var generateMipMaps = true;
  57926. if (parsedTexture.noMipmap) {
  57927. generateMipMaps = false;
  57928. }
  57929. if (parsedTexture.mirrorPlane) {
  57930. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  57931. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  57932. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  57933. return mirrorTexture;
  57934. }
  57935. else if (parsedTexture.isRenderTarget) {
  57936. var renderTargetTexture = null;
  57937. if (parsedTexture.isCube) {
  57938. // Search for an existing reflection probe (which contains a cube render target texture)
  57939. if (scene.reflectionProbes) {
  57940. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  57941. var probe = scene.reflectionProbes[index];
  57942. if (probe.name === parsedTexture.name) {
  57943. return probe.cubeTexture;
  57944. }
  57945. }
  57946. }
  57947. }
  57948. else {
  57949. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  57950. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  57951. }
  57952. return renderTargetTexture;
  57953. }
  57954. else {
  57955. var texture;
  57956. if (parsedTexture.base64String) {
  57957. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  57958. }
  57959. else {
  57960. var url = rootUrl + parsedTexture.name;
  57961. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  57962. url = parsedTexture.url;
  57963. }
  57964. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  57965. }
  57966. return texture;
  57967. }
  57968. }, parsedTexture, scene);
  57969. // Update Sampling Mode
  57970. if (parsedTexture.samplingMode) {
  57971. var sampling = parsedTexture.samplingMode;
  57972. if (texture && texture.samplingMode !== sampling) {
  57973. texture.updateSamplingMode(sampling);
  57974. }
  57975. }
  57976. // Animations
  57977. if (texture && parsedTexture.animations) {
  57978. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  57979. var parsedAnimation = parsedTexture.animations[animationIndex];
  57980. texture.animations.push(Texture._AnimationParser(parsedAnimation));
  57981. }
  57982. }
  57983. return texture;
  57984. };
  57985. /**
  57986. * Creates a texture from its base 64 representation.
  57987. * @param data Define the base64 payload without the data: prefix
  57988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  57989. * @param scene Define the scene the texture should belong to
  57990. * @param noMipmap Forces the texture to not create mip map information if true
  57991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  57992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  57993. * @param onLoad define a callback triggered when the texture has been loaded
  57994. * @param onError define a callback triggered when an error occurred during the loading session
  57995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  57996. * @returns the created texture
  57997. */
  57998. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  57999. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58000. if (onLoad === void 0) { onLoad = null; }
  58001. if (onError === void 0) { onError = null; }
  58002. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58003. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  58004. };
  58005. /**
  58006. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  58007. * @param data Define the base64 payload without the data: prefix
  58008. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58009. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58010. * @param scene Define the scene the texture should belong to
  58011. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58012. * @param noMipmap Forces the texture to not create mip map information if true
  58013. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58014. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58015. * @param onLoad define a callback triggered when the texture has been loaded
  58016. * @param onError define a callback triggered when an error occurred during the loading session
  58017. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58018. * @returns the created texture
  58019. */
  58020. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58021. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58022. if (noMipmap === void 0) { noMipmap = false; }
  58023. if (invertY === void 0) { invertY = true; }
  58024. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58025. if (onLoad === void 0) { onLoad = null; }
  58026. if (onError === void 0) { onError = null; }
  58027. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58028. if (name.substr(0, 5) !== "data:") {
  58029. name = "data:" + name;
  58030. }
  58031. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  58032. };
  58033. /** @hidden */
  58034. Texture._AnimationParser = function (jsonAnimation) {
  58035. throw "Animation needs to be imported before being deserialized.";
  58036. };
  58037. /** @hidden */
  58038. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  58039. throw "CubeTexture needs to be imported before being deserialized.";
  58040. };
  58041. /** @hidden */
  58042. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58043. throw "MirrorTexture needs to be imported before being deserialized.";
  58044. };
  58045. /** @hidden */
  58046. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58047. throw "RenderTargetTexture needs to be imported before being deserialized.";
  58048. };
  58049. /** nearest is mag = nearest and min = nearest and mip = linear */
  58050. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  58051. /** nearest is mag = nearest and min = nearest and mip = linear */
  58052. 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
  58053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58054. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  58055. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58056. 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
  58057. /** Trilinear is mag = linear and min = linear and mip = linear */
  58058. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  58059. /** Trilinear is mag = linear and min = linear and mip = linear */
  58060. 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
  58061. /** mag = nearest and min = nearest and mip = nearest */
  58062. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  58063. /** mag = nearest and min = linear and mip = nearest */
  58064. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  58065. /** mag = nearest and min = linear and mip = linear */
  58066. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  58067. /** mag = nearest and min = linear and mip = none */
  58068. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  58069. /** mag = nearest and min = nearest and mip = none */
  58070. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  58071. /** mag = linear and min = nearest and mip = nearest */
  58072. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  58073. /** mag = linear and min = nearest and mip = linear */
  58074. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  58075. /** mag = linear and min = linear and mip = none */
  58076. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  58077. /** mag = linear and min = nearest and mip = none */
  58078. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  58079. /** Explicit coordinates mode */
  58080. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  58081. /** Spherical coordinates mode */
  58082. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  58083. /** Planar coordinates mode */
  58084. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  58085. /** Cubic coordinates mode */
  58086. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  58087. /** Projection coordinates mode */
  58088. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  58089. /** Inverse Cubic coordinates mode */
  58090. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  58091. /** Inverse Cubic coordinates mode */
  58092. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  58093. /** Equirectangular coordinates mode */
  58094. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  58095. /** Equirectangular Fixed coordinates mode */
  58096. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  58097. /** Equirectangular Fixed Mirrored coordinates mode */
  58098. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  58099. /** Texture is not repeating outside of 0..1 UVs */
  58100. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58101. /** Texture is repeating outside of 0..1 UVs */
  58102. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58103. /** Texture is repeating and mirrored */
  58104. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  58105. /**
  58106. * 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
  58107. */
  58108. Texture.UseSerializedUrlIfAny = false;
  58109. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58111. ], Texture.prototype, "url", void 0);
  58112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58114. ], Texture.prototype, "uOffset", void 0);
  58115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58117. ], Texture.prototype, "vOffset", void 0);
  58118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58120. ], Texture.prototype, "uScale", void 0);
  58121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58123. ], Texture.prototype, "vScale", void 0);
  58124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58126. ], Texture.prototype, "uAng", void 0);
  58127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58129. ], Texture.prototype, "vAng", void 0);
  58130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58132. ], Texture.prototype, "wAng", void 0);
  58133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58135. ], Texture.prototype, "uRotationCenter", void 0);
  58136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58138. ], Texture.prototype, "vRotationCenter", void 0);
  58139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58141. ], Texture.prototype, "wRotationCenter", void 0);
  58142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58144. ], Texture.prototype, "isBlocking", null);
  58145. return Texture;
  58146. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  58147. // References the dependencies.
  58148. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  58149. /***/ }),
  58150. /***/ "./Materials/Textures/videoTexture.ts":
  58151. /*!********************************************!*\
  58152. !*** ./Materials/Textures/videoTexture.ts ***!
  58153. \********************************************/
  58154. /*! exports provided: VideoTexture */
  58155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58156. "use strict";
  58157. __webpack_require__.r(__webpack_exports__);
  58158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  58159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58160. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58161. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58162. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58163. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58164. /**
  58165. * If you want to display a video in your scene, this is the special texture for that.
  58166. * This special texture works similar to other textures, with the exception of a few parameters.
  58167. * @see https://doc.babylonjs.com/how_to/video_texture
  58168. */
  58169. var VideoTexture = /** @class */ (function (_super) {
  58170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  58171. /**
  58172. * Creates a video texture.
  58173. * If you want to display a video in your scene, this is the special texture for that.
  58174. * This special texture works similar to other textures, with the exception of a few parameters.
  58175. * @see https://doc.babylonjs.com/how_to/video_texture
  58176. * @param name optional name, will detect from video source, if not defined
  58177. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  58178. * @param scene is obviously the current scene.
  58179. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  58180. * @param invertY is false by default but can be used to invert video on Y axis
  58181. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  58182. * @param settings allows finer control over video usage
  58183. */
  58184. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  58185. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58186. if (invertY === void 0) { invertY = false; }
  58187. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58188. if (settings === void 0) { settings = {
  58189. autoPlay: true,
  58190. loop: true,
  58191. autoUpdateTexture: true,
  58192. }; }
  58193. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58194. _this._onUserActionRequestedObservable = null;
  58195. _this._stillImageCaptured = false;
  58196. _this._displayingPosterTexture = false;
  58197. _this._createInternalTexture = function () {
  58198. if (_this._texture != null) {
  58199. if (_this._displayingPosterTexture) {
  58200. _this._texture.dispose();
  58201. _this._displayingPosterTexture = false;
  58202. }
  58203. else {
  58204. return;
  58205. }
  58206. }
  58207. if (!_this._engine.needPOTTextures ||
  58208. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  58209. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58210. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58211. }
  58212. else {
  58213. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58214. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58215. _this._generateMipMaps = false;
  58216. }
  58217. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  58218. if (!_this.video.autoplay && !_this._settings.poster) {
  58219. var oldHandler_1 = _this.video.onplaying;
  58220. var error_1 = false;
  58221. _this.video.onplaying = function () {
  58222. _this.video.onplaying = oldHandler_1;
  58223. _this._texture.isReady = true;
  58224. _this._updateInternalTexture();
  58225. if (!error_1) {
  58226. _this.video.pause();
  58227. }
  58228. if (_this.onLoadObservable.hasObservers()) {
  58229. _this.onLoadObservable.notifyObservers(_this);
  58230. }
  58231. };
  58232. var playing = _this.video.play();
  58233. if (playing) {
  58234. playing.then(function () {
  58235. // Everything is good.
  58236. })
  58237. .catch(function () {
  58238. error_1 = true;
  58239. // On Chrome for instance, new policies might prevent playing without user interaction.
  58240. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  58241. _this._onUserActionRequestedObservable.notifyObservers(_this);
  58242. }
  58243. });
  58244. }
  58245. else {
  58246. _this.video.onplaying = oldHandler_1;
  58247. _this._texture.isReady = true;
  58248. _this._updateInternalTexture();
  58249. if (_this.onLoadObservable.hasObservers()) {
  58250. _this.onLoadObservable.notifyObservers(_this);
  58251. }
  58252. }
  58253. }
  58254. else {
  58255. _this._texture.isReady = true;
  58256. _this._updateInternalTexture();
  58257. if (_this.onLoadObservable.hasObservers()) {
  58258. _this.onLoadObservable.notifyObservers(_this);
  58259. }
  58260. }
  58261. };
  58262. _this.reset = function () {
  58263. if (_this._texture == null) {
  58264. return;
  58265. }
  58266. if (!_this._displayingPosterTexture) {
  58267. _this._texture.dispose();
  58268. _this._texture = null;
  58269. }
  58270. };
  58271. _this._updateInternalTexture = function () {
  58272. if (_this._texture == null || !_this._texture.isReady) {
  58273. return;
  58274. }
  58275. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  58276. return;
  58277. }
  58278. if (_this._displayingPosterTexture) {
  58279. return;
  58280. }
  58281. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  58282. };
  58283. _this._engine = _this.getScene().getEngine();
  58284. _this._generateMipMaps = generateMipMaps;
  58285. _this._initialSamplingMode = samplingMode;
  58286. _this.autoUpdateTexture = settings.autoUpdateTexture;
  58287. _this.name = name || _this._getName(src);
  58288. _this.video = _this._getVideo(src);
  58289. _this._settings = settings;
  58290. if (settings.poster) {
  58291. _this.video.poster = settings.poster;
  58292. }
  58293. if (settings.autoPlay !== undefined) {
  58294. _this.video.autoplay = settings.autoPlay;
  58295. }
  58296. if (settings.loop !== undefined) {
  58297. _this.video.loop = settings.loop;
  58298. }
  58299. _this.video.setAttribute("playsinline", "");
  58300. _this.video.addEventListener("paused", _this._updateInternalTexture);
  58301. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  58302. _this.video.addEventListener("emptied", _this.reset);
  58303. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  58304. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  58305. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  58306. if (settings.poster &&
  58307. (!settings.autoPlay || !videoHasEnoughData)) {
  58308. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  58309. _this._displayingPosterTexture = true;
  58310. }
  58311. else if (videoHasEnoughData) {
  58312. _this._createInternalTexture();
  58313. }
  58314. return _this;
  58315. }
  58316. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  58317. /**
  58318. * Event triggerd when a dom action is required by the user to play the video.
  58319. * This happens due to recent changes in browser policies preventing video to auto start.
  58320. */
  58321. get: function () {
  58322. if (!this._onUserActionRequestedObservable) {
  58323. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58324. }
  58325. return this._onUserActionRequestedObservable;
  58326. },
  58327. enumerable: true,
  58328. configurable: true
  58329. });
  58330. VideoTexture.prototype._getName = function (src) {
  58331. if (src instanceof HTMLVideoElement) {
  58332. return src.currentSrc;
  58333. }
  58334. if (typeof src === "object") {
  58335. return src.toString();
  58336. }
  58337. return src;
  58338. };
  58339. VideoTexture.prototype._getVideo = function (src) {
  58340. if (src instanceof HTMLVideoElement) {
  58341. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  58342. return src;
  58343. }
  58344. var video = document.createElement("video");
  58345. if (typeof src === "string") {
  58346. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  58347. video.src = src;
  58348. }
  58349. else {
  58350. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  58351. src.forEach(function (url) {
  58352. var source = document.createElement("source");
  58353. source.src = url;
  58354. video.appendChild(source);
  58355. });
  58356. }
  58357. return video;
  58358. };
  58359. /**
  58360. * @hidden Internal method to initiate `update`.
  58361. */
  58362. VideoTexture.prototype._rebuild = function () {
  58363. this.update();
  58364. };
  58365. /**
  58366. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  58367. */
  58368. VideoTexture.prototype.update = function () {
  58369. if (!this.autoUpdateTexture) {
  58370. // Expecting user to call `updateTexture` manually
  58371. return;
  58372. }
  58373. this.updateTexture(true);
  58374. };
  58375. /**
  58376. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  58377. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  58378. */
  58379. VideoTexture.prototype.updateTexture = function (isVisible) {
  58380. if (!isVisible) {
  58381. return;
  58382. }
  58383. if (this.video.paused && this._stillImageCaptured) {
  58384. return;
  58385. }
  58386. this._stillImageCaptured = true;
  58387. this._updateInternalTexture();
  58388. };
  58389. /**
  58390. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  58391. * @param url New url.
  58392. */
  58393. VideoTexture.prototype.updateURL = function (url) {
  58394. this.video.src = url;
  58395. };
  58396. /**
  58397. * Dispose the texture and release its associated resources.
  58398. */
  58399. VideoTexture.prototype.dispose = function () {
  58400. _super.prototype.dispose.call(this);
  58401. if (this._onUserActionRequestedObservable) {
  58402. this._onUserActionRequestedObservable.clear();
  58403. this._onUserActionRequestedObservable = null;
  58404. }
  58405. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  58406. this.video.removeEventListener("paused", this._updateInternalTexture);
  58407. this.video.removeEventListener("seeked", this._updateInternalTexture);
  58408. this.video.removeEventListener("emptied", this.reset);
  58409. this.video.pause();
  58410. };
  58411. /**
  58412. * Creates a video texture straight from your WebCam video feed.
  58413. * @param scene Define the scene the texture should be created in
  58414. * @param onReady Define a callback to triggered once the texture will be ready
  58415. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  58416. */
  58417. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  58418. var video = document.createElement("video");
  58419. video.setAttribute('autoplay', '');
  58420. video.setAttribute('muted', '');
  58421. video.setAttribute('playsinline', '');
  58422. var constraintsDeviceId;
  58423. if (constraints && constraints.deviceId) {
  58424. constraintsDeviceId = {
  58425. exact: constraints.deviceId,
  58426. };
  58427. }
  58428. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  58429. if (navigator.mediaDevices) {
  58430. navigator.mediaDevices.getUserMedia({ video: constraints })
  58431. .then(function (stream) {
  58432. if (video.mozSrcObject !== undefined) {
  58433. // hack for Firefox < 19
  58434. video.mozSrcObject = stream;
  58435. }
  58436. else {
  58437. video.srcObject = stream;
  58438. }
  58439. var onPlaying = function () {
  58440. if (onReady) {
  58441. onReady(new VideoTexture("video", video, scene, true, true));
  58442. }
  58443. video.removeEventListener("playing", onPlaying);
  58444. };
  58445. video.addEventListener("playing", onPlaying);
  58446. video.play();
  58447. })
  58448. .catch(function (err) {
  58449. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  58450. });
  58451. }
  58452. else {
  58453. navigator.getUserMedia =
  58454. navigator.getUserMedia ||
  58455. navigator.webkitGetUserMedia ||
  58456. navigator.mozGetUserMedia ||
  58457. navigator.msGetUserMedia;
  58458. if (navigator.getUserMedia) {
  58459. navigator.getUserMedia({
  58460. video: {
  58461. deviceId: constraintsDeviceId,
  58462. width: {
  58463. min: (constraints && constraints.minWidth) || 256,
  58464. max: (constraints && constraints.maxWidth) || 640,
  58465. },
  58466. height: {
  58467. min: (constraints && constraints.minHeight) || 256,
  58468. max: (constraints && constraints.maxHeight) || 480,
  58469. },
  58470. },
  58471. }, function (stream) {
  58472. if (video.mozSrcObject !== undefined) {
  58473. // hack for Firefox < 19
  58474. video.mozSrcObject = stream;
  58475. }
  58476. else {
  58477. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  58478. }
  58479. video.play();
  58480. if (onReady) {
  58481. onReady(new VideoTexture("video", video, scene, true, true));
  58482. }
  58483. }, function (e) {
  58484. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  58485. });
  58486. }
  58487. }
  58488. };
  58489. return VideoTexture;
  58490. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58491. /***/ }),
  58492. /***/ "./Materials/colorCurves.ts":
  58493. /*!**********************************!*\
  58494. !*** ./Materials/colorCurves.ts ***!
  58495. \**********************************/
  58496. /*! exports provided: ColorCurves */
  58497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58498. "use strict";
  58499. __webpack_require__.r(__webpack_exports__);
  58500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  58501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58502. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  58503. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  58504. /**
  58505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58507. * 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;
  58508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58509. */
  58510. var ColorCurves = /** @class */ (function () {
  58511. function ColorCurves() {
  58512. this._dirty = true;
  58513. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58514. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58515. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58516. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58517. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58518. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58519. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58520. this._globalHue = 30;
  58521. this._globalDensity = 0;
  58522. this._globalSaturation = 0;
  58523. this._globalExposure = 0;
  58524. this._highlightsHue = 30;
  58525. this._highlightsDensity = 0;
  58526. this._highlightsSaturation = 0;
  58527. this._highlightsExposure = 0;
  58528. this._midtonesHue = 30;
  58529. this._midtonesDensity = 0;
  58530. this._midtonesSaturation = 0;
  58531. this._midtonesExposure = 0;
  58532. this._shadowsHue = 30;
  58533. this._shadowsDensity = 0;
  58534. this._shadowsSaturation = 0;
  58535. this._shadowsExposure = 0;
  58536. }
  58537. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  58538. /**
  58539. * Gets the global Hue value.
  58540. * 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).
  58541. */
  58542. get: function () {
  58543. return this._globalHue;
  58544. },
  58545. /**
  58546. * Sets the global Hue value.
  58547. * 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).
  58548. */
  58549. set: function (value) {
  58550. this._globalHue = value;
  58551. this._dirty = true;
  58552. },
  58553. enumerable: true,
  58554. configurable: true
  58555. });
  58556. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  58557. /**
  58558. * Gets the global Density value.
  58559. * 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.
  58560. * Values less than zero provide a filter of opposite hue.
  58561. */
  58562. get: function () {
  58563. return this._globalDensity;
  58564. },
  58565. /**
  58566. * Sets the global Density value.
  58567. * 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.
  58568. * Values less than zero provide a filter of opposite hue.
  58569. */
  58570. set: function (value) {
  58571. this._globalDensity = value;
  58572. this._dirty = true;
  58573. },
  58574. enumerable: true,
  58575. configurable: true
  58576. });
  58577. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  58578. /**
  58579. * Gets the global Saturation value.
  58580. * 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.
  58581. */
  58582. get: function () {
  58583. return this._globalSaturation;
  58584. },
  58585. /**
  58586. * Sets the global Saturation value.
  58587. * 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.
  58588. */
  58589. set: function (value) {
  58590. this._globalSaturation = value;
  58591. this._dirty = true;
  58592. },
  58593. enumerable: true,
  58594. configurable: true
  58595. });
  58596. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  58597. /**
  58598. * Gets the global Exposure value.
  58599. * 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.
  58600. */
  58601. get: function () {
  58602. return this._globalExposure;
  58603. },
  58604. /**
  58605. * Sets the global Exposure value.
  58606. * 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.
  58607. */
  58608. set: function (value) {
  58609. this._globalExposure = value;
  58610. this._dirty = true;
  58611. },
  58612. enumerable: true,
  58613. configurable: true
  58614. });
  58615. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  58616. /**
  58617. * Gets the highlights Hue value.
  58618. * 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).
  58619. */
  58620. get: function () {
  58621. return this._highlightsHue;
  58622. },
  58623. /**
  58624. * Sets the highlights Hue value.
  58625. * 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).
  58626. */
  58627. set: function (value) {
  58628. this._highlightsHue = value;
  58629. this._dirty = true;
  58630. },
  58631. enumerable: true,
  58632. configurable: true
  58633. });
  58634. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  58635. /**
  58636. * Gets the highlights Density value.
  58637. * 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.
  58638. * Values less than zero provide a filter of opposite hue.
  58639. */
  58640. get: function () {
  58641. return this._highlightsDensity;
  58642. },
  58643. /**
  58644. * Sets the highlights Density value.
  58645. * 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.
  58646. * Values less than zero provide a filter of opposite hue.
  58647. */
  58648. set: function (value) {
  58649. this._highlightsDensity = value;
  58650. this._dirty = true;
  58651. },
  58652. enumerable: true,
  58653. configurable: true
  58654. });
  58655. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  58656. /**
  58657. * Gets the highlights Saturation value.
  58658. * 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.
  58659. */
  58660. get: function () {
  58661. return this._highlightsSaturation;
  58662. },
  58663. /**
  58664. * Sets the highlights Saturation value.
  58665. * 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.
  58666. */
  58667. set: function (value) {
  58668. this._highlightsSaturation = value;
  58669. this._dirty = true;
  58670. },
  58671. enumerable: true,
  58672. configurable: true
  58673. });
  58674. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  58675. /**
  58676. * Gets the highlights Exposure value.
  58677. * 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.
  58678. */
  58679. get: function () {
  58680. return this._highlightsExposure;
  58681. },
  58682. /**
  58683. * Sets the highlights Exposure value.
  58684. * 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.
  58685. */
  58686. set: function (value) {
  58687. this._highlightsExposure = value;
  58688. this._dirty = true;
  58689. },
  58690. enumerable: true,
  58691. configurable: true
  58692. });
  58693. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  58694. /**
  58695. * Gets the midtones Hue value.
  58696. * 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).
  58697. */
  58698. get: function () {
  58699. return this._midtonesHue;
  58700. },
  58701. /**
  58702. * Sets the midtones Hue value.
  58703. * 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).
  58704. */
  58705. set: function (value) {
  58706. this._midtonesHue = value;
  58707. this._dirty = true;
  58708. },
  58709. enumerable: true,
  58710. configurable: true
  58711. });
  58712. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  58713. /**
  58714. * Gets the midtones Density value.
  58715. * 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.
  58716. * Values less than zero provide a filter of opposite hue.
  58717. */
  58718. get: function () {
  58719. return this._midtonesDensity;
  58720. },
  58721. /**
  58722. * Sets the midtones Density value.
  58723. * 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.
  58724. * Values less than zero provide a filter of opposite hue.
  58725. */
  58726. set: function (value) {
  58727. this._midtonesDensity = value;
  58728. this._dirty = true;
  58729. },
  58730. enumerable: true,
  58731. configurable: true
  58732. });
  58733. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  58734. /**
  58735. * Gets the midtones Saturation value.
  58736. * 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.
  58737. */
  58738. get: function () {
  58739. return this._midtonesSaturation;
  58740. },
  58741. /**
  58742. * Sets the midtones Saturation value.
  58743. * 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.
  58744. */
  58745. set: function (value) {
  58746. this._midtonesSaturation = value;
  58747. this._dirty = true;
  58748. },
  58749. enumerable: true,
  58750. configurable: true
  58751. });
  58752. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  58753. /**
  58754. * Gets the midtones Exposure value.
  58755. * 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.
  58756. */
  58757. get: function () {
  58758. return this._midtonesExposure;
  58759. },
  58760. /**
  58761. * Sets the midtones Exposure value.
  58762. * 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.
  58763. */
  58764. set: function (value) {
  58765. this._midtonesExposure = value;
  58766. this._dirty = true;
  58767. },
  58768. enumerable: true,
  58769. configurable: true
  58770. });
  58771. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  58772. /**
  58773. * Gets the shadows Hue value.
  58774. * 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).
  58775. */
  58776. get: function () {
  58777. return this._shadowsHue;
  58778. },
  58779. /**
  58780. * Sets the shadows Hue value.
  58781. * 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).
  58782. */
  58783. set: function (value) {
  58784. this._shadowsHue = value;
  58785. this._dirty = true;
  58786. },
  58787. enumerable: true,
  58788. configurable: true
  58789. });
  58790. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  58791. /**
  58792. * Gets the shadows Density value.
  58793. * 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.
  58794. * Values less than zero provide a filter of opposite hue.
  58795. */
  58796. get: function () {
  58797. return this._shadowsDensity;
  58798. },
  58799. /**
  58800. * Sets the shadows Density value.
  58801. * 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.
  58802. * Values less than zero provide a filter of opposite hue.
  58803. */
  58804. set: function (value) {
  58805. this._shadowsDensity = value;
  58806. this._dirty = true;
  58807. },
  58808. enumerable: true,
  58809. configurable: true
  58810. });
  58811. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  58812. /**
  58813. * Gets the shadows Saturation value.
  58814. * 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.
  58815. */
  58816. get: function () {
  58817. return this._shadowsSaturation;
  58818. },
  58819. /**
  58820. * Sets the shadows Saturation value.
  58821. * 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.
  58822. */
  58823. set: function (value) {
  58824. this._shadowsSaturation = value;
  58825. this._dirty = true;
  58826. },
  58827. enumerable: true,
  58828. configurable: true
  58829. });
  58830. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  58831. /**
  58832. * Gets the shadows Exposure value.
  58833. * 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.
  58834. */
  58835. get: function () {
  58836. return this._shadowsExposure;
  58837. },
  58838. /**
  58839. * Sets the shadows Exposure value.
  58840. * 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.
  58841. */
  58842. set: function (value) {
  58843. this._shadowsExposure = value;
  58844. this._dirty = true;
  58845. },
  58846. enumerable: true,
  58847. configurable: true
  58848. });
  58849. /**
  58850. * Returns the class name
  58851. * @returns The class name
  58852. */
  58853. ColorCurves.prototype.getClassName = function () {
  58854. return "ColorCurves";
  58855. };
  58856. /**
  58857. * Binds the color curves to the shader.
  58858. * @param colorCurves The color curve to bind
  58859. * @param effect The effect to bind to
  58860. * @param positiveUniform The positive uniform shader parameter
  58861. * @param neutralUniform The neutral uniform shader parameter
  58862. * @param negativeUniform The negative uniform shader parameter
  58863. */
  58864. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  58865. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  58866. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  58867. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  58868. if (colorCurves._dirty) {
  58869. colorCurves._dirty = false;
  58870. // Fill in global info.
  58871. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  58872. // Compute highlights info.
  58873. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  58874. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  58875. // Compute midtones info.
  58876. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  58877. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  58878. // Compute shadows info.
  58879. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  58880. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  58881. // Compute deltas (neutral is midtones).
  58882. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  58883. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  58884. }
  58885. if (effect) {
  58886. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  58887. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  58888. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  58889. }
  58890. };
  58891. /**
  58892. * Prepare the list of uniforms associated with the ColorCurves effects.
  58893. * @param uniformsList The list of uniforms used in the effect
  58894. */
  58895. ColorCurves.PrepareUniforms = function (uniformsList) {
  58896. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  58897. };
  58898. /**
  58899. * Returns color grading data based on a hue, density, saturation and exposure value.
  58900. * @param filterHue The hue of the color filter.
  58901. * @param filterDensity The density of the color filter.
  58902. * @param saturation The saturation.
  58903. * @param exposure The exposure.
  58904. * @param result The result data container.
  58905. */
  58906. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  58907. if (hue == null) {
  58908. return;
  58909. }
  58910. hue = ColorCurves.clamp(hue, 0, 360);
  58911. density = ColorCurves.clamp(density, -100, 100);
  58912. saturation = ColorCurves.clamp(saturation, -100, 100);
  58913. exposure = ColorCurves.clamp(exposure, -100, 100);
  58914. // Remap the slider/config filter density with non-linear mapping and also scale by half
  58915. // so that the maximum filter density is only 50% control. This provides fine control
  58916. // for small values and reasonable range.
  58917. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  58918. density *= 0.5;
  58919. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  58920. if (density < 0) {
  58921. density *= -1;
  58922. hue = (hue + 180) % 360;
  58923. }
  58924. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  58925. result.scaleToRef(2, result);
  58926. result.a = 1 + 0.01 * saturation;
  58927. };
  58928. /**
  58929. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  58930. * @param value The input slider value in range [-100,100].
  58931. * @returns Adjusted value.
  58932. */
  58933. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  58934. value /= 100;
  58935. var x = Math.abs(value);
  58936. x = Math.pow(x, 2);
  58937. if (value < 0) {
  58938. x *= -1;
  58939. }
  58940. x *= 100;
  58941. return x;
  58942. };
  58943. /**
  58944. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  58945. * @param hue The hue (H) input.
  58946. * @param saturation The saturation (S) input.
  58947. * @param brightness The brightness (B) input.
  58948. * @result An RGBA color represented as Vector4.
  58949. */
  58950. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  58951. var h = ColorCurves.clamp(hue, 0, 360);
  58952. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  58953. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  58954. if (s === 0) {
  58955. result.r = v;
  58956. result.g = v;
  58957. result.b = v;
  58958. }
  58959. else {
  58960. // sector 0 to 5
  58961. h /= 60;
  58962. var i = Math.floor(h);
  58963. // fractional part of h
  58964. var f = h - i;
  58965. var p = v * (1 - s);
  58966. var q = v * (1 - s * f);
  58967. var t = v * (1 - s * (1 - f));
  58968. switch (i) {
  58969. case 0:
  58970. result.r = v;
  58971. result.g = t;
  58972. result.b = p;
  58973. break;
  58974. case 1:
  58975. result.r = q;
  58976. result.g = v;
  58977. result.b = p;
  58978. break;
  58979. case 2:
  58980. result.r = p;
  58981. result.g = v;
  58982. result.b = t;
  58983. break;
  58984. case 3:
  58985. result.r = p;
  58986. result.g = q;
  58987. result.b = v;
  58988. break;
  58989. case 4:
  58990. result.r = t;
  58991. result.g = p;
  58992. result.b = v;
  58993. break;
  58994. default: // case 5:
  58995. result.r = v;
  58996. result.g = p;
  58997. result.b = q;
  58998. break;
  58999. }
  59000. }
  59001. result.a = 1;
  59002. };
  59003. /**
  59004. * Returns a value clamped between min and max
  59005. * @param value The value to clamp
  59006. * @param min The minimum of value
  59007. * @param max The maximum of value
  59008. * @returns The clamped value.
  59009. */
  59010. ColorCurves.clamp = function (value, min, max) {
  59011. return Math.min(Math.max(value, min), max);
  59012. };
  59013. /**
  59014. * Clones the current color curve instance.
  59015. * @return The cloned curves
  59016. */
  59017. ColorCurves.prototype.clone = function () {
  59018. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  59019. };
  59020. /**
  59021. * Serializes the current color curve instance to a json representation.
  59022. * @return a JSON representation
  59023. */
  59024. ColorCurves.prototype.serialize = function () {
  59025. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59026. };
  59027. /**
  59028. * Parses the color curve from a json representation.
  59029. * @param source the JSON source to parse
  59030. * @return The parsed curves
  59031. */
  59032. ColorCurves.Parse = function (source) {
  59033. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  59034. };
  59035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59037. ], ColorCurves.prototype, "_globalHue", void 0);
  59038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59040. ], ColorCurves.prototype, "_globalDensity", void 0);
  59041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59043. ], ColorCurves.prototype, "_globalSaturation", void 0);
  59044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59046. ], ColorCurves.prototype, "_globalExposure", void 0);
  59047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59049. ], ColorCurves.prototype, "_highlightsHue", void 0);
  59050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59052. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  59053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59055. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  59056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59058. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  59059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59061. ], ColorCurves.prototype, "_midtonesHue", void 0);
  59062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59064. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  59065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59067. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  59068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59070. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  59071. return ColorCurves;
  59072. }());
  59073. // References the dependencies.
  59074. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  59075. /***/ }),
  59076. /***/ "./Materials/effect.ts":
  59077. /*!*****************************!*\
  59078. !*** ./Materials/effect.ts ***!
  59079. \*****************************/
  59080. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  59081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59082. "use strict";
  59083. __webpack_require__.r(__webpack_exports__);
  59084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  59085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  59086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  59087. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  59088. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  59089. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  59090. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  59091. /**
  59092. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  59093. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  59094. */
  59095. var EffectFallbacks = /** @class */ (function () {
  59096. function EffectFallbacks() {
  59097. this._defines = {};
  59098. this._currentRank = 32;
  59099. this._maxRank = -1;
  59100. }
  59101. /**
  59102. * Removes the fallback from the bound mesh.
  59103. */
  59104. EffectFallbacks.prototype.unBindMesh = function () {
  59105. this._mesh = null;
  59106. };
  59107. /**
  59108. * Adds a fallback on the specified property.
  59109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59110. * @param define The name of the define in the shader
  59111. */
  59112. EffectFallbacks.prototype.addFallback = function (rank, define) {
  59113. if (!this._defines[rank]) {
  59114. if (rank < this._currentRank) {
  59115. this._currentRank = rank;
  59116. }
  59117. if (rank > this._maxRank) {
  59118. this._maxRank = rank;
  59119. }
  59120. this._defines[rank] = new Array();
  59121. }
  59122. this._defines[rank].push(define);
  59123. };
  59124. /**
  59125. * Sets the mesh to use CPU skinning when needing to fallback.
  59126. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59127. * @param mesh The mesh to use the fallbacks.
  59128. */
  59129. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  59130. this._mesh = mesh;
  59131. if (rank < this._currentRank) {
  59132. this._currentRank = rank;
  59133. }
  59134. if (rank > this._maxRank) {
  59135. this._maxRank = rank;
  59136. }
  59137. };
  59138. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  59139. /**
  59140. * Checks to see if more fallbacks are still availible.
  59141. */
  59142. get: function () {
  59143. return this._currentRank <= this._maxRank;
  59144. },
  59145. enumerable: true,
  59146. configurable: true
  59147. });
  59148. /**
  59149. * Removes the defines that shoould be removed when falling back.
  59150. * @param currentDefines defines the current define statements for the shader.
  59151. * @param effect defines the current effect we try to compile
  59152. * @returns The resulting defines with defines of the current rank removed.
  59153. */
  59154. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  59155. // First we try to switch to CPU skinning
  59156. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  59157. this._mesh.computeBonesUsingShaders = false;
  59158. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  59159. effect._bonesComputationForcedToCPU = true;
  59160. var scene = this._mesh.getScene();
  59161. for (var index = 0; index < scene.meshes.length; index++) {
  59162. var otherMesh = scene.meshes[index];
  59163. if (!otherMesh.material) {
  59164. continue;
  59165. }
  59166. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  59167. continue;
  59168. }
  59169. if (otherMesh.material.getEffect() === effect) {
  59170. otherMesh.computeBonesUsingShaders = false;
  59171. }
  59172. else if (otherMesh.subMeshes) {
  59173. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  59174. var subMesh = _a[_i];
  59175. var subMeshEffect = subMesh.effect;
  59176. if (subMeshEffect === effect) {
  59177. otherMesh.computeBonesUsingShaders = false;
  59178. break;
  59179. }
  59180. }
  59181. }
  59182. }
  59183. }
  59184. else {
  59185. var currentFallbacks = this._defines[this._currentRank];
  59186. if (currentFallbacks) {
  59187. for (var index = 0; index < currentFallbacks.length; index++) {
  59188. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  59189. }
  59190. }
  59191. this._currentRank++;
  59192. }
  59193. return currentDefines;
  59194. };
  59195. return EffectFallbacks;
  59196. }());
  59197. /**
  59198. * Options to be used when creating an effect.
  59199. */
  59200. var EffectCreationOptions = /** @class */ (function () {
  59201. function EffectCreationOptions() {
  59202. }
  59203. return EffectCreationOptions;
  59204. }());
  59205. /**
  59206. * Effect containing vertex and fragment shader that can be executed on an object.
  59207. */
  59208. var Effect = /** @class */ (function () {
  59209. /**
  59210. * Instantiates an effect.
  59211. * An effect can be used to create/manage/execute vertex and fragment shaders.
  59212. * @param baseName Name of the effect.
  59213. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  59214. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  59215. * @param samplers List of sampler variables that will be passed to the shader.
  59216. * @param engine Engine to be used to render the effect
  59217. * @param defines Define statements to be added to the shader.
  59218. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  59219. * @param onCompiled Callback that will be called when the shader is compiled.
  59220. * @param onError Callback that will be called if an error occurs during shader compilation.
  59221. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  59222. */
  59223. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  59224. if (samplers === void 0) { samplers = null; }
  59225. if (defines === void 0) { defines = null; }
  59226. if (fallbacks === void 0) { fallbacks = null; }
  59227. if (onCompiled === void 0) { onCompiled = null; }
  59228. if (onError === void 0) { onError = null; }
  59229. var _this = this;
  59230. /**
  59231. * Unique ID of the effect.
  59232. */
  59233. this.uniqueId = 0;
  59234. /**
  59235. * Observable that will be called when the shader is compiled.
  59236. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  59237. */
  59238. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59239. /**
  59240. * Observable that will be called if an error occurs during shader compilation.
  59241. */
  59242. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59243. /** @hidden */
  59244. this._bonesComputationForcedToCPU = false;
  59245. this._uniformBuffersNames = {};
  59246. this._isReady = false;
  59247. this._compilationError = "";
  59248. this.name = baseName;
  59249. if (attributesNamesOrOptions.attributes) {
  59250. var options = attributesNamesOrOptions;
  59251. this._engine = uniformsNamesOrEngine;
  59252. this._attributesNames = options.attributes;
  59253. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  59254. this._samplers = options.samplers.slice();
  59255. this.defines = options.defines;
  59256. this.onError = options.onError;
  59257. this.onCompiled = options.onCompiled;
  59258. this._fallbacks = options.fallbacks;
  59259. this._indexParameters = options.indexParameters;
  59260. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  59261. if (options.uniformBuffersNames) {
  59262. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  59263. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  59264. }
  59265. }
  59266. }
  59267. else {
  59268. this._engine = engine;
  59269. this.defines = defines;
  59270. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  59271. this._samplers = samplers ? samplers.slice() : [];
  59272. this._attributesNames = attributesNamesOrOptions;
  59273. this.onError = onError;
  59274. this.onCompiled = onCompiled;
  59275. this._indexParameters = indexParameters;
  59276. this._fallbacks = fallbacks;
  59277. }
  59278. this.uniqueId = Effect._uniqueIdSeed++;
  59279. var vertexSource;
  59280. var fragmentSource;
  59281. if (baseName.vertexElement) {
  59282. vertexSource = document.getElementById(baseName.vertexElement);
  59283. if (!vertexSource) {
  59284. vertexSource = baseName.vertexElement;
  59285. }
  59286. }
  59287. else {
  59288. vertexSource = baseName.vertex || baseName;
  59289. }
  59290. if (baseName.fragmentElement) {
  59291. fragmentSource = document.getElementById(baseName.fragmentElement);
  59292. if (!fragmentSource) {
  59293. fragmentSource = baseName.fragmentElement;
  59294. }
  59295. }
  59296. else {
  59297. fragmentSource = baseName.fragment || baseName;
  59298. }
  59299. this._loadVertexShader(vertexSource, function (vertexCode) {
  59300. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  59301. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  59302. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  59303. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  59304. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  59305. if (baseName) {
  59306. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  59307. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  59308. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  59309. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  59310. }
  59311. else {
  59312. _this._vertexSourceCode = migratedVertexCode;
  59313. _this._fragmentSourceCode = migratedFragmentCode;
  59314. }
  59315. _this._prepareEffect();
  59316. });
  59317. });
  59318. });
  59319. });
  59320. });
  59321. });
  59322. }
  59323. Object.defineProperty(Effect.prototype, "onBindObservable", {
  59324. /**
  59325. * Observable that will be called when effect is bound.
  59326. */
  59327. get: function () {
  59328. if (!this._onBindObservable) {
  59329. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59330. }
  59331. return this._onBindObservable;
  59332. },
  59333. enumerable: true,
  59334. configurable: true
  59335. });
  59336. Object.defineProperty(Effect.prototype, "key", {
  59337. /**
  59338. * Unique key for this effect
  59339. */
  59340. get: function () {
  59341. return this._key;
  59342. },
  59343. enumerable: true,
  59344. configurable: true
  59345. });
  59346. /**
  59347. * If the effect has been compiled and prepared.
  59348. * @returns if the effect is compiled and prepared.
  59349. */
  59350. Effect.prototype.isReady = function () {
  59351. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  59352. return this._engine._isProgramCompiled(this._program);
  59353. }
  59354. return this._isReady;
  59355. };
  59356. /**
  59357. * The engine the effect was initialized with.
  59358. * @returns the engine.
  59359. */
  59360. Effect.prototype.getEngine = function () {
  59361. return this._engine;
  59362. };
  59363. /**
  59364. * The compiled webGL program for the effect
  59365. * @returns the webGL program.
  59366. */
  59367. Effect.prototype.getProgram = function () {
  59368. return this._program;
  59369. };
  59370. /**
  59371. * The set of names of attribute variables for the shader.
  59372. * @returns An array of attribute names.
  59373. */
  59374. Effect.prototype.getAttributesNames = function () {
  59375. return this._attributesNames;
  59376. };
  59377. /**
  59378. * Returns the attribute at the given index.
  59379. * @param index The index of the attribute.
  59380. * @returns The location of the attribute.
  59381. */
  59382. Effect.prototype.getAttributeLocation = function (index) {
  59383. return this._attributes[index];
  59384. };
  59385. /**
  59386. * Returns the attribute based on the name of the variable.
  59387. * @param name of the attribute to look up.
  59388. * @returns the attribute location.
  59389. */
  59390. Effect.prototype.getAttributeLocationByName = function (name) {
  59391. var index = this._attributesNames.indexOf(name);
  59392. return this._attributes[index];
  59393. };
  59394. /**
  59395. * The number of attributes.
  59396. * @returns the numnber of attributes.
  59397. */
  59398. Effect.prototype.getAttributesCount = function () {
  59399. return this._attributes.length;
  59400. };
  59401. /**
  59402. * Gets the index of a uniform variable.
  59403. * @param uniformName of the uniform to look up.
  59404. * @returns the index.
  59405. */
  59406. Effect.prototype.getUniformIndex = function (uniformName) {
  59407. return this._uniformsNames.indexOf(uniformName);
  59408. };
  59409. /**
  59410. * Returns the attribute based on the name of the variable.
  59411. * @param uniformName of the uniform to look up.
  59412. * @returns the location of the uniform.
  59413. */
  59414. Effect.prototype.getUniform = function (uniformName) {
  59415. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  59416. };
  59417. /**
  59418. * Returns an array of sampler variable names
  59419. * @returns The array of sampler variable neames.
  59420. */
  59421. Effect.prototype.getSamplers = function () {
  59422. return this._samplers;
  59423. };
  59424. /**
  59425. * The error from the last compilation.
  59426. * @returns the error string.
  59427. */
  59428. Effect.prototype.getCompilationError = function () {
  59429. return this._compilationError;
  59430. };
  59431. /**
  59432. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  59433. * @param func The callback to be used.
  59434. */
  59435. Effect.prototype.executeWhenCompiled = function (func) {
  59436. var _this = this;
  59437. if (this.isReady()) {
  59438. func(this);
  59439. return;
  59440. }
  59441. this.onCompileObservable.add(function (effect) {
  59442. func(effect);
  59443. });
  59444. if (!this._program || this._program.isParallelCompiled) {
  59445. setTimeout(function () {
  59446. _this._checkIsReady();
  59447. }, 16);
  59448. }
  59449. };
  59450. Effect.prototype._checkIsReady = function () {
  59451. var _this = this;
  59452. if (this.isReady()) {
  59453. return;
  59454. }
  59455. setTimeout(function () {
  59456. _this._checkIsReady();
  59457. }, 16);
  59458. };
  59459. /** @hidden */
  59460. Effect.prototype._loadVertexShader = function (vertex, callback) {
  59461. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59462. // DOM element ?
  59463. if (vertex instanceof HTMLElement) {
  59464. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  59465. callback(vertexCode);
  59466. return;
  59467. }
  59468. }
  59469. // Base64 encoded ?
  59470. if (vertex.substr(0, 7) === "base64:") {
  59471. var vertexBinary = window.atob(vertex.substr(7));
  59472. callback(vertexBinary);
  59473. return;
  59474. }
  59475. // Is in local store ?
  59476. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  59477. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  59478. return;
  59479. }
  59480. var vertexShaderUrl;
  59481. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  59482. vertexShaderUrl = vertex;
  59483. }
  59484. else {
  59485. vertexShaderUrl = Effect.ShadersRepository + vertex;
  59486. }
  59487. // Vertex shader
  59488. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  59489. };
  59490. /** @hidden */
  59491. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  59492. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59493. // DOM element ?
  59494. if (fragment instanceof HTMLElement) {
  59495. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  59496. callback(fragmentCode);
  59497. return;
  59498. }
  59499. }
  59500. // Base64 encoded ?
  59501. if (fragment.substr(0, 7) === "base64:") {
  59502. var fragmentBinary = window.atob(fragment.substr(7));
  59503. callback(fragmentBinary);
  59504. return;
  59505. }
  59506. // Is in local store ?
  59507. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  59508. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  59509. return;
  59510. }
  59511. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  59512. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  59513. return;
  59514. }
  59515. var fragmentShaderUrl;
  59516. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  59517. fragmentShaderUrl = fragment;
  59518. }
  59519. else {
  59520. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  59521. }
  59522. // Fragment shader
  59523. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  59524. };
  59525. /** @hidden */
  59526. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  59527. // Rebuild shaders source code
  59528. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  59529. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  59530. vertexCode = prefix + vertexCode;
  59531. fragmentCode = prefix + fragmentCode;
  59532. // Number lines of shaders source code
  59533. var i = 2;
  59534. var regex = /\n/gm;
  59535. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59536. i = 2;
  59537. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59538. // Dump shaders name and formatted source code
  59539. if (this.name.vertexElement) {
  59540. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  59541. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  59542. }
  59543. else if (this.name.vertex) {
  59544. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  59545. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  59546. }
  59547. else {
  59548. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  59549. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  59550. }
  59551. };
  59552. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  59553. var preparedSourceCode = this._processPrecision(sourceCode);
  59554. if (this._engine.webGLVersion == 1) {
  59555. callback(preparedSourceCode);
  59556. return;
  59557. }
  59558. // Already converted
  59559. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  59560. callback(preparedSourceCode.replace("#version 300 es", ""));
  59561. return;
  59562. }
  59563. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  59564. // Remove extensions
  59565. // #extension GL_OES_standard_derivatives : enable
  59566. // #extension GL_EXT_shader_texture_lod : enable
  59567. // #extension GL_EXT_frag_depth : enable
  59568. // #extension GL_EXT_draw_buffers : require
  59569. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  59570. var result = preparedSourceCode.replace(regex, "");
  59571. // Migrate to GLSL v300
  59572. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  59573. result = result.replace(/attribute[ \t]/g, "in ");
  59574. result = result.replace(/[ \t]attribute/g, " in");
  59575. result = result.replace(/texture2D\s*\(/g, "texture(");
  59576. if (isFragment) {
  59577. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  59578. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  59579. result = result.replace(/textureCube\s*\(/g, "texture(");
  59580. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  59581. result = result.replace(/gl_FragColor/g, "glFragColor");
  59582. result = result.replace(/gl_FragData/g, "glFragData");
  59583. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  59584. }
  59585. callback(result);
  59586. };
  59587. Effect.prototype._processIncludes = function (sourceCode, callback) {
  59588. var _this = this;
  59589. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  59590. var match = regex.exec(sourceCode);
  59591. var returnValue = new String(sourceCode);
  59592. while (match != null) {
  59593. var includeFile = match[1];
  59594. // Uniform declaration
  59595. if (includeFile.indexOf("__decl__") !== -1) {
  59596. includeFile = includeFile.replace(/__decl__/, "");
  59597. if (this._engine.supportsUniformBuffers) {
  59598. includeFile = includeFile.replace(/Vertex/, "Ubo");
  59599. includeFile = includeFile.replace(/Fragment/, "Ubo");
  59600. }
  59601. includeFile = includeFile + "Declaration";
  59602. }
  59603. if (Effect.IncludesShadersStore[includeFile]) {
  59604. // Substitution
  59605. var includeContent = Effect.IncludesShadersStore[includeFile];
  59606. if (match[2]) {
  59607. var splits = match[3].split(",");
  59608. for (var index = 0; index < splits.length; index += 2) {
  59609. var source = new RegExp(splits[index], "g");
  59610. var dest = splits[index + 1];
  59611. includeContent = includeContent.replace(source, dest);
  59612. }
  59613. }
  59614. if (match[4]) {
  59615. var indexString = match[5];
  59616. if (indexString.indexOf("..") !== -1) {
  59617. var indexSplits = indexString.split("..");
  59618. var minIndex = parseInt(indexSplits[0]);
  59619. var maxIndex = parseInt(indexSplits[1]);
  59620. var sourceIncludeContent = includeContent.slice(0);
  59621. includeContent = "";
  59622. if (isNaN(maxIndex)) {
  59623. maxIndex = this._indexParameters[indexSplits[1]];
  59624. }
  59625. for (var i = minIndex; i < maxIndex; i++) {
  59626. if (!this._engine.supportsUniformBuffers) {
  59627. // Ubo replacement
  59628. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59629. return p1 + "{X}";
  59630. });
  59631. }
  59632. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  59633. }
  59634. }
  59635. else {
  59636. if (!this._engine.supportsUniformBuffers) {
  59637. // Ubo replacement
  59638. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59639. return p1 + "{X}";
  59640. });
  59641. }
  59642. includeContent = includeContent.replace(/\{X\}/g, indexString);
  59643. }
  59644. }
  59645. // Replace
  59646. returnValue = returnValue.replace(match[0], includeContent);
  59647. }
  59648. else {
  59649. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  59650. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  59651. Effect.IncludesShadersStore[includeFile] = fileContent;
  59652. _this._processIncludes(returnValue, callback);
  59653. });
  59654. return;
  59655. }
  59656. match = regex.exec(sourceCode);
  59657. }
  59658. callback(returnValue);
  59659. };
  59660. Effect.prototype._processPrecision = function (source) {
  59661. if (source.indexOf("precision highp float") === -1) {
  59662. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  59663. source = "precision mediump float;\n" + source;
  59664. }
  59665. else {
  59666. source = "precision highp float;\n" + source;
  59667. }
  59668. }
  59669. else {
  59670. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  59671. source = source.replace("precision highp float", "precision mediump float");
  59672. }
  59673. }
  59674. return source;
  59675. };
  59676. /**
  59677. * Recompiles the webGL program
  59678. * @param vertexSourceCode The source code for the vertex shader.
  59679. * @param fragmentSourceCode The source code for the fragment shader.
  59680. * @param onCompiled Callback called when completed.
  59681. * @param onError Callback called on error.
  59682. * @hidden
  59683. */
  59684. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  59685. var _this = this;
  59686. this._isReady = false;
  59687. this._vertexSourceCodeOverride = vertexSourceCode;
  59688. this._fragmentSourceCodeOverride = fragmentSourceCode;
  59689. this.onError = function (effect, error) {
  59690. if (onError) {
  59691. onError(error);
  59692. }
  59693. };
  59694. this.onCompiled = function () {
  59695. var scenes = _this.getEngine().scenes;
  59696. for (var i = 0; i < scenes.length; i++) {
  59697. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  59698. }
  59699. if (onCompiled) {
  59700. onCompiled(_this._program);
  59701. }
  59702. };
  59703. this._fallbacks = null;
  59704. this._prepareEffect();
  59705. };
  59706. /**
  59707. * Gets the uniform locations of the the specified variable names
  59708. * @param names THe names of the variables to lookup.
  59709. * @returns Array of locations in the same order as variable names.
  59710. */
  59711. Effect.prototype.getSpecificUniformLocations = function (names) {
  59712. var engine = this._engine;
  59713. return engine.getUniforms(this._program, names);
  59714. };
  59715. /**
  59716. * Prepares the effect
  59717. * @hidden
  59718. */
  59719. Effect.prototype._prepareEffect = function () {
  59720. var _this = this;
  59721. var attributesNames = this._attributesNames;
  59722. var defines = this.defines;
  59723. var fallbacks = this._fallbacks;
  59724. this._valueCache = {};
  59725. var previousProgram = this._program;
  59726. try {
  59727. var engine_1 = this._engine;
  59728. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  59729. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  59730. }
  59731. else {
  59732. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  59733. }
  59734. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  59735. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  59736. if (engine_1.supportsUniformBuffers) {
  59737. for (var name in _this._uniformBuffersNames) {
  59738. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  59739. }
  59740. }
  59741. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  59742. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  59743. var index;
  59744. for (index = 0; index < _this._samplers.length; index++) {
  59745. var sampler = _this.getUniform(_this._samplers[index]);
  59746. if (sampler == null) {
  59747. _this._samplers.splice(index, 1);
  59748. index--;
  59749. }
  59750. }
  59751. engine_1.bindSamplers(_this);
  59752. _this._compilationError = "";
  59753. _this._isReady = true;
  59754. if (_this.onCompiled) {
  59755. _this.onCompiled(_this);
  59756. }
  59757. _this.onCompileObservable.notifyObservers(_this);
  59758. _this.onCompileObservable.clear();
  59759. // Unbind mesh reference in fallbacks
  59760. if (_this._fallbacks) {
  59761. _this._fallbacks.unBindMesh();
  59762. }
  59763. if (previousProgram) {
  59764. _this.getEngine()._deleteProgram(previousProgram);
  59765. }
  59766. });
  59767. if (this._program.isParallelCompiled) {
  59768. this._checkIsReady();
  59769. }
  59770. }
  59771. catch (e) {
  59772. this._compilationError = e.message;
  59773. // Let's go through fallbacks then
  59774. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  59775. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  59776. return " " + uniform;
  59777. }));
  59778. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  59779. return " " + attribute;
  59780. }));
  59781. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  59782. if (previousProgram) {
  59783. this._program = previousProgram;
  59784. this._isReady = true;
  59785. if (this.onError) {
  59786. this.onError(this, this._compilationError);
  59787. }
  59788. this.onErrorObservable.notifyObservers(this);
  59789. }
  59790. if (fallbacks && fallbacks.isMoreFallbacks) {
  59791. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  59792. this.defines = fallbacks.reduce(this.defines, this);
  59793. this._prepareEffect();
  59794. }
  59795. else { // Sorry we did everything we can
  59796. if (this.onError) {
  59797. this.onError(this, this._compilationError);
  59798. }
  59799. this.onErrorObservable.notifyObservers(this);
  59800. this.onErrorObservable.clear();
  59801. // Unbind mesh reference in fallbacks
  59802. if (this._fallbacks) {
  59803. this._fallbacks.unBindMesh();
  59804. }
  59805. }
  59806. }
  59807. };
  59808. Object.defineProperty(Effect.prototype, "isSupported", {
  59809. /**
  59810. * Checks if the effect is supported. (Must be called after compilation)
  59811. */
  59812. get: function () {
  59813. return this._compilationError === "";
  59814. },
  59815. enumerable: true,
  59816. configurable: true
  59817. });
  59818. /**
  59819. * Binds a texture to the engine to be used as output of the shader.
  59820. * @param channel Name of the output variable.
  59821. * @param texture Texture to bind.
  59822. * @hidden
  59823. */
  59824. Effect.prototype._bindTexture = function (channel, texture) {
  59825. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  59826. };
  59827. /**
  59828. * Sets a texture on the engine to be used in the shader.
  59829. * @param channel Name of the sampler variable.
  59830. * @param texture Texture to set.
  59831. */
  59832. Effect.prototype.setTexture = function (channel, texture) {
  59833. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  59834. };
  59835. /**
  59836. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  59837. * @param channel Name of the sampler variable.
  59838. * @param texture Texture to set.
  59839. */
  59840. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  59841. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  59842. };
  59843. /**
  59844. * Sets an array of textures on the engine to be used in the shader.
  59845. * @param channel Name of the variable.
  59846. * @param textures Textures to set.
  59847. */
  59848. Effect.prototype.setTextureArray = function (channel, textures) {
  59849. if (this._samplers.indexOf(channel + "Ex") === -1) {
  59850. var initialPos = this._samplers.indexOf(channel);
  59851. for (var index = 1; index < textures.length; index++) {
  59852. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  59853. }
  59854. }
  59855. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  59856. };
  59857. /**
  59858. * 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)
  59859. * @param channel Name of the sampler variable.
  59860. * @param postProcess Post process to get the input texture from.
  59861. */
  59862. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  59863. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  59864. };
  59865. /**
  59866. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  59867. * 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)
  59868. * @param channel Name of the sampler variable.
  59869. * @param postProcess Post process to get the output texture from.
  59870. */
  59871. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  59872. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  59873. };
  59874. /** @hidden */
  59875. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  59876. var cache = this._valueCache[uniformName];
  59877. var flag = matrix.updateFlag;
  59878. if (cache !== undefined && cache === flag) {
  59879. return false;
  59880. }
  59881. this._valueCache[uniformName] = flag;
  59882. return true;
  59883. };
  59884. /** @hidden */
  59885. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  59886. var cache = this._valueCache[uniformName];
  59887. if (!cache) {
  59888. cache = [x, y];
  59889. this._valueCache[uniformName] = cache;
  59890. return true;
  59891. }
  59892. var changed = false;
  59893. if (cache[0] !== x) {
  59894. cache[0] = x;
  59895. changed = true;
  59896. }
  59897. if (cache[1] !== y) {
  59898. cache[1] = y;
  59899. changed = true;
  59900. }
  59901. return changed;
  59902. };
  59903. /** @hidden */
  59904. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  59905. var cache = this._valueCache[uniformName];
  59906. if (!cache) {
  59907. cache = [x, y, z];
  59908. this._valueCache[uniformName] = cache;
  59909. return true;
  59910. }
  59911. var changed = false;
  59912. if (cache[0] !== x) {
  59913. cache[0] = x;
  59914. changed = true;
  59915. }
  59916. if (cache[1] !== y) {
  59917. cache[1] = y;
  59918. changed = true;
  59919. }
  59920. if (cache[2] !== z) {
  59921. cache[2] = z;
  59922. changed = true;
  59923. }
  59924. return changed;
  59925. };
  59926. /** @hidden */
  59927. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  59928. var cache = this._valueCache[uniformName];
  59929. if (!cache) {
  59930. cache = [x, y, z, w];
  59931. this._valueCache[uniformName] = cache;
  59932. return true;
  59933. }
  59934. var changed = false;
  59935. if (cache[0] !== x) {
  59936. cache[0] = x;
  59937. changed = true;
  59938. }
  59939. if (cache[1] !== y) {
  59940. cache[1] = y;
  59941. changed = true;
  59942. }
  59943. if (cache[2] !== z) {
  59944. cache[2] = z;
  59945. changed = true;
  59946. }
  59947. if (cache[3] !== w) {
  59948. cache[3] = w;
  59949. changed = true;
  59950. }
  59951. return changed;
  59952. };
  59953. /**
  59954. * Binds a buffer to a uniform.
  59955. * @param buffer Buffer to bind.
  59956. * @param name Name of the uniform variable to bind to.
  59957. */
  59958. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  59959. var bufferName = this._uniformBuffersNames[name];
  59960. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  59961. return;
  59962. }
  59963. Effect._baseCache[bufferName] = buffer;
  59964. this._engine.bindUniformBufferBase(buffer, bufferName);
  59965. };
  59966. /**
  59967. * Binds block to a uniform.
  59968. * @param blockName Name of the block to bind.
  59969. * @param index Index to bind.
  59970. */
  59971. Effect.prototype.bindUniformBlock = function (blockName, index) {
  59972. this._engine.bindUniformBlock(this._program, blockName, index);
  59973. };
  59974. /**
  59975. * Sets an interger value on a uniform variable.
  59976. * @param uniformName Name of the variable.
  59977. * @param value Value to be set.
  59978. * @returns this effect.
  59979. */
  59980. Effect.prototype.setInt = function (uniformName, value) {
  59981. var cache = this._valueCache[uniformName];
  59982. if (cache !== undefined && cache === value) {
  59983. return this;
  59984. }
  59985. this._valueCache[uniformName] = value;
  59986. this._engine.setInt(this.getUniform(uniformName), value);
  59987. return this;
  59988. };
  59989. /**
  59990. * Sets an int array on a uniform variable.
  59991. * @param uniformName Name of the variable.
  59992. * @param array array to be set.
  59993. * @returns this effect.
  59994. */
  59995. Effect.prototype.setIntArray = function (uniformName, array) {
  59996. this._valueCache[uniformName] = null;
  59997. this._engine.setIntArray(this.getUniform(uniformName), array);
  59998. return this;
  59999. };
  60000. /**
  60001. * 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)
  60002. * @param uniformName Name of the variable.
  60003. * @param array array to be set.
  60004. * @returns this effect.
  60005. */
  60006. Effect.prototype.setIntArray2 = function (uniformName, array) {
  60007. this._valueCache[uniformName] = null;
  60008. this._engine.setIntArray2(this.getUniform(uniformName), array);
  60009. return this;
  60010. };
  60011. /**
  60012. * 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)
  60013. * @param uniformName Name of the variable.
  60014. * @param array array to be set.
  60015. * @returns this effect.
  60016. */
  60017. Effect.prototype.setIntArray3 = function (uniformName, array) {
  60018. this._valueCache[uniformName] = null;
  60019. this._engine.setIntArray3(this.getUniform(uniformName), array);
  60020. return this;
  60021. };
  60022. /**
  60023. * 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)
  60024. * @param uniformName Name of the variable.
  60025. * @param array array to be set.
  60026. * @returns this effect.
  60027. */
  60028. Effect.prototype.setIntArray4 = function (uniformName, array) {
  60029. this._valueCache[uniformName] = null;
  60030. this._engine.setIntArray4(this.getUniform(uniformName), array);
  60031. return this;
  60032. };
  60033. /**
  60034. * Sets an float array on a uniform variable.
  60035. * @param uniformName Name of the variable.
  60036. * @param array array to be set.
  60037. * @returns this effect.
  60038. */
  60039. Effect.prototype.setFloatArray = function (uniformName, array) {
  60040. this._valueCache[uniformName] = null;
  60041. this._engine.setFloatArray(this.getUniform(uniformName), array);
  60042. return this;
  60043. };
  60044. /**
  60045. * 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)
  60046. * @param uniformName Name of the variable.
  60047. * @param array array to be set.
  60048. * @returns this effect.
  60049. */
  60050. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  60051. this._valueCache[uniformName] = null;
  60052. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  60053. return this;
  60054. };
  60055. /**
  60056. * 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)
  60057. * @param uniformName Name of the variable.
  60058. * @param array array to be set.
  60059. * @returns this effect.
  60060. */
  60061. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  60062. this._valueCache[uniformName] = null;
  60063. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  60064. return this;
  60065. };
  60066. /**
  60067. * 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)
  60068. * @param uniformName Name of the variable.
  60069. * @param array array to be set.
  60070. * @returns this effect.
  60071. */
  60072. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  60073. this._valueCache[uniformName] = null;
  60074. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  60075. return this;
  60076. };
  60077. /**
  60078. * Sets an array on a uniform variable.
  60079. * @param uniformName Name of the variable.
  60080. * @param array array to be set.
  60081. * @returns this effect.
  60082. */
  60083. Effect.prototype.setArray = function (uniformName, array) {
  60084. this._valueCache[uniformName] = null;
  60085. this._engine.setArray(this.getUniform(uniformName), array);
  60086. return this;
  60087. };
  60088. /**
  60089. * 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)
  60090. * @param uniformName Name of the variable.
  60091. * @param array array to be set.
  60092. * @returns this effect.
  60093. */
  60094. Effect.prototype.setArray2 = function (uniformName, array) {
  60095. this._valueCache[uniformName] = null;
  60096. this._engine.setArray2(this.getUniform(uniformName), array);
  60097. return this;
  60098. };
  60099. /**
  60100. * 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)
  60101. * @param uniformName Name of the variable.
  60102. * @param array array to be set.
  60103. * @returns this effect.
  60104. */
  60105. Effect.prototype.setArray3 = function (uniformName, array) {
  60106. this._valueCache[uniformName] = null;
  60107. this._engine.setArray3(this.getUniform(uniformName), array);
  60108. return this;
  60109. };
  60110. /**
  60111. * 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)
  60112. * @param uniformName Name of the variable.
  60113. * @param array array to be set.
  60114. * @returns this effect.
  60115. */
  60116. Effect.prototype.setArray4 = function (uniformName, array) {
  60117. this._valueCache[uniformName] = null;
  60118. this._engine.setArray4(this.getUniform(uniformName), array);
  60119. return this;
  60120. };
  60121. /**
  60122. * Sets matrices on a uniform variable.
  60123. * @param uniformName Name of the variable.
  60124. * @param matrices matrices to be set.
  60125. * @returns this effect.
  60126. */
  60127. Effect.prototype.setMatrices = function (uniformName, matrices) {
  60128. if (!matrices) {
  60129. return this;
  60130. }
  60131. this._valueCache[uniformName] = null;
  60132. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  60133. return this;
  60134. };
  60135. /**
  60136. * Sets matrix on a uniform variable.
  60137. * @param uniformName Name of the variable.
  60138. * @param matrix matrix to be set.
  60139. * @returns this effect.
  60140. */
  60141. Effect.prototype.setMatrix = function (uniformName, matrix) {
  60142. if (this._cacheMatrix(uniformName, matrix)) {
  60143. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  60144. }
  60145. return this;
  60146. };
  60147. /**
  60148. * 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)
  60149. * @param uniformName Name of the variable.
  60150. * @param matrix matrix to be set.
  60151. * @returns this effect.
  60152. */
  60153. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  60154. this._valueCache[uniformName] = null;
  60155. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  60156. return this;
  60157. };
  60158. /**
  60159. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  60160. * @param uniformName Name of the variable.
  60161. * @param matrix matrix to be set.
  60162. * @returns this effect.
  60163. */
  60164. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  60165. this._valueCache[uniformName] = null;
  60166. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  60167. return this;
  60168. };
  60169. /**
  60170. * Sets a float on a uniform variable.
  60171. * @param uniformName Name of the variable.
  60172. * @param value value to be set.
  60173. * @returns this effect.
  60174. */
  60175. Effect.prototype.setFloat = function (uniformName, value) {
  60176. var cache = this._valueCache[uniformName];
  60177. if (cache !== undefined && cache === value) {
  60178. return this;
  60179. }
  60180. this._valueCache[uniformName] = value;
  60181. this._engine.setFloat(this.getUniform(uniformName), value);
  60182. return this;
  60183. };
  60184. /**
  60185. * Sets a boolean on a uniform variable.
  60186. * @param uniformName Name of the variable.
  60187. * @param bool value to be set.
  60188. * @returns this effect.
  60189. */
  60190. Effect.prototype.setBool = function (uniformName, bool) {
  60191. var cache = this._valueCache[uniformName];
  60192. if (cache !== undefined && cache === bool) {
  60193. return this;
  60194. }
  60195. this._valueCache[uniformName] = bool;
  60196. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  60197. return this;
  60198. };
  60199. /**
  60200. * Sets a Vector2 on a uniform variable.
  60201. * @param uniformName Name of the variable.
  60202. * @param vector2 vector2 to be set.
  60203. * @returns this effect.
  60204. */
  60205. Effect.prototype.setVector2 = function (uniformName, vector2) {
  60206. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  60207. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  60208. }
  60209. return this;
  60210. };
  60211. /**
  60212. * Sets a float2 on a uniform variable.
  60213. * @param uniformName Name of the variable.
  60214. * @param x First float in float2.
  60215. * @param y Second float in float2.
  60216. * @returns this effect.
  60217. */
  60218. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  60219. if (this._cacheFloat2(uniformName, x, y)) {
  60220. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  60221. }
  60222. return this;
  60223. };
  60224. /**
  60225. * Sets a Vector3 on a uniform variable.
  60226. * @param uniformName Name of the variable.
  60227. * @param vector3 Value to be set.
  60228. * @returns this effect.
  60229. */
  60230. Effect.prototype.setVector3 = function (uniformName, vector3) {
  60231. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  60232. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  60233. }
  60234. return this;
  60235. };
  60236. /**
  60237. * Sets a float3 on a uniform variable.
  60238. * @param uniformName Name of the variable.
  60239. * @param x First float in float3.
  60240. * @param y Second float in float3.
  60241. * @param z Third float in float3.
  60242. * @returns this effect.
  60243. */
  60244. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  60245. if (this._cacheFloat3(uniformName, x, y, z)) {
  60246. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  60247. }
  60248. return this;
  60249. };
  60250. /**
  60251. * Sets a Vector4 on a uniform variable.
  60252. * @param uniformName Name of the variable.
  60253. * @param vector4 Value to be set.
  60254. * @returns this effect.
  60255. */
  60256. Effect.prototype.setVector4 = function (uniformName, vector4) {
  60257. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  60258. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  60259. }
  60260. return this;
  60261. };
  60262. /**
  60263. * Sets a float4 on a uniform variable.
  60264. * @param uniformName Name of the variable.
  60265. * @param x First float in float4.
  60266. * @param y Second float in float4.
  60267. * @param z Third float in float4.
  60268. * @param w Fourth float in float4.
  60269. * @returns this effect.
  60270. */
  60271. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  60272. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  60273. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  60274. }
  60275. return this;
  60276. };
  60277. /**
  60278. * Sets a Color3 on a uniform variable.
  60279. * @param uniformName Name of the variable.
  60280. * @param color3 Value to be set.
  60281. * @returns this effect.
  60282. */
  60283. Effect.prototype.setColor3 = function (uniformName, color3) {
  60284. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  60285. this._engine.setColor3(this.getUniform(uniformName), color3);
  60286. }
  60287. return this;
  60288. };
  60289. /**
  60290. * Sets a Color4 on a uniform variable.
  60291. * @param uniformName Name of the variable.
  60292. * @param color3 Value to be set.
  60293. * @param alpha Alpha value to be set.
  60294. * @returns this effect.
  60295. */
  60296. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  60297. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  60298. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  60299. }
  60300. return this;
  60301. };
  60302. /**
  60303. * Sets a Color4 on a uniform variable
  60304. * @param uniformName defines the name of the variable
  60305. * @param color4 defines the value to be set
  60306. * @returns this effect.
  60307. */
  60308. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  60309. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  60310. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  60311. }
  60312. return this;
  60313. };
  60314. /**
  60315. * This function will add a new shader to the shader store
  60316. * @param name the name of the shader
  60317. * @param pixelShader optional pixel shader content
  60318. * @param vertexShader optional vertex shader content
  60319. */
  60320. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  60321. if (pixelShader) {
  60322. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  60323. }
  60324. if (vertexShader) {
  60325. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  60326. }
  60327. };
  60328. /**
  60329. * Resets the cache of effects.
  60330. */
  60331. Effect.ResetCache = function () {
  60332. Effect._baseCache = {};
  60333. };
  60334. /**
  60335. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  60336. */
  60337. Effect.ShadersRepository = "src/Shaders/";
  60338. Effect._uniqueIdSeed = 0;
  60339. Effect._baseCache = {};
  60340. /**
  60341. * Store of each shader (The can be looked up using effect.key)
  60342. */
  60343. Effect.ShadersStore = {};
  60344. /**
  60345. * Store of each included file for a shader (The can be looked up using effect.key)
  60346. */
  60347. Effect.IncludesShadersStore = {};
  60348. return Effect;
  60349. }());
  60350. /***/ }),
  60351. /***/ "./Materials/fresnelParameters.ts":
  60352. /*!****************************************!*\
  60353. !*** ./Materials/fresnelParameters.ts ***!
  60354. \****************************************/
  60355. /*! exports provided: FresnelParameters */
  60356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60357. "use strict";
  60358. __webpack_require__.r(__webpack_exports__);
  60359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  60360. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  60361. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60362. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  60363. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60364. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60365. /**
  60366. * This represents all the required information to add a fresnel effect on a material:
  60367. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  60368. */
  60369. var FresnelParameters = /** @class */ (function () {
  60370. function FresnelParameters() {
  60371. this._isEnabled = true;
  60372. /**
  60373. * Define the color used on edges (grazing angle)
  60374. */
  60375. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  60376. /**
  60377. * Define the color used on center
  60378. */
  60379. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  60380. /**
  60381. * Define bias applied to computed fresnel term
  60382. */
  60383. this.bias = 0;
  60384. /**
  60385. * Defined the power exponent applied to fresnel term
  60386. */
  60387. this.power = 1;
  60388. }
  60389. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  60390. /**
  60391. * Define if the fresnel effect is enable or not.
  60392. */
  60393. get: function () {
  60394. return this._isEnabled;
  60395. },
  60396. set: function (value) {
  60397. if (this._isEnabled === value) {
  60398. return;
  60399. }
  60400. this._isEnabled = value;
  60401. _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);
  60402. },
  60403. enumerable: true,
  60404. configurable: true
  60405. });
  60406. /**
  60407. * Clones the current fresnel and its valuues
  60408. * @returns a clone fresnel configuration
  60409. */
  60410. FresnelParameters.prototype.clone = function () {
  60411. var newFresnelParameters = new FresnelParameters();
  60412. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  60413. return newFresnelParameters;
  60414. };
  60415. /**
  60416. * Serializes the current fresnel parameters to a JSON representation.
  60417. * @return the JSON serialization
  60418. */
  60419. FresnelParameters.prototype.serialize = function () {
  60420. var serializationObject = {};
  60421. serializationObject.isEnabled = this.isEnabled;
  60422. serializationObject.leftColor = this.leftColor.asArray();
  60423. serializationObject.rightColor = this.rightColor.asArray();
  60424. serializationObject.bias = this.bias;
  60425. serializationObject.power = this.power;
  60426. return serializationObject;
  60427. };
  60428. /**
  60429. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  60430. * @param parsedFresnelParameters Define the JSON representation
  60431. * @returns the parsed parameters
  60432. */
  60433. FresnelParameters.Parse = function (parsedFresnelParameters) {
  60434. var fresnelParameters = new FresnelParameters();
  60435. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  60436. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  60437. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  60438. fresnelParameters.bias = parsedFresnelParameters.bias;
  60439. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  60440. return fresnelParameters;
  60441. };
  60442. return FresnelParameters;
  60443. }());
  60444. // References the dependencies.
  60445. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  60446. /***/ }),
  60447. /***/ "./Materials/imageProcessingConfiguration.ts":
  60448. /*!***************************************************!*\
  60449. !*** ./Materials/imageProcessingConfiguration.ts ***!
  60450. \***************************************************/
  60451. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  60452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60453. "use strict";
  60454. __webpack_require__.r(__webpack_exports__);
  60455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  60456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  60457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60458. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60459. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  60461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60462. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  60463. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  60464. /**
  60465. * @hidden
  60466. */
  60467. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  60468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  60469. function ImageProcessingConfigurationDefines() {
  60470. var _this = _super.call(this) || this;
  60471. _this.IMAGEPROCESSING = false;
  60472. _this.VIGNETTE = false;
  60473. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  60474. _this.VIGNETTEBLENDMODEOPAQUE = false;
  60475. _this.TONEMAPPING = false;
  60476. _this.TONEMAPPING_ACES = false;
  60477. _this.CONTRAST = false;
  60478. _this.COLORCURVES = false;
  60479. _this.COLORGRADING = false;
  60480. _this.COLORGRADING3D = false;
  60481. _this.SAMPLER3DGREENDEPTH = false;
  60482. _this.SAMPLER3DBGRMAP = false;
  60483. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  60484. _this.EXPOSURE = false;
  60485. _this.rebuild();
  60486. return _this;
  60487. }
  60488. return ImageProcessingConfigurationDefines;
  60489. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  60490. /**
  60491. * This groups together the common properties used for image processing either in direct forward pass
  60492. * or through post processing effect depending on the use of the image processing pipeline in your scene
  60493. * or not.
  60494. */
  60495. var ImageProcessingConfiguration = /** @class */ (function () {
  60496. function ImageProcessingConfiguration() {
  60497. /**
  60498. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  60499. */
  60500. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  60501. this._colorCurvesEnabled = false;
  60502. this._colorGradingEnabled = false;
  60503. this._colorGradingWithGreenDepth = true;
  60504. this._colorGradingBGR = true;
  60505. /** @hidden */
  60506. this._exposure = 1.0;
  60507. this._toneMappingEnabled = false;
  60508. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  60509. this._contrast = 1.0;
  60510. /**
  60511. * Vignette stretch size.
  60512. */
  60513. this.vignetteStretch = 0;
  60514. /**
  60515. * Vignette centre X Offset.
  60516. */
  60517. this.vignetteCentreX = 0;
  60518. /**
  60519. * Vignette centre Y Offset.
  60520. */
  60521. this.vignetteCentreY = 0;
  60522. /**
  60523. * Vignette weight or intensity of the vignette effect.
  60524. */
  60525. this.vignetteWeight = 1.5;
  60526. /**
  60527. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  60528. * if vignetteEnabled is set to true.
  60529. */
  60530. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  60531. /**
  60532. * Camera field of view used by the Vignette effect.
  60533. */
  60534. this.vignetteCameraFov = 0.5;
  60535. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  60536. this._vignetteEnabled = false;
  60537. this._applyByPostProcess = false;
  60538. this._isEnabled = true;
  60539. /**
  60540. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  60541. */
  60542. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60543. }
  60544. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  60545. /**
  60546. * Gets wether the color curves effect is enabled.
  60547. */
  60548. get: function () {
  60549. return this._colorCurvesEnabled;
  60550. },
  60551. /**
  60552. * Sets wether the color curves effect is enabled.
  60553. */
  60554. set: function (value) {
  60555. if (this._colorCurvesEnabled === value) {
  60556. return;
  60557. }
  60558. this._colorCurvesEnabled = value;
  60559. this._updateParameters();
  60560. },
  60561. enumerable: true,
  60562. configurable: true
  60563. });
  60564. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  60565. /**
  60566. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60567. */
  60568. get: function () {
  60569. return this._colorGradingTexture;
  60570. },
  60571. /**
  60572. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60573. */
  60574. set: function (value) {
  60575. if (this._colorGradingTexture === value) {
  60576. return;
  60577. }
  60578. this._colorGradingTexture = value;
  60579. this._updateParameters();
  60580. },
  60581. enumerable: true,
  60582. configurable: true
  60583. });
  60584. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  60585. /**
  60586. * Gets wether the color grading effect is enabled.
  60587. */
  60588. get: function () {
  60589. return this._colorGradingEnabled;
  60590. },
  60591. /**
  60592. * Sets wether the color grading effect is enabled.
  60593. */
  60594. set: function (value) {
  60595. if (this._colorGradingEnabled === value) {
  60596. return;
  60597. }
  60598. this._colorGradingEnabled = value;
  60599. this._updateParameters();
  60600. },
  60601. enumerable: true,
  60602. configurable: true
  60603. });
  60604. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  60605. /**
  60606. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  60607. */
  60608. get: function () {
  60609. return this._colorGradingWithGreenDepth;
  60610. },
  60611. /**
  60612. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  60613. */
  60614. set: function (value) {
  60615. if (this._colorGradingWithGreenDepth === value) {
  60616. return;
  60617. }
  60618. this._colorGradingWithGreenDepth = value;
  60619. this._updateParameters();
  60620. },
  60621. enumerable: true,
  60622. configurable: true
  60623. });
  60624. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  60625. /**
  60626. * Gets wether the color grading texture contains BGR values.
  60627. */
  60628. get: function () {
  60629. return this._colorGradingBGR;
  60630. },
  60631. /**
  60632. * Sets wether the color grading texture contains BGR values.
  60633. */
  60634. set: function (value) {
  60635. if (this._colorGradingBGR === value) {
  60636. return;
  60637. }
  60638. this._colorGradingBGR = value;
  60639. this._updateParameters();
  60640. },
  60641. enumerable: true,
  60642. configurable: true
  60643. });
  60644. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  60645. /**
  60646. * Gets the Exposure used in the effect.
  60647. */
  60648. get: function () {
  60649. return this._exposure;
  60650. },
  60651. /**
  60652. * Sets the Exposure used in the effect.
  60653. */
  60654. set: function (value) {
  60655. if (this._exposure === value) {
  60656. return;
  60657. }
  60658. this._exposure = value;
  60659. this._updateParameters();
  60660. },
  60661. enumerable: true,
  60662. configurable: true
  60663. });
  60664. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  60665. /**
  60666. * Gets wether the tone mapping effect is enabled.
  60667. */
  60668. get: function () {
  60669. return this._toneMappingEnabled;
  60670. },
  60671. /**
  60672. * Sets wether the tone mapping effect is enabled.
  60673. */
  60674. set: function (value) {
  60675. if (this._toneMappingEnabled === value) {
  60676. return;
  60677. }
  60678. this._toneMappingEnabled = value;
  60679. this._updateParameters();
  60680. },
  60681. enumerable: true,
  60682. configurable: true
  60683. });
  60684. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  60685. /**
  60686. * Gets the type of tone mapping effect.
  60687. */
  60688. get: function () {
  60689. return this._toneMappingType;
  60690. },
  60691. /**
  60692. * Sets the type of tone mapping effect used in BabylonJS.
  60693. */
  60694. set: function (value) {
  60695. if (this._toneMappingType === value) {
  60696. return;
  60697. }
  60698. this._toneMappingType = value;
  60699. this._updateParameters();
  60700. },
  60701. enumerable: true,
  60702. configurable: true
  60703. });
  60704. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  60705. /**
  60706. * Gets the contrast used in the effect.
  60707. */
  60708. get: function () {
  60709. return this._contrast;
  60710. },
  60711. /**
  60712. * Sets the contrast used in the effect.
  60713. */
  60714. set: function (value) {
  60715. if (this._contrast === value) {
  60716. return;
  60717. }
  60718. this._contrast = value;
  60719. this._updateParameters();
  60720. },
  60721. enumerable: true,
  60722. configurable: true
  60723. });
  60724. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  60725. /**
  60726. * Gets the vignette blend mode allowing different kind of effect.
  60727. */
  60728. get: function () {
  60729. return this._vignetteBlendMode;
  60730. },
  60731. /**
  60732. * Sets the vignette blend mode allowing different kind of effect.
  60733. */
  60734. set: function (value) {
  60735. if (this._vignetteBlendMode === value) {
  60736. return;
  60737. }
  60738. this._vignetteBlendMode = value;
  60739. this._updateParameters();
  60740. },
  60741. enumerable: true,
  60742. configurable: true
  60743. });
  60744. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  60745. /**
  60746. * Gets wether the vignette effect is enabled.
  60747. */
  60748. get: function () {
  60749. return this._vignetteEnabled;
  60750. },
  60751. /**
  60752. * Sets wether the vignette effect is enabled.
  60753. */
  60754. set: function (value) {
  60755. if (this._vignetteEnabled === value) {
  60756. return;
  60757. }
  60758. this._vignetteEnabled = value;
  60759. this._updateParameters();
  60760. },
  60761. enumerable: true,
  60762. configurable: true
  60763. });
  60764. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  60765. /**
  60766. * Gets wether the image processing is applied through a post process or not.
  60767. */
  60768. get: function () {
  60769. return this._applyByPostProcess;
  60770. },
  60771. /**
  60772. * Sets wether the image processing is applied through a post process or not.
  60773. */
  60774. set: function (value) {
  60775. if (this._applyByPostProcess === value) {
  60776. return;
  60777. }
  60778. this._applyByPostProcess = value;
  60779. this._updateParameters();
  60780. },
  60781. enumerable: true,
  60782. configurable: true
  60783. });
  60784. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  60785. /**
  60786. * Gets wether the image processing is enabled or not.
  60787. */
  60788. get: function () {
  60789. return this._isEnabled;
  60790. },
  60791. /**
  60792. * Sets wether the image processing is enabled or not.
  60793. */
  60794. set: function (value) {
  60795. if (this._isEnabled === value) {
  60796. return;
  60797. }
  60798. this._isEnabled = value;
  60799. this._updateParameters();
  60800. },
  60801. enumerable: true,
  60802. configurable: true
  60803. });
  60804. /**
  60805. * Method called each time the image processing information changes requires to recompile the effect.
  60806. */
  60807. ImageProcessingConfiguration.prototype._updateParameters = function () {
  60808. this.onUpdateParameters.notifyObservers(this);
  60809. };
  60810. /**
  60811. * Gets the current class name.
  60812. * @return "ImageProcessingConfiguration"
  60813. */
  60814. ImageProcessingConfiguration.prototype.getClassName = function () {
  60815. return "ImageProcessingConfiguration";
  60816. };
  60817. /**
  60818. * Prepare the list of uniforms associated with the Image Processing effects.
  60819. * @param uniforms The list of uniforms used in the effect
  60820. * @param defines the list of defines currently in use
  60821. */
  60822. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  60823. if (defines.EXPOSURE) {
  60824. uniforms.push("exposureLinear");
  60825. }
  60826. if (defines.CONTRAST) {
  60827. uniforms.push("contrast");
  60828. }
  60829. if (defines.COLORGRADING) {
  60830. uniforms.push("colorTransformSettings");
  60831. }
  60832. if (defines.VIGNETTE) {
  60833. uniforms.push("vInverseScreenSize");
  60834. uniforms.push("vignetteSettings1");
  60835. uniforms.push("vignetteSettings2");
  60836. }
  60837. if (defines.COLORCURVES) {
  60838. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  60839. }
  60840. };
  60841. /**
  60842. * Prepare the list of samplers associated with the Image Processing effects.
  60843. * @param samplersList The list of uniforms used in the effect
  60844. * @param defines the list of defines currently in use
  60845. */
  60846. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  60847. if (defines.COLORGRADING) {
  60848. samplersList.push("txColorTransform");
  60849. }
  60850. };
  60851. /**
  60852. * Prepare the list of defines associated to the shader.
  60853. * @param defines the list of defines to complete
  60854. * @param forPostProcess Define if we are currently in post process mode or not
  60855. */
  60856. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  60857. if (forPostProcess === void 0) { forPostProcess = false; }
  60858. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  60859. defines.VIGNETTE = false;
  60860. defines.TONEMAPPING = false;
  60861. defines.TONEMAPPING_ACES = false;
  60862. defines.CONTRAST = false;
  60863. defines.EXPOSURE = false;
  60864. defines.COLORCURVES = false;
  60865. defines.COLORGRADING = false;
  60866. defines.COLORGRADING3D = false;
  60867. defines.IMAGEPROCESSING = false;
  60868. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  60869. return;
  60870. }
  60871. defines.VIGNETTE = this.vignetteEnabled;
  60872. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  60873. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  60874. defines.TONEMAPPING = this.toneMappingEnabled;
  60875. switch (this._toneMappingType) {
  60876. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  60877. defines.TONEMAPPING_ACES = true;
  60878. break;
  60879. default:
  60880. defines.TONEMAPPING_ACES = false;
  60881. break;
  60882. }
  60883. defines.CONTRAST = (this.contrast !== 1.0);
  60884. defines.EXPOSURE = (this.exposure !== 1.0);
  60885. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  60886. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  60887. if (defines.COLORGRADING) {
  60888. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  60889. }
  60890. else {
  60891. defines.COLORGRADING3D = false;
  60892. }
  60893. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  60894. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  60895. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  60896. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  60897. };
  60898. /**
  60899. * Returns true if all the image processing information are ready.
  60900. * @returns True if ready, otherwise, false
  60901. */
  60902. ImageProcessingConfiguration.prototype.isReady = function () {
  60903. // Color Grading texure can not be none blocking.
  60904. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  60905. };
  60906. /**
  60907. * Binds the image processing to the shader.
  60908. * @param effect The effect to bind to
  60909. * @param aspectRatio Define the current aspect ratio of the effect
  60910. */
  60911. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  60912. if (aspectRatio === void 0) { aspectRatio = 1; }
  60913. // Color Curves
  60914. if (this._colorCurvesEnabled && this.colorCurves) {
  60915. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  60916. }
  60917. // Vignette
  60918. if (this._vignetteEnabled) {
  60919. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  60920. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  60921. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  60922. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  60923. var vignetteScaleX = vignetteScaleY * aspectRatio;
  60924. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  60925. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  60926. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  60927. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  60928. var vignettePower = -2.0 * this.vignetteWeight;
  60929. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  60930. }
  60931. // Exposure
  60932. effect.setFloat("exposureLinear", this.exposure);
  60933. // Contrast
  60934. effect.setFloat("contrast", this.contrast);
  60935. // Color transform settings
  60936. if (this.colorGradingTexture) {
  60937. effect.setTexture("txColorTransform", this.colorGradingTexture);
  60938. var textureSize = this.colorGradingTexture.getSize().height;
  60939. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  60940. 0.5 / textureSize, // textureOffset
  60941. textureSize, // textureSize
  60942. this.colorGradingTexture.level // weight
  60943. );
  60944. }
  60945. };
  60946. /**
  60947. * Clones the current image processing instance.
  60948. * @return The cloned image processing
  60949. */
  60950. ImageProcessingConfiguration.prototype.clone = function () {
  60951. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  60952. };
  60953. /**
  60954. * Serializes the current image processing instance to a json representation.
  60955. * @return a JSON representation
  60956. */
  60957. ImageProcessingConfiguration.prototype.serialize = function () {
  60958. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60959. };
  60960. /**
  60961. * Parses the image processing from a json representation.
  60962. * @param source the JSON source to parse
  60963. * @return The parsed image processing
  60964. */
  60965. ImageProcessingConfiguration.Parse = function (source) {
  60966. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  60967. };
  60968. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  60969. /**
  60970. * Used to apply the vignette as a mix with the pixel color.
  60971. */
  60972. get: function () {
  60973. return this._VIGNETTEMODE_MULTIPLY;
  60974. },
  60975. enumerable: true,
  60976. configurable: true
  60977. });
  60978. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  60979. /**
  60980. * Used to apply the vignette as a replacement of the pixel color.
  60981. */
  60982. get: function () {
  60983. return this._VIGNETTEMODE_OPAQUE;
  60984. },
  60985. enumerable: true,
  60986. configurable: true
  60987. });
  60988. /**
  60989. * Default tone mapping applied in BabylonJS.
  60990. */
  60991. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  60992. /**
  60993. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  60994. * to other engines rendering to increase portability.
  60995. */
  60996. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  60997. // Static constants associated to the image processing.
  60998. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  60999. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61002. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61005. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  61006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  61008. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  61009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61011. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  61012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61014. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  61015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61017. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  61018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61020. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  61021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61023. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  61024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61026. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  61027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61029. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  61030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61032. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  61033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61035. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  61036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61038. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  61039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61041. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  61042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  61044. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  61045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61047. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  61048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61050. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  61051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61053. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  61054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61056. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  61057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61059. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  61060. return ImageProcessingConfiguration;
  61061. }());
  61062. // References the dependencies.
  61063. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  61064. /***/ }),
  61065. /***/ "./Materials/index.ts":
  61066. /*!****************************!*\
  61067. !*** ./Materials/index.ts ***!
  61068. \****************************/
  61069. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  61070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61071. "use strict";
  61072. __webpack_require__.r(__webpack_exports__);
  61073. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  61074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  61075. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  61076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  61077. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  61078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  61079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  61080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  61081. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  61082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  61083. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  61084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  61085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  61086. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  61087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  61088. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  61089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  61090. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  61091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  61092. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  61093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  61094. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  61095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  61096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  61097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  61098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  61099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  61100. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  61101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  61102. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  61103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  61104. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  61105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  61106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  61107. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  61108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  61109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  61110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  61111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  61112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  61113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  61114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  61115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  61116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  61117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  61118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  61119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  61120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  61121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  61122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  61123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  61124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  61125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  61126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  61127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  61128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  61129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  61130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  61131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  61132. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  61134. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  61135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  61136. /***/ }),
  61137. /***/ "./Materials/material.ts":
  61138. /*!*******************************!*\
  61139. !*** ./Materials/material.ts ***!
  61140. \*******************************/
  61141. /*! exports provided: Material */
  61142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61143. "use strict";
  61144. __webpack_require__.r(__webpack_exports__);
  61145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  61146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61147. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61148. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61149. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61151. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  61152. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  61153. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61154. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61155. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61156. /**
  61157. * Base class for the main features of a material in Babylon.js
  61158. */
  61159. var Material = /** @class */ (function () {
  61160. /**
  61161. * Creates a material instance
  61162. * @param name defines the name of the material
  61163. * @param scene defines the scene to reference
  61164. * @param doNotAdd specifies if the material should be added to the scene
  61165. */
  61166. function Material(name, scene, doNotAdd) {
  61167. /**
  61168. * Gets or sets user defined metadata
  61169. */
  61170. this.metadata = null;
  61171. /**
  61172. * For internal use only. Please do not use.
  61173. */
  61174. this.reservedDataStore = null;
  61175. /**
  61176. * Specifies if the ready state should be checked on each call
  61177. */
  61178. this.checkReadyOnEveryCall = false;
  61179. /**
  61180. * Specifies if the ready state should be checked once
  61181. */
  61182. this.checkReadyOnlyOnce = false;
  61183. /**
  61184. * The state of the material
  61185. */
  61186. this.state = "";
  61187. /**
  61188. * The alpha value of the material
  61189. */
  61190. this._alpha = 1.0;
  61191. /**
  61192. * Specifies if back face culling is enabled
  61193. */
  61194. this._backFaceCulling = true;
  61195. /**
  61196. * Specifies if the material should be serialized
  61197. */
  61198. this.doNotSerialize = false;
  61199. /**
  61200. * @hidden
  61201. */
  61202. this._storeEffectOnSubMeshes = false;
  61203. /**
  61204. * An event triggered when the material is disposed
  61205. */
  61206. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61207. /**
  61208. * Stores the value of the alpha mode
  61209. */
  61210. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  61211. /**
  61212. * Stores the state of the need depth pre-pass value
  61213. */
  61214. this._needDepthPrePass = false;
  61215. /**
  61216. * Specifies if depth writing should be disabled
  61217. */
  61218. this.disableDepthWrite = false;
  61219. /**
  61220. * Specifies if depth writing should be forced
  61221. */
  61222. this.forceDepthWrite = false;
  61223. /**
  61224. * Specifies if there should be a separate pass for culling
  61225. */
  61226. this.separateCullingPass = false;
  61227. /**
  61228. * Stores the state specifing if fog should be enabled
  61229. */
  61230. this._fogEnabled = true;
  61231. /**
  61232. * Stores the size of points
  61233. */
  61234. this.pointSize = 1.0;
  61235. /**
  61236. * Stores the z offset value
  61237. */
  61238. this.zOffset = 0;
  61239. /**
  61240. * @hidden
  61241. * Specifies if the material was previously ready
  61242. */
  61243. this._wasPreviouslyReady = false;
  61244. /**
  61245. * Stores the fill mode state
  61246. */
  61247. this._fillMode = Material.TriangleFillMode;
  61248. /** @hidden */
  61249. this._indexInSceneMaterialArray = -1;
  61250. this.name = name;
  61251. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  61252. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  61253. this.uniqueId = this._scene.getUniqueId();
  61254. if (this._scene.useRightHandedSystem) {
  61255. this.sideOrientation = Material.ClockWiseSideOrientation;
  61256. }
  61257. else {
  61258. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  61259. }
  61260. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  61261. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  61262. if (!doNotAdd) {
  61263. this._scene.addMaterial(this);
  61264. }
  61265. if (this._scene.useMaterialMeshMap) {
  61266. this.meshMap = {};
  61267. }
  61268. }
  61269. Object.defineProperty(Material.prototype, "alpha", {
  61270. /**
  61271. * Gets the alpha value of the material
  61272. */
  61273. get: function () {
  61274. return this._alpha;
  61275. },
  61276. /**
  61277. * Sets the alpha value of the material
  61278. */
  61279. set: function (value) {
  61280. if (this._alpha === value) {
  61281. return;
  61282. }
  61283. this._alpha = value;
  61284. this.markAsDirty(Material.MiscDirtyFlag);
  61285. },
  61286. enumerable: true,
  61287. configurable: true
  61288. });
  61289. Object.defineProperty(Material.prototype, "backFaceCulling", {
  61290. /**
  61291. * Gets the back-face culling state
  61292. */
  61293. get: function () {
  61294. return this._backFaceCulling;
  61295. },
  61296. /**
  61297. * Sets the back-face culling state
  61298. */
  61299. set: function (value) {
  61300. if (this._backFaceCulling === value) {
  61301. return;
  61302. }
  61303. this._backFaceCulling = value;
  61304. this.markAsDirty(Material.TextureDirtyFlag);
  61305. },
  61306. enumerable: true,
  61307. configurable: true
  61308. });
  61309. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  61310. /**
  61311. * Gets a boolean indicating that current material needs to register RTT
  61312. */
  61313. get: function () {
  61314. return false;
  61315. },
  61316. enumerable: true,
  61317. configurable: true
  61318. });
  61319. Object.defineProperty(Material.prototype, "onDispose", {
  61320. /**
  61321. * Called during a dispose event
  61322. */
  61323. set: function (callback) {
  61324. if (this._onDisposeObserver) {
  61325. this.onDisposeObservable.remove(this._onDisposeObserver);
  61326. }
  61327. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  61328. },
  61329. enumerable: true,
  61330. configurable: true
  61331. });
  61332. Object.defineProperty(Material.prototype, "onBindObservable", {
  61333. /**
  61334. * An event triggered when the material is bound
  61335. */
  61336. get: function () {
  61337. if (!this._onBindObservable) {
  61338. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61339. }
  61340. return this._onBindObservable;
  61341. },
  61342. enumerable: true,
  61343. configurable: true
  61344. });
  61345. Object.defineProperty(Material.prototype, "onBind", {
  61346. /**
  61347. * Called during a bind event
  61348. */
  61349. set: function (callback) {
  61350. if (this._onBindObserver) {
  61351. this.onBindObservable.remove(this._onBindObserver);
  61352. }
  61353. this._onBindObserver = this.onBindObservable.add(callback);
  61354. },
  61355. enumerable: true,
  61356. configurable: true
  61357. });
  61358. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  61359. /**
  61360. * An event triggered when the material is unbound
  61361. */
  61362. get: function () {
  61363. if (!this._onUnBindObservable) {
  61364. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61365. }
  61366. return this._onUnBindObservable;
  61367. },
  61368. enumerable: true,
  61369. configurable: true
  61370. });
  61371. Object.defineProperty(Material.prototype, "alphaMode", {
  61372. /**
  61373. * Gets the value of the alpha mode
  61374. */
  61375. get: function () {
  61376. return this._alphaMode;
  61377. },
  61378. /**
  61379. * Sets the value of the alpha mode.
  61380. *
  61381. * | Value | Type | Description |
  61382. * | --- | --- | --- |
  61383. * | 0 | ALPHA_DISABLE | |
  61384. * | 1 | ALPHA_ADD | |
  61385. * | 2 | ALPHA_COMBINE | |
  61386. * | 3 | ALPHA_SUBTRACT | |
  61387. * | 4 | ALPHA_MULTIPLY | |
  61388. * | 5 | ALPHA_MAXIMIZED | |
  61389. * | 6 | ALPHA_ONEONE | |
  61390. * | 7 | ALPHA_PREMULTIPLIED | |
  61391. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  61392. * | 9 | ALPHA_INTERPOLATE | |
  61393. * | 10 | ALPHA_SCREENMODE | |
  61394. *
  61395. */
  61396. set: function (value) {
  61397. if (this._alphaMode === value) {
  61398. return;
  61399. }
  61400. this._alphaMode = value;
  61401. this.markAsDirty(Material.TextureDirtyFlag);
  61402. },
  61403. enumerable: true,
  61404. configurable: true
  61405. });
  61406. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  61407. /**
  61408. * Gets the depth pre-pass value
  61409. */
  61410. get: function () {
  61411. return this._needDepthPrePass;
  61412. },
  61413. /**
  61414. * Sets the need depth pre-pass value
  61415. */
  61416. set: function (value) {
  61417. if (this._needDepthPrePass === value) {
  61418. return;
  61419. }
  61420. this._needDepthPrePass = value;
  61421. if (this._needDepthPrePass) {
  61422. this.checkReadyOnEveryCall = true;
  61423. }
  61424. },
  61425. enumerable: true,
  61426. configurable: true
  61427. });
  61428. Object.defineProperty(Material.prototype, "fogEnabled", {
  61429. /**
  61430. * Gets the value of the fog enabled state
  61431. */
  61432. get: function () {
  61433. return this._fogEnabled;
  61434. },
  61435. /**
  61436. * Sets the state for enabling fog
  61437. */
  61438. set: function (value) {
  61439. if (this._fogEnabled === value) {
  61440. return;
  61441. }
  61442. this._fogEnabled = value;
  61443. this.markAsDirty(Material.MiscDirtyFlag);
  61444. },
  61445. enumerable: true,
  61446. configurable: true
  61447. });
  61448. Object.defineProperty(Material.prototype, "wireframe", {
  61449. /**
  61450. * Gets a value specifying if wireframe mode is enabled
  61451. */
  61452. get: function () {
  61453. switch (this._fillMode) {
  61454. case Material.WireFrameFillMode:
  61455. case Material.LineListDrawMode:
  61456. case Material.LineLoopDrawMode:
  61457. case Material.LineStripDrawMode:
  61458. return true;
  61459. }
  61460. return this._scene.forceWireframe;
  61461. },
  61462. /**
  61463. * Sets the state of wireframe mode
  61464. */
  61465. set: function (value) {
  61466. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  61467. },
  61468. enumerable: true,
  61469. configurable: true
  61470. });
  61471. Object.defineProperty(Material.prototype, "pointsCloud", {
  61472. /**
  61473. * Gets the value specifying if point clouds are enabled
  61474. */
  61475. get: function () {
  61476. switch (this._fillMode) {
  61477. case Material.PointFillMode:
  61478. case Material.PointListDrawMode:
  61479. return true;
  61480. }
  61481. return this._scene.forcePointsCloud;
  61482. },
  61483. /**
  61484. * Sets the state of point cloud mode
  61485. */
  61486. set: function (value) {
  61487. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  61488. },
  61489. enumerable: true,
  61490. configurable: true
  61491. });
  61492. Object.defineProperty(Material.prototype, "fillMode", {
  61493. /**
  61494. * Gets the material fill mode
  61495. */
  61496. get: function () {
  61497. return this._fillMode;
  61498. },
  61499. /**
  61500. * Sets the material fill mode
  61501. */
  61502. set: function (value) {
  61503. if (this._fillMode === value) {
  61504. return;
  61505. }
  61506. this._fillMode = value;
  61507. this.markAsDirty(Material.MiscDirtyFlag);
  61508. },
  61509. enumerable: true,
  61510. configurable: true
  61511. });
  61512. /**
  61513. * Returns a string representation of the current material
  61514. * @param fullDetails defines a boolean indicating which levels of logging is desired
  61515. * @returns a string with material information
  61516. */
  61517. Material.prototype.toString = function (fullDetails) {
  61518. var ret = "Name: " + this.name;
  61519. if (fullDetails) {
  61520. }
  61521. return ret;
  61522. };
  61523. /**
  61524. * Gets the class name of the material
  61525. * @returns a string with the class name of the material
  61526. */
  61527. Material.prototype.getClassName = function () {
  61528. return "Material";
  61529. };
  61530. Object.defineProperty(Material.prototype, "isFrozen", {
  61531. /**
  61532. * Specifies if updates for the material been locked
  61533. */
  61534. get: function () {
  61535. return this.checkReadyOnlyOnce;
  61536. },
  61537. enumerable: true,
  61538. configurable: true
  61539. });
  61540. /**
  61541. * Locks updates for the material
  61542. */
  61543. Material.prototype.freeze = function () {
  61544. this.checkReadyOnlyOnce = true;
  61545. };
  61546. /**
  61547. * Unlocks updates for the material
  61548. */
  61549. Material.prototype.unfreeze = function () {
  61550. this.checkReadyOnlyOnce = false;
  61551. };
  61552. /**
  61553. * Specifies if the material is ready to be used
  61554. * @param mesh defines the mesh to check
  61555. * @param useInstances specifies if instances should be used
  61556. * @returns a boolean indicating if the material is ready to be used
  61557. */
  61558. Material.prototype.isReady = function (mesh, useInstances) {
  61559. return true;
  61560. };
  61561. /**
  61562. * Specifies that the submesh is ready to be used
  61563. * @param mesh defines the mesh to check
  61564. * @param subMesh defines which submesh to check
  61565. * @param useInstances specifies that instances should be used
  61566. * @returns a boolean indicating that the submesh is ready or not
  61567. */
  61568. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  61569. return false;
  61570. };
  61571. /**
  61572. * Returns the material effect
  61573. * @returns the effect associated with the material
  61574. */
  61575. Material.prototype.getEffect = function () {
  61576. return this._effect;
  61577. };
  61578. /**
  61579. * Returns the current scene
  61580. * @returns a Scene
  61581. */
  61582. Material.prototype.getScene = function () {
  61583. return this._scene;
  61584. };
  61585. /**
  61586. * Specifies if the material will require alpha blending
  61587. * @returns a boolean specifying if alpha blending is needed
  61588. */
  61589. Material.prototype.needAlphaBlending = function () {
  61590. return (this.alpha < 1.0);
  61591. };
  61592. /**
  61593. * Specifies if the mesh will require alpha blending
  61594. * @param mesh defines the mesh to check
  61595. * @returns a boolean specifying if alpha blending is needed for the mesh
  61596. */
  61597. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  61598. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  61599. };
  61600. /**
  61601. * Specifies if this material should be rendered in alpha test mode
  61602. * @returns a boolean specifying if an alpha test is needed.
  61603. */
  61604. Material.prototype.needAlphaTesting = function () {
  61605. return false;
  61606. };
  61607. /**
  61608. * Gets the texture used for the alpha test
  61609. * @returns the texture to use for alpha testing
  61610. */
  61611. Material.prototype.getAlphaTestTexture = function () {
  61612. return null;
  61613. };
  61614. /**
  61615. * Marks the material to indicate that it needs to be re-calculated
  61616. */
  61617. Material.prototype.markDirty = function () {
  61618. this._wasPreviouslyReady = false;
  61619. };
  61620. /** @hidden */
  61621. Material.prototype._preBind = function (effect, overrideOrientation) {
  61622. if (overrideOrientation === void 0) { overrideOrientation = null; }
  61623. var engine = this._scene.getEngine();
  61624. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  61625. var reverse = orientation === Material.ClockWiseSideOrientation;
  61626. engine.enableEffect(effect ? effect : this._effect);
  61627. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  61628. return reverse;
  61629. };
  61630. /**
  61631. * Binds the material to the mesh
  61632. * @param world defines the world transformation matrix
  61633. * @param mesh defines the mesh to bind the material to
  61634. */
  61635. Material.prototype.bind = function (world, mesh) {
  61636. };
  61637. /**
  61638. * Binds the submesh to the material
  61639. * @param world defines the world transformation matrix
  61640. * @param mesh defines the mesh containing the submesh
  61641. * @param subMesh defines the submesh to bind the material to
  61642. */
  61643. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  61644. };
  61645. /**
  61646. * Binds the world matrix to the material
  61647. * @param world defines the world transformation matrix
  61648. */
  61649. Material.prototype.bindOnlyWorldMatrix = function (world) {
  61650. };
  61651. /**
  61652. * Binds the scene's uniform buffer to the effect.
  61653. * @param effect defines the effect to bind to the scene uniform buffer
  61654. * @param sceneUbo defines the uniform buffer storing scene data
  61655. */
  61656. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  61657. sceneUbo.bindToEffect(effect, "Scene");
  61658. };
  61659. /**
  61660. * Binds the view matrix to the effect
  61661. * @param effect defines the effect to bind the view matrix to
  61662. */
  61663. Material.prototype.bindView = function (effect) {
  61664. if (!this._useUBO) {
  61665. effect.setMatrix("view", this.getScene().getViewMatrix());
  61666. }
  61667. else {
  61668. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61669. }
  61670. };
  61671. /**
  61672. * Binds the view projection matrix to the effect
  61673. * @param effect defines the effect to bind the view projection matrix to
  61674. */
  61675. Material.prototype.bindViewProjection = function (effect) {
  61676. if (!this._useUBO) {
  61677. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  61678. }
  61679. else {
  61680. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61681. }
  61682. };
  61683. /**
  61684. * Specifies if material alpha testing should be turned on for the mesh
  61685. * @param mesh defines the mesh to check
  61686. */
  61687. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  61688. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  61689. };
  61690. /**
  61691. * Processes to execute after binding the material to a mesh
  61692. * @param mesh defines the rendered mesh
  61693. */
  61694. Material.prototype._afterBind = function (mesh) {
  61695. this._scene._cachedMaterial = this;
  61696. if (mesh) {
  61697. this._scene._cachedVisibility = mesh.visibility;
  61698. }
  61699. else {
  61700. this._scene._cachedVisibility = 1;
  61701. }
  61702. if (this._onBindObservable && mesh) {
  61703. this._onBindObservable.notifyObservers(mesh);
  61704. }
  61705. if (this.disableDepthWrite) {
  61706. var engine = this._scene.getEngine();
  61707. this._cachedDepthWriteState = engine.getDepthWrite();
  61708. engine.setDepthWrite(false);
  61709. }
  61710. };
  61711. /**
  61712. * Unbinds the material from the mesh
  61713. */
  61714. Material.prototype.unbind = function () {
  61715. if (this._onUnBindObservable) {
  61716. this._onUnBindObservable.notifyObservers(this);
  61717. }
  61718. if (this.disableDepthWrite) {
  61719. var engine = this._scene.getEngine();
  61720. engine.setDepthWrite(this._cachedDepthWriteState);
  61721. }
  61722. };
  61723. /**
  61724. * Gets the active textures from the material
  61725. * @returns an array of textures
  61726. */
  61727. Material.prototype.getActiveTextures = function () {
  61728. return [];
  61729. };
  61730. /**
  61731. * Specifies if the material uses a texture
  61732. * @param texture defines the texture to check against the material
  61733. * @returns a boolean specifying if the material uses the texture
  61734. */
  61735. Material.prototype.hasTexture = function (texture) {
  61736. return false;
  61737. };
  61738. /**
  61739. * Makes a duplicate of the material, and gives it a new name
  61740. * @param name defines the new name for the duplicated material
  61741. * @returns the cloned material
  61742. */
  61743. Material.prototype.clone = function (name) {
  61744. return null;
  61745. };
  61746. /**
  61747. * Gets the meshes bound to the material
  61748. * @returns an array of meshes bound to the material
  61749. */
  61750. Material.prototype.getBindedMeshes = function () {
  61751. var _this = this;
  61752. if (this.meshMap) {
  61753. var result = new Array();
  61754. for (var meshId in this.meshMap) {
  61755. var mesh = this.meshMap[meshId];
  61756. if (mesh) {
  61757. result.push(mesh);
  61758. }
  61759. }
  61760. return result;
  61761. }
  61762. else {
  61763. var meshes = this._scene.meshes;
  61764. return meshes.filter(function (mesh) { return mesh.material === _this; });
  61765. }
  61766. };
  61767. /**
  61768. * Force shader compilation
  61769. * @param mesh defines the mesh associated with this material
  61770. * @param onCompiled defines a function to execute once the material is compiled
  61771. * @param options defines the options to configure the compilation
  61772. */
  61773. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  61774. var _this = this;
  61775. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  61776. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  61777. var scene = this.getScene();
  61778. var checkReady = function () {
  61779. if (!_this._scene || !_this._scene.getEngine()) {
  61780. return;
  61781. }
  61782. if (subMesh._materialDefines) {
  61783. subMesh._materialDefines._renderId = -1;
  61784. }
  61785. var clipPlaneState = scene.clipPlane;
  61786. if (localOptions.clipPlane) {
  61787. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  61788. }
  61789. if (_this._storeEffectOnSubMeshes) {
  61790. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  61791. if (onCompiled) {
  61792. onCompiled(_this);
  61793. }
  61794. }
  61795. else {
  61796. setTimeout(checkReady, 16);
  61797. }
  61798. }
  61799. else {
  61800. if (_this.isReady()) {
  61801. if (onCompiled) {
  61802. onCompiled(_this);
  61803. }
  61804. }
  61805. else {
  61806. setTimeout(checkReady, 16);
  61807. }
  61808. }
  61809. if (localOptions.clipPlane) {
  61810. scene.clipPlane = clipPlaneState;
  61811. }
  61812. };
  61813. checkReady();
  61814. };
  61815. /**
  61816. * Force shader compilation
  61817. * @param mesh defines the mesh that will use this material
  61818. * @param options defines additional options for compiling the shaders
  61819. * @returns a promise that resolves when the compilation completes
  61820. */
  61821. Material.prototype.forceCompilationAsync = function (mesh, options) {
  61822. var _this = this;
  61823. return new Promise(function (resolve) {
  61824. _this.forceCompilation(mesh, function () {
  61825. resolve();
  61826. }, options);
  61827. });
  61828. };
  61829. /**
  61830. * Marks a define in the material to indicate that it needs to be re-computed
  61831. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  61832. */
  61833. Material.prototype.markAsDirty = function (flag) {
  61834. if (this.getScene().blockMaterialDirtyMechanism) {
  61835. return;
  61836. }
  61837. Material._DirtyCallbackArray.length = 0;
  61838. if (flag & Material.TextureDirtyFlag) {
  61839. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  61840. }
  61841. if (flag & Material.LightDirtyFlag) {
  61842. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  61843. }
  61844. if (flag & Material.FresnelDirtyFlag) {
  61845. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  61846. }
  61847. if (flag & Material.AttributesDirtyFlag) {
  61848. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  61849. }
  61850. if (flag & Material.MiscDirtyFlag) {
  61851. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  61852. }
  61853. if (Material._DirtyCallbackArray.length) {
  61854. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  61855. }
  61856. this.getScene().resetCachedMaterial();
  61857. };
  61858. /**
  61859. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  61860. * @param func defines a function which checks material defines against the submeshes
  61861. */
  61862. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  61863. if (this.getScene().blockMaterialDirtyMechanism) {
  61864. return;
  61865. }
  61866. var meshes = this.getScene().meshes;
  61867. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  61868. var mesh = meshes_1[_i];
  61869. if (!mesh.subMeshes) {
  61870. continue;
  61871. }
  61872. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  61873. var subMesh = _b[_a];
  61874. if (subMesh.getMaterial() !== this) {
  61875. continue;
  61876. }
  61877. if (!subMesh._materialDefines) {
  61878. continue;
  61879. }
  61880. func(subMesh._materialDefines);
  61881. }
  61882. }
  61883. };
  61884. /**
  61885. * Indicates that image processing needs to be re-calculated for all submeshes
  61886. */
  61887. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  61888. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  61889. };
  61890. /**
  61891. * Indicates that textures need to be re-calculated for all submeshes
  61892. */
  61893. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  61894. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  61895. };
  61896. /**
  61897. * Indicates that fresnel needs to be re-calculated for all submeshes
  61898. */
  61899. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  61900. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  61901. };
  61902. /**
  61903. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  61904. */
  61905. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  61906. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  61907. };
  61908. /**
  61909. * Indicates that lights need to be re-calculated for all submeshes
  61910. */
  61911. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  61912. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  61913. };
  61914. /**
  61915. * Indicates that attributes need to be re-calculated for all submeshes
  61916. */
  61917. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  61918. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  61919. };
  61920. /**
  61921. * Indicates that misc needs to be re-calculated for all submeshes
  61922. */
  61923. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  61924. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  61925. };
  61926. /**
  61927. * Indicates that textures and misc need to be re-calculated for all submeshes
  61928. */
  61929. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  61930. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  61931. };
  61932. /**
  61933. * Disposes the material
  61934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61937. */
  61938. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  61939. var scene = this.getScene();
  61940. // Animations
  61941. scene.stopAnimation(this);
  61942. scene.freeProcessedMaterials();
  61943. // Remove from scene
  61944. scene.removeMaterial(this);
  61945. if (notBoundToMesh !== true) {
  61946. // Remove from meshes
  61947. if (this.meshMap) {
  61948. for (var meshId in this.meshMap) {
  61949. var mesh = this.meshMap[meshId];
  61950. if (mesh) {
  61951. mesh.material = null; // will set the entry in the map to undefined
  61952. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  61953. }
  61954. }
  61955. }
  61956. else {
  61957. var meshes = scene.meshes;
  61958. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  61959. var mesh = meshes_2[_i];
  61960. if (mesh.material === this) {
  61961. mesh.material = null;
  61962. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  61963. }
  61964. }
  61965. }
  61966. }
  61967. this._uniformBuffer.dispose();
  61968. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  61969. if (forceDisposeEffect && this._effect) {
  61970. if (!this._storeEffectOnSubMeshes) {
  61971. scene.getEngine()._releaseEffect(this._effect);
  61972. }
  61973. this._effect = null;
  61974. }
  61975. // Callback
  61976. this.onDisposeObservable.notifyObservers(this);
  61977. this.onDisposeObservable.clear();
  61978. if (this._onBindObservable) {
  61979. this._onBindObservable.clear();
  61980. }
  61981. if (this._onUnBindObservable) {
  61982. this._onUnBindObservable.clear();
  61983. }
  61984. };
  61985. /** @hidden */
  61986. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  61987. if (mesh.geometry) {
  61988. var geometry = (mesh.geometry);
  61989. var scene = this.getScene();
  61990. if (this._storeEffectOnSubMeshes) {
  61991. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  61992. var subMesh = _a[_i];
  61993. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  61994. if (forceDisposeEffect && subMesh._materialEffect) {
  61995. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  61996. }
  61997. }
  61998. }
  61999. else {
  62000. geometry._releaseVertexArrayObject(this._effect);
  62001. }
  62002. }
  62003. };
  62004. /**
  62005. * Serializes this material
  62006. * @returns the serialized material object
  62007. */
  62008. Material.prototype.serialize = function () {
  62009. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62010. };
  62011. /**
  62012. * Creates a material from parsed material data
  62013. * @param parsedMaterial defines parsed material data
  62014. * @param scene defines the hosting scene
  62015. * @param rootUrl defines the root URL to use to load textures
  62016. * @returns a new material
  62017. */
  62018. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  62019. if (!parsedMaterial.customType) {
  62020. parsedMaterial.customType = "BABYLON.StandardMaterial";
  62021. }
  62022. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  62023. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  62024. if (!BABYLON.LegacyPBRMaterial) {
  62025. _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.");
  62026. return;
  62027. }
  62028. }
  62029. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  62030. return materialType.Parse(parsedMaterial, scene, rootUrl);
  62031. };
  62032. /**
  62033. * Returns the triangle fill mode
  62034. */
  62035. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  62036. /**
  62037. * Returns the wireframe mode
  62038. */
  62039. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  62040. /**
  62041. * Returns the point fill mode
  62042. */
  62043. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  62044. /**
  62045. * Returns the point list draw mode
  62046. */
  62047. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  62048. /**
  62049. * Returns the line list draw mode
  62050. */
  62051. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  62052. /**
  62053. * Returns the line loop draw mode
  62054. */
  62055. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  62056. /**
  62057. * Returns the line strip draw mode
  62058. */
  62059. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  62060. /**
  62061. * Returns the triangle strip draw mode
  62062. */
  62063. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  62064. /**
  62065. * Returns the triangle fan draw mode
  62066. */
  62067. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  62068. /**
  62069. * Stores the clock-wise side orientation
  62070. */
  62071. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  62072. /**
  62073. * Stores the counter clock-wise side orientation
  62074. */
  62075. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  62076. /**
  62077. * The dirty texture flag value
  62078. */
  62079. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  62080. /**
  62081. * The dirty light flag value
  62082. */
  62083. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  62084. /**
  62085. * The dirty fresnel flag value
  62086. */
  62087. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  62088. /**
  62089. * The dirty attribute flag value
  62090. */
  62091. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  62092. /**
  62093. * The dirty misc flag value
  62094. */
  62095. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  62096. /**
  62097. * The all dirty flag value
  62098. */
  62099. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  62100. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  62101. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  62102. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  62103. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  62104. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  62105. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  62106. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  62107. Material._FresnelDirtyCallBack(defines);
  62108. Material._MiscDirtyCallBack(defines);
  62109. };
  62110. Material._TextureAndMiscDirtyCallBack = function (defines) {
  62111. Material._TextureDirtyCallBack(defines);
  62112. Material._MiscDirtyCallBack(defines);
  62113. };
  62114. Material._DirtyCallbackArray = [];
  62115. Material._RunDirtyCallBacks = function (defines) {
  62116. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  62117. var cb = _a[_i];
  62118. cb(defines);
  62119. }
  62120. };
  62121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62123. ], Material.prototype, "id", void 0);
  62124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62126. ], Material.prototype, "uniqueId", void 0);
  62127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62129. ], Material.prototype, "name", void 0);
  62130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62132. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  62133. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62135. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  62136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62138. ], Material.prototype, "state", void 0);
  62139. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  62141. ], Material.prototype, "_alpha", void 0);
  62142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  62144. ], Material.prototype, "_backFaceCulling", void 0);
  62145. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62147. ], Material.prototype, "sideOrientation", void 0);
  62148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  62150. ], Material.prototype, "_alphaMode", void 0);
  62151. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62153. ], Material.prototype, "_needDepthPrePass", void 0);
  62154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62156. ], Material.prototype, "disableDepthWrite", void 0);
  62157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62159. ], Material.prototype, "forceDepthWrite", void 0);
  62160. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62161. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62162. ], Material.prototype, "separateCullingPass", void 0);
  62163. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  62165. ], Material.prototype, "_fogEnabled", void 0);
  62166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62168. ], Material.prototype, "pointSize", void 0);
  62169. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62170. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62171. ], Material.prototype, "zOffset", void 0);
  62172. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62173. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62174. ], Material.prototype, "wireframe", null);
  62175. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62177. ], Material.prototype, "pointsCloud", null);
  62178. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62180. ], Material.prototype, "fillMode", null);
  62181. return Material;
  62182. }());
  62183. /***/ }),
  62184. /***/ "./Materials/materialDefines.ts":
  62185. /*!**************************************!*\
  62186. !*** ./Materials/materialDefines.ts ***!
  62187. \**************************************/
  62188. /*! exports provided: MaterialDefines */
  62189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62190. "use strict";
  62191. __webpack_require__.r(__webpack_exports__);
  62192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  62193. /**
  62194. * Manages the defines for the Material
  62195. */
  62196. var MaterialDefines = /** @class */ (function () {
  62197. function MaterialDefines() {
  62198. this._isDirty = true;
  62199. /** @hidden */
  62200. this._areLightsDirty = true;
  62201. /** @hidden */
  62202. this._areAttributesDirty = true;
  62203. /** @hidden */
  62204. this._areTexturesDirty = true;
  62205. /** @hidden */
  62206. this._areFresnelDirty = true;
  62207. /** @hidden */
  62208. this._areMiscDirty = true;
  62209. /** @hidden */
  62210. this._areImageProcessingDirty = true;
  62211. /** @hidden */
  62212. this._normals = false;
  62213. /** @hidden */
  62214. this._uvs = false;
  62215. /** @hidden */
  62216. this._needNormals = false;
  62217. /** @hidden */
  62218. this._needUVs = false;
  62219. }
  62220. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  62221. /**
  62222. * Specifies if the material needs to be re-calculated
  62223. */
  62224. get: function () {
  62225. return this._isDirty;
  62226. },
  62227. enumerable: true,
  62228. configurable: true
  62229. });
  62230. /**
  62231. * Marks the material to indicate that it has been re-calculated
  62232. */
  62233. MaterialDefines.prototype.markAsProcessed = function () {
  62234. this._isDirty = false;
  62235. this._areAttributesDirty = false;
  62236. this._areTexturesDirty = false;
  62237. this._areFresnelDirty = false;
  62238. this._areLightsDirty = false;
  62239. this._areMiscDirty = false;
  62240. this._areImageProcessingDirty = false;
  62241. };
  62242. /**
  62243. * Marks the material to indicate that it needs to be re-calculated
  62244. */
  62245. MaterialDefines.prototype.markAsUnprocessed = function () {
  62246. this._isDirty = true;
  62247. };
  62248. /**
  62249. * Marks the material to indicate all of its defines need to be re-calculated
  62250. */
  62251. MaterialDefines.prototype.markAllAsDirty = function () {
  62252. this._areTexturesDirty = true;
  62253. this._areAttributesDirty = true;
  62254. this._areLightsDirty = true;
  62255. this._areFresnelDirty = true;
  62256. this._areMiscDirty = true;
  62257. this._areImageProcessingDirty = true;
  62258. this._isDirty = true;
  62259. };
  62260. /**
  62261. * Marks the material to indicate that image processing needs to be re-calculated
  62262. */
  62263. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  62264. this._areImageProcessingDirty = true;
  62265. this._isDirty = true;
  62266. };
  62267. /**
  62268. * Marks the material to indicate the lights need to be re-calculated
  62269. */
  62270. MaterialDefines.prototype.markAsLightDirty = function () {
  62271. this._areLightsDirty = true;
  62272. this._isDirty = true;
  62273. };
  62274. /**
  62275. * Marks the attribute state as changed
  62276. */
  62277. MaterialDefines.prototype.markAsAttributesDirty = function () {
  62278. this._areAttributesDirty = true;
  62279. this._isDirty = true;
  62280. };
  62281. /**
  62282. * Marks the texture state as changed
  62283. */
  62284. MaterialDefines.prototype.markAsTexturesDirty = function () {
  62285. this._areTexturesDirty = true;
  62286. this._isDirty = true;
  62287. };
  62288. /**
  62289. * Marks the fresnel state as changed
  62290. */
  62291. MaterialDefines.prototype.markAsFresnelDirty = function () {
  62292. this._areFresnelDirty = true;
  62293. this._isDirty = true;
  62294. };
  62295. /**
  62296. * Marks the misc state as changed
  62297. */
  62298. MaterialDefines.prototype.markAsMiscDirty = function () {
  62299. this._areMiscDirty = true;
  62300. this._isDirty = true;
  62301. };
  62302. /**
  62303. * Rebuilds the material defines
  62304. */
  62305. MaterialDefines.prototype.rebuild = function () {
  62306. if (this._keys) {
  62307. delete this._keys;
  62308. }
  62309. this._keys = [];
  62310. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  62311. var key = _a[_i];
  62312. if (key[0] === "_") {
  62313. continue;
  62314. }
  62315. this._keys.push(key);
  62316. }
  62317. };
  62318. /**
  62319. * Specifies if two material defines are equal
  62320. * @param other - A material define instance to compare to
  62321. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62322. */
  62323. MaterialDefines.prototype.isEqual = function (other) {
  62324. if (this._keys.length !== other._keys.length) {
  62325. return false;
  62326. }
  62327. for (var index = 0; index < this._keys.length; index++) {
  62328. var prop = this._keys[index];
  62329. if (this[prop] !== other[prop]) {
  62330. return false;
  62331. }
  62332. }
  62333. return true;
  62334. };
  62335. /**
  62336. * Clones this instance's defines to another instance
  62337. * @param other - material defines to clone values to
  62338. */
  62339. MaterialDefines.prototype.cloneTo = function (other) {
  62340. if (this._keys.length !== other._keys.length) {
  62341. other._keys = this._keys.slice(0);
  62342. }
  62343. for (var index = 0; index < this._keys.length; index++) {
  62344. var prop = this._keys[index];
  62345. other[prop] = this[prop];
  62346. }
  62347. };
  62348. /**
  62349. * Resets the material define values
  62350. */
  62351. MaterialDefines.prototype.reset = function () {
  62352. for (var index = 0; index < this._keys.length; index++) {
  62353. var prop = this._keys[index];
  62354. var type = typeof this[prop];
  62355. switch (type) {
  62356. case "number":
  62357. this[prop] = 0;
  62358. break;
  62359. case "string":
  62360. this[prop] = "";
  62361. break;
  62362. default:
  62363. this[prop] = false;
  62364. break;
  62365. }
  62366. }
  62367. };
  62368. /**
  62369. * Converts the material define values to a string
  62370. * @returns - String of material define information
  62371. */
  62372. MaterialDefines.prototype.toString = function () {
  62373. var result = "";
  62374. for (var index = 0; index < this._keys.length; index++) {
  62375. var prop = this._keys[index];
  62376. var value = this[prop];
  62377. var type = typeof value;
  62378. switch (type) {
  62379. case "number":
  62380. case "string":
  62381. result += "#define " + prop + " " + value + "\n";
  62382. break;
  62383. default:
  62384. if (value) {
  62385. result += "#define " + prop + "\n";
  62386. }
  62387. break;
  62388. }
  62389. }
  62390. return result;
  62391. };
  62392. return MaterialDefines;
  62393. }());
  62394. /***/ }),
  62395. /***/ "./Materials/materialFlags.ts":
  62396. /*!************************************!*\
  62397. !*** ./Materials/materialFlags.ts ***!
  62398. \************************************/
  62399. /*! exports provided: MaterialFlags */
  62400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62401. "use strict";
  62402. __webpack_require__.r(__webpack_exports__);
  62403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  62404. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  62405. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62406. /**
  62407. * This groups all the flags used to control the materials channel.
  62408. */
  62409. var MaterialFlags = /** @class */ (function () {
  62410. function MaterialFlags() {
  62411. }
  62412. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  62413. /**
  62414. * Are diffuse textures enabled in the application.
  62415. */
  62416. get: function () {
  62417. return this._DiffuseTextureEnabled;
  62418. },
  62419. set: function (value) {
  62420. if (this._DiffuseTextureEnabled === value) {
  62421. return;
  62422. }
  62423. this._DiffuseTextureEnabled = value;
  62424. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62425. },
  62426. enumerable: true,
  62427. configurable: true
  62428. });
  62429. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  62430. /**
  62431. * Are ambient textures enabled in the application.
  62432. */
  62433. get: function () {
  62434. return this._AmbientTextureEnabled;
  62435. },
  62436. set: function (value) {
  62437. if (this._AmbientTextureEnabled === value) {
  62438. return;
  62439. }
  62440. this._AmbientTextureEnabled = value;
  62441. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62442. },
  62443. enumerable: true,
  62444. configurable: true
  62445. });
  62446. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  62447. /**
  62448. * Are opacity textures enabled in the application.
  62449. */
  62450. get: function () {
  62451. return this._OpacityTextureEnabled;
  62452. },
  62453. set: function (value) {
  62454. if (this._OpacityTextureEnabled === value) {
  62455. return;
  62456. }
  62457. this._OpacityTextureEnabled = value;
  62458. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62459. },
  62460. enumerable: true,
  62461. configurable: true
  62462. });
  62463. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  62464. /**
  62465. * Are reflection textures enabled in the application.
  62466. */
  62467. get: function () {
  62468. return this._ReflectionTextureEnabled;
  62469. },
  62470. set: function (value) {
  62471. if (this._ReflectionTextureEnabled === value) {
  62472. return;
  62473. }
  62474. this._ReflectionTextureEnabled = value;
  62475. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62476. },
  62477. enumerable: true,
  62478. configurable: true
  62479. });
  62480. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  62481. /**
  62482. * Are emissive textures enabled in the application.
  62483. */
  62484. get: function () {
  62485. return this._EmissiveTextureEnabled;
  62486. },
  62487. set: function (value) {
  62488. if (this._EmissiveTextureEnabled === value) {
  62489. return;
  62490. }
  62491. this._EmissiveTextureEnabled = value;
  62492. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62493. },
  62494. enumerable: true,
  62495. configurable: true
  62496. });
  62497. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  62498. /**
  62499. * Are specular textures enabled in the application.
  62500. */
  62501. get: function () {
  62502. return this._SpecularTextureEnabled;
  62503. },
  62504. set: function (value) {
  62505. if (this._SpecularTextureEnabled === value) {
  62506. return;
  62507. }
  62508. this._SpecularTextureEnabled = value;
  62509. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62510. },
  62511. enumerable: true,
  62512. configurable: true
  62513. });
  62514. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  62515. /**
  62516. * Are bump textures enabled in the application.
  62517. */
  62518. get: function () {
  62519. return this._BumpTextureEnabled;
  62520. },
  62521. set: function (value) {
  62522. if (this._BumpTextureEnabled === value) {
  62523. return;
  62524. }
  62525. this._BumpTextureEnabled = value;
  62526. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62527. },
  62528. enumerable: true,
  62529. configurable: true
  62530. });
  62531. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  62532. /**
  62533. * Are lightmap textures enabled in the application.
  62534. */
  62535. get: function () {
  62536. return this._LightmapTextureEnabled;
  62537. },
  62538. set: function (value) {
  62539. if (this._LightmapTextureEnabled === value) {
  62540. return;
  62541. }
  62542. this._LightmapTextureEnabled = value;
  62543. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62544. },
  62545. enumerable: true,
  62546. configurable: true
  62547. });
  62548. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  62549. /**
  62550. * Are refraction textures enabled in the application.
  62551. */
  62552. get: function () {
  62553. return this._RefractionTextureEnabled;
  62554. },
  62555. set: function (value) {
  62556. if (this._RefractionTextureEnabled === value) {
  62557. return;
  62558. }
  62559. this._RefractionTextureEnabled = value;
  62560. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62561. },
  62562. enumerable: true,
  62563. configurable: true
  62564. });
  62565. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  62566. /**
  62567. * Are color grading textures enabled in the application.
  62568. */
  62569. get: function () {
  62570. return this._ColorGradingTextureEnabled;
  62571. },
  62572. set: function (value) {
  62573. if (this._ColorGradingTextureEnabled === value) {
  62574. return;
  62575. }
  62576. this._ColorGradingTextureEnabled = value;
  62577. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62578. },
  62579. enumerable: true,
  62580. configurable: true
  62581. });
  62582. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  62583. /**
  62584. * Are fresnels enabled in the application.
  62585. */
  62586. get: function () {
  62587. return this._FresnelEnabled;
  62588. },
  62589. set: function (value) {
  62590. if (this._FresnelEnabled === value) {
  62591. return;
  62592. }
  62593. this._FresnelEnabled = value;
  62594. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  62595. },
  62596. enumerable: true,
  62597. configurable: true
  62598. });
  62599. // Flags used to enable or disable a type of texture for all Standard Materials
  62600. MaterialFlags._DiffuseTextureEnabled = true;
  62601. MaterialFlags._AmbientTextureEnabled = true;
  62602. MaterialFlags._OpacityTextureEnabled = true;
  62603. MaterialFlags._ReflectionTextureEnabled = true;
  62604. MaterialFlags._EmissiveTextureEnabled = true;
  62605. MaterialFlags._SpecularTextureEnabled = true;
  62606. MaterialFlags._BumpTextureEnabled = true;
  62607. MaterialFlags._LightmapTextureEnabled = true;
  62608. MaterialFlags._RefractionTextureEnabled = true;
  62609. MaterialFlags._ColorGradingTextureEnabled = true;
  62610. MaterialFlags._FresnelEnabled = true;
  62611. return MaterialFlags;
  62612. }());
  62613. /***/ }),
  62614. /***/ "./Materials/materialHelper.ts":
  62615. /*!*************************************!*\
  62616. !*** ./Materials/materialHelper.ts ***!
  62617. \*************************************/
  62618. /*! exports provided: MaterialHelper */
  62619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62620. "use strict";
  62621. __webpack_require__.r(__webpack_exports__);
  62622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  62623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62624. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  62625. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62626. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62627. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  62628. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  62629. /**
  62630. * "Static Class" containing the most commonly used helper while dealing with material for
  62631. * rendering purpose.
  62632. *
  62633. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  62634. *
  62635. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  62636. */
  62637. var MaterialHelper = /** @class */ (function () {
  62638. function MaterialHelper() {
  62639. }
  62640. /**
  62641. * Bind the current view position to an effect.
  62642. * @param effect The effect to be bound
  62643. * @param scene The scene the eyes position is used from
  62644. */
  62645. MaterialHelper.BindEyePosition = function (effect, scene) {
  62646. if (scene._forcedViewPosition) {
  62647. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  62648. return;
  62649. }
  62650. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  62651. };
  62652. /**
  62653. * Helps preparing the defines values about the UVs in used in the effect.
  62654. * UVs are shared as much as we can accross channels in the shaders.
  62655. * @param texture The texture we are preparing the UVs for
  62656. * @param defines The defines to update
  62657. * @param key The channel key "diffuse", "specular"... used in the shader
  62658. */
  62659. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  62660. defines._needUVs = true;
  62661. defines[key] = true;
  62662. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  62663. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  62664. if (texture.coordinatesIndex === 0) {
  62665. defines["MAINUV1"] = true;
  62666. }
  62667. else {
  62668. defines["MAINUV2"] = true;
  62669. }
  62670. }
  62671. else {
  62672. defines[key + "DIRECTUV"] = 0;
  62673. }
  62674. };
  62675. /**
  62676. * Binds a texture matrix value to its corrsponding uniform
  62677. * @param texture The texture to bind the matrix for
  62678. * @param uniformBuffer The uniform buffer receivin the data
  62679. * @param key The channel key "diffuse", "specular"... used in the shader
  62680. */
  62681. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  62682. var matrix = texture.getTextureMatrix();
  62683. if (!matrix.isIdentityAs3x2()) {
  62684. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  62685. }
  62686. };
  62687. /**
  62688. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  62689. * @param mesh defines the current mesh
  62690. * @param scene defines the current scene
  62691. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  62692. * @param pointsCloud defines if point cloud rendering has to be turned on
  62693. * @param fogEnabled defines if fog has to be turned on
  62694. * @param alphaTest defines if alpha testing has to be turned on
  62695. * @param defines defines the current list of defines
  62696. */
  62697. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  62698. if (defines._areMiscDirty) {
  62699. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  62700. defines["POINTSIZE"] = pointsCloud;
  62701. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  62702. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  62703. defines["ALPHATEST"] = alphaTest;
  62704. }
  62705. };
  62706. /**
  62707. * Helper used to prepare the list of defines associated with frame values for shader compilation
  62708. * @param scene defines the current scene
  62709. * @param engine defines the current engine
  62710. * @param defines specifies the list of active defines
  62711. * @param useInstances defines if instances have to be turned on
  62712. * @param useClipPlane defines if clip plane have to be turned on
  62713. */
  62714. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  62715. if (useClipPlane === void 0) { useClipPlane = null; }
  62716. var changed = false;
  62717. var useClipPlane1 = false;
  62718. var useClipPlane2 = false;
  62719. var useClipPlane3 = false;
  62720. var useClipPlane4 = false;
  62721. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  62722. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  62723. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  62724. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  62725. if (defines["CLIPPLANE"] !== useClipPlane1) {
  62726. defines["CLIPPLANE"] = useClipPlane1;
  62727. changed = true;
  62728. }
  62729. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  62730. defines["CLIPPLANE2"] = useClipPlane2;
  62731. changed = true;
  62732. }
  62733. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  62734. defines["CLIPPLANE3"] = useClipPlane3;
  62735. changed = true;
  62736. }
  62737. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  62738. defines["CLIPPLANE4"] = useClipPlane4;
  62739. changed = true;
  62740. }
  62741. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  62742. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  62743. changed = true;
  62744. }
  62745. if (defines["INSTANCES"] !== useInstances) {
  62746. defines["INSTANCES"] = useInstances;
  62747. changed = true;
  62748. }
  62749. if (changed) {
  62750. defines.markAsUnprocessed();
  62751. }
  62752. };
  62753. /**
  62754. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  62755. * @param mesh The mesh containing the geometry data we will draw
  62756. * @param defines The defines to update
  62757. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  62758. * @param useBones Precise whether bones should be used or not (override mesh info)
  62759. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  62760. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  62761. * @returns false if defines are considered not dirty and have not been checked
  62762. */
  62763. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  62764. if (useMorphTargets === void 0) { useMorphTargets = false; }
  62765. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  62766. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  62767. return false;
  62768. }
  62769. defines._normals = defines._needNormals;
  62770. defines._uvs = defines._needUVs;
  62771. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  62772. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  62773. defines["TANGENT"] = true;
  62774. }
  62775. if (defines._needUVs) {
  62776. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  62777. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  62778. }
  62779. else {
  62780. defines["UV1"] = false;
  62781. defines["UV2"] = false;
  62782. }
  62783. if (useVertexColor) {
  62784. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  62785. defines["VERTEXCOLOR"] = hasVertexColors;
  62786. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  62787. }
  62788. if (useBones) {
  62789. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  62790. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  62791. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  62792. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  62793. defines["BONETEXTURE"] = true;
  62794. }
  62795. else {
  62796. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  62797. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  62798. }
  62799. }
  62800. else {
  62801. defines["NUM_BONE_INFLUENCERS"] = 0;
  62802. defines["BonesPerMesh"] = 0;
  62803. }
  62804. }
  62805. if (useMorphTargets) {
  62806. var manager = mesh.morphTargetManager;
  62807. if (manager) {
  62808. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  62809. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  62810. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  62811. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  62812. }
  62813. else {
  62814. defines["MORPHTARGETS_TANGENT"] = false;
  62815. defines["MORPHTARGETS_NORMAL"] = false;
  62816. defines["MORPHTARGETS"] = false;
  62817. defines["NUM_MORPH_INFLUENCERS"] = 0;
  62818. }
  62819. }
  62820. return true;
  62821. };
  62822. /**
  62823. * Prepares the defines related to the light information passed in parameter
  62824. * @param scene The scene we are intending to draw
  62825. * @param mesh The mesh the effect is compiling for
  62826. * @param defines The defines to update
  62827. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  62828. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  62829. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  62830. * @returns true if normals will be required for the rest of the effect
  62831. */
  62832. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  62833. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  62834. if (disableLighting === void 0) { disableLighting = false; }
  62835. if (!defines._areLightsDirty) {
  62836. return defines._needNormals;
  62837. }
  62838. var lightIndex = 0;
  62839. var needNormals = false;
  62840. var needRebuild = false;
  62841. var lightmapMode = false;
  62842. var shadowEnabled = false;
  62843. var specularEnabled = false;
  62844. if (scene.lightsEnabled && !disableLighting) {
  62845. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  62846. var light = _a[_i];
  62847. needNormals = true;
  62848. if (defines["LIGHT" + lightIndex] === undefined) {
  62849. needRebuild = true;
  62850. }
  62851. defines["LIGHT" + lightIndex] = true;
  62852. defines["SPOTLIGHT" + lightIndex] = false;
  62853. defines["HEMILIGHT" + lightIndex] = false;
  62854. defines["POINTLIGHT" + lightIndex] = false;
  62855. defines["DIRLIGHT" + lightIndex] = false;
  62856. light.prepareLightSpecificDefines(defines, lightIndex);
  62857. // FallOff.
  62858. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  62859. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  62860. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  62861. switch (light.falloffType) {
  62862. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  62863. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  62864. break;
  62865. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  62866. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  62867. break;
  62868. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  62869. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  62870. break;
  62871. }
  62872. // Specular
  62873. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  62874. specularEnabled = true;
  62875. }
  62876. // Shadows
  62877. defines["SHADOW" + lightIndex] = false;
  62878. defines["SHADOWPCF" + lightIndex] = false;
  62879. defines["SHADOWPCSS" + lightIndex] = false;
  62880. defines["SHADOWPOISSON" + lightIndex] = false;
  62881. defines["SHADOWESM" + lightIndex] = false;
  62882. defines["SHADOWCUBE" + lightIndex] = false;
  62883. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  62884. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  62885. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  62886. var shadowGenerator = light.getShadowGenerator();
  62887. if (shadowGenerator) {
  62888. var shadowMap = shadowGenerator.getShadowMap();
  62889. if (shadowMap) {
  62890. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  62891. shadowEnabled = true;
  62892. shadowGenerator.prepareDefines(defines, lightIndex);
  62893. }
  62894. }
  62895. }
  62896. }
  62897. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  62898. lightmapMode = true;
  62899. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  62900. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  62901. }
  62902. else {
  62903. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  62904. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  62905. }
  62906. lightIndex++;
  62907. if (lightIndex === maxSimultaneousLights) {
  62908. break;
  62909. }
  62910. }
  62911. }
  62912. defines["SPECULARTERM"] = specularEnabled;
  62913. defines["SHADOWS"] = shadowEnabled;
  62914. // Resetting all other lights if any
  62915. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  62916. if (defines["LIGHT" + index] !== undefined) {
  62917. defines["LIGHT" + index] = false;
  62918. defines["HEMILIGHT" + lightIndex] = false;
  62919. defines["POINTLIGHT" + lightIndex] = false;
  62920. defines["DIRLIGHT" + lightIndex] = false;
  62921. defines["SPOTLIGHT" + lightIndex] = false;
  62922. defines["SHADOW" + lightIndex] = false;
  62923. }
  62924. }
  62925. var caps = scene.getEngine().getCaps();
  62926. if (defines["SHADOWFLOAT"] === undefined) {
  62927. needRebuild = true;
  62928. }
  62929. defines["SHADOWFLOAT"] = shadowEnabled &&
  62930. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  62931. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  62932. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  62933. if (needRebuild) {
  62934. defines.rebuild();
  62935. }
  62936. return needNormals;
  62937. };
  62938. /**
  62939. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  62940. * that won t be acctive due to defines being turned off.
  62941. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  62942. * @param samplersList The samplers list
  62943. * @param defines The defines helping in the list generation
  62944. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  62945. */
  62946. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  62947. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  62948. var uniformsList;
  62949. var uniformBuffersList = null;
  62950. if (uniformsListOrOptions.uniformsNames) {
  62951. var options = uniformsListOrOptions;
  62952. uniformsList = options.uniformsNames;
  62953. uniformBuffersList = options.uniformBuffersNames;
  62954. samplersList = options.samplers;
  62955. defines = options.defines;
  62956. maxSimultaneousLights = options.maxSimultaneousLights;
  62957. }
  62958. else {
  62959. uniformsList = uniformsListOrOptions;
  62960. if (!samplersList) {
  62961. samplersList = [];
  62962. }
  62963. }
  62964. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  62965. if (!defines["LIGHT" + lightIndex]) {
  62966. break;
  62967. }
  62968. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  62969. if (uniformBuffersList) {
  62970. uniformBuffersList.push("Light" + lightIndex);
  62971. }
  62972. samplersList.push("shadowSampler" + lightIndex);
  62973. samplersList.push("depthSampler" + lightIndex);
  62974. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  62975. samplersList.push("projectionLightSampler" + lightIndex);
  62976. uniformsList.push("textureProjectionMatrix" + lightIndex);
  62977. }
  62978. }
  62979. if (defines["NUM_MORPH_INFLUENCERS"]) {
  62980. uniformsList.push("morphTargetInfluences");
  62981. }
  62982. };
  62983. /**
  62984. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  62985. * @param defines The defines to update while falling back
  62986. * @param fallbacks The authorized effect fallbacks
  62987. * @param maxSimultaneousLights The maximum number of lights allowed
  62988. * @param rank the current rank of the Effect
  62989. * @returns The newly affected rank
  62990. */
  62991. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  62992. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  62993. if (rank === void 0) { rank = 0; }
  62994. var lightFallbackRank = 0;
  62995. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  62996. if (!defines["LIGHT" + lightIndex]) {
  62997. break;
  62998. }
  62999. if (lightIndex > 0) {
  63000. lightFallbackRank = rank + lightIndex;
  63001. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  63002. }
  63003. if (!defines["SHADOWS"]) {
  63004. if (defines["SHADOW" + lightIndex]) {
  63005. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  63006. }
  63007. if (defines["SHADOWPCF" + lightIndex]) {
  63008. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  63009. }
  63010. if (defines["SHADOWPCSS" + lightIndex]) {
  63011. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  63012. }
  63013. if (defines["SHADOWPOISSON" + lightIndex]) {
  63014. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  63015. }
  63016. if (defines["SHADOWESM" + lightIndex]) {
  63017. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  63018. }
  63019. }
  63020. }
  63021. return lightFallbackRank++;
  63022. };
  63023. /**
  63024. * Prepares the list of attributes required for morph targets according to the effect defines.
  63025. * @param attribs The current list of supported attribs
  63026. * @param mesh The mesh to prepare the morph targets attributes for
  63027. * @param defines The current Defines of the effect
  63028. */
  63029. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  63030. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  63031. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  63032. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  63033. var manager = mesh.morphTargetManager;
  63034. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  63035. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  63036. for (var index = 0; index < influencers; index++) {
  63037. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  63038. if (normal) {
  63039. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  63040. }
  63041. if (tangent) {
  63042. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  63043. }
  63044. if (attribs.length > maxAttributesCount) {
  63045. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  63046. }
  63047. }
  63048. }
  63049. };
  63050. /**
  63051. * Prepares the list of attributes required for bones according to the effect defines.
  63052. * @param attribs The current list of supported attribs
  63053. * @param mesh The mesh to prepare the bones attributes for
  63054. * @param defines The current Defines of the effect
  63055. * @param fallbacks The current efffect fallback strategy
  63056. */
  63057. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  63058. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  63059. fallbacks.addCPUSkinningFallback(0, mesh);
  63060. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  63061. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  63062. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  63063. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  63064. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  63065. }
  63066. }
  63067. };
  63068. /**
  63069. * Prepares the list of attributes required for instances according to the effect defines.
  63070. * @param attribs The current list of supported attribs
  63071. * @param defines The current Defines of the effect
  63072. */
  63073. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  63074. if (defines["INSTANCES"]) {
  63075. attribs.push("world0");
  63076. attribs.push("world1");
  63077. attribs.push("world2");
  63078. attribs.push("world3");
  63079. }
  63080. };
  63081. /**
  63082. * Binds the light shadow information to the effect for the given mesh.
  63083. * @param light The light containing the generator
  63084. * @param scene The scene the lights belongs to
  63085. * @param mesh The mesh we are binding the information to render
  63086. * @param lightIndex The light index in the effect used to render the mesh
  63087. * @param effect The effect we are binding the data to
  63088. */
  63089. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  63090. if (light.shadowEnabled && mesh.receiveShadows) {
  63091. var shadowGenerator = light.getShadowGenerator();
  63092. if (shadowGenerator) {
  63093. shadowGenerator.bindShadowLight(lightIndex, effect);
  63094. }
  63095. }
  63096. };
  63097. /**
  63098. * Binds the light information to the effect.
  63099. * @param light The light containing the generator
  63100. * @param effect The effect we are binding the data to
  63101. * @param lightIndex The light index in the effect used to render
  63102. */
  63103. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  63104. light.transferToEffect(effect, lightIndex + "");
  63105. };
  63106. /**
  63107. * Binds the lights information from the scene to the effect for the given mesh.
  63108. * @param scene The scene the lights belongs to
  63109. * @param mesh The mesh we are binding the information to render
  63110. * @param effect The effect we are binding the data to
  63111. * @param defines The generated defines for the effect
  63112. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  63113. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  63114. */
  63115. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  63116. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63117. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  63118. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  63119. for (var i = 0; i < len; i++) {
  63120. var light = mesh._lightSources[i];
  63121. var iAsString = i.toString();
  63122. var scaledIntensity = light.getScaledIntensity();
  63123. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  63124. MaterialHelper.BindLightProperties(light, effect, i);
  63125. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  63126. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  63127. if (defines["SPECULARTERM"]) {
  63128. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  63129. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  63130. }
  63131. // Shadows
  63132. if (scene.shadowsEnabled) {
  63133. this.BindLightShadow(light, mesh, iAsString, effect);
  63134. }
  63135. light._uniformBuffer.update();
  63136. }
  63137. };
  63138. /**
  63139. * Binds the fog information from the scene to the effect for the given mesh.
  63140. * @param scene The scene the lights belongs to
  63141. * @param mesh The mesh we are binding the information to render
  63142. * @param effect The effect we are binding the data to
  63143. * @param linearSpace Defines if the fog effect is applied in linear space
  63144. */
  63145. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  63146. if (linearSpace === void 0) { linearSpace = false; }
  63147. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  63148. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  63149. // Convert fog color to linear space if used in a linear space computed shader.
  63150. if (linearSpace) {
  63151. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  63152. effect.setColor3("vFogColor", this._tempFogColor);
  63153. }
  63154. else {
  63155. effect.setColor3("vFogColor", scene.fogColor);
  63156. }
  63157. }
  63158. };
  63159. /**
  63160. * Binds the bones information from the mesh to the effect.
  63161. * @param mesh The mesh we are binding the information to render
  63162. * @param effect The effect we are binding the data to
  63163. */
  63164. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  63165. if (!effect || !mesh) {
  63166. return;
  63167. }
  63168. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  63169. mesh.computeBonesUsingShaders = false;
  63170. }
  63171. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63172. var skeleton = mesh.skeleton;
  63173. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  63174. var boneTexture = skeleton.getTransformMatrixTexture();
  63175. effect.setTexture("boneSampler", boneTexture);
  63176. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  63177. }
  63178. else {
  63179. var matrices = skeleton.getTransformMatrices(mesh);
  63180. if (matrices) {
  63181. effect.setMatrices("mBones", matrices);
  63182. }
  63183. }
  63184. }
  63185. };
  63186. /**
  63187. * Binds the morph targets information from the mesh to the effect.
  63188. * @param abstractMesh The mesh we are binding the information to render
  63189. * @param effect The effect we are binding the data to
  63190. */
  63191. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  63192. var manager = abstractMesh.morphTargetManager;
  63193. if (!abstractMesh || !manager) {
  63194. return;
  63195. }
  63196. effect.setFloatArray("morphTargetInfluences", manager.influences);
  63197. };
  63198. /**
  63199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  63200. * @param defines The generated defines used in the effect
  63201. * @param effect The effect we are binding the data to
  63202. * @param scene The scene we are willing to render with logarithmic scale for
  63203. */
  63204. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  63205. if (defines["LOGARITHMICDEPTH"]) {
  63206. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  63207. }
  63208. };
  63209. /**
  63210. * Binds the clip plane information from the scene to the effect.
  63211. * @param scene The scene the clip plane information are extracted from
  63212. * @param effect The effect we are binding the data to
  63213. */
  63214. MaterialHelper.BindClipPlane = function (effect, scene) {
  63215. if (scene.clipPlane) {
  63216. var clipPlane = scene.clipPlane;
  63217. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63218. }
  63219. if (scene.clipPlane2) {
  63220. var clipPlane = scene.clipPlane2;
  63221. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63222. }
  63223. if (scene.clipPlane3) {
  63224. var clipPlane = scene.clipPlane3;
  63225. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63226. }
  63227. if (scene.clipPlane4) {
  63228. var clipPlane = scene.clipPlane4;
  63229. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63230. }
  63231. };
  63232. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  63233. return MaterialHelper;
  63234. }());
  63235. /***/ }),
  63236. /***/ "./Materials/multiMaterial.ts":
  63237. /*!************************************!*\
  63238. !*** ./Materials/multiMaterial.ts ***!
  63239. \************************************/
  63240. /*! exports provided: MultiMaterial */
  63241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63242. "use strict";
  63243. __webpack_require__.r(__webpack_exports__);
  63244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  63245. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63246. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63247. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  63248. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63249. /**
  63250. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63251. * separate meshes. This can be use to improve performances.
  63252. * @see http://doc.babylonjs.com/how_to/multi_materials
  63253. */
  63254. var MultiMaterial = /** @class */ (function (_super) {
  63255. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  63256. /**
  63257. * Instantiates a new Multi Material
  63258. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63259. * separate meshes. This can be use to improve performances.
  63260. * @see http://doc.babylonjs.com/how_to/multi_materials
  63261. * @param name Define the name in the scene
  63262. * @param scene Define the scene the material belongs to
  63263. */
  63264. function MultiMaterial(name, scene) {
  63265. var _this = _super.call(this, name, scene, true) || this;
  63266. scene.multiMaterials.push(_this);
  63267. _this.subMaterials = new Array();
  63268. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  63269. return _this;
  63270. }
  63271. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  63272. /**
  63273. * Gets or Sets the list of Materials used within the multi material.
  63274. * They need to be ordered according to the submeshes order in the associated mesh
  63275. */
  63276. get: function () {
  63277. return this._subMaterials;
  63278. },
  63279. set: function (value) {
  63280. this._subMaterials = value;
  63281. this._hookArray(value);
  63282. },
  63283. enumerable: true,
  63284. configurable: true
  63285. });
  63286. /**
  63287. * Function used to align with Node.getChildren()
  63288. * @returns the list of Materials used within the multi material
  63289. */
  63290. MultiMaterial.prototype.getChildren = function () {
  63291. return this.subMaterials;
  63292. };
  63293. MultiMaterial.prototype._hookArray = function (array) {
  63294. var _this = this;
  63295. var oldPush = array.push;
  63296. array.push = function () {
  63297. var items = [];
  63298. for (var _i = 0; _i < arguments.length; _i++) {
  63299. items[_i] = arguments[_i];
  63300. }
  63301. var result = oldPush.apply(array, items);
  63302. _this._markAllSubMeshesAsTexturesDirty();
  63303. return result;
  63304. };
  63305. var oldSplice = array.splice;
  63306. array.splice = function (index, deleteCount) {
  63307. var deleted = oldSplice.apply(array, [index, deleteCount]);
  63308. _this._markAllSubMeshesAsTexturesDirty();
  63309. return deleted;
  63310. };
  63311. };
  63312. /**
  63313. * Get one of the submaterial by its index in the submaterials array
  63314. * @param index The index to look the sub material at
  63315. * @returns The Material if the index has been defined
  63316. */
  63317. MultiMaterial.prototype.getSubMaterial = function (index) {
  63318. if (index < 0 || index >= this.subMaterials.length) {
  63319. return this.getScene().defaultMaterial;
  63320. }
  63321. return this.subMaterials[index];
  63322. };
  63323. /**
  63324. * Get the list of active textures for the whole sub materials list.
  63325. * @returns All the textures that will be used during the rendering
  63326. */
  63327. MultiMaterial.prototype.getActiveTextures = function () {
  63328. var _a;
  63329. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  63330. if (subMaterial) {
  63331. return subMaterial.getActiveTextures();
  63332. }
  63333. else {
  63334. return [];
  63335. }
  63336. }));
  63337. };
  63338. /**
  63339. * Gets the current class name of the material e.g. "MultiMaterial"
  63340. * Mainly use in serialization.
  63341. * @returns the class name
  63342. */
  63343. MultiMaterial.prototype.getClassName = function () {
  63344. return "MultiMaterial";
  63345. };
  63346. /**
  63347. * Checks if the material is ready to render the requested sub mesh
  63348. * @param mesh Define the mesh the submesh belongs to
  63349. * @param subMesh Define the sub mesh to look readyness for
  63350. * @param useInstances Define whether or not the material is used with instances
  63351. * @returns true if ready, otherwise false
  63352. */
  63353. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  63354. for (var index = 0; index < this.subMaterials.length; index++) {
  63355. var subMaterial = this.subMaterials[index];
  63356. if (subMaterial) {
  63357. if (subMaterial._storeEffectOnSubMeshes) {
  63358. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  63359. return false;
  63360. }
  63361. continue;
  63362. }
  63363. if (!subMaterial.isReady(mesh)) {
  63364. return false;
  63365. }
  63366. }
  63367. }
  63368. return true;
  63369. };
  63370. /**
  63371. * Clones the current material and its related sub materials
  63372. * @param name Define the name of the newly cloned material
  63373. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  63374. * @returns the cloned material
  63375. */
  63376. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  63377. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  63378. for (var index = 0; index < this.subMaterials.length; index++) {
  63379. var subMaterial = null;
  63380. var current = this.subMaterials[index];
  63381. if (cloneChildren && current) {
  63382. subMaterial = current.clone(name + "-" + current.name);
  63383. }
  63384. else {
  63385. subMaterial = this.subMaterials[index];
  63386. }
  63387. newMultiMaterial.subMaterials.push(subMaterial);
  63388. }
  63389. return newMultiMaterial;
  63390. };
  63391. /**
  63392. * Serializes the materials into a JSON representation.
  63393. * @returns the JSON representation
  63394. */
  63395. MultiMaterial.prototype.serialize = function () {
  63396. var serializationObject = {};
  63397. serializationObject.name = this.name;
  63398. serializationObject.id = this.id;
  63399. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63400. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  63401. }
  63402. serializationObject.materials = [];
  63403. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  63404. var subMat = this.subMaterials[matIndex];
  63405. if (subMat) {
  63406. serializationObject.materials.push(subMat.id);
  63407. }
  63408. else {
  63409. serializationObject.materials.push(null);
  63410. }
  63411. }
  63412. return serializationObject;
  63413. };
  63414. /**
  63415. * Dispose the material and release its associated resources
  63416. * @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)
  63417. * @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)
  63418. * @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)
  63419. */
  63420. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  63421. var scene = this.getScene();
  63422. if (!scene) {
  63423. return;
  63424. }
  63425. if (forceDisposeChildren) {
  63426. for (var index = 0; index < this.subMaterials.length; index++) {
  63427. var subMaterial = this.subMaterials[index];
  63428. if (subMaterial) {
  63429. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  63430. }
  63431. }
  63432. }
  63433. var index = scene.multiMaterials.indexOf(this);
  63434. if (index >= 0) {
  63435. scene.multiMaterials.splice(index, 1);
  63436. }
  63437. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  63438. };
  63439. /**
  63440. * Creates a MultiMaterial from parsed MultiMaterial data.
  63441. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  63442. * @param scene defines the hosting scene
  63443. * @returns a new MultiMaterial
  63444. */
  63445. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  63446. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  63447. multiMaterial.id = parsedMultiMaterial.id;
  63448. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63449. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  63450. }
  63451. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  63452. var subMatId = parsedMultiMaterial.materials[matIndex];
  63453. if (subMatId) {
  63454. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  63455. }
  63456. else {
  63457. multiMaterial.subMaterials.push(null);
  63458. }
  63459. }
  63460. return multiMaterial;
  63461. };
  63462. return MultiMaterial;
  63463. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  63464. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  63465. /***/ }),
  63466. /***/ "./Materials/pushMaterial.ts":
  63467. /*!***********************************!*\
  63468. !*** ./Materials/pushMaterial.ts ***!
  63469. \***********************************/
  63470. /*! exports provided: PushMaterial */
  63471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63472. "use strict";
  63473. __webpack_require__.r(__webpack_exports__);
  63474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  63475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63476. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63477. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63478. /**
  63479. * Base class of materials working in push mode in babylon JS
  63480. * @hidden
  63481. */
  63482. var PushMaterial = /** @class */ (function (_super) {
  63483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  63484. function PushMaterial(name, scene) {
  63485. var _this = _super.call(this, name, scene) || this;
  63486. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  63487. /**
  63488. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  63489. * This means that the material can keep using a previous shader while a new one is being compiled.
  63490. * This is mostly used when shader parallel compilation is supported (true by default)
  63491. */
  63492. _this.allowShaderHotSwapping = true;
  63493. _this._storeEffectOnSubMeshes = true;
  63494. return _this;
  63495. }
  63496. PushMaterial.prototype.getEffect = function () {
  63497. return this._activeEffect;
  63498. };
  63499. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  63500. if (!mesh) {
  63501. return false;
  63502. }
  63503. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  63504. return true;
  63505. }
  63506. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  63507. };
  63508. /**
  63509. * Binds the given world matrix to the active effect
  63510. *
  63511. * @param world the matrix to bind
  63512. */
  63513. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  63514. this._activeEffect.setMatrix("world", world);
  63515. };
  63516. /**
  63517. * Binds the given normal matrix to the active effect
  63518. *
  63519. * @param normalMatrix the matrix to bind
  63520. */
  63521. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  63522. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  63523. };
  63524. PushMaterial.prototype.bind = function (world, mesh) {
  63525. if (!mesh) {
  63526. return;
  63527. }
  63528. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  63529. };
  63530. PushMaterial.prototype._afterBind = function (mesh, effect) {
  63531. if (effect === void 0) { effect = null; }
  63532. _super.prototype._afterBind.call(this, mesh);
  63533. this.getScene()._cachedEffect = effect;
  63534. };
  63535. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  63536. if (visibility === void 0) { visibility = 1; }
  63537. return scene.isCachedMaterialInvalid(this, effect, visibility);
  63538. };
  63539. return PushMaterial;
  63540. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  63541. /***/ }),
  63542. /***/ "./Materials/shaderMaterial.ts":
  63543. /*!*************************************!*\
  63544. !*** ./Materials/shaderMaterial.ts ***!
  63545. \*************************************/
  63546. /*! exports provided: ShaderMaterial */
  63547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63548. "use strict";
  63549. __webpack_require__.r(__webpack_exports__);
  63550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  63551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63552. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63553. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63554. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63555. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  63556. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  63557. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  63558. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  63559. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63560. /**
  63561. * 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.
  63562. *
  63563. * This returned material effects how the mesh will look based on the code in the shaders.
  63564. *
  63565. * @see http://doc.babylonjs.com/how_to/shader_material
  63566. */
  63567. var ShaderMaterial = /** @class */ (function (_super) {
  63568. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  63569. /**
  63570. * Instantiate a new shader material.
  63571. * 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.
  63572. * This returned material effects how the mesh will look based on the code in the shaders.
  63573. * @see http://doc.babylonjs.com/how_to/shader_material
  63574. * @param name Define the name of the material in the scene
  63575. * @param scene Define the scene the material belongs to
  63576. * @param shaderPath Defines the route to the shader code in one of three ways:
  63577. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  63578. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  63579. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  63580. * @param options Define the options used to create the shader
  63581. */
  63582. function ShaderMaterial(name, scene, shaderPath, options) {
  63583. if (options === void 0) { options = {}; }
  63584. var _this = _super.call(this, name, scene) || this;
  63585. _this._textures = {};
  63586. _this._textureArrays = {};
  63587. _this._floats = {};
  63588. _this._ints = {};
  63589. _this._floatsArrays = {};
  63590. _this._colors3 = {};
  63591. _this._colors3Arrays = {};
  63592. _this._colors4 = {};
  63593. _this._vectors2 = {};
  63594. _this._vectors3 = {};
  63595. _this._vectors4 = {};
  63596. _this._matrices = {};
  63597. _this._matrices3x3 = {};
  63598. _this._matrices2x2 = {};
  63599. _this._vectors2Arrays = {};
  63600. _this._vectors3Arrays = {};
  63601. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  63602. _this._shaderPath = shaderPath;
  63603. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  63604. return _this;
  63605. }
  63606. /**
  63607. * Gets the current class name of the material e.g. "ShaderMaterial"
  63608. * Mainly use in serialization.
  63609. * @returns the class name
  63610. */
  63611. ShaderMaterial.prototype.getClassName = function () {
  63612. return "ShaderMaterial";
  63613. };
  63614. /**
  63615. * Specifies if the material will require alpha blending
  63616. * @returns a boolean specifying if alpha blending is needed
  63617. */
  63618. ShaderMaterial.prototype.needAlphaBlending = function () {
  63619. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  63620. };
  63621. /**
  63622. * Specifies if this material should be rendered in alpha test mode
  63623. * @returns a boolean specifying if an alpha test is needed.
  63624. */
  63625. ShaderMaterial.prototype.needAlphaTesting = function () {
  63626. return this._options.needAlphaTesting;
  63627. };
  63628. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  63629. if (this._options.uniforms.indexOf(uniformName) === -1) {
  63630. this._options.uniforms.push(uniformName);
  63631. }
  63632. };
  63633. /**
  63634. * Set a texture in the shader.
  63635. * @param name Define the name of the uniform samplers as defined in the shader
  63636. * @param texture Define the texture to bind to this sampler
  63637. * @return the material itself allowing "fluent" like uniform updates
  63638. */
  63639. ShaderMaterial.prototype.setTexture = function (name, texture) {
  63640. if (this._options.samplers.indexOf(name) === -1) {
  63641. this._options.samplers.push(name);
  63642. }
  63643. this._textures[name] = texture;
  63644. return this;
  63645. };
  63646. /**
  63647. * Set a texture array in the shader.
  63648. * @param name Define the name of the uniform sampler array as defined in the shader
  63649. * @param textures Define the list of textures to bind to this sampler
  63650. * @return the material itself allowing "fluent" like uniform updates
  63651. */
  63652. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  63653. if (this._options.samplers.indexOf(name) === -1) {
  63654. this._options.samplers.push(name);
  63655. }
  63656. this._checkUniform(name);
  63657. this._textureArrays[name] = textures;
  63658. return this;
  63659. };
  63660. /**
  63661. * Set a float in the shader.
  63662. * @param name Define the name of the uniform as defined in the shader
  63663. * @param value Define the value to give to the uniform
  63664. * @return the material itself allowing "fluent" like uniform updates
  63665. */
  63666. ShaderMaterial.prototype.setFloat = function (name, value) {
  63667. this._checkUniform(name);
  63668. this._floats[name] = value;
  63669. return this;
  63670. };
  63671. /**
  63672. * Set a int in the shader.
  63673. * @param name Define the name of the uniform as defined in the shader
  63674. * @param value Define the value to give to the uniform
  63675. * @return the material itself allowing "fluent" like uniform updates
  63676. */
  63677. ShaderMaterial.prototype.setInt = function (name, value) {
  63678. this._checkUniform(name);
  63679. this._ints[name] = value;
  63680. return this;
  63681. };
  63682. /**
  63683. * Set an array of floats in the shader.
  63684. * @param name Define the name of the uniform as defined in the shader
  63685. * @param value Define the value to give to the uniform
  63686. * @return the material itself allowing "fluent" like uniform updates
  63687. */
  63688. ShaderMaterial.prototype.setFloats = function (name, value) {
  63689. this._checkUniform(name);
  63690. this._floatsArrays[name] = value;
  63691. return this;
  63692. };
  63693. /**
  63694. * Set a vec3 in the shader from a Color3.
  63695. * @param name Define the name of the uniform as defined in the shader
  63696. * @param value Define the value to give to the uniform
  63697. * @return the material itself allowing "fluent" like uniform updates
  63698. */
  63699. ShaderMaterial.prototype.setColor3 = function (name, value) {
  63700. this._checkUniform(name);
  63701. this._colors3[name] = value;
  63702. return this;
  63703. };
  63704. /**
  63705. * Set a vec3 array in the shader from a Color3 array.
  63706. * @param name Define the name of the uniform as defined in the shader
  63707. * @param value Define the value to give to the uniform
  63708. * @return the material itself allowing "fluent" like uniform updates
  63709. */
  63710. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  63711. this._checkUniform(name);
  63712. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  63713. color.toArray(arr, arr.length);
  63714. return arr;
  63715. }, []);
  63716. return this;
  63717. };
  63718. /**
  63719. * Set a vec4 in the shader from a Color4.
  63720. * @param name Define the name of the uniform as defined in the shader
  63721. * @param value Define the value to give to the uniform
  63722. * @return the material itself allowing "fluent" like uniform updates
  63723. */
  63724. ShaderMaterial.prototype.setColor4 = function (name, value) {
  63725. this._checkUniform(name);
  63726. this._colors4[name] = value;
  63727. return this;
  63728. };
  63729. /**
  63730. * Set a vec2 in the shader from a Vector2.
  63731. * @param name Define the name of the uniform as defined in the shader
  63732. * @param value Define the value to give to the uniform
  63733. * @return the material itself allowing "fluent" like uniform updates
  63734. */
  63735. ShaderMaterial.prototype.setVector2 = function (name, value) {
  63736. this._checkUniform(name);
  63737. this._vectors2[name] = value;
  63738. return this;
  63739. };
  63740. /**
  63741. * Set a vec3 in the shader from a Vector3.
  63742. * @param name Define the name of the uniform as defined in the shader
  63743. * @param value Define the value to give to the uniform
  63744. * @return the material itself allowing "fluent" like uniform updates
  63745. */
  63746. ShaderMaterial.prototype.setVector3 = function (name, value) {
  63747. this._checkUniform(name);
  63748. this._vectors3[name] = value;
  63749. return this;
  63750. };
  63751. /**
  63752. * Set a vec4 in the shader from a Vector4.
  63753. * @param name Define the name of the uniform as defined in the shader
  63754. * @param value Define the value to give to the uniform
  63755. * @return the material itself allowing "fluent" like uniform updates
  63756. */
  63757. ShaderMaterial.prototype.setVector4 = function (name, value) {
  63758. this._checkUniform(name);
  63759. this._vectors4[name] = value;
  63760. return this;
  63761. };
  63762. /**
  63763. * Set a mat4 in the shader from a Matrix.
  63764. * @param name Define the name of the uniform as defined in the shader
  63765. * @param value Define the value to give to the uniform
  63766. * @return the material itself allowing "fluent" like uniform updates
  63767. */
  63768. ShaderMaterial.prototype.setMatrix = function (name, value) {
  63769. this._checkUniform(name);
  63770. this._matrices[name] = value;
  63771. return this;
  63772. };
  63773. /**
  63774. * Set a mat3 in the shader from a Float32Array.
  63775. * @param name Define the name of the uniform as defined in the shader
  63776. * @param value Define the value to give to the uniform
  63777. * @return the material itself allowing "fluent" like uniform updates
  63778. */
  63779. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  63780. this._checkUniform(name);
  63781. this._matrices3x3[name] = value;
  63782. return this;
  63783. };
  63784. /**
  63785. * Set a mat2 in the shader from a Float32Array.
  63786. * @param name Define the name of the uniform as defined in the shader
  63787. * @param value Define the value to give to the uniform
  63788. * @return the material itself allowing "fluent" like uniform updates
  63789. */
  63790. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  63791. this._checkUniform(name);
  63792. this._matrices2x2[name] = value;
  63793. return this;
  63794. };
  63795. /**
  63796. * Set a vec2 array in the shader from a number array.
  63797. * @param name Define the name of the uniform as defined in the shader
  63798. * @param value Define the value to give to the uniform
  63799. * @return the material itself allowing "fluent" like uniform updates
  63800. */
  63801. ShaderMaterial.prototype.setArray2 = function (name, value) {
  63802. this._checkUniform(name);
  63803. this._vectors2Arrays[name] = value;
  63804. return this;
  63805. };
  63806. /**
  63807. * Set a vec3 array in the shader from a number array.
  63808. * @param name Define the name of the uniform as defined in the shader
  63809. * @param value Define the value to give to the uniform
  63810. * @return the material itself allowing "fluent" like uniform updates
  63811. */
  63812. ShaderMaterial.prototype.setArray3 = function (name, value) {
  63813. this._checkUniform(name);
  63814. this._vectors3Arrays[name] = value;
  63815. return this;
  63816. };
  63817. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  63818. if (!mesh) {
  63819. return true;
  63820. }
  63821. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  63822. return false;
  63823. }
  63824. return false;
  63825. };
  63826. /**
  63827. * Checks if the material is ready to render the requested mesh
  63828. * @param mesh Define the mesh to render
  63829. * @param useInstances Define whether or not the material is used with instances
  63830. * @returns true if ready, otherwise false
  63831. */
  63832. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  63833. var scene = this.getScene();
  63834. var engine = scene.getEngine();
  63835. if (!this.checkReadyOnEveryCall) {
  63836. if (this._renderId === scene.getRenderId()) {
  63837. if (this._checkCache(mesh, useInstances)) {
  63838. return true;
  63839. }
  63840. }
  63841. }
  63842. // Instances
  63843. var defines = [];
  63844. var attribs = [];
  63845. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  63846. for (var index = 0; index < this._options.defines.length; index++) {
  63847. defines.push(this._options.defines[index]);
  63848. }
  63849. for (var index = 0; index < this._options.attributes.length; index++) {
  63850. attribs.push(this._options.attributes[index]);
  63851. }
  63852. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  63853. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  63854. defines.push("#define VERTEXCOLOR");
  63855. }
  63856. if (useInstances) {
  63857. defines.push("#define INSTANCES");
  63858. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  63859. }
  63860. // Bones
  63861. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63862. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  63863. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  63864. if (mesh.numBoneInfluencers > 4) {
  63865. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  63866. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  63867. }
  63868. var skeleton = mesh.skeleton;
  63869. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  63870. fallbacks.addCPUSkinningFallback(0, mesh);
  63871. if (skeleton.isUsingTextureForMatrices) {
  63872. defines.push("#define BONETEXTURE");
  63873. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  63874. this._options.uniforms.push("boneTextureWidth");
  63875. }
  63876. if (this._options.samplers.indexOf("boneSampler") === -1) {
  63877. this._options.samplers.push("boneSampler");
  63878. }
  63879. }
  63880. else {
  63881. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  63882. if (this._options.uniforms.indexOf("mBones") === -1) {
  63883. this._options.uniforms.push("mBones");
  63884. }
  63885. }
  63886. }
  63887. else {
  63888. defines.push("#define NUM_BONE_INFLUENCERS 0");
  63889. }
  63890. // Textures
  63891. for (var name in this._textures) {
  63892. if (!this._textures[name].isReady()) {
  63893. return false;
  63894. }
  63895. }
  63896. // Alpha test
  63897. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  63898. defines.push("#define ALPHATEST");
  63899. }
  63900. var previousEffect = this._effect;
  63901. var join = defines.join("\n");
  63902. this._effect = engine.createEffect(this._shaderPath, {
  63903. attributes: attribs,
  63904. uniformsNames: this._options.uniforms,
  63905. uniformBuffersNames: this._options.uniformBuffers,
  63906. samplers: this._options.samplers,
  63907. defines: join,
  63908. fallbacks: fallbacks,
  63909. onCompiled: this.onCompiled,
  63910. onError: this.onError
  63911. }, engine);
  63912. if (!this._effect.isReady()) {
  63913. return false;
  63914. }
  63915. if (previousEffect !== this._effect) {
  63916. scene.resetCachedMaterial();
  63917. }
  63918. this._renderId = scene.getRenderId();
  63919. return true;
  63920. };
  63921. /**
  63922. * Binds the world matrix to the material
  63923. * @param world defines the world transformation matrix
  63924. */
  63925. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  63926. var scene = this.getScene();
  63927. if (!this._effect) {
  63928. return;
  63929. }
  63930. if (this._options.uniforms.indexOf("world") !== -1) {
  63931. this._effect.setMatrix("world", world);
  63932. }
  63933. if (this._options.uniforms.indexOf("worldView") !== -1) {
  63934. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  63935. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  63936. }
  63937. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  63938. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  63939. }
  63940. };
  63941. /**
  63942. * Binds the material to the mesh
  63943. * @param world defines the world transformation matrix
  63944. * @param mesh defines the mesh to bind the material to
  63945. */
  63946. ShaderMaterial.prototype.bind = function (world, mesh) {
  63947. // Std values
  63948. this.bindOnlyWorldMatrix(world);
  63949. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  63950. if (this._options.uniforms.indexOf("view") !== -1) {
  63951. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  63952. }
  63953. if (this._options.uniforms.indexOf("projection") !== -1) {
  63954. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  63955. }
  63956. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  63957. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  63958. }
  63959. // Bones
  63960. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  63961. var name;
  63962. // Texture
  63963. for (name in this._textures) {
  63964. this._effect.setTexture(name, this._textures[name]);
  63965. }
  63966. // Texture arrays
  63967. for (name in this._textureArrays) {
  63968. this._effect.setTextureArray(name, this._textureArrays[name]);
  63969. }
  63970. // Int
  63971. for (name in this._ints) {
  63972. this._effect.setInt(name, this._ints[name]);
  63973. }
  63974. // Float
  63975. for (name in this._floats) {
  63976. this._effect.setFloat(name, this._floats[name]);
  63977. }
  63978. // Floats
  63979. for (name in this._floatsArrays) {
  63980. this._effect.setArray(name, this._floatsArrays[name]);
  63981. }
  63982. // Color3
  63983. for (name in this._colors3) {
  63984. this._effect.setColor3(name, this._colors3[name]);
  63985. }
  63986. for (name in this._colors3Arrays) {
  63987. this._effect.setArray3(name, this._colors3Arrays[name]);
  63988. }
  63989. // Color4
  63990. for (name in this._colors4) {
  63991. var color = this._colors4[name];
  63992. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  63993. }
  63994. // Vector2
  63995. for (name in this._vectors2) {
  63996. this._effect.setVector2(name, this._vectors2[name]);
  63997. }
  63998. // Vector3
  63999. for (name in this._vectors3) {
  64000. this._effect.setVector3(name, this._vectors3[name]);
  64001. }
  64002. // Vector4
  64003. for (name in this._vectors4) {
  64004. this._effect.setVector4(name, this._vectors4[name]);
  64005. }
  64006. // Matrix
  64007. for (name in this._matrices) {
  64008. this._effect.setMatrix(name, this._matrices[name]);
  64009. }
  64010. // Matrix 3x3
  64011. for (name in this._matrices3x3) {
  64012. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  64013. }
  64014. // Matrix 2x2
  64015. for (name in this._matrices2x2) {
  64016. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  64017. }
  64018. // Vector2Array
  64019. for (name in this._vectors2Arrays) {
  64020. this._effect.setArray2(name, this._vectors2Arrays[name]);
  64021. }
  64022. // Vector3Array
  64023. for (name in this._vectors3Arrays) {
  64024. this._effect.setArray3(name, this._vectors3Arrays[name]);
  64025. }
  64026. }
  64027. this._afterBind(mesh);
  64028. };
  64029. /**
  64030. * Gets the active textures from the material
  64031. * @returns an array of textures
  64032. */
  64033. ShaderMaterial.prototype.getActiveTextures = function () {
  64034. var activeTextures = _super.prototype.getActiveTextures.call(this);
  64035. for (var name in this._textures) {
  64036. activeTextures.push(this._textures[name]);
  64037. }
  64038. for (var name in this._textureArrays) {
  64039. var array = this._textureArrays[name];
  64040. for (var index = 0; index < array.length; index++) {
  64041. activeTextures.push(array[index]);
  64042. }
  64043. }
  64044. return activeTextures;
  64045. };
  64046. /**
  64047. * Specifies if the material uses a texture
  64048. * @param texture defines the texture to check against the material
  64049. * @returns a boolean specifying if the material uses the texture
  64050. */
  64051. ShaderMaterial.prototype.hasTexture = function (texture) {
  64052. if (_super.prototype.hasTexture.call(this, texture)) {
  64053. return true;
  64054. }
  64055. for (var name in this._textures) {
  64056. if (this._textures[name] === texture) {
  64057. return true;
  64058. }
  64059. }
  64060. for (var name in this._textureArrays) {
  64061. var array = this._textureArrays[name];
  64062. for (var index = 0; index < array.length; index++) {
  64063. if (array[index] === texture) {
  64064. return true;
  64065. }
  64066. }
  64067. }
  64068. return false;
  64069. };
  64070. /**
  64071. * Makes a duplicate of the material, and gives it a new name
  64072. * @param name defines the new name for the duplicated material
  64073. * @returns the cloned material
  64074. */
  64075. ShaderMaterial.prototype.clone = function (name) {
  64076. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  64077. return newShaderMaterial;
  64078. };
  64079. /**
  64080. * Disposes the material
  64081. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64082. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64083. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64084. */
  64085. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64086. if (forceDisposeTextures) {
  64087. var name;
  64088. for (name in this._textures) {
  64089. this._textures[name].dispose();
  64090. }
  64091. for (name in this._textureArrays) {
  64092. var array = this._textureArrays[name];
  64093. for (var index = 0; index < array.length; index++) {
  64094. array[index].dispose();
  64095. }
  64096. }
  64097. }
  64098. this._textures = {};
  64099. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  64100. };
  64101. /**
  64102. * Serializes this material in a JSON representation
  64103. * @returns the serialized material object
  64104. */
  64105. ShaderMaterial.prototype.serialize = function () {
  64106. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64107. serializationObject.customType = "ShaderMaterial";
  64108. serializationObject.options = this._options;
  64109. serializationObject.shaderPath = this._shaderPath;
  64110. var name;
  64111. // Texture
  64112. serializationObject.textures = {};
  64113. for (name in this._textures) {
  64114. serializationObject.textures[name] = this._textures[name].serialize();
  64115. }
  64116. // Texture arrays
  64117. serializationObject.textureArrays = {};
  64118. for (name in this._textureArrays) {
  64119. serializationObject.textureArrays[name] = [];
  64120. var array = this._textureArrays[name];
  64121. for (var index = 0; index < array.length; index++) {
  64122. serializationObject.textureArrays[name].push(array[index].serialize());
  64123. }
  64124. }
  64125. // Float
  64126. serializationObject.floats = {};
  64127. for (name in this._floats) {
  64128. serializationObject.floats[name] = this._floats[name];
  64129. }
  64130. // Float s
  64131. serializationObject.FloatArrays = {};
  64132. for (name in this._floatsArrays) {
  64133. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  64134. }
  64135. // Color3
  64136. serializationObject.colors3 = {};
  64137. for (name in this._colors3) {
  64138. serializationObject.colors3[name] = this._colors3[name].asArray();
  64139. }
  64140. // Color3 array
  64141. serializationObject.colors3Arrays = {};
  64142. for (name in this._colors3Arrays) {
  64143. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  64144. }
  64145. // Color4
  64146. serializationObject.colors4 = {};
  64147. for (name in this._colors4) {
  64148. serializationObject.colors4[name] = this._colors4[name].asArray();
  64149. }
  64150. // Vector2
  64151. serializationObject.vectors2 = {};
  64152. for (name in this._vectors2) {
  64153. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  64154. }
  64155. // Vector3
  64156. serializationObject.vectors3 = {};
  64157. for (name in this._vectors3) {
  64158. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  64159. }
  64160. // Vector4
  64161. serializationObject.vectors4 = {};
  64162. for (name in this._vectors4) {
  64163. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  64164. }
  64165. // Matrix
  64166. serializationObject.matrices = {};
  64167. for (name in this._matrices) {
  64168. serializationObject.matrices[name] = this._matrices[name].asArray();
  64169. }
  64170. // Matrix 3x3
  64171. serializationObject.matrices3x3 = {};
  64172. for (name in this._matrices3x3) {
  64173. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  64174. }
  64175. // Matrix 2x2
  64176. serializationObject.matrices2x2 = {};
  64177. for (name in this._matrices2x2) {
  64178. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  64179. }
  64180. // Vector2Array
  64181. serializationObject.vectors2Arrays = {};
  64182. for (name in this._vectors2Arrays) {
  64183. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  64184. }
  64185. // Vector3Array
  64186. serializationObject.vectors3Arrays = {};
  64187. for (name in this._vectors3Arrays) {
  64188. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  64189. }
  64190. return serializationObject;
  64191. };
  64192. /**
  64193. * Creates a shader material from parsed shader material data
  64194. * @param source defines the JSON represnetation of the material
  64195. * @param scene defines the hosting scene
  64196. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64197. * @returns a new material
  64198. */
  64199. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  64200. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  64201. var name;
  64202. // Texture
  64203. for (name in source.textures) {
  64204. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  64205. }
  64206. // Texture arrays
  64207. for (name in source.textureArrays) {
  64208. var array = source.textureArrays[name];
  64209. var textureArray = new Array();
  64210. for (var index = 0; index < array.length; index++) {
  64211. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  64212. }
  64213. material.setTextureArray(name, textureArray);
  64214. }
  64215. // Float
  64216. for (name in source.floats) {
  64217. material.setFloat(name, source.floats[name]);
  64218. }
  64219. // Float s
  64220. for (name in source.floatsArrays) {
  64221. material.setFloats(name, source.floatsArrays[name]);
  64222. }
  64223. // Color3
  64224. for (name in source.colors3) {
  64225. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  64226. }
  64227. // Color3 arrays
  64228. for (name in source.colors3Arrays) {
  64229. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  64230. if (i % 3 === 0) {
  64231. arr.push([num]);
  64232. }
  64233. else {
  64234. arr[arr.length - 1].push(num);
  64235. }
  64236. return arr;
  64237. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  64238. material.setColor3Array(name, colors);
  64239. }
  64240. // Color4
  64241. for (name in source.colors4) {
  64242. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  64243. }
  64244. // Vector2
  64245. for (name in source.vectors2) {
  64246. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  64247. }
  64248. // Vector3
  64249. for (name in source.vectors3) {
  64250. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  64251. }
  64252. // Vector4
  64253. for (name in source.vectors4) {
  64254. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  64255. }
  64256. // Matrix
  64257. for (name in source.matrices) {
  64258. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  64259. }
  64260. // Matrix 3x3
  64261. for (name in source.matrices3x3) {
  64262. material.setMatrix3x3(name, source.matrices3x3[name]);
  64263. }
  64264. // Matrix 2x2
  64265. for (name in source.matrices2x2) {
  64266. material.setMatrix2x2(name, source.matrices2x2[name]);
  64267. }
  64268. // Vector2Array
  64269. for (name in source.vectors2Arrays) {
  64270. material.setArray2(name, source.vectors2Arrays[name]);
  64271. }
  64272. // Vector3Array
  64273. for (name in source.vectors3Arrays) {
  64274. material.setArray3(name, source.vectors3Arrays[name]);
  64275. }
  64276. return material;
  64277. };
  64278. return ShaderMaterial;
  64279. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  64280. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  64281. /***/ }),
  64282. /***/ "./Materials/standardMaterial.ts":
  64283. /*!***************************************!*\
  64284. !*** ./Materials/standardMaterial.ts ***!
  64285. \***************************************/
  64286. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  64287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64288. "use strict";
  64289. __webpack_require__.r(__webpack_exports__);
  64290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  64291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  64292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64293. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64294. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  64295. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  64296. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64297. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64298. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64299. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64300. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64301. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64302. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64303. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64304. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64305. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64306. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  64307. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  64308. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64309. /** @hidden */
  64310. var StandardMaterialDefines = /** @class */ (function (_super) {
  64311. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  64312. function StandardMaterialDefines() {
  64313. var _this = _super.call(this) || this;
  64314. _this.MAINUV1 = false;
  64315. _this.MAINUV2 = false;
  64316. _this.DIFFUSE = false;
  64317. _this.DIFFUSEDIRECTUV = 0;
  64318. _this.AMBIENT = false;
  64319. _this.AMBIENTDIRECTUV = 0;
  64320. _this.OPACITY = false;
  64321. _this.OPACITYDIRECTUV = 0;
  64322. _this.OPACITYRGB = false;
  64323. _this.REFLECTION = false;
  64324. _this.EMISSIVE = false;
  64325. _this.EMISSIVEDIRECTUV = 0;
  64326. _this.SPECULAR = false;
  64327. _this.SPECULARDIRECTUV = 0;
  64328. _this.BUMP = false;
  64329. _this.BUMPDIRECTUV = 0;
  64330. _this.PARALLAX = false;
  64331. _this.PARALLAXOCCLUSION = false;
  64332. _this.SPECULAROVERALPHA = false;
  64333. _this.CLIPPLANE = false;
  64334. _this.CLIPPLANE2 = false;
  64335. _this.CLIPPLANE3 = false;
  64336. _this.CLIPPLANE4 = false;
  64337. _this.ALPHATEST = false;
  64338. _this.DEPTHPREPASS = false;
  64339. _this.ALPHAFROMDIFFUSE = false;
  64340. _this.POINTSIZE = false;
  64341. _this.FOG = false;
  64342. _this.SPECULARTERM = false;
  64343. _this.DIFFUSEFRESNEL = false;
  64344. _this.OPACITYFRESNEL = false;
  64345. _this.REFLECTIONFRESNEL = false;
  64346. _this.REFRACTIONFRESNEL = false;
  64347. _this.EMISSIVEFRESNEL = false;
  64348. _this.FRESNEL = false;
  64349. _this.NORMAL = false;
  64350. _this.UV1 = false;
  64351. _this.UV2 = false;
  64352. _this.VERTEXCOLOR = false;
  64353. _this.VERTEXALPHA = false;
  64354. _this.NUM_BONE_INFLUENCERS = 0;
  64355. _this.BonesPerMesh = 0;
  64356. _this.BONETEXTURE = false;
  64357. _this.INSTANCES = false;
  64358. _this.GLOSSINESS = false;
  64359. _this.ROUGHNESS = false;
  64360. _this.EMISSIVEASILLUMINATION = false;
  64361. _this.LINKEMISSIVEWITHDIFFUSE = false;
  64362. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  64363. _this.LIGHTMAP = false;
  64364. _this.LIGHTMAPDIRECTUV = 0;
  64365. _this.OBJECTSPACE_NORMALMAP = false;
  64366. _this.USELIGHTMAPASSHADOWMAP = false;
  64367. _this.REFLECTIONMAP_3D = false;
  64368. _this.REFLECTIONMAP_SPHERICAL = false;
  64369. _this.REFLECTIONMAP_PLANAR = false;
  64370. _this.REFLECTIONMAP_CUBIC = false;
  64371. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  64372. _this.REFLECTIONMAP_PROJECTION = false;
  64373. _this.REFLECTIONMAP_SKYBOX = false;
  64374. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  64375. _this.REFLECTIONMAP_EXPLICIT = false;
  64376. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  64377. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  64378. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  64379. _this.INVERTCUBICMAP = false;
  64380. _this.LOGARITHMICDEPTH = false;
  64381. _this.REFRACTION = false;
  64382. _this.REFRACTIONMAP_3D = false;
  64383. _this.REFLECTIONOVERALPHA = false;
  64384. _this.TWOSIDEDLIGHTING = false;
  64385. _this.SHADOWFLOAT = false;
  64386. _this.MORPHTARGETS = false;
  64387. _this.MORPHTARGETS_NORMAL = false;
  64388. _this.MORPHTARGETS_TANGENT = false;
  64389. _this.NUM_MORPH_INFLUENCERS = 0;
  64390. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  64391. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  64392. _this.IMAGEPROCESSING = false;
  64393. _this.VIGNETTE = false;
  64394. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64395. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64396. _this.TONEMAPPING = false;
  64397. _this.TONEMAPPING_ACES = false;
  64398. _this.CONTRAST = false;
  64399. _this.COLORCURVES = false;
  64400. _this.COLORGRADING = false;
  64401. _this.COLORGRADING3D = false;
  64402. _this.SAMPLER3DGREENDEPTH = false;
  64403. _this.SAMPLER3DBGRMAP = false;
  64404. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64405. /**
  64406. * If the reflection texture on this material is in linear color space
  64407. * @hidden
  64408. */
  64409. _this.IS_REFLECTION_LINEAR = false;
  64410. /**
  64411. * If the refraction texture on this material is in linear color space
  64412. * @hidden
  64413. */
  64414. _this.IS_REFRACTION_LINEAR = false;
  64415. _this.EXPOSURE = false;
  64416. _this.rebuild();
  64417. return _this;
  64418. }
  64419. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  64420. var modes = [
  64421. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  64422. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  64423. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  64424. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  64425. ];
  64426. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  64427. var mode = modes_1[_i];
  64428. this[mode] = (mode === modeToEnable);
  64429. }
  64430. };
  64431. return StandardMaterialDefines;
  64432. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  64433. /**
  64434. * This is the default material used in Babylon. It is the best trade off between quality
  64435. * and performances.
  64436. * @see http://doc.babylonjs.com/babylon101/materials
  64437. */
  64438. var StandardMaterial = /** @class */ (function (_super) {
  64439. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  64440. /**
  64441. * Instantiates a new standard material.
  64442. * This is the default material used in Babylon. It is the best trade off between quality
  64443. * and performances.
  64444. * @see http://doc.babylonjs.com/babylon101/materials
  64445. * @param name Define the name of the material in the scene
  64446. * @param scene Define the scene the material belong to
  64447. */
  64448. function StandardMaterial(name, scene) {
  64449. var _this = _super.call(this, name, scene) || this;
  64450. /**
  64451. * The color of the material lit by the environmental background lighting.
  64452. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  64453. */
  64454. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64455. /**
  64456. * The basic color of the material as viewed under a light.
  64457. */
  64458. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64459. /**
  64460. * Define how the color and intensity of the highlight given by the light in the material.
  64461. */
  64462. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64463. /**
  64464. * Define the color of the material as if self lit.
  64465. * This will be mixed in the final result even in the absence of light.
  64466. */
  64467. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64468. /**
  64469. * Defines how sharp are the highlights in the material.
  64470. * The bigger the value the sharper giving a more glossy feeling to the result.
  64471. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  64472. */
  64473. _this.specularPower = 64;
  64474. _this._useAlphaFromDiffuseTexture = false;
  64475. _this._useEmissiveAsIllumination = false;
  64476. _this._linkEmissiveWithDiffuse = false;
  64477. _this._useSpecularOverAlpha = false;
  64478. _this._useReflectionOverAlpha = false;
  64479. _this._disableLighting = false;
  64480. _this._useObjectSpaceNormalMap = false;
  64481. _this._useParallax = false;
  64482. _this._useParallaxOcclusion = false;
  64483. /**
  64484. * 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.
  64485. */
  64486. _this.parallaxScaleBias = 0.05;
  64487. _this._roughness = 0;
  64488. /**
  64489. * In case of refraction, define the value of the indice of refraction.
  64490. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64491. */
  64492. _this.indexOfRefraction = 0.98;
  64493. /**
  64494. * Invert the refraction texture alongside the y axis.
  64495. * It can be useful with procedural textures or probe for instance.
  64496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64497. */
  64498. _this.invertRefractionY = true;
  64499. /**
  64500. * Defines the alpha limits in alpha test mode.
  64501. */
  64502. _this.alphaCutOff = 0.4;
  64503. _this._useLightmapAsShadowmap = false;
  64504. _this._useReflectionFresnelFromSpecular = false;
  64505. _this._useGlossinessFromSpecularMapAlpha = false;
  64506. _this._maxSimultaneousLights = 4;
  64507. _this._invertNormalMapX = false;
  64508. _this._invertNormalMapY = false;
  64509. _this._twoSidedLighting = false;
  64510. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  64511. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  64512. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64513. // Setup the default processing configuration to the scene.
  64514. _this._attachImageProcessingConfiguration(null);
  64515. _this.getRenderTargetTextures = function () {
  64516. _this._renderTargets.reset();
  64517. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  64518. _this._renderTargets.push(_this._reflectionTexture);
  64519. }
  64520. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  64521. _this._renderTargets.push(_this._refractionTexture);
  64522. }
  64523. return _this._renderTargets;
  64524. };
  64525. return _this;
  64526. }
  64527. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  64528. /**
  64529. * Gets the image processing configuration used either in this material.
  64530. */
  64531. get: function () {
  64532. return this._imageProcessingConfiguration;
  64533. },
  64534. /**
  64535. * Sets the Default image processing configuration used either in the this material.
  64536. *
  64537. * If sets to null, the scene one is in use.
  64538. */
  64539. set: function (value) {
  64540. this._attachImageProcessingConfiguration(value);
  64541. // Ensure the effect will be rebuilt.
  64542. this._markAllSubMeshesAsTexturesDirty();
  64543. },
  64544. enumerable: true,
  64545. configurable: true
  64546. });
  64547. /**
  64548. * Attaches a new image processing configuration to the Standard Material.
  64549. * @param configuration
  64550. */
  64551. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  64552. var _this = this;
  64553. if (configuration === this._imageProcessingConfiguration) {
  64554. return;
  64555. }
  64556. // Detaches observer.
  64557. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  64558. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  64559. }
  64560. // Pick the scene configuration if needed.
  64561. if (!configuration) {
  64562. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  64563. }
  64564. else {
  64565. this._imageProcessingConfiguration = configuration;
  64566. }
  64567. // Attaches observer.
  64568. if (this._imageProcessingConfiguration) {
  64569. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  64570. _this._markAllSubMeshesAsImageProcessingDirty();
  64571. });
  64572. }
  64573. };
  64574. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  64575. /**
  64576. * Gets wether the color curves effect is enabled.
  64577. */
  64578. get: function () {
  64579. return this.imageProcessingConfiguration.colorCurvesEnabled;
  64580. },
  64581. /**
  64582. * Sets wether the color curves effect is enabled.
  64583. */
  64584. set: function (value) {
  64585. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  64586. },
  64587. enumerable: true,
  64588. configurable: true
  64589. });
  64590. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  64591. /**
  64592. * Gets wether the color grading effect is enabled.
  64593. */
  64594. get: function () {
  64595. return this.imageProcessingConfiguration.colorGradingEnabled;
  64596. },
  64597. /**
  64598. * Gets wether the color grading effect is enabled.
  64599. */
  64600. set: function (value) {
  64601. this.imageProcessingConfiguration.colorGradingEnabled = value;
  64602. },
  64603. enumerable: true,
  64604. configurable: true
  64605. });
  64606. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  64607. /**
  64608. * Gets wether tonemapping is enabled or not.
  64609. */
  64610. get: function () {
  64611. return this._imageProcessingConfiguration.toneMappingEnabled;
  64612. },
  64613. /**
  64614. * Sets wether tonemapping is enabled or not
  64615. */
  64616. set: function (value) {
  64617. this._imageProcessingConfiguration.toneMappingEnabled = value;
  64618. },
  64619. enumerable: true,
  64620. configurable: true
  64621. });
  64622. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  64623. /**
  64624. * The camera exposure used on this material.
  64625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64626. * This corresponds to a photographic exposure.
  64627. */
  64628. get: function () {
  64629. return this._imageProcessingConfiguration.exposure;
  64630. },
  64631. /**
  64632. * The camera exposure used on this material.
  64633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64634. * This corresponds to a photographic exposure.
  64635. */
  64636. set: function (value) {
  64637. this._imageProcessingConfiguration.exposure = value;
  64638. },
  64639. enumerable: true,
  64640. configurable: true
  64641. });
  64642. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  64643. /**
  64644. * Gets The camera contrast used on this material.
  64645. */
  64646. get: function () {
  64647. return this._imageProcessingConfiguration.contrast;
  64648. },
  64649. /**
  64650. * Sets The camera contrast used on this material.
  64651. */
  64652. set: function (value) {
  64653. this._imageProcessingConfiguration.contrast = value;
  64654. },
  64655. enumerable: true,
  64656. configurable: true
  64657. });
  64658. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  64659. /**
  64660. * Gets the Color Grading 2D Lookup Texture.
  64661. */
  64662. get: function () {
  64663. return this._imageProcessingConfiguration.colorGradingTexture;
  64664. },
  64665. /**
  64666. * Sets the Color Grading 2D Lookup Texture.
  64667. */
  64668. set: function (value) {
  64669. this._imageProcessingConfiguration.colorGradingTexture = value;
  64670. },
  64671. enumerable: true,
  64672. configurable: true
  64673. });
  64674. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  64675. /**
  64676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64678. * 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;
  64679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64680. */
  64681. get: function () {
  64682. return this._imageProcessingConfiguration.colorCurves;
  64683. },
  64684. /**
  64685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64687. * 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;
  64688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64689. */
  64690. set: function (value) {
  64691. this._imageProcessingConfiguration.colorCurves = value;
  64692. },
  64693. enumerable: true,
  64694. configurable: true
  64695. });
  64696. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  64697. /**
  64698. * Gets a boolean indicating that current material needs to register RTT
  64699. */
  64700. get: function () {
  64701. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  64702. return true;
  64703. }
  64704. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  64705. return true;
  64706. }
  64707. return false;
  64708. },
  64709. enumerable: true,
  64710. configurable: true
  64711. });
  64712. /**
  64713. * Gets the current class name of the material e.g. "StandardMaterial"
  64714. * Mainly use in serialization.
  64715. * @returns the class name
  64716. */
  64717. StandardMaterial.prototype.getClassName = function () {
  64718. return "StandardMaterial";
  64719. };
  64720. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  64721. /**
  64722. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  64723. * You can try switching to logarithmic depth.
  64724. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  64725. */
  64726. get: function () {
  64727. return this._useLogarithmicDepth;
  64728. },
  64729. set: function (value) {
  64730. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  64731. this._markAllSubMeshesAsMiscDirty();
  64732. },
  64733. enumerable: true,
  64734. configurable: true
  64735. });
  64736. /**
  64737. * Specifies if the material will require alpha blending
  64738. * @returns a boolean specifying if alpha blending is needed
  64739. */
  64740. StandardMaterial.prototype.needAlphaBlending = function () {
  64741. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  64742. };
  64743. /**
  64744. * Specifies if this material should be rendered in alpha test mode
  64745. * @returns a boolean specifying if an alpha test is needed.
  64746. */
  64747. StandardMaterial.prototype.needAlphaTesting = function () {
  64748. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  64749. };
  64750. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  64751. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  64752. };
  64753. /**
  64754. * Get the texture used for alpha test purpose.
  64755. * @returns the diffuse texture in case of the standard material.
  64756. */
  64757. StandardMaterial.prototype.getAlphaTestTexture = function () {
  64758. return this._diffuseTexture;
  64759. };
  64760. /**
  64761. * Get if the submesh is ready to be used and all its information available.
  64762. * Child classes can use it to update shaders
  64763. * @param mesh defines the mesh to check
  64764. * @param subMesh defines which submesh to check
  64765. * @param useInstances specifies that instances should be used
  64766. * @returns a boolean indicating that the submesh is ready or not
  64767. */
  64768. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64769. if (useInstances === void 0) { useInstances = false; }
  64770. if (subMesh.effect && this.isFrozen) {
  64771. if (this._wasPreviouslyReady) {
  64772. return true;
  64773. }
  64774. }
  64775. if (!subMesh._materialDefines) {
  64776. subMesh._materialDefines = new StandardMaterialDefines();
  64777. }
  64778. var scene = this.getScene();
  64779. var defines = subMesh._materialDefines;
  64780. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  64781. if (defines._renderId === scene.getRenderId()) {
  64782. return true;
  64783. }
  64784. }
  64785. var engine = scene.getEngine();
  64786. // Lights
  64787. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  64788. // Textures
  64789. if (defines._areTexturesDirty) {
  64790. defines._needUVs = false;
  64791. defines.MAINUV1 = false;
  64792. defines.MAINUV2 = false;
  64793. if (scene.texturesEnabled) {
  64794. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  64795. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  64796. return false;
  64797. }
  64798. else {
  64799. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  64800. }
  64801. }
  64802. else {
  64803. defines.DIFFUSE = false;
  64804. }
  64805. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  64806. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  64807. return false;
  64808. }
  64809. else {
  64810. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  64811. }
  64812. }
  64813. else {
  64814. defines.AMBIENT = false;
  64815. }
  64816. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  64817. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  64818. return false;
  64819. }
  64820. else {
  64821. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  64822. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  64823. }
  64824. }
  64825. else {
  64826. defines.OPACITY = false;
  64827. }
  64828. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  64829. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  64830. return false;
  64831. }
  64832. else {
  64833. defines._needNormals = true;
  64834. defines.REFLECTION = true;
  64835. defines.ROUGHNESS = (this._roughness > 0);
  64836. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  64837. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  64838. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  64839. switch (this._reflectionTexture.coordinatesMode) {
  64840. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  64841. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  64842. break;
  64843. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  64844. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  64845. break;
  64846. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  64847. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  64848. break;
  64849. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  64850. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  64851. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  64852. break;
  64853. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  64854. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  64855. break;
  64856. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  64857. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  64858. break;
  64859. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  64860. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  64861. break;
  64862. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  64863. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  64864. break;
  64865. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  64866. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  64867. default:
  64868. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  64869. break;
  64870. }
  64871. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  64872. }
  64873. }
  64874. else {
  64875. defines.REFLECTION = false;
  64876. }
  64877. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  64878. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  64879. return false;
  64880. }
  64881. else {
  64882. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  64883. }
  64884. }
  64885. else {
  64886. defines.EMISSIVE = false;
  64887. }
  64888. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  64889. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  64890. return false;
  64891. }
  64892. else {
  64893. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  64894. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  64895. }
  64896. }
  64897. else {
  64898. defines.LIGHTMAP = false;
  64899. }
  64900. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  64901. if (!this._specularTexture.isReadyOrNotBlocking()) {
  64902. return false;
  64903. }
  64904. else {
  64905. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  64906. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  64907. }
  64908. }
  64909. else {
  64910. defines.SPECULAR = false;
  64911. }
  64912. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  64913. // Bump texure can not be not blocking.
  64914. if (!this._bumpTexture.isReady()) {
  64915. return false;
  64916. }
  64917. else {
  64918. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  64919. defines.PARALLAX = this._useParallax;
  64920. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  64921. }
  64922. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  64923. }
  64924. else {
  64925. defines.BUMP = false;
  64926. }
  64927. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  64928. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  64929. return false;
  64930. }
  64931. else {
  64932. defines._needUVs = true;
  64933. defines.REFRACTION = true;
  64934. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  64935. }
  64936. }
  64937. else {
  64938. defines.REFRACTION = false;
  64939. }
  64940. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  64941. }
  64942. else {
  64943. defines.DIFFUSE = false;
  64944. defines.AMBIENT = false;
  64945. defines.OPACITY = false;
  64946. defines.REFLECTION = false;
  64947. defines.EMISSIVE = false;
  64948. defines.LIGHTMAP = false;
  64949. defines.BUMP = false;
  64950. defines.REFRACTION = false;
  64951. }
  64952. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  64953. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  64954. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  64955. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  64956. 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);
  64957. }
  64958. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  64959. if (!this._imageProcessingConfiguration.isReady()) {
  64960. return false;
  64961. }
  64962. this._imageProcessingConfiguration.prepareDefines(defines);
  64963. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  64964. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  64965. }
  64966. if (defines._areFresnelDirty) {
  64967. if (StandardMaterial.FresnelEnabled) {
  64968. // Fresnel
  64969. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  64970. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  64971. this._reflectionFresnelParameters) {
  64972. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  64973. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  64974. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  64975. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  64976. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  64977. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  64978. defines._needNormals = true;
  64979. defines.FRESNEL = true;
  64980. }
  64981. }
  64982. else {
  64983. defines.FRESNEL = false;
  64984. }
  64985. }
  64986. // Misc.
  64987. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  64988. // Attribs
  64989. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  64990. // Values that need to be evaluated on every frame
  64991. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  64992. // Get correct effect
  64993. if (defines.isDirty) {
  64994. defines.markAsProcessed();
  64995. // Fallbacks
  64996. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  64997. if (defines.REFLECTION) {
  64998. fallbacks.addFallback(0, "REFLECTION");
  64999. }
  65000. if (defines.SPECULAR) {
  65001. fallbacks.addFallback(0, "SPECULAR");
  65002. }
  65003. if (defines.BUMP) {
  65004. fallbacks.addFallback(0, "BUMP");
  65005. }
  65006. if (defines.PARALLAX) {
  65007. fallbacks.addFallback(1, "PARALLAX");
  65008. }
  65009. if (defines.PARALLAXOCCLUSION) {
  65010. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  65011. }
  65012. if (defines.SPECULAROVERALPHA) {
  65013. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  65014. }
  65015. if (defines.FOG) {
  65016. fallbacks.addFallback(1, "FOG");
  65017. }
  65018. if (defines.POINTSIZE) {
  65019. fallbacks.addFallback(0, "POINTSIZE");
  65020. }
  65021. if (defines.LOGARITHMICDEPTH) {
  65022. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  65023. }
  65024. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  65025. if (defines.SPECULARTERM) {
  65026. fallbacks.addFallback(0, "SPECULARTERM");
  65027. }
  65028. if (defines.DIFFUSEFRESNEL) {
  65029. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  65030. }
  65031. if (defines.OPACITYFRESNEL) {
  65032. fallbacks.addFallback(2, "OPACITYFRESNEL");
  65033. }
  65034. if (defines.REFLECTIONFRESNEL) {
  65035. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  65036. }
  65037. if (defines.EMISSIVEFRESNEL) {
  65038. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  65039. }
  65040. if (defines.FRESNEL) {
  65041. fallbacks.addFallback(4, "FRESNEL");
  65042. }
  65043. //Attributes
  65044. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  65045. if (defines.NORMAL) {
  65046. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  65047. }
  65048. if (defines.UV1) {
  65049. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  65050. }
  65051. if (defines.UV2) {
  65052. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  65053. }
  65054. if (defines.VERTEXCOLOR) {
  65055. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  65056. }
  65057. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  65058. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65059. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  65060. var shaderName = "default";
  65061. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  65062. "vFogInfos", "vFogColor", "pointSize",
  65063. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  65064. "mBones",
  65065. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  65066. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  65067. "vReflectionPosition", "vReflectionSize",
  65068. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  65069. ];
  65070. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  65071. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  65072. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  65073. var uniformBuffers = ["Material", "Scene"];
  65074. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  65075. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  65076. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  65077. }
  65078. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  65079. uniformsNames: uniforms,
  65080. uniformBuffersNames: uniformBuffers,
  65081. samplers: samplers,
  65082. defines: defines,
  65083. maxSimultaneousLights: this._maxSimultaneousLights
  65084. });
  65085. if (this.customShaderNameResolve) {
  65086. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  65087. }
  65088. var join = defines.toString();
  65089. var previousEffect = subMesh.effect;
  65090. var effect = scene.getEngine().createEffect(shaderName, {
  65091. attributes: attribs,
  65092. uniformsNames: uniforms,
  65093. uniformBuffersNames: uniformBuffers,
  65094. samplers: samplers,
  65095. defines: join,
  65096. fallbacks: fallbacks,
  65097. onCompiled: this.onCompiled,
  65098. onError: this.onError,
  65099. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  65100. }, engine);
  65101. if (effect) {
  65102. // Use previous effect while new one is compiling
  65103. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  65104. effect = previousEffect;
  65105. defines.markAsUnprocessed();
  65106. }
  65107. else {
  65108. scene.resetCachedMaterial();
  65109. subMesh.setEffect(effect, defines);
  65110. this.buildUniformLayout();
  65111. }
  65112. }
  65113. }
  65114. if (!subMesh.effect || !subMesh.effect.isReady()) {
  65115. return false;
  65116. }
  65117. defines._renderId = scene.getRenderId();
  65118. this._wasPreviouslyReady = true;
  65119. return true;
  65120. };
  65121. /**
  65122. * Builds the material UBO layouts.
  65123. * Used internally during the effect preparation.
  65124. */
  65125. StandardMaterial.prototype.buildUniformLayout = function () {
  65126. // Order is important !
  65127. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  65128. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  65129. this._uniformBuffer.addUniform("opacityParts", 4);
  65130. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  65131. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  65132. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  65133. this._uniformBuffer.addUniform("refractionRightColor", 4);
  65134. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  65135. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  65136. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  65137. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  65138. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  65139. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  65140. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  65141. this._uniformBuffer.addUniform("vReflectionSize", 3);
  65142. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  65143. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  65144. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  65145. this._uniformBuffer.addUniform("vBumpInfos", 3);
  65146. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  65147. this._uniformBuffer.addUniform("ambientMatrix", 16);
  65148. this._uniformBuffer.addUniform("opacityMatrix", 16);
  65149. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  65150. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  65151. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  65152. this._uniformBuffer.addUniform("specularMatrix", 16);
  65153. this._uniformBuffer.addUniform("bumpMatrix", 16);
  65154. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  65155. this._uniformBuffer.addUniform("refractionMatrix", 16);
  65156. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  65157. this._uniformBuffer.addUniform("vSpecularColor", 4);
  65158. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  65159. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  65160. this._uniformBuffer.addUniform("pointSize", 1);
  65161. this._uniformBuffer.create();
  65162. };
  65163. /**
  65164. * Unbinds the material from the mesh
  65165. */
  65166. StandardMaterial.prototype.unbind = function () {
  65167. if (this._activeEffect) {
  65168. var needFlag = false;
  65169. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65170. this._activeEffect.setTexture("reflection2DSampler", null);
  65171. needFlag = true;
  65172. }
  65173. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65174. this._activeEffect.setTexture("refraction2DSampler", null);
  65175. needFlag = true;
  65176. }
  65177. if (needFlag) {
  65178. this._markAllSubMeshesAsTexturesDirty();
  65179. }
  65180. }
  65181. _super.prototype.unbind.call(this);
  65182. };
  65183. /**
  65184. * Binds the submesh to this material by preparing the effect and shader to draw
  65185. * @param world defines the world transformation matrix
  65186. * @param mesh defines the mesh containing the submesh
  65187. * @param subMesh defines the submesh to bind the material to
  65188. */
  65189. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65190. var scene = this.getScene();
  65191. var defines = subMesh._materialDefines;
  65192. if (!defines) {
  65193. return;
  65194. }
  65195. var effect = subMesh.effect;
  65196. if (!effect) {
  65197. return;
  65198. }
  65199. this._activeEffect = effect;
  65200. // Matrices
  65201. this.bindOnlyWorldMatrix(world);
  65202. // Normal Matrix
  65203. if (defines.OBJECTSPACE_NORMALMAP) {
  65204. world.toNormalMatrix(this._normalMatrix);
  65205. this.bindOnlyNormalMatrix(this._normalMatrix);
  65206. }
  65207. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  65208. // Bones
  65209. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  65210. if (mustRebind) {
  65211. this._uniformBuffer.bindToEffect(effect, "Material");
  65212. this.bindViewProjection(effect);
  65213. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  65214. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  65215. // Fresnel
  65216. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  65217. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  65218. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  65219. }
  65220. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  65221. 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);
  65222. }
  65223. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  65224. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  65225. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  65226. }
  65227. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  65228. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  65229. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  65230. }
  65231. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  65232. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  65233. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  65234. }
  65235. }
  65236. // Textures
  65237. if (scene.texturesEnabled) {
  65238. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65239. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  65240. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  65241. if (this._diffuseTexture.hasAlpha) {
  65242. effect.setFloat("alphaCutOff", this.alphaCutOff);
  65243. }
  65244. }
  65245. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65246. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  65247. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  65248. }
  65249. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65250. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  65251. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  65252. }
  65253. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65254. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  65255. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  65256. if (this._reflectionTexture.boundingBoxSize) {
  65257. var cubeTexture = this._reflectionTexture;
  65258. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  65259. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  65260. }
  65261. }
  65262. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65263. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  65264. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  65265. }
  65266. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65267. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  65268. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  65269. }
  65270. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65271. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  65272. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  65273. }
  65274. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65275. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  65276. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  65277. if (scene._mirroredCameraPosition) {
  65278. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  65279. }
  65280. else {
  65281. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  65282. }
  65283. }
  65284. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65285. var depth = 1.0;
  65286. if (!this._refractionTexture.isCube) {
  65287. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  65288. if (this._refractionTexture.depth) {
  65289. depth = this._refractionTexture.depth;
  65290. }
  65291. }
  65292. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  65293. }
  65294. }
  65295. // Point size
  65296. if (this.pointsCloud) {
  65297. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  65298. }
  65299. if (defines.SPECULARTERM) {
  65300. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  65301. }
  65302. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  65303. // Diffuse
  65304. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  65305. }
  65306. // Textures
  65307. if (scene.texturesEnabled) {
  65308. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65309. effect.setTexture("diffuseSampler", this._diffuseTexture);
  65310. }
  65311. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65312. effect.setTexture("ambientSampler", this._ambientTexture);
  65313. }
  65314. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65315. effect.setTexture("opacitySampler", this._opacityTexture);
  65316. }
  65317. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65318. if (this._reflectionTexture.isCube) {
  65319. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  65320. }
  65321. else {
  65322. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  65323. }
  65324. }
  65325. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65326. effect.setTexture("emissiveSampler", this._emissiveTexture);
  65327. }
  65328. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65329. effect.setTexture("lightmapSampler", this._lightmapTexture);
  65330. }
  65331. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65332. effect.setTexture("specularSampler", this._specularTexture);
  65333. }
  65334. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65335. effect.setTexture("bumpSampler", this._bumpTexture);
  65336. }
  65337. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65338. var depth = 1.0;
  65339. if (this._refractionTexture.isCube) {
  65340. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  65341. }
  65342. else {
  65343. effect.setTexture("refraction2DSampler", this._refractionTexture);
  65344. }
  65345. }
  65346. }
  65347. // Clip plane
  65348. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  65349. // Colors
  65350. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  65351. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  65352. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  65353. }
  65354. if (mustRebind || !this.isFrozen) {
  65355. // Lights
  65356. if (scene.lightsEnabled && !this._disableLighting) {
  65357. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  65358. }
  65359. // View
  65360. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  65361. this.bindView(effect);
  65362. }
  65363. // Fog
  65364. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  65365. // Morph targets
  65366. if (defines.NUM_MORPH_INFLUENCERS) {
  65367. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  65368. }
  65369. // Log. depth
  65370. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  65371. // image processing
  65372. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  65373. this._imageProcessingConfiguration.bind(this._activeEffect);
  65374. }
  65375. }
  65376. this._uniformBuffer.update();
  65377. this._afterBind(mesh, this._activeEffect);
  65378. };
  65379. /**
  65380. * Get the list of animatables in the material.
  65381. * @returns the list of animatables object used in the material
  65382. */
  65383. StandardMaterial.prototype.getAnimatables = function () {
  65384. var results = [];
  65385. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  65386. results.push(this._diffuseTexture);
  65387. }
  65388. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  65389. results.push(this._ambientTexture);
  65390. }
  65391. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  65392. results.push(this._opacityTexture);
  65393. }
  65394. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  65395. results.push(this._reflectionTexture);
  65396. }
  65397. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  65398. results.push(this._emissiveTexture);
  65399. }
  65400. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  65401. results.push(this._specularTexture);
  65402. }
  65403. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  65404. results.push(this._bumpTexture);
  65405. }
  65406. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  65407. results.push(this._lightmapTexture);
  65408. }
  65409. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  65410. results.push(this._refractionTexture);
  65411. }
  65412. return results;
  65413. };
  65414. /**
  65415. * Gets the active textures from the material
  65416. * @returns an array of textures
  65417. */
  65418. StandardMaterial.prototype.getActiveTextures = function () {
  65419. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65420. if (this._diffuseTexture) {
  65421. activeTextures.push(this._diffuseTexture);
  65422. }
  65423. if (this._ambientTexture) {
  65424. activeTextures.push(this._ambientTexture);
  65425. }
  65426. if (this._opacityTexture) {
  65427. activeTextures.push(this._opacityTexture);
  65428. }
  65429. if (this._reflectionTexture) {
  65430. activeTextures.push(this._reflectionTexture);
  65431. }
  65432. if (this._emissiveTexture) {
  65433. activeTextures.push(this._emissiveTexture);
  65434. }
  65435. if (this._specularTexture) {
  65436. activeTextures.push(this._specularTexture);
  65437. }
  65438. if (this._bumpTexture) {
  65439. activeTextures.push(this._bumpTexture);
  65440. }
  65441. if (this._lightmapTexture) {
  65442. activeTextures.push(this._lightmapTexture);
  65443. }
  65444. if (this._refractionTexture) {
  65445. activeTextures.push(this._refractionTexture);
  65446. }
  65447. return activeTextures;
  65448. };
  65449. /**
  65450. * Specifies if the material uses a texture
  65451. * @param texture defines the texture to check against the material
  65452. * @returns a boolean specifying if the material uses the texture
  65453. */
  65454. StandardMaterial.prototype.hasTexture = function (texture) {
  65455. if (_super.prototype.hasTexture.call(this, texture)) {
  65456. return true;
  65457. }
  65458. if (this._diffuseTexture === texture) {
  65459. return true;
  65460. }
  65461. if (this._ambientTexture === texture) {
  65462. return true;
  65463. }
  65464. if (this._opacityTexture === texture) {
  65465. return true;
  65466. }
  65467. if (this._reflectionTexture === texture) {
  65468. return true;
  65469. }
  65470. if (this._emissiveTexture === texture) {
  65471. return true;
  65472. }
  65473. if (this._specularTexture === texture) {
  65474. return true;
  65475. }
  65476. if (this._bumpTexture === texture) {
  65477. return true;
  65478. }
  65479. if (this._lightmapTexture === texture) {
  65480. return true;
  65481. }
  65482. if (this._refractionTexture === texture) {
  65483. return true;
  65484. }
  65485. return false;
  65486. };
  65487. /**
  65488. * Disposes the material
  65489. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65490. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65491. */
  65492. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  65493. if (forceDisposeTextures) {
  65494. if (this._diffuseTexture) {
  65495. this._diffuseTexture.dispose();
  65496. }
  65497. if (this._ambientTexture) {
  65498. this._ambientTexture.dispose();
  65499. }
  65500. if (this._opacityTexture) {
  65501. this._opacityTexture.dispose();
  65502. }
  65503. if (this._reflectionTexture) {
  65504. this._reflectionTexture.dispose();
  65505. }
  65506. if (this._emissiveTexture) {
  65507. this._emissiveTexture.dispose();
  65508. }
  65509. if (this._specularTexture) {
  65510. this._specularTexture.dispose();
  65511. }
  65512. if (this._bumpTexture) {
  65513. this._bumpTexture.dispose();
  65514. }
  65515. if (this._lightmapTexture) {
  65516. this._lightmapTexture.dispose();
  65517. }
  65518. if (this._refractionTexture) {
  65519. this._refractionTexture.dispose();
  65520. }
  65521. }
  65522. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65523. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65524. }
  65525. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  65526. };
  65527. /**
  65528. * Makes a duplicate of the material, and gives it a new name
  65529. * @param name defines the new name for the duplicated material
  65530. * @returns the cloned material
  65531. */
  65532. StandardMaterial.prototype.clone = function (name) {
  65533. var _this = this;
  65534. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  65535. result.name = name;
  65536. result.id = name;
  65537. return result;
  65538. };
  65539. /**
  65540. * Serializes this material in a JSON representation
  65541. * @returns the serialized material object
  65542. */
  65543. StandardMaterial.prototype.serialize = function () {
  65544. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65545. };
  65546. /**
  65547. * Creates a standard material from parsed material data
  65548. * @param source defines the JSON representation of the material
  65549. * @param scene defines the hosting scene
  65550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65551. * @returns a new standard material
  65552. */
  65553. StandardMaterial.Parse = function (source, scene, rootUrl) {
  65554. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  65555. };
  65556. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  65557. // Flags used to enable or disable a type of texture for all Standard Materials
  65558. /**
  65559. * Are diffuse textures enabled in the application.
  65560. */
  65561. get: function () {
  65562. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  65563. },
  65564. set: function (value) {
  65565. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  65566. },
  65567. enumerable: true,
  65568. configurable: true
  65569. });
  65570. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  65571. /**
  65572. * Are ambient textures enabled in the application.
  65573. */
  65574. get: function () {
  65575. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  65576. },
  65577. set: function (value) {
  65578. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  65579. },
  65580. enumerable: true,
  65581. configurable: true
  65582. });
  65583. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  65584. /**
  65585. * Are opacity textures enabled in the application.
  65586. */
  65587. get: function () {
  65588. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  65589. },
  65590. set: function (value) {
  65591. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  65592. },
  65593. enumerable: true,
  65594. configurable: true
  65595. });
  65596. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  65597. /**
  65598. * Are reflection textures enabled in the application.
  65599. */
  65600. get: function () {
  65601. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  65602. },
  65603. set: function (value) {
  65604. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  65605. },
  65606. enumerable: true,
  65607. configurable: true
  65608. });
  65609. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  65610. /**
  65611. * Are emissive textures enabled in the application.
  65612. */
  65613. get: function () {
  65614. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  65615. },
  65616. set: function (value) {
  65617. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  65618. },
  65619. enumerable: true,
  65620. configurable: true
  65621. });
  65622. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  65623. /**
  65624. * Are specular textures enabled in the application.
  65625. */
  65626. get: function () {
  65627. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  65628. },
  65629. set: function (value) {
  65630. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  65631. },
  65632. enumerable: true,
  65633. configurable: true
  65634. });
  65635. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  65636. /**
  65637. * Are bump textures enabled in the application.
  65638. */
  65639. get: function () {
  65640. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  65641. },
  65642. set: function (value) {
  65643. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  65644. },
  65645. enumerable: true,
  65646. configurable: true
  65647. });
  65648. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  65649. /**
  65650. * Are lightmap textures enabled in the application.
  65651. */
  65652. get: function () {
  65653. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  65654. },
  65655. set: function (value) {
  65656. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  65657. },
  65658. enumerable: true,
  65659. configurable: true
  65660. });
  65661. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  65662. /**
  65663. * Are refraction textures enabled in the application.
  65664. */
  65665. get: function () {
  65666. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  65667. },
  65668. set: function (value) {
  65669. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  65670. },
  65671. enumerable: true,
  65672. configurable: true
  65673. });
  65674. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  65675. /**
  65676. * Are color grading textures enabled in the application.
  65677. */
  65678. get: function () {
  65679. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  65680. },
  65681. set: function (value) {
  65682. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  65683. },
  65684. enumerable: true,
  65685. configurable: true
  65686. });
  65687. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  65688. /**
  65689. * Are fresnels enabled in the application.
  65690. */
  65691. get: function () {
  65692. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  65693. },
  65694. set: function (value) {
  65695. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  65696. },
  65697. enumerable: true,
  65698. configurable: true
  65699. });
  65700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  65702. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  65703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  65705. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  65706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  65708. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  65709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65711. ], StandardMaterial.prototype, "ambientTexture", void 0);
  65712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  65714. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  65715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  65717. ], StandardMaterial.prototype, "opacityTexture", void 0);
  65718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  65720. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  65721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65723. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  65724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  65726. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  65727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65729. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  65730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  65732. ], StandardMaterial.prototype, "_specularTexture", void 0);
  65733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65735. ], StandardMaterial.prototype, "specularTexture", void 0);
  65736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  65738. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  65739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65741. ], StandardMaterial.prototype, "bumpTexture", void 0);
  65742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  65744. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  65745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65747. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  65748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  65750. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  65751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65753. ], StandardMaterial.prototype, "refractionTexture", void 0);
  65754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  65756. ], StandardMaterial.prototype, "ambientColor", void 0);
  65757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  65759. ], StandardMaterial.prototype, "diffuseColor", void 0);
  65760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  65762. ], StandardMaterial.prototype, "specularColor", void 0);
  65763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  65765. ], StandardMaterial.prototype, "emissiveColor", void 0);
  65766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65768. ], StandardMaterial.prototype, "specularPower", void 0);
  65769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  65771. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  65772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65774. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  65775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  65777. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  65778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65780. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  65781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  65783. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  65784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65786. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  65787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  65789. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  65790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65792. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  65793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  65795. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  65796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65798. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  65799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  65801. ], StandardMaterial.prototype, "_disableLighting", void 0);
  65802. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65803. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  65804. ], StandardMaterial.prototype, "disableLighting", void 0);
  65805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  65807. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  65808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65810. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  65811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  65813. ], StandardMaterial.prototype, "_useParallax", void 0);
  65814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65816. ], StandardMaterial.prototype, "useParallax", void 0);
  65817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  65819. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  65820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65822. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  65823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65825. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  65826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  65828. ], StandardMaterial.prototype, "_roughness", void 0);
  65829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65831. ], StandardMaterial.prototype, "roughness", void 0);
  65832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65834. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  65835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65837. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  65838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65840. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  65841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  65843. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  65844. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65846. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  65847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  65849. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  65850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  65852. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  65853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  65855. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  65856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  65858. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  65859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  65861. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  65862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  65864. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  65865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  65867. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  65868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  65870. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  65871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  65873. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  65874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  65876. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  65877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  65879. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  65880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  65882. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  65883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  65885. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  65886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65888. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  65889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  65891. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  65892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  65894. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  65895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  65897. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  65898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65900. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  65901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  65903. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  65904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65906. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  65907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  65909. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  65910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65912. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  65913. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65915. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  65916. return StandardMaterial;
  65917. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  65918. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  65919. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  65920. return new StandardMaterial("default material", scene);
  65921. };
  65922. /***/ }),
  65923. /***/ "./Materials/uniformBuffer.ts":
  65924. /*!************************************!*\
  65925. !*** ./Materials/uniformBuffer.ts ***!
  65926. \************************************/
  65927. /*! exports provided: UniformBuffer */
  65928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65929. "use strict";
  65930. __webpack_require__.r(__webpack_exports__);
  65931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  65932. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65933. /**
  65934. * Uniform buffer objects.
  65935. *
  65936. * Handles blocks of uniform on the GPU.
  65937. *
  65938. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  65939. *
  65940. * For more information, please refer to :
  65941. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  65942. */
  65943. var UniformBuffer = /** @class */ (function () {
  65944. /**
  65945. * Instantiates a new Uniform buffer objects.
  65946. *
  65947. * Handles blocks of uniform on the GPU.
  65948. *
  65949. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  65950. *
  65951. * For more information, please refer to :
  65952. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  65953. * @param engine Define the engine the buffer is associated with
  65954. * @param data Define the data contained in the buffer
  65955. * @param dynamic Define if the buffer is updatable
  65956. */
  65957. function UniformBuffer(engine, data, dynamic) {
  65958. this._engine = engine;
  65959. this._noUBO = !engine.supportsUniformBuffers;
  65960. this._dynamic = dynamic;
  65961. this._data = data || [];
  65962. this._uniformLocations = {};
  65963. this._uniformSizes = {};
  65964. this._uniformLocationPointer = 0;
  65965. this._needSync = false;
  65966. if (this._noUBO) {
  65967. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  65968. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  65969. this.updateFloat = this._updateFloatForEffect;
  65970. this.updateFloat2 = this._updateFloat2ForEffect;
  65971. this.updateFloat3 = this._updateFloat3ForEffect;
  65972. this.updateFloat4 = this._updateFloat4ForEffect;
  65973. this.updateMatrix = this._updateMatrixForEffect;
  65974. this.updateVector3 = this._updateVector3ForEffect;
  65975. this.updateVector4 = this._updateVector4ForEffect;
  65976. this.updateColor3 = this._updateColor3ForEffect;
  65977. this.updateColor4 = this._updateColor4ForEffect;
  65978. }
  65979. else {
  65980. this._engine._uniformBuffers.push(this);
  65981. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  65982. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  65983. this.updateFloat = this._updateFloatForUniform;
  65984. this.updateFloat2 = this._updateFloat2ForUniform;
  65985. this.updateFloat3 = this._updateFloat3ForUniform;
  65986. this.updateFloat4 = this._updateFloat4ForUniform;
  65987. this.updateMatrix = this._updateMatrixForUniform;
  65988. this.updateVector3 = this._updateVector3ForUniform;
  65989. this.updateVector4 = this._updateVector4ForUniform;
  65990. this.updateColor3 = this._updateColor3ForUniform;
  65991. this.updateColor4 = this._updateColor4ForUniform;
  65992. }
  65993. }
  65994. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  65995. /**
  65996. * Indicates if the buffer is using the WebGL2 UBO implementation,
  65997. * or just falling back on setUniformXXX calls.
  65998. */
  65999. get: function () {
  66000. return !this._noUBO;
  66001. },
  66002. enumerable: true,
  66003. configurable: true
  66004. });
  66005. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  66006. /**
  66007. * Indicates if the WebGL underlying uniform buffer is in sync
  66008. * with the javascript cache data.
  66009. */
  66010. get: function () {
  66011. return !this._needSync;
  66012. },
  66013. enumerable: true,
  66014. configurable: true
  66015. });
  66016. /**
  66017. * Indicates if the WebGL underlying uniform buffer is dynamic.
  66018. * Also, a dynamic UniformBuffer will disable cache verification and always
  66019. * update the underlying WebGL uniform buffer to the GPU.
  66020. * @returns if Dynamic, otherwise false
  66021. */
  66022. UniformBuffer.prototype.isDynamic = function () {
  66023. return this._dynamic !== undefined;
  66024. };
  66025. /**
  66026. * The data cache on JS side.
  66027. * @returns the underlying data as a float array
  66028. */
  66029. UniformBuffer.prototype.getData = function () {
  66030. return this._bufferData;
  66031. };
  66032. /**
  66033. * The underlying WebGL Uniform buffer.
  66034. * @returns the webgl buffer
  66035. */
  66036. UniformBuffer.prototype.getBuffer = function () {
  66037. return this._buffer;
  66038. };
  66039. /**
  66040. * std140 layout specifies how to align data within an UBO structure.
  66041. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  66042. * for specs.
  66043. */
  66044. UniformBuffer.prototype._fillAlignment = function (size) {
  66045. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  66046. // and 4x4 matrices
  66047. // TODO : change if other types are used
  66048. var alignment;
  66049. if (size <= 2) {
  66050. alignment = size;
  66051. }
  66052. else {
  66053. alignment = 4;
  66054. }
  66055. if ((this._uniformLocationPointer % alignment) !== 0) {
  66056. var oldPointer = this._uniformLocationPointer;
  66057. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  66058. var diff = this._uniformLocationPointer - oldPointer;
  66059. for (var i = 0; i < diff; i++) {
  66060. this._data.push(0);
  66061. }
  66062. }
  66063. };
  66064. /**
  66065. * Adds an uniform in the buffer.
  66066. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  66067. * for the layout to be correct !
  66068. * @param name Name of the uniform, as used in the uniform block in the shader.
  66069. * @param size Data size, or data directly.
  66070. */
  66071. UniformBuffer.prototype.addUniform = function (name, size) {
  66072. if (this._noUBO) {
  66073. return;
  66074. }
  66075. if (this._uniformLocations[name] !== undefined) {
  66076. // Already existing uniform
  66077. return;
  66078. }
  66079. // This function must be called in the order of the shader layout !
  66080. // size can be the size of the uniform, or data directly
  66081. var data;
  66082. if (size instanceof Array) {
  66083. data = size;
  66084. size = data.length;
  66085. }
  66086. else {
  66087. size = size;
  66088. data = [];
  66089. // Fill with zeros
  66090. for (var i = 0; i < size; i++) {
  66091. data.push(0);
  66092. }
  66093. }
  66094. this._fillAlignment(size);
  66095. this._uniformSizes[name] = size;
  66096. this._uniformLocations[name] = this._uniformLocationPointer;
  66097. this._uniformLocationPointer += size;
  66098. for (var i = 0; i < size; i++) {
  66099. this._data.push(data[i]);
  66100. }
  66101. this._needSync = true;
  66102. };
  66103. /**
  66104. * Adds a Matrix 4x4 to the uniform buffer.
  66105. * @param name Name of the uniform, as used in the uniform block in the shader.
  66106. * @param mat A 4x4 matrix.
  66107. */
  66108. UniformBuffer.prototype.addMatrix = function (name, mat) {
  66109. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  66110. };
  66111. /**
  66112. * Adds a vec2 to the uniform buffer.
  66113. * @param name Name of the uniform, as used in the uniform block in the shader.
  66114. * @param x Define the x component value of the vec2
  66115. * @param y Define the y component value of the vec2
  66116. */
  66117. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  66118. var temp = [x, y];
  66119. this.addUniform(name, temp);
  66120. };
  66121. /**
  66122. * Adds a vec3 to the uniform buffer.
  66123. * @param name Name of the uniform, as used in the uniform block in the shader.
  66124. * @param x Define the x component value of the vec3
  66125. * @param y Define the y component value of the vec3
  66126. * @param z Define the z component value of the vec3
  66127. */
  66128. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  66129. var temp = [x, y, z];
  66130. this.addUniform(name, temp);
  66131. };
  66132. /**
  66133. * Adds a vec3 to the uniform buffer.
  66134. * @param name Name of the uniform, as used in the uniform block in the shader.
  66135. * @param color Define the vec3 from a Color
  66136. */
  66137. UniformBuffer.prototype.addColor3 = function (name, color) {
  66138. var temp = new Array();
  66139. color.toArray(temp);
  66140. this.addUniform(name, temp);
  66141. };
  66142. /**
  66143. * Adds a vec4 to the uniform buffer.
  66144. * @param name Name of the uniform, as used in the uniform block in the shader.
  66145. * @param color Define the rgb components from a Color
  66146. * @param alpha Define the a component of the vec4
  66147. */
  66148. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  66149. var temp = new Array();
  66150. color.toArray(temp);
  66151. temp.push(alpha);
  66152. this.addUniform(name, temp);
  66153. };
  66154. /**
  66155. * Adds a vec3 to the uniform buffer.
  66156. * @param name Name of the uniform, as used in the uniform block in the shader.
  66157. * @param vector Define the vec3 components from a Vector
  66158. */
  66159. UniformBuffer.prototype.addVector3 = function (name, vector) {
  66160. var temp = new Array();
  66161. vector.toArray(temp);
  66162. this.addUniform(name, temp);
  66163. };
  66164. /**
  66165. * Adds a Matrix 3x3 to the uniform buffer.
  66166. * @param name Name of the uniform, as used in the uniform block in the shader.
  66167. */
  66168. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  66169. this.addUniform(name, 12);
  66170. };
  66171. /**
  66172. * Adds a Matrix 2x2 to the uniform buffer.
  66173. * @param name Name of the uniform, as used in the uniform block in the shader.
  66174. */
  66175. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  66176. this.addUniform(name, 8);
  66177. };
  66178. /**
  66179. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  66180. */
  66181. UniformBuffer.prototype.create = function () {
  66182. if (this._noUBO) {
  66183. return;
  66184. }
  66185. if (this._buffer) {
  66186. return; // nothing to do
  66187. }
  66188. // See spec, alignment must be filled as a vec4
  66189. this._fillAlignment(4);
  66190. this._bufferData = new Float32Array(this._data);
  66191. this._rebuild();
  66192. this._needSync = true;
  66193. };
  66194. /** @hidden */
  66195. UniformBuffer.prototype._rebuild = function () {
  66196. if (this._noUBO) {
  66197. return;
  66198. }
  66199. if (this._dynamic) {
  66200. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  66201. }
  66202. else {
  66203. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  66204. }
  66205. };
  66206. /**
  66207. * Updates the WebGL Uniform Buffer on the GPU.
  66208. * If the `dynamic` flag is set to true, no cache comparison is done.
  66209. * Otherwise, the buffer will be updated only if the cache differs.
  66210. */
  66211. UniformBuffer.prototype.update = function () {
  66212. if (!this._buffer) {
  66213. this.create();
  66214. return;
  66215. }
  66216. if (!this._dynamic && !this._needSync) {
  66217. return;
  66218. }
  66219. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  66220. this._needSync = false;
  66221. };
  66222. /**
  66223. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  66224. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66225. * @param data Define the flattened data
  66226. * @param size Define the size of the data.
  66227. */
  66228. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  66229. var location = this._uniformLocations[uniformName];
  66230. if (location === undefined) {
  66231. if (this._buffer) {
  66232. // Cannot add an uniform if the buffer is already created
  66233. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  66234. return;
  66235. }
  66236. this.addUniform(uniformName, size);
  66237. location = this._uniformLocations[uniformName];
  66238. }
  66239. if (!this._buffer) {
  66240. this.create();
  66241. }
  66242. if (!this._dynamic) {
  66243. // Cache for static uniform buffers
  66244. var changed = false;
  66245. for (var i = 0; i < size; i++) {
  66246. if (this._bufferData[location + i] !== data[i]) {
  66247. changed = true;
  66248. this._bufferData[location + i] = data[i];
  66249. }
  66250. }
  66251. this._needSync = this._needSync || changed;
  66252. }
  66253. else {
  66254. // No cache for dynamic
  66255. for (var i = 0; i < size; i++) {
  66256. this._bufferData[location + i] = data[i];
  66257. }
  66258. }
  66259. };
  66260. // Update methods
  66261. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  66262. // To match std140, matrix must be realigned
  66263. for (var i = 0; i < 3; i++) {
  66264. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  66265. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  66266. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  66267. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66268. }
  66269. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  66270. };
  66271. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  66272. this._currentEffect.setMatrix3x3(name, matrix);
  66273. };
  66274. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  66275. this._currentEffect.setMatrix2x2(name, matrix);
  66276. };
  66277. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  66278. // To match std140, matrix must be realigned
  66279. for (var i = 0; i < 2; i++) {
  66280. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  66281. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  66282. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  66283. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66284. }
  66285. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  66286. };
  66287. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  66288. this._currentEffect.setFloat(name, x);
  66289. };
  66290. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  66291. UniformBuffer._tempBuffer[0] = x;
  66292. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  66293. };
  66294. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  66295. if (suffix === void 0) { suffix = ""; }
  66296. this._currentEffect.setFloat2(name + suffix, x, y);
  66297. };
  66298. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  66299. UniformBuffer._tempBuffer[0] = x;
  66300. UniformBuffer._tempBuffer[1] = y;
  66301. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  66302. };
  66303. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  66304. if (suffix === void 0) { suffix = ""; }
  66305. this._currentEffect.setFloat3(name + suffix, x, y, z);
  66306. };
  66307. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  66308. UniformBuffer._tempBuffer[0] = x;
  66309. UniformBuffer._tempBuffer[1] = y;
  66310. UniformBuffer._tempBuffer[2] = z;
  66311. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66312. };
  66313. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  66314. if (suffix === void 0) { suffix = ""; }
  66315. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  66316. };
  66317. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  66318. UniformBuffer._tempBuffer[0] = x;
  66319. UniformBuffer._tempBuffer[1] = y;
  66320. UniformBuffer._tempBuffer[2] = z;
  66321. UniformBuffer._tempBuffer[3] = w;
  66322. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66323. };
  66324. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  66325. this._currentEffect.setMatrix(name, mat);
  66326. };
  66327. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  66328. this.updateUniform(name, mat.toArray(), 16);
  66329. };
  66330. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  66331. this._currentEffect.setVector3(name, vector);
  66332. };
  66333. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  66334. vector.toArray(UniformBuffer._tempBuffer);
  66335. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66336. };
  66337. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  66338. this._currentEffect.setVector4(name, vector);
  66339. };
  66340. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  66341. vector.toArray(UniformBuffer._tempBuffer);
  66342. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66343. };
  66344. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  66345. if (suffix === void 0) { suffix = ""; }
  66346. this._currentEffect.setColor3(name + suffix, color);
  66347. };
  66348. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  66349. color.toArray(UniformBuffer._tempBuffer);
  66350. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66351. };
  66352. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  66353. if (suffix === void 0) { suffix = ""; }
  66354. this._currentEffect.setColor4(name + suffix, color, alpha);
  66355. };
  66356. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  66357. color.toArray(UniformBuffer._tempBuffer);
  66358. UniformBuffer._tempBuffer[3] = alpha;
  66359. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66360. };
  66361. /**
  66362. * Sets a sampler uniform on the effect.
  66363. * @param name Define the name of the sampler.
  66364. * @param texture Define the texture to set in the sampler
  66365. */
  66366. UniformBuffer.prototype.setTexture = function (name, texture) {
  66367. this._currentEffect.setTexture(name, texture);
  66368. };
  66369. /**
  66370. * Directly updates the value of the uniform in the cache AND on the GPU.
  66371. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66372. * @param data Define the flattened data
  66373. */
  66374. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  66375. this.updateUniform(uniformName, data, data.length);
  66376. this.update();
  66377. };
  66378. /**
  66379. * Binds this uniform buffer to an effect.
  66380. * @param effect Define the effect to bind the buffer to
  66381. * @param name Name of the uniform block in the shader.
  66382. */
  66383. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  66384. this._currentEffect = effect;
  66385. if (this._noUBO || !this._buffer) {
  66386. return;
  66387. }
  66388. effect.bindUniformBuffer(this._buffer, name);
  66389. };
  66390. /**
  66391. * Disposes the uniform buffer.
  66392. */
  66393. UniformBuffer.prototype.dispose = function () {
  66394. if (this._noUBO) {
  66395. return;
  66396. }
  66397. var uniformBuffers = this._engine._uniformBuffers;
  66398. var index = uniformBuffers.indexOf(this);
  66399. if (index !== -1) {
  66400. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  66401. uniformBuffers.pop();
  66402. }
  66403. if (!this._buffer) {
  66404. return;
  66405. }
  66406. if (this._engine._releaseBuffer(this._buffer)) {
  66407. this._buffer = null;
  66408. }
  66409. };
  66410. // Pool for avoiding memory leaks
  66411. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  66412. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  66413. return UniformBuffer;
  66414. }());
  66415. /***/ }),
  66416. /***/ "./Maths/index.ts":
  66417. /*!************************!*\
  66418. !*** ./Maths/index.ts ***!
  66419. \************************/
  66420. /*! 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 */
  66421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66422. "use strict";
  66423. __webpack_require__.r(__webpack_exports__);
  66424. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  66425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  66426. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  66427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  66428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  66429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  66430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  66431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  66432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  66433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  66434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  66435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  66436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  66437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  66438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  66439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  66440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  66441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  66442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  66443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  66444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  66445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  66446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  66447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  66448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  66449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  66450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  66451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  66452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  66453. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  66454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  66455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  66456. /***/ }),
  66457. /***/ "./Maths/math.scalar.ts":
  66458. /*!******************************!*\
  66459. !*** ./Maths/math.scalar.ts ***!
  66460. \******************************/
  66461. /*! exports provided: Scalar */
  66462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66463. "use strict";
  66464. __webpack_require__.r(__webpack_exports__);
  66465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  66466. /**
  66467. * Scalar computation library
  66468. */
  66469. var Scalar = /** @class */ (function () {
  66470. function Scalar() {
  66471. }
  66472. /**
  66473. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66474. * @param a number
  66475. * @param b number
  66476. * @param epsilon (default = 1.401298E-45)
  66477. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66478. */
  66479. Scalar.WithinEpsilon = function (a, b, epsilon) {
  66480. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  66481. var num = a - b;
  66482. return -epsilon <= num && num <= epsilon;
  66483. };
  66484. /**
  66485. * Returns a string : the upper case translation of the number i to hexadecimal.
  66486. * @param i number
  66487. * @returns the upper case translation of the number i to hexadecimal.
  66488. */
  66489. Scalar.ToHex = function (i) {
  66490. var str = i.toString(16);
  66491. if (i <= 15) {
  66492. return ("0" + str).toUpperCase();
  66493. }
  66494. return str.toUpperCase();
  66495. };
  66496. /**
  66497. * Returns -1 if value is negative and +1 is value is positive.
  66498. * @param value the value
  66499. * @returns the value itself if it's equal to zero.
  66500. */
  66501. Scalar.Sign = function (value) {
  66502. value = +value; // convert to a number
  66503. if (value === 0 || isNaN(value)) {
  66504. return value;
  66505. }
  66506. return value > 0 ? 1 : -1;
  66507. };
  66508. /**
  66509. * Returns the value itself if it's between min and max.
  66510. * Returns min if the value is lower than min.
  66511. * Returns max if the value is greater than max.
  66512. * @param value the value to clmap
  66513. * @param min the min value to clamp to (default: 0)
  66514. * @param max the max value to clamp to (default: 1)
  66515. * @returns the clamped value
  66516. */
  66517. Scalar.Clamp = function (value, min, max) {
  66518. if (min === void 0) { min = 0; }
  66519. if (max === void 0) { max = 1; }
  66520. return Math.min(max, Math.max(min, value));
  66521. };
  66522. /**
  66523. * the log2 of value.
  66524. * @param value the value to compute log2 of
  66525. * @returns the log2 of value.
  66526. */
  66527. Scalar.Log2 = function (value) {
  66528. return Math.log(value) * Math.LOG2E;
  66529. };
  66530. /**
  66531. * Loops the value, so that it is never larger than length and never smaller than 0.
  66532. *
  66533. * This is similar to the modulo operator but it works with floating point numbers.
  66534. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66535. * With t = 5 and length = 2.5, the result would be 0.0.
  66536. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66537. * @param value the value
  66538. * @param length the length
  66539. * @returns the looped value
  66540. */
  66541. Scalar.Repeat = function (value, length) {
  66542. return value - Math.floor(value / length) * length;
  66543. };
  66544. /**
  66545. * Normalize the value between 0.0 and 1.0 using min and max values
  66546. * @param value value to normalize
  66547. * @param min max to normalize between
  66548. * @param max min to normalize between
  66549. * @returns the normalized value
  66550. */
  66551. Scalar.Normalize = function (value, min, max) {
  66552. return (value - min) / (max - min);
  66553. };
  66554. /**
  66555. * Denormalize the value from 0.0 and 1.0 using min and max values
  66556. * @param normalized value to denormalize
  66557. * @param min max to denormalize between
  66558. * @param max min to denormalize between
  66559. * @returns the denormalized value
  66560. */
  66561. Scalar.Denormalize = function (normalized, min, max) {
  66562. return (normalized * (max - min) + min);
  66563. };
  66564. /**
  66565. * Calculates the shortest difference between two given angles given in degrees.
  66566. * @param current current angle in degrees
  66567. * @param target target angle in degrees
  66568. * @returns the delta
  66569. */
  66570. Scalar.DeltaAngle = function (current, target) {
  66571. var num = Scalar.Repeat(target - current, 360.0);
  66572. if (num > 180.0) {
  66573. num -= 360.0;
  66574. }
  66575. return num;
  66576. };
  66577. /**
  66578. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66579. * @param tx value
  66580. * @param length length
  66581. * @returns The returned value will move back and forth between 0 and length
  66582. */
  66583. Scalar.PingPong = function (tx, length) {
  66584. var t = Scalar.Repeat(tx, length * 2.0);
  66585. return length - Math.abs(t - length);
  66586. };
  66587. /**
  66588. * Interpolates between min and max with smoothing at the limits.
  66589. *
  66590. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66591. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66592. * @param from from
  66593. * @param to to
  66594. * @param tx value
  66595. * @returns the smooth stepped value
  66596. */
  66597. Scalar.SmoothStep = function (from, to, tx) {
  66598. var t = Scalar.Clamp(tx);
  66599. t = -2.0 * t * t * t + 3.0 * t * t;
  66600. return to * t + from * (1.0 - t);
  66601. };
  66602. /**
  66603. * Moves a value current towards target.
  66604. *
  66605. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66606. * Negative values of maxDelta pushes the value away from target.
  66607. * @param current current value
  66608. * @param target target value
  66609. * @param maxDelta max distance to move
  66610. * @returns resulting value
  66611. */
  66612. Scalar.MoveTowards = function (current, target, maxDelta) {
  66613. var result = 0;
  66614. if (Math.abs(target - current) <= maxDelta) {
  66615. result = target;
  66616. }
  66617. else {
  66618. result = current + Scalar.Sign(target - current) * maxDelta;
  66619. }
  66620. return result;
  66621. };
  66622. /**
  66623. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66624. *
  66625. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66626. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66627. * @param current current value
  66628. * @param target target value
  66629. * @param maxDelta max distance to move
  66630. * @returns resulting angle
  66631. */
  66632. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  66633. var num = Scalar.DeltaAngle(current, target);
  66634. var result = 0;
  66635. if (-maxDelta < num && num < maxDelta) {
  66636. result = target;
  66637. }
  66638. else {
  66639. target = current + num;
  66640. result = Scalar.MoveTowards(current, target, maxDelta);
  66641. }
  66642. return result;
  66643. };
  66644. /**
  66645. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66646. * @param start start value
  66647. * @param end target value
  66648. * @param amount amount to lerp between
  66649. * @returns the lerped value
  66650. */
  66651. Scalar.Lerp = function (start, end, amount) {
  66652. return start + ((end - start) * amount);
  66653. };
  66654. /**
  66655. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66656. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66657. * @param start start value
  66658. * @param end target value
  66659. * @param amount amount to lerp between
  66660. * @returns the lerped value
  66661. */
  66662. Scalar.LerpAngle = function (start, end, amount) {
  66663. var num = Scalar.Repeat(end - start, 360.0);
  66664. if (num > 180.0) {
  66665. num -= 360.0;
  66666. }
  66667. return start + num * Scalar.Clamp(amount);
  66668. };
  66669. /**
  66670. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66671. * @param a start value
  66672. * @param b target value
  66673. * @param value value between a and b
  66674. * @returns the inverseLerp value
  66675. */
  66676. Scalar.InverseLerp = function (a, b, value) {
  66677. var result = 0;
  66678. if (a != b) {
  66679. result = Scalar.Clamp((value - a) / (b - a));
  66680. }
  66681. else {
  66682. result = 0.0;
  66683. }
  66684. return result;
  66685. };
  66686. /**
  66687. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66688. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66689. * @param value1 spline value
  66690. * @param tangent1 spline value
  66691. * @param value2 spline value
  66692. * @param tangent2 spline value
  66693. * @param amount input value
  66694. * @returns hermite result
  66695. */
  66696. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  66697. var squared = amount * amount;
  66698. var cubed = amount * squared;
  66699. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  66700. var part2 = (-2.0 * cubed) + (3.0 * squared);
  66701. var part3 = (cubed - (2.0 * squared)) + amount;
  66702. var part4 = cubed - squared;
  66703. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  66704. };
  66705. /**
  66706. * Returns a random float number between and min and max values
  66707. * @param min min value of random
  66708. * @param max max value of random
  66709. * @returns random value
  66710. */
  66711. Scalar.RandomRange = function (min, max) {
  66712. if (min === max) {
  66713. return min;
  66714. }
  66715. return ((Math.random() * (max - min)) + min);
  66716. };
  66717. /**
  66718. * This function returns percentage of a number in a given range.
  66719. *
  66720. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66721. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66722. * @param number to convert to percentage
  66723. * @param min min range
  66724. * @param max max range
  66725. * @returns the percentage
  66726. */
  66727. Scalar.RangeToPercent = function (number, min, max) {
  66728. return ((number - min) / (max - min));
  66729. };
  66730. /**
  66731. * This function returns number that corresponds to the percentage in a given range.
  66732. *
  66733. * PercentToRange(0.34,0,100) will return 34.
  66734. * @param percent to convert to number
  66735. * @param min min range
  66736. * @param max max range
  66737. * @returns the number
  66738. */
  66739. Scalar.PercentToRange = function (percent, min, max) {
  66740. return ((max - min) * percent + min);
  66741. };
  66742. /**
  66743. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66744. * @param angle The angle to normalize in radian.
  66745. * @return The converted angle.
  66746. */
  66747. Scalar.NormalizeRadians = function (angle) {
  66748. // More precise but slower version kept for reference.
  66749. // angle = angle % Tools.TwoPi;
  66750. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  66751. //if (angle > Math.PI) {
  66752. // angle -= Tools.TwoPi;
  66753. //}
  66754. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  66755. return angle;
  66756. };
  66757. /**
  66758. * Two pi constants convenient for computation.
  66759. */
  66760. Scalar.TwoPi = Math.PI * 2;
  66761. return Scalar;
  66762. }());
  66763. /***/ }),
  66764. /***/ "./Maths/math.ts":
  66765. /*!***********************!*\
  66766. !*** ./Maths/math.ts ***!
  66767. \***********************/
  66768. /*! 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 */
  66769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66770. "use strict";
  66771. __webpack_require__.r(__webpack_exports__);
  66772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  66773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  66774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  66775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  66776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  66777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  66778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  66779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  66780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  66781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  66782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  66783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  66784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  66785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  66786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  66787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  66788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  66789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  66790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  66791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  66792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  66793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  66794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  66795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  66796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  66797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  66798. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  66799. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  66800. /**
  66801. * Constant used to convert a value to gamma space
  66802. * @ignorenaming
  66803. */
  66804. var ToGammaSpace = 1 / 2.2;
  66805. /**
  66806. * Constant used to convert a value to linear space
  66807. * @ignorenaming
  66808. */
  66809. var ToLinearSpace = 2.2;
  66810. /**
  66811. * Constant used to define the minimal number value in Babylon.js
  66812. * @ignorenaming
  66813. */
  66814. var Epsilon = 0.001;
  66815. /**
  66816. * Class used to hold a RBG color
  66817. */
  66818. var Color3 = /** @class */ (function () {
  66819. /**
  66820. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  66821. * @param r defines the red component (between 0 and 1, default is 0)
  66822. * @param g defines the green component (between 0 and 1, default is 0)
  66823. * @param b defines the blue component (between 0 and 1, default is 0)
  66824. */
  66825. function Color3(
  66826. /**
  66827. * Defines the red component (between 0 and 1, default is 0)
  66828. */
  66829. r,
  66830. /**
  66831. * Defines the green component (between 0 and 1, default is 0)
  66832. */
  66833. g,
  66834. /**
  66835. * Defines the blue component (between 0 and 1, default is 0)
  66836. */
  66837. b) {
  66838. if (r === void 0) { r = 0; }
  66839. if (g === void 0) { g = 0; }
  66840. if (b === void 0) { b = 0; }
  66841. this.r = r;
  66842. this.g = g;
  66843. this.b = b;
  66844. }
  66845. /**
  66846. * Creates a string with the Color3 current values
  66847. * @returns the string representation of the Color3 object
  66848. */
  66849. Color3.prototype.toString = function () {
  66850. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  66851. };
  66852. /**
  66853. * Returns the string "Color3"
  66854. * @returns "Color3"
  66855. */
  66856. Color3.prototype.getClassName = function () {
  66857. return "Color3";
  66858. };
  66859. /**
  66860. * Compute the Color3 hash code
  66861. * @returns an unique number that can be used to hash Color3 objects
  66862. */
  66863. Color3.prototype.getHashCode = function () {
  66864. var hash = this.r || 0;
  66865. hash = (hash * 397) ^ (this.g || 0);
  66866. hash = (hash * 397) ^ (this.b || 0);
  66867. return hash;
  66868. };
  66869. // Operators
  66870. /**
  66871. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  66872. * @param array defines the array where to store the r,g,b components
  66873. * @param index defines an optional index in the target array to define where to start storing values
  66874. * @returns the current Color3 object
  66875. */
  66876. Color3.prototype.toArray = function (array, index) {
  66877. if (index === void 0) { index = 0; }
  66878. array[index] = this.r;
  66879. array[index + 1] = this.g;
  66880. array[index + 2] = this.b;
  66881. return this;
  66882. };
  66883. /**
  66884. * Returns a new Color4 object from the current Color3 and the given alpha
  66885. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  66886. * @returns a new Color4 object
  66887. */
  66888. Color3.prototype.toColor4 = function (alpha) {
  66889. if (alpha === void 0) { alpha = 1; }
  66890. return new Color4(this.r, this.g, this.b, alpha);
  66891. };
  66892. /**
  66893. * Returns a new array populated with 3 numeric elements : red, green and blue values
  66894. * @returns the new array
  66895. */
  66896. Color3.prototype.asArray = function () {
  66897. var result = new Array();
  66898. this.toArray(result, 0);
  66899. return result;
  66900. };
  66901. /**
  66902. * Returns the luminance value
  66903. * @returns a float value
  66904. */
  66905. Color3.prototype.toLuminance = function () {
  66906. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  66907. };
  66908. /**
  66909. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  66910. * @param otherColor defines the second operand
  66911. * @returns the new Color3 object
  66912. */
  66913. Color3.prototype.multiply = function (otherColor) {
  66914. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  66915. };
  66916. /**
  66917. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  66918. * @param otherColor defines the second operand
  66919. * @param result defines the Color3 object where to store the result
  66920. * @returns the current Color3
  66921. */
  66922. Color3.prototype.multiplyToRef = function (otherColor, result) {
  66923. result.r = this.r * otherColor.r;
  66924. result.g = this.g * otherColor.g;
  66925. result.b = this.b * otherColor.b;
  66926. return this;
  66927. };
  66928. /**
  66929. * Determines equality between Color3 objects
  66930. * @param otherColor defines the second operand
  66931. * @returns true if the rgb values are equal to the given ones
  66932. */
  66933. Color3.prototype.equals = function (otherColor) {
  66934. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  66935. };
  66936. /**
  66937. * Determines equality between the current Color3 object and a set of r,b,g values
  66938. * @param r defines the red component to check
  66939. * @param g defines the green component to check
  66940. * @param b defines the blue component to check
  66941. * @returns true if the rgb values are equal to the given ones
  66942. */
  66943. Color3.prototype.equalsFloats = function (r, g, b) {
  66944. return this.r === r && this.g === g && this.b === b;
  66945. };
  66946. /**
  66947. * Multiplies in place each rgb value by scale
  66948. * @param scale defines the scaling factor
  66949. * @returns the updated Color3
  66950. */
  66951. Color3.prototype.scale = function (scale) {
  66952. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  66953. };
  66954. /**
  66955. * Multiplies the rgb values by scale and stores the result into "result"
  66956. * @param scale defines the scaling factor
  66957. * @param result defines the Color3 object where to store the result
  66958. * @returns the unmodified current Color3
  66959. */
  66960. Color3.prototype.scaleToRef = function (scale, result) {
  66961. result.r = this.r * scale;
  66962. result.g = this.g * scale;
  66963. result.b = this.b * scale;
  66964. return this;
  66965. };
  66966. /**
  66967. * Scale the current Color3 values by a factor and add the result to a given Color3
  66968. * @param scale defines the scale factor
  66969. * @param result defines color to store the result into
  66970. * @returns the unmodified current Color3
  66971. */
  66972. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  66973. result.r += this.r * scale;
  66974. result.g += this.g * scale;
  66975. result.b += this.b * scale;
  66976. return this;
  66977. };
  66978. /**
  66979. * Clamps the rgb values by the min and max values and stores the result into "result"
  66980. * @param min defines minimum clamping value (default is 0)
  66981. * @param max defines maximum clamping value (default is 1)
  66982. * @param result defines color to store the result into
  66983. * @returns the original Color3
  66984. */
  66985. Color3.prototype.clampToRef = function (min, max, result) {
  66986. if (min === void 0) { min = 0; }
  66987. if (max === void 0) { max = 1; }
  66988. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  66989. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  66990. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  66991. return this;
  66992. };
  66993. /**
  66994. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  66995. * @param otherColor defines the second operand
  66996. * @returns the new Color3
  66997. */
  66998. Color3.prototype.add = function (otherColor) {
  66999. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  67000. };
  67001. /**
  67002. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  67003. * @param otherColor defines the second operand
  67004. * @param result defines Color3 object to store the result into
  67005. * @returns the unmodified current Color3
  67006. */
  67007. Color3.prototype.addToRef = function (otherColor, result) {
  67008. result.r = this.r + otherColor.r;
  67009. result.g = this.g + otherColor.g;
  67010. result.b = this.b + otherColor.b;
  67011. return this;
  67012. };
  67013. /**
  67014. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  67015. * @param otherColor defines the second operand
  67016. * @returns the new Color3
  67017. */
  67018. Color3.prototype.subtract = function (otherColor) {
  67019. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  67020. };
  67021. /**
  67022. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  67023. * @param otherColor defines the second operand
  67024. * @param result defines Color3 object to store the result into
  67025. * @returns the unmodified current Color3
  67026. */
  67027. Color3.prototype.subtractToRef = function (otherColor, result) {
  67028. result.r = this.r - otherColor.r;
  67029. result.g = this.g - otherColor.g;
  67030. result.b = this.b - otherColor.b;
  67031. return this;
  67032. };
  67033. /**
  67034. * Copy the current object
  67035. * @returns a new Color3 copied the current one
  67036. */
  67037. Color3.prototype.clone = function () {
  67038. return new Color3(this.r, this.g, this.b);
  67039. };
  67040. /**
  67041. * Copies the rgb values from the source in the current Color3
  67042. * @param source defines the source Color3 object
  67043. * @returns the updated Color3 object
  67044. */
  67045. Color3.prototype.copyFrom = function (source) {
  67046. this.r = source.r;
  67047. this.g = source.g;
  67048. this.b = source.b;
  67049. return this;
  67050. };
  67051. /**
  67052. * Updates the Color3 rgb values from the given floats
  67053. * @param r defines the red component to read from
  67054. * @param g defines the green component to read from
  67055. * @param b defines the blue component to read from
  67056. * @returns the current Color3 object
  67057. */
  67058. Color3.prototype.copyFromFloats = function (r, g, b) {
  67059. this.r = r;
  67060. this.g = g;
  67061. this.b = b;
  67062. return this;
  67063. };
  67064. /**
  67065. * Updates the Color3 rgb values from the given floats
  67066. * @param r defines the red component to read from
  67067. * @param g defines the green component to read from
  67068. * @param b defines the blue component to read from
  67069. * @returns the current Color3 object
  67070. */
  67071. Color3.prototype.set = function (r, g, b) {
  67072. return this.copyFromFloats(r, g, b);
  67073. };
  67074. /**
  67075. * Compute the Color3 hexadecimal code as a string
  67076. * @returns a string containing the hexadecimal representation of the Color3 object
  67077. */
  67078. Color3.prototype.toHexString = function () {
  67079. var intR = (this.r * 255) | 0;
  67080. var intG = (this.g * 255) | 0;
  67081. var intB = (this.b * 255) | 0;
  67082. 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);
  67083. };
  67084. /**
  67085. * Computes a new Color3 converted from the current one to linear space
  67086. * @returns a new Color3 object
  67087. */
  67088. Color3.prototype.toLinearSpace = function () {
  67089. var convertedColor = new Color3();
  67090. this.toLinearSpaceToRef(convertedColor);
  67091. return convertedColor;
  67092. };
  67093. /**
  67094. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  67095. * @param convertedColor defines the Color3 object where to store the linear space version
  67096. * @returns the unmodified Color3
  67097. */
  67098. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  67099. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67100. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67101. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67102. return this;
  67103. };
  67104. /**
  67105. * Computes a new Color3 converted from the current one to gamma space
  67106. * @returns a new Color3 object
  67107. */
  67108. Color3.prototype.toGammaSpace = function () {
  67109. var convertedColor = new Color3();
  67110. this.toGammaSpaceToRef(convertedColor);
  67111. return convertedColor;
  67112. };
  67113. /**
  67114. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  67115. * @param convertedColor defines the Color3 object where to store the gamma space version
  67116. * @returns the unmodified Color3
  67117. */
  67118. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  67119. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67120. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67121. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67122. return this;
  67123. };
  67124. /**
  67125. * Creates a new Color3 from the string containing valid hexadecimal values
  67126. * @param hex defines a string containing valid hexadecimal values
  67127. * @returns a new Color3 object
  67128. */
  67129. Color3.FromHexString = function (hex) {
  67130. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  67131. return new Color3(0, 0, 0);
  67132. }
  67133. var r = parseInt(hex.substring(1, 3), 16);
  67134. var g = parseInt(hex.substring(3, 5), 16);
  67135. var b = parseInt(hex.substring(5, 7), 16);
  67136. return Color3.FromInts(r, g, b);
  67137. };
  67138. /**
  67139. * Creates a new Vector3 from the starting index of the given array
  67140. * @param array defines the source array
  67141. * @param offset defines an offset in the source array
  67142. * @returns a new Color3 object
  67143. */
  67144. Color3.FromArray = function (array, offset) {
  67145. if (offset === void 0) { offset = 0; }
  67146. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  67147. };
  67148. /**
  67149. * Creates a new Color3 from integer values (< 256)
  67150. * @param r defines the red component to read from (value between 0 and 255)
  67151. * @param g defines the green component to read from (value between 0 and 255)
  67152. * @param b defines the blue component to read from (value between 0 and 255)
  67153. * @returns a new Color3 object
  67154. */
  67155. Color3.FromInts = function (r, g, b) {
  67156. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  67157. };
  67158. /**
  67159. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67160. * @param start defines the start Color3 value
  67161. * @param end defines the end Color3 value
  67162. * @param amount defines the gradient value between start and end
  67163. * @returns a new Color3 object
  67164. */
  67165. Color3.Lerp = function (start, end, amount) {
  67166. var result = new Color3(0.0, 0.0, 0.0);
  67167. Color3.LerpToRef(start, end, amount, result);
  67168. return result;
  67169. };
  67170. /**
  67171. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67172. * @param left defines the start value
  67173. * @param right defines the end value
  67174. * @param amount defines the gradient factor
  67175. * @param result defines the Color3 object where to store the result
  67176. */
  67177. Color3.LerpToRef = function (left, right, amount, result) {
  67178. result.r = left.r + ((right.r - left.r) * amount);
  67179. result.g = left.g + ((right.g - left.g) * amount);
  67180. result.b = left.b + ((right.b - left.b) * amount);
  67181. };
  67182. /**
  67183. * Returns a Color3 value containing a red color
  67184. * @returns a new Color3 object
  67185. */
  67186. Color3.Red = function () { return new Color3(1, 0, 0); };
  67187. /**
  67188. * Returns a Color3 value containing a green color
  67189. * @returns a new Color3 object
  67190. */
  67191. Color3.Green = function () { return new Color3(0, 1, 0); };
  67192. /**
  67193. * Returns a Color3 value containing a blue color
  67194. * @returns a new Color3 object
  67195. */
  67196. Color3.Blue = function () { return new Color3(0, 0, 1); };
  67197. /**
  67198. * Returns a Color3 value containing a black color
  67199. * @returns a new Color3 object
  67200. */
  67201. Color3.Black = function () { return new Color3(0, 0, 0); };
  67202. Object.defineProperty(Color3, "BlackReadOnly", {
  67203. /**
  67204. * Gets a Color3 value containing a black color that must not be updated
  67205. */
  67206. get: function () {
  67207. return Color3._BlackReadOnly;
  67208. },
  67209. enumerable: true,
  67210. configurable: true
  67211. });
  67212. /**
  67213. * Returns a Color3 value containing a white color
  67214. * @returns a new Color3 object
  67215. */
  67216. Color3.White = function () { return new Color3(1, 1, 1); };
  67217. /**
  67218. * Returns a Color3 value containing a purple color
  67219. * @returns a new Color3 object
  67220. */
  67221. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  67222. /**
  67223. * Returns a Color3 value containing a magenta color
  67224. * @returns a new Color3 object
  67225. */
  67226. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  67227. /**
  67228. * Returns a Color3 value containing a yellow color
  67229. * @returns a new Color3 object
  67230. */
  67231. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  67232. /**
  67233. * Returns a Color3 value containing a gray color
  67234. * @returns a new Color3 object
  67235. */
  67236. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  67237. /**
  67238. * Returns a Color3 value containing a teal color
  67239. * @returns a new Color3 object
  67240. */
  67241. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  67242. /**
  67243. * Returns a Color3 value containing a random color
  67244. * @returns a new Color3 object
  67245. */
  67246. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  67247. // Statics
  67248. Color3._BlackReadOnly = Color3.Black();
  67249. return Color3;
  67250. }());
  67251. /**
  67252. * Class used to hold a RBGA color
  67253. */
  67254. var Color4 = /** @class */ (function () {
  67255. /**
  67256. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  67257. * @param r defines the red component (between 0 and 1, default is 0)
  67258. * @param g defines the green component (between 0 and 1, default is 0)
  67259. * @param b defines the blue component (between 0 and 1, default is 0)
  67260. * @param a defines the alpha component (between 0 and 1, default is 1)
  67261. */
  67262. function Color4(
  67263. /**
  67264. * Defines the red component (between 0 and 1, default is 0)
  67265. */
  67266. r,
  67267. /**
  67268. * Defines the green component (between 0 and 1, default is 0)
  67269. */
  67270. g,
  67271. /**
  67272. * Defines the blue component (between 0 and 1, default is 0)
  67273. */
  67274. b,
  67275. /**
  67276. * Defines the alpha component (between 0 and 1, default is 1)
  67277. */
  67278. a) {
  67279. if (r === void 0) { r = 0; }
  67280. if (g === void 0) { g = 0; }
  67281. if (b === void 0) { b = 0; }
  67282. if (a === void 0) { a = 1; }
  67283. this.r = r;
  67284. this.g = g;
  67285. this.b = b;
  67286. this.a = a;
  67287. }
  67288. // Operators
  67289. /**
  67290. * Adds in place the given Color4 values to the current Color4 object
  67291. * @param right defines the second operand
  67292. * @returns the current updated Color4 object
  67293. */
  67294. Color4.prototype.addInPlace = function (right) {
  67295. this.r += right.r;
  67296. this.g += right.g;
  67297. this.b += right.b;
  67298. this.a += right.a;
  67299. return this;
  67300. };
  67301. /**
  67302. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  67303. * @returns the new array
  67304. */
  67305. Color4.prototype.asArray = function () {
  67306. var result = new Array();
  67307. this.toArray(result, 0);
  67308. return result;
  67309. };
  67310. /**
  67311. * Stores from the starting index in the given array the Color4 successive values
  67312. * @param array defines the array where to store the r,g,b components
  67313. * @param index defines an optional index in the target array to define where to start storing values
  67314. * @returns the current Color4 object
  67315. */
  67316. Color4.prototype.toArray = function (array, index) {
  67317. if (index === void 0) { index = 0; }
  67318. array[index] = this.r;
  67319. array[index + 1] = this.g;
  67320. array[index + 2] = this.b;
  67321. array[index + 3] = this.a;
  67322. return this;
  67323. };
  67324. /**
  67325. * Determines equality between Color4 objects
  67326. * @param otherColor defines the second operand
  67327. * @returns true if the rgba values are equal to the given ones
  67328. */
  67329. Color4.prototype.equals = function (otherColor) {
  67330. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  67331. };
  67332. /**
  67333. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  67334. * @param right defines the second operand
  67335. * @returns a new Color4 object
  67336. */
  67337. Color4.prototype.add = function (right) {
  67338. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  67339. };
  67340. /**
  67341. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  67342. * @param right defines the second operand
  67343. * @returns a new Color4 object
  67344. */
  67345. Color4.prototype.subtract = function (right) {
  67346. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  67347. };
  67348. /**
  67349. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  67350. * @param right defines the second operand
  67351. * @param result defines the Color4 object where to store the result
  67352. * @returns the current Color4 object
  67353. */
  67354. Color4.prototype.subtractToRef = function (right, result) {
  67355. result.r = this.r - right.r;
  67356. result.g = this.g - right.g;
  67357. result.b = this.b - right.b;
  67358. result.a = this.a - right.a;
  67359. return this;
  67360. };
  67361. /**
  67362. * Creates a new Color4 with the current Color4 values multiplied by scale
  67363. * @param scale defines the scaling factor to apply
  67364. * @returns a new Color4 object
  67365. */
  67366. Color4.prototype.scale = function (scale) {
  67367. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  67368. };
  67369. /**
  67370. * Multiplies the current Color4 values by scale and stores the result in "result"
  67371. * @param scale defines the scaling factor to apply
  67372. * @param result defines the Color4 object where to store the result
  67373. * @returns the current unmodified Color4
  67374. */
  67375. Color4.prototype.scaleToRef = function (scale, result) {
  67376. result.r = this.r * scale;
  67377. result.g = this.g * scale;
  67378. result.b = this.b * scale;
  67379. result.a = this.a * scale;
  67380. return this;
  67381. };
  67382. /**
  67383. * Scale the current Color4 values by a factor and add the result to a given Color4
  67384. * @param scale defines the scale factor
  67385. * @param result defines the Color4 object where to store the result
  67386. * @returns the unmodified current Color4
  67387. */
  67388. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  67389. result.r += this.r * scale;
  67390. result.g += this.g * scale;
  67391. result.b += this.b * scale;
  67392. result.a += this.a * scale;
  67393. return this;
  67394. };
  67395. /**
  67396. * Clamps the rgb values by the min and max values and stores the result into "result"
  67397. * @param min defines minimum clamping value (default is 0)
  67398. * @param max defines maximum clamping value (default is 1)
  67399. * @param result defines color to store the result into.
  67400. * @returns the cuurent Color4
  67401. */
  67402. Color4.prototype.clampToRef = function (min, max, result) {
  67403. if (min === void 0) { min = 0; }
  67404. if (max === void 0) { max = 1; }
  67405. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67406. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67407. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67408. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  67409. return this;
  67410. };
  67411. /**
  67412. * Multipy an Color4 value by another and return a new Color4 object
  67413. * @param color defines the Color4 value to multiply by
  67414. * @returns a new Color4 object
  67415. */
  67416. Color4.prototype.multiply = function (color) {
  67417. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  67418. };
  67419. /**
  67420. * Multipy a Color4 value by another and push the result in a reference value
  67421. * @param color defines the Color4 value to multiply by
  67422. * @param result defines the Color4 to fill the result in
  67423. * @returns the result Color4
  67424. */
  67425. Color4.prototype.multiplyToRef = function (color, result) {
  67426. result.r = this.r * color.r;
  67427. result.g = this.g * color.g;
  67428. result.b = this.b * color.b;
  67429. result.a = this.a * color.a;
  67430. return result;
  67431. };
  67432. /**
  67433. * Creates a string with the Color4 current values
  67434. * @returns the string representation of the Color4 object
  67435. */
  67436. Color4.prototype.toString = function () {
  67437. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  67438. };
  67439. /**
  67440. * Returns the string "Color4"
  67441. * @returns "Color4"
  67442. */
  67443. Color4.prototype.getClassName = function () {
  67444. return "Color4";
  67445. };
  67446. /**
  67447. * Compute the Color4 hash code
  67448. * @returns an unique number that can be used to hash Color4 objects
  67449. */
  67450. Color4.prototype.getHashCode = function () {
  67451. var hash = this.r || 0;
  67452. hash = (hash * 397) ^ (this.g || 0);
  67453. hash = (hash * 397) ^ (this.b || 0);
  67454. hash = (hash * 397) ^ (this.a || 0);
  67455. return hash;
  67456. };
  67457. /**
  67458. * Creates a new Color4 copied from the current one
  67459. * @returns a new Color4 object
  67460. */
  67461. Color4.prototype.clone = function () {
  67462. return new Color4(this.r, this.g, this.b, this.a);
  67463. };
  67464. /**
  67465. * Copies the given Color4 values into the current one
  67466. * @param source defines the source Color4 object
  67467. * @returns the current updated Color4 object
  67468. */
  67469. Color4.prototype.copyFrom = function (source) {
  67470. this.r = source.r;
  67471. this.g = source.g;
  67472. this.b = source.b;
  67473. this.a = source.a;
  67474. return this;
  67475. };
  67476. /**
  67477. * Copies the given float values into the current one
  67478. * @param r defines the red component to read from
  67479. * @param g defines the green component to read from
  67480. * @param b defines the blue component to read from
  67481. * @param a defines the alpha component to read from
  67482. * @returns the current updated Color4 object
  67483. */
  67484. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  67485. this.r = r;
  67486. this.g = g;
  67487. this.b = b;
  67488. this.a = a;
  67489. return this;
  67490. };
  67491. /**
  67492. * Copies the given float values into the current one
  67493. * @param r defines the red component to read from
  67494. * @param g defines the green component to read from
  67495. * @param b defines the blue component to read from
  67496. * @param a defines the alpha component to read from
  67497. * @returns the current updated Color4 object
  67498. */
  67499. Color4.prototype.set = function (r, g, b, a) {
  67500. return this.copyFromFloats(r, g, b, a);
  67501. };
  67502. /**
  67503. * Compute the Color4 hexadecimal code as a string
  67504. * @returns a string containing the hexadecimal representation of the Color4 object
  67505. */
  67506. Color4.prototype.toHexString = function () {
  67507. var intR = (this.r * 255) | 0;
  67508. var intG = (this.g * 255) | 0;
  67509. var intB = (this.b * 255) | 0;
  67510. var intA = (this.a * 255) | 0;
  67511. 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);
  67512. };
  67513. /**
  67514. * Computes a new Color4 converted from the current one to linear space
  67515. * @returns a new Color4 object
  67516. */
  67517. Color4.prototype.toLinearSpace = function () {
  67518. var convertedColor = new Color4();
  67519. this.toLinearSpaceToRef(convertedColor);
  67520. return convertedColor;
  67521. };
  67522. /**
  67523. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  67524. * @param convertedColor defines the Color4 object where to store the linear space version
  67525. * @returns the unmodified Color4
  67526. */
  67527. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  67528. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67529. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67530. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67531. convertedColor.a = this.a;
  67532. return this;
  67533. };
  67534. /**
  67535. * Computes a new Color4 converted from the current one to gamma space
  67536. * @returns a new Color4 object
  67537. */
  67538. Color4.prototype.toGammaSpace = function () {
  67539. var convertedColor = new Color4();
  67540. this.toGammaSpaceToRef(convertedColor);
  67541. return convertedColor;
  67542. };
  67543. /**
  67544. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  67545. * @param convertedColor defines the Color4 object where to store the gamma space version
  67546. * @returns the unmodified Color4
  67547. */
  67548. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  67549. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67550. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67551. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67552. convertedColor.a = this.a;
  67553. return this;
  67554. };
  67555. // Statics
  67556. /**
  67557. * Creates a new Color4 from the string containing valid hexadecimal values
  67558. * @param hex defines a string containing valid hexadecimal values
  67559. * @returns a new Color4 object
  67560. */
  67561. Color4.FromHexString = function (hex) {
  67562. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  67563. return new Color4(0.0, 0.0, 0.0, 0.0);
  67564. }
  67565. var r = parseInt(hex.substring(1, 3), 16);
  67566. var g = parseInt(hex.substring(3, 5), 16);
  67567. var b = parseInt(hex.substring(5, 7), 16);
  67568. var a = parseInt(hex.substring(7, 9), 16);
  67569. return Color4.FromInts(r, g, b, a);
  67570. };
  67571. /**
  67572. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67573. * @param left defines the start value
  67574. * @param right defines the end value
  67575. * @param amount defines the gradient factor
  67576. * @returns a new Color4 object
  67577. */
  67578. Color4.Lerp = function (left, right, amount) {
  67579. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  67580. Color4.LerpToRef(left, right, amount, result);
  67581. return result;
  67582. };
  67583. /**
  67584. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67585. * @param left defines the start value
  67586. * @param right defines the end value
  67587. * @param amount defines the gradient factor
  67588. * @param result defines the Color4 object where to store data
  67589. */
  67590. Color4.LerpToRef = function (left, right, amount, result) {
  67591. result.r = left.r + (right.r - left.r) * amount;
  67592. result.g = left.g + (right.g - left.g) * amount;
  67593. result.b = left.b + (right.b - left.b) * amount;
  67594. result.a = left.a + (right.a - left.a) * amount;
  67595. };
  67596. /**
  67597. * Creates a new Color4 from a Color3 and an alpha value
  67598. * @param color3 defines the source Color3 to read from
  67599. * @param alpha defines the alpha component (1.0 by default)
  67600. * @returns a new Color4 object
  67601. */
  67602. Color4.FromColor3 = function (color3, alpha) {
  67603. if (alpha === void 0) { alpha = 1.0; }
  67604. return new Color4(color3.r, color3.g, color3.b, alpha);
  67605. };
  67606. /**
  67607. * Creates a new Color4 from the starting index element of the given array
  67608. * @param array defines the source array to read from
  67609. * @param offset defines the offset in the source array
  67610. * @returns a new Color4 object
  67611. */
  67612. Color4.FromArray = function (array, offset) {
  67613. if (offset === void 0) { offset = 0; }
  67614. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  67615. };
  67616. /**
  67617. * Creates a new Color3 from integer values (< 256)
  67618. * @param r defines the red component to read from (value between 0 and 255)
  67619. * @param g defines the green component to read from (value between 0 and 255)
  67620. * @param b defines the blue component to read from (value between 0 and 255)
  67621. * @param a defines the alpha component to read from (value between 0 and 255)
  67622. * @returns a new Color3 object
  67623. */
  67624. Color4.FromInts = function (r, g, b, a) {
  67625. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  67626. };
  67627. /**
  67628. * Check the content of a given array and convert it to an array containing RGBA data
  67629. * If the original array was already containing count * 4 values then it is returned directly
  67630. * @param colors defines the array to check
  67631. * @param count defines the number of RGBA data to expect
  67632. * @returns an array containing count * 4 values (RGBA)
  67633. */
  67634. Color4.CheckColors4 = function (colors, count) {
  67635. // Check if color3 was used
  67636. if (colors.length === count * 3) {
  67637. var colors4 = [];
  67638. for (var index = 0; index < colors.length; index += 3) {
  67639. var newIndex = (index / 3) * 4;
  67640. colors4[newIndex] = colors[index];
  67641. colors4[newIndex + 1] = colors[index + 1];
  67642. colors4[newIndex + 2] = colors[index + 2];
  67643. colors4[newIndex + 3] = 1.0;
  67644. }
  67645. return colors4;
  67646. }
  67647. return colors;
  67648. };
  67649. return Color4;
  67650. }());
  67651. /**
  67652. * Class representing a vector containing 2 coordinates
  67653. */
  67654. var Vector2 = /** @class */ (function () {
  67655. /**
  67656. * Creates a new Vector2 from the given x and y coordinates
  67657. * @param x defines the first coordinate
  67658. * @param y defines the second coordinate
  67659. */
  67660. function Vector2(
  67661. /** defines the first coordinate */
  67662. x,
  67663. /** defines the second coordinate */
  67664. y) {
  67665. if (x === void 0) { x = 0; }
  67666. if (y === void 0) { y = 0; }
  67667. this.x = x;
  67668. this.y = y;
  67669. }
  67670. /**
  67671. * Gets a string with the Vector2 coordinates
  67672. * @returns a string with the Vector2 coordinates
  67673. */
  67674. Vector2.prototype.toString = function () {
  67675. return "{X: " + this.x + " Y:" + this.y + "}";
  67676. };
  67677. /**
  67678. * Gets class name
  67679. * @returns the string "Vector2"
  67680. */
  67681. Vector2.prototype.getClassName = function () {
  67682. return "Vector2";
  67683. };
  67684. /**
  67685. * Gets current vector hash code
  67686. * @returns the Vector2 hash code as a number
  67687. */
  67688. Vector2.prototype.getHashCode = function () {
  67689. var hash = this.x || 0;
  67690. hash = (hash * 397) ^ (this.y || 0);
  67691. return hash;
  67692. };
  67693. // Operators
  67694. /**
  67695. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67696. * @param array defines the source array
  67697. * @param index defines the offset in source array
  67698. * @returns the current Vector2
  67699. */
  67700. Vector2.prototype.toArray = function (array, index) {
  67701. if (index === void 0) { index = 0; }
  67702. array[index] = this.x;
  67703. array[index + 1] = this.y;
  67704. return this;
  67705. };
  67706. /**
  67707. * Copy the current vector to an array
  67708. * @returns a new array with 2 elements: the Vector2 coordinates.
  67709. */
  67710. Vector2.prototype.asArray = function () {
  67711. var result = new Array();
  67712. this.toArray(result, 0);
  67713. return result;
  67714. };
  67715. /**
  67716. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67717. * @param source defines the source Vector2
  67718. * @returns the current updated Vector2
  67719. */
  67720. Vector2.prototype.copyFrom = function (source) {
  67721. this.x = source.x;
  67722. this.y = source.y;
  67723. return this;
  67724. };
  67725. /**
  67726. * Sets the Vector2 coordinates with the given floats
  67727. * @param x defines the first coordinate
  67728. * @param y defines the second coordinate
  67729. * @returns the current updated Vector2
  67730. */
  67731. Vector2.prototype.copyFromFloats = function (x, y) {
  67732. this.x = x;
  67733. this.y = y;
  67734. return this;
  67735. };
  67736. /**
  67737. * Sets the Vector2 coordinates with the given floats
  67738. * @param x defines the first coordinate
  67739. * @param y defines the second coordinate
  67740. * @returns the current updated Vector2
  67741. */
  67742. Vector2.prototype.set = function (x, y) {
  67743. return this.copyFromFloats(x, y);
  67744. };
  67745. /**
  67746. * Add another vector with the current one
  67747. * @param otherVector defines the other vector
  67748. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67749. */
  67750. Vector2.prototype.add = function (otherVector) {
  67751. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  67752. };
  67753. /**
  67754. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67755. * @param otherVector defines the other vector
  67756. * @param result defines the target vector
  67757. * @returns the unmodified current Vector2
  67758. */
  67759. Vector2.prototype.addToRef = function (otherVector, result) {
  67760. result.x = this.x + otherVector.x;
  67761. result.y = this.y + otherVector.y;
  67762. return this;
  67763. };
  67764. /**
  67765. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67766. * @param otherVector defines the other vector
  67767. * @returns the current updated Vector2
  67768. */
  67769. Vector2.prototype.addInPlace = function (otherVector) {
  67770. this.x += otherVector.x;
  67771. this.y += otherVector.y;
  67772. return this;
  67773. };
  67774. /**
  67775. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67776. * @param otherVector defines the other vector
  67777. * @returns a new Vector2
  67778. */
  67779. Vector2.prototype.addVector3 = function (otherVector) {
  67780. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  67781. };
  67782. /**
  67783. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67784. * @param otherVector defines the other vector
  67785. * @returns a new Vector2
  67786. */
  67787. Vector2.prototype.subtract = function (otherVector) {
  67788. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  67789. };
  67790. /**
  67791. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67792. * @param otherVector defines the other vector
  67793. * @param result defines the target vector
  67794. * @returns the unmodified current Vector2
  67795. */
  67796. Vector2.prototype.subtractToRef = function (otherVector, result) {
  67797. result.x = this.x - otherVector.x;
  67798. result.y = this.y - otherVector.y;
  67799. return this;
  67800. };
  67801. /**
  67802. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67803. * @param otherVector defines the other vector
  67804. * @returns the current updated Vector2
  67805. */
  67806. Vector2.prototype.subtractInPlace = function (otherVector) {
  67807. this.x -= otherVector.x;
  67808. this.y -= otherVector.y;
  67809. return this;
  67810. };
  67811. /**
  67812. * Multiplies in place the current Vector2 coordinates by the given ones
  67813. * @param otherVector defines the other vector
  67814. * @returns the current updated Vector2
  67815. */
  67816. Vector2.prototype.multiplyInPlace = function (otherVector) {
  67817. this.x *= otherVector.x;
  67818. this.y *= otherVector.y;
  67819. return this;
  67820. };
  67821. /**
  67822. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67823. * @param otherVector defines the other vector
  67824. * @returns a new Vector2
  67825. */
  67826. Vector2.prototype.multiply = function (otherVector) {
  67827. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  67828. };
  67829. /**
  67830. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67831. * @param otherVector defines the other vector
  67832. * @param result defines the target vector
  67833. * @returns the unmodified current Vector2
  67834. */
  67835. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  67836. result.x = this.x * otherVector.x;
  67837. result.y = this.y * otherVector.y;
  67838. return this;
  67839. };
  67840. /**
  67841. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67842. * @param x defines the first coordinate
  67843. * @param y defines the second coordinate
  67844. * @returns a new Vector2
  67845. */
  67846. Vector2.prototype.multiplyByFloats = function (x, y) {
  67847. return new Vector2(this.x * x, this.y * y);
  67848. };
  67849. /**
  67850. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67851. * @param otherVector defines the other vector
  67852. * @returns a new Vector2
  67853. */
  67854. Vector2.prototype.divide = function (otherVector) {
  67855. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  67856. };
  67857. /**
  67858. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67859. * @param otherVector defines the other vector
  67860. * @param result defines the target vector
  67861. * @returns the unmodified current Vector2
  67862. */
  67863. Vector2.prototype.divideToRef = function (otherVector, result) {
  67864. result.x = this.x / otherVector.x;
  67865. result.y = this.y / otherVector.y;
  67866. return this;
  67867. };
  67868. /**
  67869. * Divides the current Vector2 coordinates by the given ones
  67870. * @param otherVector defines the other vector
  67871. * @returns the current updated Vector2
  67872. */
  67873. Vector2.prototype.divideInPlace = function (otherVector) {
  67874. return this.divideToRef(otherVector, this);
  67875. };
  67876. /**
  67877. * Gets a new Vector2 with current Vector2 negated coordinates
  67878. * @returns a new Vector2
  67879. */
  67880. Vector2.prototype.negate = function () {
  67881. return new Vector2(-this.x, -this.y);
  67882. };
  67883. /**
  67884. * Multiply the Vector2 coordinates by scale
  67885. * @param scale defines the scaling factor
  67886. * @returns the current updated Vector2
  67887. */
  67888. Vector2.prototype.scaleInPlace = function (scale) {
  67889. this.x *= scale;
  67890. this.y *= scale;
  67891. return this;
  67892. };
  67893. /**
  67894. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67895. * @param scale defines the scaling factor
  67896. * @returns a new Vector2
  67897. */
  67898. Vector2.prototype.scale = function (scale) {
  67899. var result = new Vector2(0, 0);
  67900. this.scaleToRef(scale, result);
  67901. return result;
  67902. };
  67903. /**
  67904. * Scale the current Vector2 values by a factor to a given Vector2
  67905. * @param scale defines the scale factor
  67906. * @param result defines the Vector2 object where to store the result
  67907. * @returns the unmodified current Vector2
  67908. */
  67909. Vector2.prototype.scaleToRef = function (scale, result) {
  67910. result.x = this.x * scale;
  67911. result.y = this.y * scale;
  67912. return this;
  67913. };
  67914. /**
  67915. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67916. * @param scale defines the scale factor
  67917. * @param result defines the Vector2 object where to store the result
  67918. * @returns the unmodified current Vector2
  67919. */
  67920. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  67921. result.x += this.x * scale;
  67922. result.y += this.y * scale;
  67923. return this;
  67924. };
  67925. /**
  67926. * Gets a boolean if two vectors are equals
  67927. * @param otherVector defines the other vector
  67928. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67929. */
  67930. Vector2.prototype.equals = function (otherVector) {
  67931. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  67932. };
  67933. /**
  67934. * Gets a boolean if two vectors are equals (using an epsilon value)
  67935. * @param otherVector defines the other vector
  67936. * @param epsilon defines the minimal distance to consider equality
  67937. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67938. */
  67939. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  67940. if (epsilon === void 0) { epsilon = Epsilon; }
  67941. 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);
  67942. };
  67943. /**
  67944. * Gets a new Vector2 from current Vector2 floored values
  67945. * @returns a new Vector2
  67946. */
  67947. Vector2.prototype.floor = function () {
  67948. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  67949. };
  67950. /**
  67951. * Gets a new Vector2 from current Vector2 floored values
  67952. * @returns a new Vector2
  67953. */
  67954. Vector2.prototype.fract = function () {
  67955. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  67956. };
  67957. // Properties
  67958. /**
  67959. * Gets the length of the vector
  67960. * @returns the vector length (float)
  67961. */
  67962. Vector2.prototype.length = function () {
  67963. return Math.sqrt(this.x * this.x + this.y * this.y);
  67964. };
  67965. /**
  67966. * Gets the vector squared length
  67967. * @returns the vector squared length (float)
  67968. */
  67969. Vector2.prototype.lengthSquared = function () {
  67970. return (this.x * this.x + this.y * this.y);
  67971. };
  67972. // Methods
  67973. /**
  67974. * Normalize the vector
  67975. * @returns the current updated Vector2
  67976. */
  67977. Vector2.prototype.normalize = function () {
  67978. var len = this.length();
  67979. if (len === 0) {
  67980. return this;
  67981. }
  67982. var num = 1.0 / len;
  67983. this.x *= num;
  67984. this.y *= num;
  67985. return this;
  67986. };
  67987. /**
  67988. * Gets a new Vector2 copied from the Vector2
  67989. * @returns a new Vector2
  67990. */
  67991. Vector2.prototype.clone = function () {
  67992. return new Vector2(this.x, this.y);
  67993. };
  67994. // Statics
  67995. /**
  67996. * Gets a new Vector2(0, 0)
  67997. * @returns a new Vector2
  67998. */
  67999. Vector2.Zero = function () {
  68000. return new Vector2(0, 0);
  68001. };
  68002. /**
  68003. * Gets a new Vector2(1, 1)
  68004. * @returns a new Vector2
  68005. */
  68006. Vector2.One = function () {
  68007. return new Vector2(1, 1);
  68008. };
  68009. /**
  68010. * Gets a new Vector2 set from the given index element of the given array
  68011. * @param array defines the data source
  68012. * @param offset defines the offset in the data source
  68013. * @returns a new Vector2
  68014. */
  68015. Vector2.FromArray = function (array, offset) {
  68016. if (offset === void 0) { offset = 0; }
  68017. return new Vector2(array[offset], array[offset + 1]);
  68018. };
  68019. /**
  68020. * Sets "result" from the given index element of the given array
  68021. * @param array defines the data source
  68022. * @param offset defines the offset in the data source
  68023. * @param result defines the target vector
  68024. */
  68025. Vector2.FromArrayToRef = function (array, offset, result) {
  68026. result.x = array[offset];
  68027. result.y = array[offset + 1];
  68028. };
  68029. /**
  68030. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68031. * @param value1 defines 1st point of control
  68032. * @param value2 defines 2nd point of control
  68033. * @param value3 defines 3rd point of control
  68034. * @param value4 defines 4th point of control
  68035. * @param amount defines the interpolation factor
  68036. * @returns a new Vector2
  68037. */
  68038. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  68039. var squared = amount * amount;
  68040. var cubed = amount * squared;
  68041. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  68042. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  68043. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  68044. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  68045. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  68046. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  68047. return new Vector2(x, y);
  68048. };
  68049. /**
  68050. * 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".
  68051. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68052. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68053. * @param value defines the value to clamp
  68054. * @param min defines the lower limit
  68055. * @param max defines the upper limit
  68056. * @returns a new Vector2
  68057. */
  68058. Vector2.Clamp = function (value, min, max) {
  68059. var x = value.x;
  68060. x = (x > max.x) ? max.x : x;
  68061. x = (x < min.x) ? min.x : x;
  68062. var y = value.y;
  68063. y = (y > max.y) ? max.y : y;
  68064. y = (y < min.y) ? min.y : y;
  68065. return new Vector2(x, y);
  68066. };
  68067. /**
  68068. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68069. * @param value1 defines the 1st control point
  68070. * @param tangent1 defines the outgoing tangent
  68071. * @param value2 defines the 2nd control point
  68072. * @param tangent2 defines the incoming tangent
  68073. * @param amount defines the interpolation factor
  68074. * @returns a new Vector2
  68075. */
  68076. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68077. var squared = amount * amount;
  68078. var cubed = amount * squared;
  68079. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68080. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68081. var part3 = (cubed - (2.0 * squared)) + amount;
  68082. var part4 = cubed - squared;
  68083. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  68084. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  68085. return new Vector2(x, y);
  68086. };
  68087. /**
  68088. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68089. * @param start defines the start vector
  68090. * @param end defines the end vector
  68091. * @param amount defines the interpolation factor
  68092. * @returns a new Vector2
  68093. */
  68094. Vector2.Lerp = function (start, end, amount) {
  68095. var x = start.x + ((end.x - start.x) * amount);
  68096. var y = start.y + ((end.y - start.y) * amount);
  68097. return new Vector2(x, y);
  68098. };
  68099. /**
  68100. * Gets the dot product of the vector "left" and the vector "right"
  68101. * @param left defines first vector
  68102. * @param right defines second vector
  68103. * @returns the dot product (float)
  68104. */
  68105. Vector2.Dot = function (left, right) {
  68106. return left.x * right.x + left.y * right.y;
  68107. };
  68108. /**
  68109. * Returns a new Vector2 equal to the normalized given vector
  68110. * @param vector defines the vector to normalize
  68111. * @returns a new Vector2
  68112. */
  68113. Vector2.Normalize = function (vector) {
  68114. var newVector = vector.clone();
  68115. newVector.normalize();
  68116. return newVector;
  68117. };
  68118. /**
  68119. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68120. * @param left defines 1st vector
  68121. * @param right defines 2nd vector
  68122. * @returns a new Vector2
  68123. */
  68124. Vector2.Minimize = function (left, right) {
  68125. var x = (left.x < right.x) ? left.x : right.x;
  68126. var y = (left.y < right.y) ? left.y : right.y;
  68127. return new Vector2(x, y);
  68128. };
  68129. /**
  68130. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68131. * @param left defines 1st vector
  68132. * @param right defines 2nd vector
  68133. * @returns a new Vector2
  68134. */
  68135. Vector2.Maximize = function (left, right) {
  68136. var x = (left.x > right.x) ? left.x : right.x;
  68137. var y = (left.y > right.y) ? left.y : right.y;
  68138. return new Vector2(x, y);
  68139. };
  68140. /**
  68141. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68142. * @param vector defines the vector to transform
  68143. * @param transformation defines the matrix to apply
  68144. * @returns a new Vector2
  68145. */
  68146. Vector2.Transform = function (vector, transformation) {
  68147. var r = Vector2.Zero();
  68148. Vector2.TransformToRef(vector, transformation, r);
  68149. return r;
  68150. };
  68151. /**
  68152. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68153. * @param vector defines the vector to transform
  68154. * @param transformation defines the matrix to apply
  68155. * @param result defines the target vector
  68156. */
  68157. Vector2.TransformToRef = function (vector, transformation, result) {
  68158. var m = transformation.m;
  68159. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  68160. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  68161. result.x = x;
  68162. result.y = y;
  68163. };
  68164. /**
  68165. * Determines if a given vector is included in a triangle
  68166. * @param p defines the vector to test
  68167. * @param p0 defines 1st triangle point
  68168. * @param p1 defines 2nd triangle point
  68169. * @param p2 defines 3rd triangle point
  68170. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  68171. */
  68172. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  68173. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  68174. var sign = a < 0 ? -1 : 1;
  68175. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  68176. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  68177. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  68178. };
  68179. /**
  68180. * Gets the distance between the vectors "value1" and "value2"
  68181. * @param value1 defines first vector
  68182. * @param value2 defines second vector
  68183. * @returns the distance between vectors
  68184. */
  68185. Vector2.Distance = function (value1, value2) {
  68186. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  68187. };
  68188. /**
  68189. * Returns the squared distance between the vectors "value1" and "value2"
  68190. * @param value1 defines first vector
  68191. * @param value2 defines second vector
  68192. * @returns the squared distance between vectors
  68193. */
  68194. Vector2.DistanceSquared = function (value1, value2) {
  68195. var x = value1.x - value2.x;
  68196. var y = value1.y - value2.y;
  68197. return (x * x) + (y * y);
  68198. };
  68199. /**
  68200. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  68201. * @param value1 defines first vector
  68202. * @param value2 defines second vector
  68203. * @returns a new Vector2
  68204. */
  68205. Vector2.Center = function (value1, value2) {
  68206. var center = value1.add(value2);
  68207. center.scaleInPlace(0.5);
  68208. return center;
  68209. };
  68210. /**
  68211. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  68212. * @param p defines the middle point
  68213. * @param segA defines one point of the segment
  68214. * @param segB defines the other point of the segment
  68215. * @returns the shortest distance
  68216. */
  68217. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  68218. var l2 = Vector2.DistanceSquared(segA, segB);
  68219. if (l2 === 0.0) {
  68220. return Vector2.Distance(p, segA);
  68221. }
  68222. var v = segB.subtract(segA);
  68223. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  68224. var proj = segA.add(v.multiplyByFloats(t, t));
  68225. return Vector2.Distance(p, proj);
  68226. };
  68227. return Vector2;
  68228. }());
  68229. /**
  68230. * Classed used to store (x,y,z) vector representation
  68231. * A Vector3 is the main object used in 3D geometry
  68232. * It can represent etiher the coordinates of a point the space, either a direction
  68233. * Reminder: js uses a left handed forward facing system
  68234. */
  68235. var Vector3 = /** @class */ (function () {
  68236. /**
  68237. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68238. * @param x defines the first coordinates (on X axis)
  68239. * @param y defines the second coordinates (on Y axis)
  68240. * @param z defines the third coordinates (on Z axis)
  68241. */
  68242. function Vector3(
  68243. /**
  68244. * Defines the first coordinates (on X axis)
  68245. */
  68246. x,
  68247. /**
  68248. * Defines the second coordinates (on Y axis)
  68249. */
  68250. y,
  68251. /**
  68252. * Defines the third coordinates (on Z axis)
  68253. */
  68254. z) {
  68255. if (x === void 0) { x = 0; }
  68256. if (y === void 0) { y = 0; }
  68257. if (z === void 0) { z = 0; }
  68258. this.x = x;
  68259. this.y = y;
  68260. this.z = z;
  68261. }
  68262. /**
  68263. * Creates a string representation of the Vector3
  68264. * @returns a string with the Vector3 coordinates.
  68265. */
  68266. Vector3.prototype.toString = function () {
  68267. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  68268. };
  68269. /**
  68270. * Gets the class name
  68271. * @returns the string "Vector3"
  68272. */
  68273. Vector3.prototype.getClassName = function () {
  68274. return "Vector3";
  68275. };
  68276. /**
  68277. * Creates the Vector3 hash code
  68278. * @returns a number which tends to be unique between Vector3 instances
  68279. */
  68280. Vector3.prototype.getHashCode = function () {
  68281. var hash = this.x || 0;
  68282. hash = (hash * 397) ^ (this.y || 0);
  68283. hash = (hash * 397) ^ (this.z || 0);
  68284. return hash;
  68285. };
  68286. // Operators
  68287. /**
  68288. * Creates an array containing three elements : the coordinates of the Vector3
  68289. * @returns a new array of numbers
  68290. */
  68291. Vector3.prototype.asArray = function () {
  68292. var result = [];
  68293. this.toArray(result, 0);
  68294. return result;
  68295. };
  68296. /**
  68297. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68298. * @param array defines the destination array
  68299. * @param index defines the offset in the destination array
  68300. * @returns the current Vector3
  68301. */
  68302. Vector3.prototype.toArray = function (array, index) {
  68303. if (index === void 0) { index = 0; }
  68304. array[index] = this.x;
  68305. array[index + 1] = this.y;
  68306. array[index + 2] = this.z;
  68307. return this;
  68308. };
  68309. /**
  68310. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68311. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68312. */
  68313. Vector3.prototype.toQuaternion = function () {
  68314. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  68315. };
  68316. /**
  68317. * Adds the given vector to the current Vector3
  68318. * @param otherVector defines the second operand
  68319. * @returns the current updated Vector3
  68320. */
  68321. Vector3.prototype.addInPlace = function (otherVector) {
  68322. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  68323. };
  68324. /**
  68325. * Adds the given coordinates to the current Vector3
  68326. * @param x defines the x coordinate of the operand
  68327. * @param y defines the y coordinate of the operand
  68328. * @param z defines the z coordinate of the operand
  68329. * @returns the current updated Vector3
  68330. */
  68331. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  68332. this.x += x;
  68333. this.y += y;
  68334. this.z += z;
  68335. return this;
  68336. };
  68337. /**
  68338. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68339. * @param otherVector defines the second operand
  68340. * @returns the resulting Vector3
  68341. */
  68342. Vector3.prototype.add = function (otherVector) {
  68343. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68344. };
  68345. /**
  68346. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68347. * @param otherVector defines the second operand
  68348. * @param result defines the Vector3 object where to store the result
  68349. * @returns the current Vector3
  68350. */
  68351. Vector3.prototype.addToRef = function (otherVector, result) {
  68352. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68353. };
  68354. /**
  68355. * Subtract the given vector from the current Vector3
  68356. * @param otherVector defines the second operand
  68357. * @returns the current updated Vector3
  68358. */
  68359. Vector3.prototype.subtractInPlace = function (otherVector) {
  68360. this.x -= otherVector.x;
  68361. this.y -= otherVector.y;
  68362. this.z -= otherVector.z;
  68363. return this;
  68364. };
  68365. /**
  68366. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68367. * @param otherVector defines the second operand
  68368. * @returns the resulting Vector3
  68369. */
  68370. Vector3.prototype.subtract = function (otherVector) {
  68371. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  68372. };
  68373. /**
  68374. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68375. * @param otherVector defines the second operand
  68376. * @param result defines the Vector3 object where to store the result
  68377. * @returns the current Vector3
  68378. */
  68379. Vector3.prototype.subtractToRef = function (otherVector, result) {
  68380. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  68381. };
  68382. /**
  68383. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68384. * @param x defines the x coordinate of the operand
  68385. * @param y defines the y coordinate of the operand
  68386. * @param z defines the z coordinate of the operand
  68387. * @returns the resulting Vector3
  68388. */
  68389. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  68390. return new Vector3(this.x - x, this.y - y, this.z - z);
  68391. };
  68392. /**
  68393. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68394. * @param x defines the x coordinate of the operand
  68395. * @param y defines the y coordinate of the operand
  68396. * @param z defines the z coordinate of the operand
  68397. * @param result defines the Vector3 object where to store the result
  68398. * @returns the current Vector3
  68399. */
  68400. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  68401. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  68402. };
  68403. /**
  68404. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68405. * @returns a new Vector3
  68406. */
  68407. Vector3.prototype.negate = function () {
  68408. return new Vector3(-this.x, -this.y, -this.z);
  68409. };
  68410. /**
  68411. * Multiplies the Vector3 coordinates by the float "scale"
  68412. * @param scale defines the multiplier factor
  68413. * @returns the current updated Vector3
  68414. */
  68415. Vector3.prototype.scaleInPlace = function (scale) {
  68416. this.x *= scale;
  68417. this.y *= scale;
  68418. this.z *= scale;
  68419. return this;
  68420. };
  68421. /**
  68422. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68423. * @param scale defines the multiplier factor
  68424. * @returns a new Vector3
  68425. */
  68426. Vector3.prototype.scale = function (scale) {
  68427. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  68428. };
  68429. /**
  68430. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68431. * @param scale defines the multiplier factor
  68432. * @param result defines the Vector3 object where to store the result
  68433. * @returns the current Vector3
  68434. */
  68435. Vector3.prototype.scaleToRef = function (scale, result) {
  68436. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68437. };
  68438. /**
  68439. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68440. * @param scale defines the scale factor
  68441. * @param result defines the Vector3 object where to store the result
  68442. * @returns the unmodified current Vector3
  68443. */
  68444. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  68445. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68446. };
  68447. /**
  68448. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68449. * @param otherVector defines the second operand
  68450. * @returns true if both vectors are equals
  68451. */
  68452. Vector3.prototype.equals = function (otherVector) {
  68453. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  68454. };
  68455. /**
  68456. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68457. * @param otherVector defines the second operand
  68458. * @param epsilon defines the minimal distance to define values as equals
  68459. * @returns true if both vectors are distant less than epsilon
  68460. */
  68461. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68462. if (epsilon === void 0) { epsilon = Epsilon; }
  68463. 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);
  68464. };
  68465. /**
  68466. * Returns true if the current Vector3 coordinates equals the given floats
  68467. * @param x defines the x coordinate of the operand
  68468. * @param y defines the y coordinate of the operand
  68469. * @param z defines the z coordinate of the operand
  68470. * @returns true if both vectors are equals
  68471. */
  68472. Vector3.prototype.equalsToFloats = function (x, y, z) {
  68473. return this.x === x && this.y === y && this.z === z;
  68474. };
  68475. /**
  68476. * Multiplies the current Vector3 coordinates by the given ones
  68477. * @param otherVector defines the second operand
  68478. * @returns the current updated Vector3
  68479. */
  68480. Vector3.prototype.multiplyInPlace = function (otherVector) {
  68481. this.x *= otherVector.x;
  68482. this.y *= otherVector.y;
  68483. this.z *= otherVector.z;
  68484. return this;
  68485. };
  68486. /**
  68487. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68488. * @param otherVector defines the second operand
  68489. * @returns the new Vector3
  68490. */
  68491. Vector3.prototype.multiply = function (otherVector) {
  68492. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  68493. };
  68494. /**
  68495. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68496. * @param otherVector defines the second operand
  68497. * @param result defines the Vector3 object where to store the result
  68498. * @returns the current Vector3
  68499. */
  68500. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  68501. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  68502. };
  68503. /**
  68504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68505. * @param x defines the x coordinate of the operand
  68506. * @param y defines the y coordinate of the operand
  68507. * @param z defines the z coordinate of the operand
  68508. * @returns the new Vector3
  68509. */
  68510. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  68511. return new Vector3(this.x * x, this.y * y, this.z * z);
  68512. };
  68513. /**
  68514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68515. * @param otherVector defines the second operand
  68516. * @returns the new Vector3
  68517. */
  68518. Vector3.prototype.divide = function (otherVector) {
  68519. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68520. };
  68521. /**
  68522. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68523. * @param otherVector defines the second operand
  68524. * @param result defines the Vector3 object where to store the result
  68525. * @returns the current Vector3
  68526. */
  68527. Vector3.prototype.divideToRef = function (otherVector, result) {
  68528. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68529. };
  68530. /**
  68531. * Divides the current Vector3 coordinates by the given ones.
  68532. * @param otherVector defines the second operand
  68533. * @returns the current updated Vector3
  68534. */
  68535. Vector3.prototype.divideInPlace = function (otherVector) {
  68536. return this.divideToRef(otherVector, this);
  68537. };
  68538. /**
  68539. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68540. * @param other defines the second operand
  68541. * @returns the current updated Vector3
  68542. */
  68543. Vector3.prototype.minimizeInPlace = function (other) {
  68544. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  68545. };
  68546. /**
  68547. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68548. * @param other defines the second operand
  68549. * @returns the current updated Vector3
  68550. */
  68551. Vector3.prototype.maximizeInPlace = function (other) {
  68552. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  68553. };
  68554. /**
  68555. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68556. * @param x defines the x coordinate of the operand
  68557. * @param y defines the y coordinate of the operand
  68558. * @param z defines the z coordinate of the operand
  68559. * @returns the current updated Vector3
  68560. */
  68561. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  68562. if (x < this.x) {
  68563. this.x = x;
  68564. }
  68565. if (y < this.y) {
  68566. this.y = y;
  68567. }
  68568. if (z < this.z) {
  68569. this.z = z;
  68570. }
  68571. return this;
  68572. };
  68573. /**
  68574. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68575. * @param x defines the x coordinate of the operand
  68576. * @param y defines the y coordinate of the operand
  68577. * @param z defines the z coordinate of the operand
  68578. * @returns the current updated Vector3
  68579. */
  68580. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  68581. if (x > this.x) {
  68582. this.x = x;
  68583. }
  68584. if (y > this.y) {
  68585. this.y = y;
  68586. }
  68587. if (z > this.z) {
  68588. this.z = z;
  68589. }
  68590. return this;
  68591. };
  68592. /**
  68593. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68594. * Check if is non uniform within a certain amount of decimal places to account for this
  68595. * @param epsilon the amount the values can differ
  68596. * @returns if the the vector is non uniform to a certain number of decimal places
  68597. */
  68598. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  68599. var absX = Math.abs(this.x);
  68600. var absY = Math.abs(this.y);
  68601. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  68602. return true;
  68603. }
  68604. var absZ = Math.abs(this.z);
  68605. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  68606. return true;
  68607. }
  68608. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  68609. return true;
  68610. }
  68611. return false;
  68612. };
  68613. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  68614. /**
  68615. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68616. */
  68617. get: function () {
  68618. var absX = Math.abs(this.x);
  68619. var absY = Math.abs(this.y);
  68620. if (absX !== absY) {
  68621. return true;
  68622. }
  68623. var absZ = Math.abs(this.z);
  68624. if (absX !== absZ) {
  68625. return true;
  68626. }
  68627. if (absY !== absZ) {
  68628. return true;
  68629. }
  68630. return false;
  68631. },
  68632. enumerable: true,
  68633. configurable: true
  68634. });
  68635. /**
  68636. * Gets a new Vector3 from current Vector3 floored values
  68637. * @returns a new Vector3
  68638. */
  68639. Vector3.prototype.floor = function () {
  68640. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  68641. };
  68642. /**
  68643. * Gets a new Vector3 from current Vector3 floored values
  68644. * @returns a new Vector3
  68645. */
  68646. Vector3.prototype.fract = function () {
  68647. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  68648. };
  68649. // Properties
  68650. /**
  68651. * Gets the length of the Vector3
  68652. * @returns the length of the Vecto3
  68653. */
  68654. Vector3.prototype.length = function () {
  68655. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  68656. };
  68657. /**
  68658. * Gets the squared length of the Vector3
  68659. * @returns squared length of the Vector3
  68660. */
  68661. Vector3.prototype.lengthSquared = function () {
  68662. return (this.x * this.x + this.y * this.y + this.z * this.z);
  68663. };
  68664. /**
  68665. * Normalize the current Vector3.
  68666. * Please note that this is an in place operation.
  68667. * @returns the current updated Vector3
  68668. */
  68669. Vector3.prototype.normalize = function () {
  68670. return this.normalizeFromLength(this.length());
  68671. };
  68672. /**
  68673. * Reorders the x y z properties of the vector in place
  68674. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68675. * @returns the current updated vector
  68676. */
  68677. Vector3.prototype.reorderInPlace = function (order) {
  68678. var _this = this;
  68679. order = order.toLowerCase();
  68680. if (order === "xyz") {
  68681. return this;
  68682. }
  68683. MathTmp.Vector3[0].copyFrom(this);
  68684. ["x", "y", "z"].forEach(function (val, i) {
  68685. _this[val] = MathTmp.Vector3[0][order[i]];
  68686. });
  68687. return this;
  68688. };
  68689. /**
  68690. * Rotates the vector around 0,0,0 by a quaternion
  68691. * @param quaternion the rotation quaternion
  68692. * @param result vector to store the result
  68693. * @returns the resulting vector
  68694. */
  68695. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  68696. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  68697. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  68698. return result;
  68699. };
  68700. /**
  68701. * Rotates a vector around a given point
  68702. * @param quaternion the rotation quaternion
  68703. * @param point the point to rotate around
  68704. * @param result vector to store the result
  68705. * @returns the resulting vector
  68706. */
  68707. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  68708. this.subtractToRef(point, MathTmp.Vector3[0]);
  68709. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  68710. point.addToRef(MathTmp.Vector3[0], result);
  68711. return result;
  68712. };
  68713. /**
  68714. * Normalize the current Vector3 with the given input length.
  68715. * Please note that this is an in place operation.
  68716. * @param len the length of the vector
  68717. * @returns the current updated Vector3
  68718. */
  68719. Vector3.prototype.normalizeFromLength = function (len) {
  68720. if (len === 0 || len === 1.0) {
  68721. return this;
  68722. }
  68723. return this.scaleInPlace(1.0 / len);
  68724. };
  68725. /**
  68726. * Normalize the current Vector3 to a new vector
  68727. * @returns the new Vector3
  68728. */
  68729. Vector3.prototype.normalizeToNew = function () {
  68730. var normalized = new Vector3(0, 0, 0);
  68731. this.normalizeToRef(normalized);
  68732. return normalized;
  68733. };
  68734. /**
  68735. * Normalize the current Vector3 to the reference
  68736. * @param reference define the Vector3 to update
  68737. * @returns the updated Vector3
  68738. */
  68739. Vector3.prototype.normalizeToRef = function (reference) {
  68740. var len = this.length();
  68741. if (len === 0 || len === 1.0) {
  68742. return reference.copyFromFloats(this.x, this.y, this.z);
  68743. }
  68744. return this.scaleToRef(1.0 / len, reference);
  68745. };
  68746. /**
  68747. * Creates a new Vector3 copied from the current Vector3
  68748. * @returns the new Vector3
  68749. */
  68750. Vector3.prototype.clone = function () {
  68751. return new Vector3(this.x, this.y, this.z);
  68752. };
  68753. /**
  68754. * Copies the given vector coordinates to the current Vector3 ones
  68755. * @param source defines the source Vector3
  68756. * @returns the current updated Vector3
  68757. */
  68758. Vector3.prototype.copyFrom = function (source) {
  68759. return this.copyFromFloats(source.x, source.y, source.z);
  68760. };
  68761. /**
  68762. * Copies the given floats to the current Vector3 coordinates
  68763. * @param x defines the x coordinate of the operand
  68764. * @param y defines the y coordinate of the operand
  68765. * @param z defines the z coordinate of the operand
  68766. * @returns the current updated Vector3
  68767. */
  68768. Vector3.prototype.copyFromFloats = function (x, y, z) {
  68769. this.x = x;
  68770. this.y = y;
  68771. this.z = z;
  68772. return this;
  68773. };
  68774. /**
  68775. * Copies the given floats to the current Vector3 coordinates
  68776. * @param x defines the x coordinate of the operand
  68777. * @param y defines the y coordinate of the operand
  68778. * @param z defines the z coordinate of the operand
  68779. * @returns the current updated Vector3
  68780. */
  68781. Vector3.prototype.set = function (x, y, z) {
  68782. return this.copyFromFloats(x, y, z);
  68783. };
  68784. /**
  68785. * Copies the given float to the current Vector3 coordinates
  68786. * @param v defines the x, y and z coordinates of the operand
  68787. * @returns the current updated Vector3
  68788. */
  68789. Vector3.prototype.setAll = function (v) {
  68790. this.x = this.y = this.z = v;
  68791. return this;
  68792. };
  68793. // Statics
  68794. /**
  68795. * Get the clip factor between two vectors
  68796. * @param vector0 defines the first operand
  68797. * @param vector1 defines the second operand
  68798. * @param axis defines the axis to use
  68799. * @param size defines the size along the axis
  68800. * @returns the clip factor
  68801. */
  68802. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  68803. var d0 = Vector3.Dot(vector0, axis) - size;
  68804. var d1 = Vector3.Dot(vector1, axis) - size;
  68805. var s = d0 / (d0 - d1);
  68806. return s;
  68807. };
  68808. /**
  68809. * Get angle between two vectors
  68810. * @param vector0 angle between vector0 and vector1
  68811. * @param vector1 angle between vector0 and vector1
  68812. * @param normal direction of the normal
  68813. * @return the angle between vector0 and vector1
  68814. */
  68815. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  68816. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  68817. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  68818. var dot = Vector3.Dot(v0, v1);
  68819. var n = MathTmp.Vector3[3];
  68820. Vector3.CrossToRef(v0, v1, n);
  68821. if (Vector3.Dot(n, normal) > 0) {
  68822. return Math.acos(dot);
  68823. }
  68824. return -Math.acos(dot);
  68825. };
  68826. /**
  68827. * Returns a new Vector3 set from the index "offset" of the given array
  68828. * @param array defines the source array
  68829. * @param offset defines the offset in the source array
  68830. * @returns the new Vector3
  68831. */
  68832. Vector3.FromArray = function (array, offset) {
  68833. if (offset === void 0) { offset = 0; }
  68834. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  68835. };
  68836. /**
  68837. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68838. * This function is deprecated. Use FromArray instead
  68839. * @param array defines the source array
  68840. * @param offset defines the offset in the source array
  68841. * @returns the new Vector3
  68842. */
  68843. Vector3.FromFloatArray = function (array, offset) {
  68844. return Vector3.FromArray(array, offset);
  68845. };
  68846. /**
  68847. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68848. * @param array defines the source array
  68849. * @param offset defines the offset in the source array
  68850. * @param result defines the Vector3 where to store the result
  68851. */
  68852. Vector3.FromArrayToRef = function (array, offset, result) {
  68853. result.x = array[offset];
  68854. result.y = array[offset + 1];
  68855. result.z = array[offset + 2];
  68856. };
  68857. /**
  68858. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68859. * This function is deprecated. Use FromArrayToRef instead.
  68860. * @param array defines the source array
  68861. * @param offset defines the offset in the source array
  68862. * @param result defines the Vector3 where to store the result
  68863. */
  68864. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  68865. return Vector3.FromArrayToRef(array, offset, result);
  68866. };
  68867. /**
  68868. * Sets the given vector "result" with the given floats.
  68869. * @param x defines the x coordinate of the source
  68870. * @param y defines the y coordinate of the source
  68871. * @param z defines the z coordinate of the source
  68872. * @param result defines the Vector3 where to store the result
  68873. */
  68874. Vector3.FromFloatsToRef = function (x, y, z, result) {
  68875. result.copyFromFloats(x, y, z);
  68876. };
  68877. /**
  68878. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68879. * @returns a new empty Vector3
  68880. */
  68881. Vector3.Zero = function () {
  68882. return new Vector3(0.0, 0.0, 0.0);
  68883. };
  68884. /**
  68885. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68886. * @returns a new unit Vector3
  68887. */
  68888. Vector3.One = function () {
  68889. return new Vector3(1.0, 1.0, 1.0);
  68890. };
  68891. /**
  68892. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68893. * @returns a new up Vector3
  68894. */
  68895. Vector3.Up = function () {
  68896. return new Vector3(0.0, 1.0, 0.0);
  68897. };
  68898. Object.defineProperty(Vector3, "UpReadOnly", {
  68899. /**
  68900. * Gets a up Vector3 that must not be updated
  68901. */
  68902. get: function () {
  68903. return Vector3._UpReadOnly;
  68904. },
  68905. enumerable: true,
  68906. configurable: true
  68907. });
  68908. /**
  68909. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68910. * @returns a new down Vector3
  68911. */
  68912. Vector3.Down = function () {
  68913. return new Vector3(0.0, -1.0, 0.0);
  68914. };
  68915. /**
  68916. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68917. * @returns a new forward Vector3
  68918. */
  68919. Vector3.Forward = function () {
  68920. return new Vector3(0.0, 0.0, 1.0);
  68921. };
  68922. /**
  68923. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68924. * @returns a new forward Vector3
  68925. */
  68926. Vector3.Backward = function () {
  68927. return new Vector3(0.0, 0.0, -1.0);
  68928. };
  68929. /**
  68930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68931. * @returns a new right Vector3
  68932. */
  68933. Vector3.Right = function () {
  68934. return new Vector3(1.0, 0.0, 0.0);
  68935. };
  68936. /**
  68937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68938. * @returns a new left Vector3
  68939. */
  68940. Vector3.Left = function () {
  68941. return new Vector3(-1.0, 0.0, 0.0);
  68942. };
  68943. /**
  68944. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68945. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68946. * @param vector defines the Vector3 to transform
  68947. * @param transformation defines the transformation matrix
  68948. * @returns the transformed Vector3
  68949. */
  68950. Vector3.TransformCoordinates = function (vector, transformation) {
  68951. var result = Vector3.Zero();
  68952. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  68953. return result;
  68954. };
  68955. /**
  68956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68958. * @param vector defines the Vector3 to transform
  68959. * @param transformation defines the transformation matrix
  68960. * @param result defines the Vector3 where to store the result
  68961. */
  68962. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  68963. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  68964. };
  68965. /**
  68966. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68967. * This method computes tranformed coordinates only, not transformed direction vectors
  68968. * @param x define the x coordinate of the source vector
  68969. * @param y define the y coordinate of the source vector
  68970. * @param z define the z coordinate of the source vector
  68971. * @param transformation defines the transformation matrix
  68972. * @param result defines the Vector3 where to store the result
  68973. */
  68974. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  68975. var m = transformation.m;
  68976. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  68977. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  68978. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  68979. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  68980. result.x = rx * rw;
  68981. result.y = ry * rw;
  68982. result.z = rz * rw;
  68983. };
  68984. /**
  68985. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68987. * @param vector defines the Vector3 to transform
  68988. * @param transformation defines the transformation matrix
  68989. * @returns the new Vector3
  68990. */
  68991. Vector3.TransformNormal = function (vector, transformation) {
  68992. var result = Vector3.Zero();
  68993. Vector3.TransformNormalToRef(vector, transformation, result);
  68994. return result;
  68995. };
  68996. /**
  68997. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68998. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68999. * @param vector defines the Vector3 to transform
  69000. * @param transformation defines the transformation matrix
  69001. * @param result defines the Vector3 where to store the result
  69002. */
  69003. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  69004. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69005. };
  69006. /**
  69007. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69008. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69009. * @param x define the x coordinate of the source vector
  69010. * @param y define the y coordinate of the source vector
  69011. * @param z define the z coordinate of the source vector
  69012. * @param transformation defines the transformation matrix
  69013. * @param result defines the Vector3 where to store the result
  69014. */
  69015. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  69016. var m = transformation.m;
  69017. result.x = x * m[0] + y * m[4] + z * m[8];
  69018. result.y = x * m[1] + y * m[5] + z * m[9];
  69019. result.z = x * m[2] + y * m[6] + z * m[10];
  69020. };
  69021. /**
  69022. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69023. * @param value1 defines the first control point
  69024. * @param value2 defines the second control point
  69025. * @param value3 defines the third control point
  69026. * @param value4 defines the fourth control point
  69027. * @param amount defines the amount on the spline to use
  69028. * @returns the new Vector3
  69029. */
  69030. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  69031. var squared = amount * amount;
  69032. var cubed = amount * squared;
  69033. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69034. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69035. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69036. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69037. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69038. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69039. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  69040. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  69041. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  69042. return new Vector3(x, y, z);
  69043. };
  69044. /**
  69045. * 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"
  69046. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69047. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69048. * @param value defines the current value
  69049. * @param min defines the lower range value
  69050. * @param max defines the upper range value
  69051. * @returns the new Vector3
  69052. */
  69053. Vector3.Clamp = function (value, min, max) {
  69054. var v = new Vector3();
  69055. Vector3.ClampToRef(value, min, max, v);
  69056. return v;
  69057. };
  69058. /**
  69059. * 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"
  69060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69062. * @param value defines the current value
  69063. * @param min defines the lower range value
  69064. * @param max defines the upper range value
  69065. * @param result defines the Vector3 where to store the result
  69066. */
  69067. Vector3.ClampToRef = function (value, min, max, result) {
  69068. var x = value.x;
  69069. x = (x > max.x) ? max.x : x;
  69070. x = (x < min.x) ? min.x : x;
  69071. var y = value.y;
  69072. y = (y > max.y) ? max.y : y;
  69073. y = (y < min.y) ? min.y : y;
  69074. var z = value.z;
  69075. z = (z > max.z) ? max.z : z;
  69076. z = (z < min.z) ? min.z : z;
  69077. result.copyFromFloats(x, y, z);
  69078. };
  69079. /**
  69080. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69081. * @param value1 defines the first control point
  69082. * @param tangent1 defines the first tangent vector
  69083. * @param value2 defines the second control point
  69084. * @param tangent2 defines the second tangent vector
  69085. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69086. * @returns the new Vector3
  69087. */
  69088. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69089. var squared = amount * amount;
  69090. var cubed = amount * squared;
  69091. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69092. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69093. var part3 = (cubed - (2.0 * squared)) + amount;
  69094. var part4 = cubed - squared;
  69095. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69096. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69097. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  69098. return new Vector3(x, y, z);
  69099. };
  69100. /**
  69101. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69102. * @param start defines the start value
  69103. * @param end defines the end value
  69104. * @param amount max defines amount between both (between 0 and 1)
  69105. * @returns the new Vector3
  69106. */
  69107. Vector3.Lerp = function (start, end, amount) {
  69108. var result = new Vector3(0, 0, 0);
  69109. Vector3.LerpToRef(start, end, amount, result);
  69110. return result;
  69111. };
  69112. /**
  69113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69114. * @param start defines the start value
  69115. * @param end defines the end value
  69116. * @param amount max defines amount between both (between 0 and 1)
  69117. * @param result defines the Vector3 where to store the result
  69118. */
  69119. Vector3.LerpToRef = function (start, end, amount, result) {
  69120. result.x = start.x + ((end.x - start.x) * amount);
  69121. result.y = start.y + ((end.y - start.y) * amount);
  69122. result.z = start.z + ((end.z - start.z) * amount);
  69123. };
  69124. /**
  69125. * Returns the dot product (float) between the vectors "left" and "right"
  69126. * @param left defines the left operand
  69127. * @param right defines the right operand
  69128. * @returns the dot product
  69129. */
  69130. Vector3.Dot = function (left, right) {
  69131. return (left.x * right.x + left.y * right.y + left.z * right.z);
  69132. };
  69133. /**
  69134. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69135. * The cross product is then orthogonal to both "left" and "right"
  69136. * @param left defines the left operand
  69137. * @param right defines the right operand
  69138. * @returns the cross product
  69139. */
  69140. Vector3.Cross = function (left, right) {
  69141. var result = Vector3.Zero();
  69142. Vector3.CrossToRef(left, right, result);
  69143. return result;
  69144. };
  69145. /**
  69146. * Sets the given vector "result" with the cross product of "left" and "right"
  69147. * The cross product is then orthogonal to both "left" and "right"
  69148. * @param left defines the left operand
  69149. * @param right defines the right operand
  69150. * @param result defines the Vector3 where to store the result
  69151. */
  69152. Vector3.CrossToRef = function (left, right, result) {
  69153. var x = left.y * right.z - left.z * right.y;
  69154. var y = left.z * right.x - left.x * right.z;
  69155. var z = left.x * right.y - left.y * right.x;
  69156. result.copyFromFloats(x, y, z);
  69157. };
  69158. /**
  69159. * Returns a new Vector3 as the normalization of the given vector
  69160. * @param vector defines the Vector3 to normalize
  69161. * @returns the new Vector3
  69162. */
  69163. Vector3.Normalize = function (vector) {
  69164. var result = Vector3.Zero();
  69165. Vector3.NormalizeToRef(vector, result);
  69166. return result;
  69167. };
  69168. /**
  69169. * Sets the given vector "result" with the normalization of the given first vector
  69170. * @param vector defines the Vector3 to normalize
  69171. * @param result defines the Vector3 where to store the result
  69172. */
  69173. Vector3.NormalizeToRef = function (vector, result) {
  69174. vector.normalizeToRef(result);
  69175. };
  69176. /**
  69177. * Project a Vector3 onto screen space
  69178. * @param vector defines the Vector3 to project
  69179. * @param world defines the world matrix to use
  69180. * @param transform defines the transform (view x projection) matrix to use
  69181. * @param viewport defines the screen viewport to use
  69182. * @returns the new Vector3
  69183. */
  69184. Vector3.Project = function (vector, world, transform, viewport) {
  69185. var cw = viewport.width;
  69186. var ch = viewport.height;
  69187. var cx = viewport.x;
  69188. var cy = viewport.y;
  69189. var viewportMatrix = MathTmp.Matrix[1];
  69190. 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);
  69191. var matrix = MathTmp.Matrix[0];
  69192. world.multiplyToRef(transform, matrix);
  69193. matrix.multiplyToRef(viewportMatrix, matrix);
  69194. return Vector3.TransformCoordinates(vector, matrix);
  69195. };
  69196. /** @hidden */
  69197. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  69198. Vector3.TransformCoordinatesToRef(source, matrix, result);
  69199. var m = matrix.m;
  69200. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  69201. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  69202. result.scaleInPlace(1.0 / num);
  69203. }
  69204. };
  69205. /**
  69206. * Unproject from screen space to object space
  69207. * @param source defines the screen space Vector3 to use
  69208. * @param viewportWidth defines the current width of the viewport
  69209. * @param viewportHeight defines the current height of the viewport
  69210. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69211. * @param transform defines the transform (view x projection) matrix to use
  69212. * @returns the new Vector3
  69213. */
  69214. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  69215. var matrix = MathTmp.Matrix[0];
  69216. world.multiplyToRef(transform, matrix);
  69217. matrix.invert();
  69218. source.x = source.x / viewportWidth * 2 - 1;
  69219. source.y = -(source.y / viewportHeight * 2 - 1);
  69220. var vector = new Vector3();
  69221. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  69222. return vector;
  69223. };
  69224. /**
  69225. * Unproject from screen space to object space
  69226. * @param source defines the screen space Vector3 to use
  69227. * @param viewportWidth defines the current width of the viewport
  69228. * @param viewportHeight defines the current height of the viewport
  69229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69230. * @param view defines the view matrix to use
  69231. * @param projection defines the projection matrix to use
  69232. * @returns the new Vector3
  69233. */
  69234. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  69235. var result = Vector3.Zero();
  69236. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  69237. return result;
  69238. };
  69239. /**
  69240. * Unproject from screen space to object space
  69241. * @param source defines the screen space Vector3 to use
  69242. * @param viewportWidth defines the current width of the viewport
  69243. * @param viewportHeight defines the current height of the viewport
  69244. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69245. * @param view defines the view matrix to use
  69246. * @param projection defines the projection matrix to use
  69247. * @param result defines the Vector3 where to store the result
  69248. */
  69249. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  69250. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  69251. };
  69252. /**
  69253. * Unproject from screen space to object space
  69254. * @param sourceX defines the screen space x coordinate to use
  69255. * @param sourceY defines the screen space y coordinate to use
  69256. * @param sourceZ defines the screen space z coordinate to use
  69257. * @param viewportWidth defines the current width of the viewport
  69258. * @param viewportHeight defines the current height of the viewport
  69259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69260. * @param view defines the view matrix to use
  69261. * @param projection defines the projection matrix to use
  69262. * @param result defines the Vector3 where to store the result
  69263. */
  69264. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  69265. var matrix = MathTmp.Matrix[0];
  69266. world.multiplyToRef(view, matrix);
  69267. matrix.multiplyToRef(projection, matrix);
  69268. matrix.invert();
  69269. var screenSource = MathTmp.Vector3[0];
  69270. screenSource.x = sourceX / viewportWidth * 2 - 1;
  69271. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  69272. screenSource.z = 2 * sourceZ - 1.0;
  69273. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  69274. };
  69275. /**
  69276. * Gets the minimal coordinate values between two Vector3
  69277. * @param left defines the first operand
  69278. * @param right defines the second operand
  69279. * @returns the new Vector3
  69280. */
  69281. Vector3.Minimize = function (left, right) {
  69282. var min = left.clone();
  69283. min.minimizeInPlace(right);
  69284. return min;
  69285. };
  69286. /**
  69287. * Gets the maximal coordinate values between two Vector3
  69288. * @param left defines the first operand
  69289. * @param right defines the second operand
  69290. * @returns the new Vector3
  69291. */
  69292. Vector3.Maximize = function (left, right) {
  69293. var max = left.clone();
  69294. max.maximizeInPlace(right);
  69295. return max;
  69296. };
  69297. /**
  69298. * Returns the distance between the vectors "value1" and "value2"
  69299. * @param value1 defines the first operand
  69300. * @param value2 defines the second operand
  69301. * @returns the distance
  69302. */
  69303. Vector3.Distance = function (value1, value2) {
  69304. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  69305. };
  69306. /**
  69307. * Returns the squared distance between the vectors "value1" and "value2"
  69308. * @param value1 defines the first operand
  69309. * @param value2 defines the second operand
  69310. * @returns the squared distance
  69311. */
  69312. Vector3.DistanceSquared = function (value1, value2) {
  69313. var x = value1.x - value2.x;
  69314. var y = value1.y - value2.y;
  69315. var z = value1.z - value2.z;
  69316. return (x * x) + (y * y) + (z * z);
  69317. };
  69318. /**
  69319. * Returns a new Vector3 located at the center between "value1" and "value2"
  69320. * @param value1 defines the first operand
  69321. * @param value2 defines the second operand
  69322. * @returns the new Vector3
  69323. */
  69324. Vector3.Center = function (value1, value2) {
  69325. var center = value1.add(value2);
  69326. center.scaleInPlace(0.5);
  69327. return center;
  69328. };
  69329. /**
  69330. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69331. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69332. * to something in order to rotate it from its local system to the given target system
  69333. * Note: axis1, axis2 and axis3 are normalized during this operation
  69334. * @param axis1 defines the first axis
  69335. * @param axis2 defines the second axis
  69336. * @param axis3 defines the third axis
  69337. * @returns a new Vector3
  69338. */
  69339. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  69340. var rotation = Vector3.Zero();
  69341. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  69342. return rotation;
  69343. };
  69344. /**
  69345. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69346. * @param axis1 defines the first axis
  69347. * @param axis2 defines the second axis
  69348. * @param axis3 defines the third axis
  69349. * @param ref defines the Vector3 where to store the result
  69350. */
  69351. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  69352. var quat = MathTmp.Quaternion[0];
  69353. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  69354. quat.toEulerAnglesToRef(ref);
  69355. };
  69356. Vector3._UpReadOnly = Vector3.Up();
  69357. return Vector3;
  69358. }());
  69359. /**
  69360. * Vector4 class created for EulerAngle class conversion to Quaternion
  69361. */
  69362. var Vector4 = /** @class */ (function () {
  69363. /**
  69364. * Creates a Vector4 object from the given floats.
  69365. * @param x x value of the vector
  69366. * @param y y value of the vector
  69367. * @param z z value of the vector
  69368. * @param w w value of the vector
  69369. */
  69370. function Vector4(
  69371. /** x value of the vector */
  69372. x,
  69373. /** y value of the vector */
  69374. y,
  69375. /** z value of the vector */
  69376. z,
  69377. /** w value of the vector */
  69378. w) {
  69379. this.x = x;
  69380. this.y = y;
  69381. this.z = z;
  69382. this.w = w;
  69383. }
  69384. /**
  69385. * Returns the string with the Vector4 coordinates.
  69386. * @returns a string containing all the vector values
  69387. */
  69388. Vector4.prototype.toString = function () {
  69389. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  69390. };
  69391. /**
  69392. * Returns the string "Vector4".
  69393. * @returns "Vector4"
  69394. */
  69395. Vector4.prototype.getClassName = function () {
  69396. return "Vector4";
  69397. };
  69398. /**
  69399. * Returns the Vector4 hash code.
  69400. * @returns a unique hash code
  69401. */
  69402. Vector4.prototype.getHashCode = function () {
  69403. var hash = this.x || 0;
  69404. hash = (hash * 397) ^ (this.y || 0);
  69405. hash = (hash * 397) ^ (this.z || 0);
  69406. hash = (hash * 397) ^ (this.w || 0);
  69407. return hash;
  69408. };
  69409. // Operators
  69410. /**
  69411. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69412. * @returns the resulting array
  69413. */
  69414. Vector4.prototype.asArray = function () {
  69415. var result = new Array();
  69416. this.toArray(result, 0);
  69417. return result;
  69418. };
  69419. /**
  69420. * Populates the given array from the given index with the Vector4 coordinates.
  69421. * @param array array to populate
  69422. * @param index index of the array to start at (default: 0)
  69423. * @returns the Vector4.
  69424. */
  69425. Vector4.prototype.toArray = function (array, index) {
  69426. if (index === undefined) {
  69427. index = 0;
  69428. }
  69429. array[index] = this.x;
  69430. array[index + 1] = this.y;
  69431. array[index + 2] = this.z;
  69432. array[index + 3] = this.w;
  69433. return this;
  69434. };
  69435. /**
  69436. * Adds the given vector to the current Vector4.
  69437. * @param otherVector the vector to add
  69438. * @returns the updated Vector4.
  69439. */
  69440. Vector4.prototype.addInPlace = function (otherVector) {
  69441. this.x += otherVector.x;
  69442. this.y += otherVector.y;
  69443. this.z += otherVector.z;
  69444. this.w += otherVector.w;
  69445. return this;
  69446. };
  69447. /**
  69448. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69449. * @param otherVector the vector to add
  69450. * @returns the resulting vector
  69451. */
  69452. Vector4.prototype.add = function (otherVector) {
  69453. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  69454. };
  69455. /**
  69456. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69457. * @param otherVector the vector to add
  69458. * @param result the vector to store the result
  69459. * @returns the current Vector4.
  69460. */
  69461. Vector4.prototype.addToRef = function (otherVector, result) {
  69462. result.x = this.x + otherVector.x;
  69463. result.y = this.y + otherVector.y;
  69464. result.z = this.z + otherVector.z;
  69465. result.w = this.w + otherVector.w;
  69466. return this;
  69467. };
  69468. /**
  69469. * Subtract in place the given vector from the current Vector4.
  69470. * @param otherVector the vector to subtract
  69471. * @returns the updated Vector4.
  69472. */
  69473. Vector4.prototype.subtractInPlace = function (otherVector) {
  69474. this.x -= otherVector.x;
  69475. this.y -= otherVector.y;
  69476. this.z -= otherVector.z;
  69477. this.w -= otherVector.w;
  69478. return this;
  69479. };
  69480. /**
  69481. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69482. * @param otherVector the vector to add
  69483. * @returns the new vector with the result
  69484. */
  69485. Vector4.prototype.subtract = function (otherVector) {
  69486. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  69487. };
  69488. /**
  69489. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69490. * @param otherVector the vector to subtract
  69491. * @param result the vector to store the result
  69492. * @returns the current Vector4.
  69493. */
  69494. Vector4.prototype.subtractToRef = function (otherVector, result) {
  69495. result.x = this.x - otherVector.x;
  69496. result.y = this.y - otherVector.y;
  69497. result.z = this.z - otherVector.z;
  69498. result.w = this.w - otherVector.w;
  69499. return this;
  69500. };
  69501. /**
  69502. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69503. */
  69504. /**
  69505. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69506. * @param x value to subtract
  69507. * @param y value to subtract
  69508. * @param z value to subtract
  69509. * @param w value to subtract
  69510. * @returns new vector containing the result
  69511. */
  69512. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  69513. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  69514. };
  69515. /**
  69516. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69517. * @param x value to subtract
  69518. * @param y value to subtract
  69519. * @param z value to subtract
  69520. * @param w value to subtract
  69521. * @param result the vector to store the result in
  69522. * @returns the current Vector4.
  69523. */
  69524. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  69525. result.x = this.x - x;
  69526. result.y = this.y - y;
  69527. result.z = this.z - z;
  69528. result.w = this.w - w;
  69529. return this;
  69530. };
  69531. /**
  69532. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69533. * @returns a new vector with the negated values
  69534. */
  69535. Vector4.prototype.negate = function () {
  69536. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  69537. };
  69538. /**
  69539. * Multiplies the current Vector4 coordinates by scale (float).
  69540. * @param scale the number to scale with
  69541. * @returns the updated Vector4.
  69542. */
  69543. Vector4.prototype.scaleInPlace = function (scale) {
  69544. this.x *= scale;
  69545. this.y *= scale;
  69546. this.z *= scale;
  69547. this.w *= scale;
  69548. return this;
  69549. };
  69550. /**
  69551. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69552. * @param scale the number to scale with
  69553. * @returns a new vector with the result
  69554. */
  69555. Vector4.prototype.scale = function (scale) {
  69556. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  69557. };
  69558. /**
  69559. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69560. * @param scale the number to scale with
  69561. * @param result a vector to store the result in
  69562. * @returns the current Vector4.
  69563. */
  69564. Vector4.prototype.scaleToRef = function (scale, result) {
  69565. result.x = this.x * scale;
  69566. result.y = this.y * scale;
  69567. result.z = this.z * scale;
  69568. result.w = this.w * scale;
  69569. return this;
  69570. };
  69571. /**
  69572. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69573. * @param scale defines the scale factor
  69574. * @param result defines the Vector4 object where to store the result
  69575. * @returns the unmodified current Vector4
  69576. */
  69577. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  69578. result.x += this.x * scale;
  69579. result.y += this.y * scale;
  69580. result.z += this.z * scale;
  69581. result.w += this.w * scale;
  69582. return this;
  69583. };
  69584. /**
  69585. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69586. * @param otherVector the vector to compare against
  69587. * @returns true if they are equal
  69588. */
  69589. Vector4.prototype.equals = function (otherVector) {
  69590. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  69591. };
  69592. /**
  69593. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69594. * @param otherVector vector to compare against
  69595. * @param epsilon (Default: very small number)
  69596. * @returns true if they are equal
  69597. */
  69598. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69599. if (epsilon === void 0) { epsilon = Epsilon; }
  69600. return otherVector
  69601. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  69602. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  69603. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  69604. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  69605. };
  69606. /**
  69607. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69608. * @param x x value to compare against
  69609. * @param y y value to compare against
  69610. * @param z z value to compare against
  69611. * @param w w value to compare against
  69612. * @returns true if equal
  69613. */
  69614. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  69615. return this.x === x && this.y === y && this.z === z && this.w === w;
  69616. };
  69617. /**
  69618. * Multiplies in place the current Vector4 by the given one.
  69619. * @param otherVector vector to multiple with
  69620. * @returns the updated Vector4.
  69621. */
  69622. Vector4.prototype.multiplyInPlace = function (otherVector) {
  69623. this.x *= otherVector.x;
  69624. this.y *= otherVector.y;
  69625. this.z *= otherVector.z;
  69626. this.w *= otherVector.w;
  69627. return this;
  69628. };
  69629. /**
  69630. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69631. * @param otherVector vector to multiple with
  69632. * @returns resulting new vector
  69633. */
  69634. Vector4.prototype.multiply = function (otherVector) {
  69635. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  69636. };
  69637. /**
  69638. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69639. * @param otherVector vector to multiple with
  69640. * @param result vector to store the result
  69641. * @returns the current Vector4.
  69642. */
  69643. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  69644. result.x = this.x * otherVector.x;
  69645. result.y = this.y * otherVector.y;
  69646. result.z = this.z * otherVector.z;
  69647. result.w = this.w * otherVector.w;
  69648. return this;
  69649. };
  69650. /**
  69651. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69652. * @param x x value multiply with
  69653. * @param y y value multiply with
  69654. * @param z z value multiply with
  69655. * @param w w value multiply with
  69656. * @returns resulting new vector
  69657. */
  69658. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  69659. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  69660. };
  69661. /**
  69662. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69663. * @param otherVector vector to devide with
  69664. * @returns resulting new vector
  69665. */
  69666. Vector4.prototype.divide = function (otherVector) {
  69667. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  69668. };
  69669. /**
  69670. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69671. * @param otherVector vector to devide with
  69672. * @param result vector to store the result
  69673. * @returns the current Vector4.
  69674. */
  69675. Vector4.prototype.divideToRef = function (otherVector, result) {
  69676. result.x = this.x / otherVector.x;
  69677. result.y = this.y / otherVector.y;
  69678. result.z = this.z / otherVector.z;
  69679. result.w = this.w / otherVector.w;
  69680. return this;
  69681. };
  69682. /**
  69683. * Divides the current Vector3 coordinates by the given ones.
  69684. * @param otherVector vector to devide with
  69685. * @returns the updated Vector3.
  69686. */
  69687. Vector4.prototype.divideInPlace = function (otherVector) {
  69688. return this.divideToRef(otherVector, this);
  69689. };
  69690. /**
  69691. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69692. * @param other defines the second operand
  69693. * @returns the current updated Vector4
  69694. */
  69695. Vector4.prototype.minimizeInPlace = function (other) {
  69696. if (other.x < this.x) {
  69697. this.x = other.x;
  69698. }
  69699. if (other.y < this.y) {
  69700. this.y = other.y;
  69701. }
  69702. if (other.z < this.z) {
  69703. this.z = other.z;
  69704. }
  69705. if (other.w < this.w) {
  69706. this.w = other.w;
  69707. }
  69708. return this;
  69709. };
  69710. /**
  69711. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  69712. * @param other defines the second operand
  69713. * @returns the current updated Vector4
  69714. */
  69715. Vector4.prototype.maximizeInPlace = function (other) {
  69716. if (other.x > this.x) {
  69717. this.x = other.x;
  69718. }
  69719. if (other.y > this.y) {
  69720. this.y = other.y;
  69721. }
  69722. if (other.z > this.z) {
  69723. this.z = other.z;
  69724. }
  69725. if (other.w > this.w) {
  69726. this.w = other.w;
  69727. }
  69728. return this;
  69729. };
  69730. /**
  69731. * Gets a new Vector4 from current Vector4 floored values
  69732. * @returns a new Vector4
  69733. */
  69734. Vector4.prototype.floor = function () {
  69735. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  69736. };
  69737. /**
  69738. * Gets a new Vector4 from current Vector3 floored values
  69739. * @returns a new Vector4
  69740. */
  69741. Vector4.prototype.fract = function () {
  69742. 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));
  69743. };
  69744. // Properties
  69745. /**
  69746. * Returns the Vector4 length (float).
  69747. * @returns the length
  69748. */
  69749. Vector4.prototype.length = function () {
  69750. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  69751. };
  69752. /**
  69753. * Returns the Vector4 squared length (float).
  69754. * @returns the length squared
  69755. */
  69756. Vector4.prototype.lengthSquared = function () {
  69757. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  69758. };
  69759. // Methods
  69760. /**
  69761. * Normalizes in place the Vector4.
  69762. * @returns the updated Vector4.
  69763. */
  69764. Vector4.prototype.normalize = function () {
  69765. var len = this.length();
  69766. if (len === 0) {
  69767. return this;
  69768. }
  69769. return this.scaleInPlace(1.0 / len);
  69770. };
  69771. /**
  69772. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  69773. * @returns this converted to a new vector3
  69774. */
  69775. Vector4.prototype.toVector3 = function () {
  69776. return new Vector3(this.x, this.y, this.z);
  69777. };
  69778. /**
  69779. * Returns a new Vector4 copied from the current one.
  69780. * @returns the new cloned vector
  69781. */
  69782. Vector4.prototype.clone = function () {
  69783. return new Vector4(this.x, this.y, this.z, this.w);
  69784. };
  69785. /**
  69786. * Updates the current Vector4 with the given one coordinates.
  69787. * @param source the source vector to copy from
  69788. * @returns the updated Vector4.
  69789. */
  69790. Vector4.prototype.copyFrom = function (source) {
  69791. this.x = source.x;
  69792. this.y = source.y;
  69793. this.z = source.z;
  69794. this.w = source.w;
  69795. return this;
  69796. };
  69797. /**
  69798. * Updates the current Vector4 coordinates with the given floats.
  69799. * @param x float to copy from
  69800. * @param y float to copy from
  69801. * @param z float to copy from
  69802. * @param w float to copy from
  69803. * @returns the updated Vector4.
  69804. */
  69805. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  69806. this.x = x;
  69807. this.y = y;
  69808. this.z = z;
  69809. this.w = w;
  69810. return this;
  69811. };
  69812. /**
  69813. * Updates the current Vector4 coordinates with the given floats.
  69814. * @param x float to set from
  69815. * @param y float to set from
  69816. * @param z float to set from
  69817. * @param w float to set from
  69818. * @returns the updated Vector4.
  69819. */
  69820. Vector4.prototype.set = function (x, y, z, w) {
  69821. return this.copyFromFloats(x, y, z, w);
  69822. };
  69823. /**
  69824. * Copies the given float to the current Vector3 coordinates
  69825. * @param v defines the x, y, z and w coordinates of the operand
  69826. * @returns the current updated Vector3
  69827. */
  69828. Vector4.prototype.setAll = function (v) {
  69829. this.x = this.y = this.z = this.w = v;
  69830. return this;
  69831. };
  69832. // Statics
  69833. /**
  69834. * Returns a new Vector4 set from the starting index of the given array.
  69835. * @param array the array to pull values from
  69836. * @param offset the offset into the array to start at
  69837. * @returns the new vector
  69838. */
  69839. Vector4.FromArray = function (array, offset) {
  69840. if (!offset) {
  69841. offset = 0;
  69842. }
  69843. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  69844. };
  69845. /**
  69846. * Updates the given vector "result" from the starting index of the given array.
  69847. * @param array the array to pull values from
  69848. * @param offset the offset into the array to start at
  69849. * @param result the vector to store the result in
  69850. */
  69851. Vector4.FromArrayToRef = function (array, offset, result) {
  69852. result.x = array[offset];
  69853. result.y = array[offset + 1];
  69854. result.z = array[offset + 2];
  69855. result.w = array[offset + 3];
  69856. };
  69857. /**
  69858. * Updates the given vector "result" from the starting index of the given Float32Array.
  69859. * @param array the array to pull values from
  69860. * @param offset the offset into the array to start at
  69861. * @param result the vector to store the result in
  69862. */
  69863. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  69864. Vector4.FromArrayToRef(array, offset, result);
  69865. };
  69866. /**
  69867. * Updates the given vector "result" coordinates from the given floats.
  69868. * @param x float to set from
  69869. * @param y float to set from
  69870. * @param z float to set from
  69871. * @param w float to set from
  69872. * @param result the vector to the floats in
  69873. */
  69874. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  69875. result.x = x;
  69876. result.y = y;
  69877. result.z = z;
  69878. result.w = w;
  69879. };
  69880. /**
  69881. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  69882. * @returns the new vector
  69883. */
  69884. Vector4.Zero = function () {
  69885. return new Vector4(0.0, 0.0, 0.0, 0.0);
  69886. };
  69887. /**
  69888. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  69889. * @returns the new vector
  69890. */
  69891. Vector4.One = function () {
  69892. return new Vector4(1.0, 1.0, 1.0, 1.0);
  69893. };
  69894. /**
  69895. * Returns a new normalized Vector4 from the given one.
  69896. * @param vector the vector to normalize
  69897. * @returns the vector
  69898. */
  69899. Vector4.Normalize = function (vector) {
  69900. var result = Vector4.Zero();
  69901. Vector4.NormalizeToRef(vector, result);
  69902. return result;
  69903. };
  69904. /**
  69905. * Updates the given vector "result" from the normalization of the given one.
  69906. * @param vector the vector to normalize
  69907. * @param result the vector to store the result in
  69908. */
  69909. Vector4.NormalizeToRef = function (vector, result) {
  69910. result.copyFrom(vector);
  69911. result.normalize();
  69912. };
  69913. /**
  69914. * Returns a vector with the minimum values from the left and right vectors
  69915. * @param left left vector to minimize
  69916. * @param right right vector to minimize
  69917. * @returns a new vector with the minimum of the left and right vector values
  69918. */
  69919. Vector4.Minimize = function (left, right) {
  69920. var min = left.clone();
  69921. min.minimizeInPlace(right);
  69922. return min;
  69923. };
  69924. /**
  69925. * Returns a vector with the maximum values from the left and right vectors
  69926. * @param left left vector to maximize
  69927. * @param right right vector to maximize
  69928. * @returns a new vector with the maximum of the left and right vector values
  69929. */
  69930. Vector4.Maximize = function (left, right) {
  69931. var max = left.clone();
  69932. max.maximizeInPlace(right);
  69933. return max;
  69934. };
  69935. /**
  69936. * Returns the distance (float) between the vectors "value1" and "value2".
  69937. * @param value1 value to calulate the distance between
  69938. * @param value2 value to calulate the distance between
  69939. * @return the distance between the two vectors
  69940. */
  69941. Vector4.Distance = function (value1, value2) {
  69942. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  69943. };
  69944. /**
  69945. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69946. * @param value1 value to calulate the distance between
  69947. * @param value2 value to calulate the distance between
  69948. * @return the distance between the two vectors squared
  69949. */
  69950. Vector4.DistanceSquared = function (value1, value2) {
  69951. var x = value1.x - value2.x;
  69952. var y = value1.y - value2.y;
  69953. var z = value1.z - value2.z;
  69954. var w = value1.w - value2.w;
  69955. return (x * x) + (y * y) + (z * z) + (w * w);
  69956. };
  69957. /**
  69958. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69959. * @param value1 value to calulate the center between
  69960. * @param value2 value to calulate the center between
  69961. * @return the center between the two vectors
  69962. */
  69963. Vector4.Center = function (value1, value2) {
  69964. var center = value1.add(value2);
  69965. center.scaleInPlace(0.5);
  69966. return center;
  69967. };
  69968. /**
  69969. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69970. * This methods computes transformed normalized direction vectors only.
  69971. * @param vector the vector to transform
  69972. * @param transformation the transformation matrix to apply
  69973. * @returns the new vector
  69974. */
  69975. Vector4.TransformNormal = function (vector, transformation) {
  69976. var result = Vector4.Zero();
  69977. Vector4.TransformNormalToRef(vector, transformation, result);
  69978. return result;
  69979. };
  69980. /**
  69981. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69982. * This methods computes transformed normalized direction vectors only.
  69983. * @param vector the vector to transform
  69984. * @param transformation the transformation matrix to apply
  69985. * @param result the vector to store the result in
  69986. */
  69987. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  69988. var m = transformation.m;
  69989. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  69990. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  69991. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  69992. result.x = x;
  69993. result.y = y;
  69994. result.z = z;
  69995. result.w = vector.w;
  69996. };
  69997. /**
  69998. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69999. * This methods computes transformed normalized direction vectors only.
  70000. * @param x value to transform
  70001. * @param y value to transform
  70002. * @param z value to transform
  70003. * @param w value to transform
  70004. * @param transformation the transformation matrix to apply
  70005. * @param result the vector to store the results in
  70006. */
  70007. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  70008. var m = transformation.m;
  70009. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  70010. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  70011. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  70012. result.w = w;
  70013. };
  70014. /**
  70015. * Creates a new Vector4 from a Vector3
  70016. * @param source defines the source data
  70017. * @param w defines the 4th component (default is 0)
  70018. * @returns a new Vector4
  70019. */
  70020. Vector4.FromVector3 = function (source, w) {
  70021. if (w === void 0) { w = 0; }
  70022. return new Vector4(source.x, source.y, source.z, w);
  70023. };
  70024. return Vector4;
  70025. }());
  70026. /**
  70027. * Size containing widht and height
  70028. */
  70029. var Size = /** @class */ (function () {
  70030. /**
  70031. * Creates a Size object from the given width and height (floats).
  70032. * @param width width of the new size
  70033. * @param height height of the new size
  70034. */
  70035. function Size(width, height) {
  70036. this.width = width;
  70037. this.height = height;
  70038. }
  70039. /**
  70040. * Returns a string with the Size width and height
  70041. * @returns a string with the Size width and height
  70042. */
  70043. Size.prototype.toString = function () {
  70044. return "{W: " + this.width + ", H: " + this.height + "}";
  70045. };
  70046. /**
  70047. * "Size"
  70048. * @returns the string "Size"
  70049. */
  70050. Size.prototype.getClassName = function () {
  70051. return "Size";
  70052. };
  70053. /**
  70054. * Returns the Size hash code.
  70055. * @returns a hash code for a unique width and height
  70056. */
  70057. Size.prototype.getHashCode = function () {
  70058. var hash = this.width || 0;
  70059. hash = (hash * 397) ^ (this.height || 0);
  70060. return hash;
  70061. };
  70062. /**
  70063. * Updates the current size from the given one.
  70064. * @param src the given size
  70065. */
  70066. Size.prototype.copyFrom = function (src) {
  70067. this.width = src.width;
  70068. this.height = src.height;
  70069. };
  70070. /**
  70071. * Updates in place the current Size from the given floats.
  70072. * @param width width of the new size
  70073. * @param height height of the new size
  70074. * @returns the updated Size.
  70075. */
  70076. Size.prototype.copyFromFloats = function (width, height) {
  70077. this.width = width;
  70078. this.height = height;
  70079. return this;
  70080. };
  70081. /**
  70082. * Updates in place the current Size from the given floats.
  70083. * @param width width to set
  70084. * @param height height to set
  70085. * @returns the updated Size.
  70086. */
  70087. Size.prototype.set = function (width, height) {
  70088. return this.copyFromFloats(width, height);
  70089. };
  70090. /**
  70091. * Multiplies the width and height by numbers
  70092. * @param w factor to multiple the width by
  70093. * @param h factor to multiple the height by
  70094. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  70095. */
  70096. Size.prototype.multiplyByFloats = function (w, h) {
  70097. return new Size(this.width * w, this.height * h);
  70098. };
  70099. /**
  70100. * Clones the size
  70101. * @returns a new Size copied from the given one.
  70102. */
  70103. Size.prototype.clone = function () {
  70104. return new Size(this.width, this.height);
  70105. };
  70106. /**
  70107. * True if the current Size and the given one width and height are strictly equal.
  70108. * @param other the other size to compare against
  70109. * @returns True if the current Size and the given one width and height are strictly equal.
  70110. */
  70111. Size.prototype.equals = function (other) {
  70112. if (!other) {
  70113. return false;
  70114. }
  70115. return (this.width === other.width) && (this.height === other.height);
  70116. };
  70117. Object.defineProperty(Size.prototype, "surface", {
  70118. /**
  70119. * The surface of the Size : width * height (float).
  70120. */
  70121. get: function () {
  70122. return this.width * this.height;
  70123. },
  70124. enumerable: true,
  70125. configurable: true
  70126. });
  70127. /**
  70128. * Create a new size of zero
  70129. * @returns a new Size set to (0.0, 0.0)
  70130. */
  70131. Size.Zero = function () {
  70132. return new Size(0.0, 0.0);
  70133. };
  70134. /**
  70135. * Sums the width and height of two sizes
  70136. * @param otherSize size to add to this size
  70137. * @returns a new Size set as the addition result of the current Size and the given one.
  70138. */
  70139. Size.prototype.add = function (otherSize) {
  70140. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  70141. return r;
  70142. };
  70143. /**
  70144. * Subtracts the width and height of two
  70145. * @param otherSize size to subtract to this size
  70146. * @returns a new Size set as the subtraction result of the given one from the current Size.
  70147. */
  70148. Size.prototype.subtract = function (otherSize) {
  70149. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  70150. return r;
  70151. };
  70152. /**
  70153. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  70154. * @param start starting size to lerp between
  70155. * @param end end size to lerp between
  70156. * @param amount amount to lerp between the start and end values
  70157. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  70158. */
  70159. Size.Lerp = function (start, end, amount) {
  70160. var w = start.width + ((end.width - start.width) * amount);
  70161. var h = start.height + ((end.height - start.height) * amount);
  70162. return new Size(w, h);
  70163. };
  70164. return Size;
  70165. }());
  70166. /**
  70167. * Class used to store quaternion data
  70168. * @see https://en.wikipedia.org/wiki/Quaternion
  70169. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70170. */
  70171. var Quaternion = /** @class */ (function () {
  70172. /**
  70173. * Creates a new Quaternion from the given floats
  70174. * @param x defines the first component (0 by default)
  70175. * @param y defines the second component (0 by default)
  70176. * @param z defines the third component (0 by default)
  70177. * @param w defines the fourth component (1.0 by default)
  70178. */
  70179. function Quaternion(
  70180. /** defines the first component (0 by default) */
  70181. x,
  70182. /** defines the second component (0 by default) */
  70183. y,
  70184. /** defines the third component (0 by default) */
  70185. z,
  70186. /** defines the fourth component (1.0 by default) */
  70187. w) {
  70188. if (x === void 0) { x = 0.0; }
  70189. if (y === void 0) { y = 0.0; }
  70190. if (z === void 0) { z = 0.0; }
  70191. if (w === void 0) { w = 1.0; }
  70192. this.x = x;
  70193. this.y = y;
  70194. this.z = z;
  70195. this.w = w;
  70196. }
  70197. /**
  70198. * Gets a string representation for the current quaternion
  70199. * @returns a string with the Quaternion coordinates
  70200. */
  70201. Quaternion.prototype.toString = function () {
  70202. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70203. };
  70204. /**
  70205. * Gets the class name of the quaternion
  70206. * @returns the string "Quaternion"
  70207. */
  70208. Quaternion.prototype.getClassName = function () {
  70209. return "Quaternion";
  70210. };
  70211. /**
  70212. * Gets a hash code for this quaternion
  70213. * @returns the quaternion hash code
  70214. */
  70215. Quaternion.prototype.getHashCode = function () {
  70216. var hash = this.x || 0;
  70217. hash = (hash * 397) ^ (this.y || 0);
  70218. hash = (hash * 397) ^ (this.z || 0);
  70219. hash = (hash * 397) ^ (this.w || 0);
  70220. return hash;
  70221. };
  70222. /**
  70223. * Copy the quaternion to an array
  70224. * @returns a new array populated with 4 elements from the quaternion coordinates
  70225. */
  70226. Quaternion.prototype.asArray = function () {
  70227. return [this.x, this.y, this.z, this.w];
  70228. };
  70229. /**
  70230. * Check if two quaternions are equals
  70231. * @param otherQuaternion defines the second operand
  70232. * @return true if the current quaternion and the given one coordinates are strictly equals
  70233. */
  70234. Quaternion.prototype.equals = function (otherQuaternion) {
  70235. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  70236. };
  70237. /**
  70238. * Clone the current quaternion
  70239. * @returns a new quaternion copied from the current one
  70240. */
  70241. Quaternion.prototype.clone = function () {
  70242. return new Quaternion(this.x, this.y, this.z, this.w);
  70243. };
  70244. /**
  70245. * Copy a quaternion to the current one
  70246. * @param other defines the other quaternion
  70247. * @returns the updated current quaternion
  70248. */
  70249. Quaternion.prototype.copyFrom = function (other) {
  70250. this.x = other.x;
  70251. this.y = other.y;
  70252. this.z = other.z;
  70253. this.w = other.w;
  70254. return this;
  70255. };
  70256. /**
  70257. * Updates the current quaternion with the given float coordinates
  70258. * @param x defines the x coordinate
  70259. * @param y defines the y coordinate
  70260. * @param z defines the z coordinate
  70261. * @param w defines the w coordinate
  70262. * @returns the updated current quaternion
  70263. */
  70264. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  70265. this.x = x;
  70266. this.y = y;
  70267. this.z = z;
  70268. this.w = w;
  70269. return this;
  70270. };
  70271. /**
  70272. * Updates the current quaternion from the given float coordinates
  70273. * @param x defines the x coordinate
  70274. * @param y defines the y coordinate
  70275. * @param z defines the z coordinate
  70276. * @param w defines the w coordinate
  70277. * @returns the updated current quaternion
  70278. */
  70279. Quaternion.prototype.set = function (x, y, z, w) {
  70280. return this.copyFromFloats(x, y, z, w);
  70281. };
  70282. /**
  70283. * Adds two quaternions
  70284. * @param other defines the second operand
  70285. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70286. */
  70287. Quaternion.prototype.add = function (other) {
  70288. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  70289. };
  70290. /**
  70291. * Add a quaternion to the current one
  70292. * @param other defines the quaternion to add
  70293. * @returns the current quaternion
  70294. */
  70295. Quaternion.prototype.addInPlace = function (other) {
  70296. this.x += other.x;
  70297. this.y += other.y;
  70298. this.z += other.z;
  70299. this.w += other.w;
  70300. return this;
  70301. };
  70302. /**
  70303. * Subtract two quaternions
  70304. * @param other defines the second operand
  70305. * @returns a new quaternion as the subtraction result of the given one from the current one
  70306. */
  70307. Quaternion.prototype.subtract = function (other) {
  70308. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  70309. };
  70310. /**
  70311. * Multiplies the current quaternion by a scale factor
  70312. * @param value defines the scale factor
  70313. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70314. */
  70315. Quaternion.prototype.scale = function (value) {
  70316. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  70317. };
  70318. /**
  70319. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70320. * @param scale defines the scale factor
  70321. * @param result defines the Quaternion object where to store the result
  70322. * @returns the unmodified current quaternion
  70323. */
  70324. Quaternion.prototype.scaleToRef = function (scale, result) {
  70325. result.x = this.x * scale;
  70326. result.y = this.y * scale;
  70327. result.z = this.z * scale;
  70328. result.w = this.w * scale;
  70329. return this;
  70330. };
  70331. /**
  70332. * Multiplies in place the current quaternion by a scale factor
  70333. * @param value defines the scale factor
  70334. * @returns the current modified quaternion
  70335. */
  70336. Quaternion.prototype.scaleInPlace = function (value) {
  70337. this.x *= value;
  70338. this.y *= value;
  70339. this.z *= value;
  70340. this.w *= value;
  70341. return this;
  70342. };
  70343. /**
  70344. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70345. * @param scale defines the scale factor
  70346. * @param result defines the Quaternion object where to store the result
  70347. * @returns the unmodified current quaternion
  70348. */
  70349. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  70350. result.x += this.x * scale;
  70351. result.y += this.y * scale;
  70352. result.z += this.z * scale;
  70353. result.w += this.w * scale;
  70354. return this;
  70355. };
  70356. /**
  70357. * Multiplies two quaternions
  70358. * @param q1 defines the second operand
  70359. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70360. */
  70361. Quaternion.prototype.multiply = function (q1) {
  70362. var result = new Quaternion(0, 0, 0, 1.0);
  70363. this.multiplyToRef(q1, result);
  70364. return result;
  70365. };
  70366. /**
  70367. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70368. * @param q1 defines the second operand
  70369. * @param result defines the target quaternion
  70370. * @returns the current quaternion
  70371. */
  70372. Quaternion.prototype.multiplyToRef = function (q1, result) {
  70373. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  70374. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  70375. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  70376. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  70377. result.copyFromFloats(x, y, z, w);
  70378. return this;
  70379. };
  70380. /**
  70381. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70382. * @param q1 defines the second operand
  70383. * @returns the currentupdated quaternion
  70384. */
  70385. Quaternion.prototype.multiplyInPlace = function (q1) {
  70386. this.multiplyToRef(q1, this);
  70387. return this;
  70388. };
  70389. /**
  70390. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70391. * @param ref defines the target quaternion
  70392. * @returns the current quaternion
  70393. */
  70394. Quaternion.prototype.conjugateToRef = function (ref) {
  70395. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  70396. return this;
  70397. };
  70398. /**
  70399. * Conjugates in place (1-q) the current quaternion
  70400. * @returns the current updated quaternion
  70401. */
  70402. Quaternion.prototype.conjugateInPlace = function () {
  70403. this.x *= -1;
  70404. this.y *= -1;
  70405. this.z *= -1;
  70406. return this;
  70407. };
  70408. /**
  70409. * Conjugates in place (1-q) the current quaternion
  70410. * @returns a new quaternion
  70411. */
  70412. Quaternion.prototype.conjugate = function () {
  70413. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  70414. return result;
  70415. };
  70416. /**
  70417. * Gets length of current quaternion
  70418. * @returns the quaternion length (float)
  70419. */
  70420. Quaternion.prototype.length = function () {
  70421. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  70422. };
  70423. /**
  70424. * Normalize in place the current quaternion
  70425. * @returns the current updated quaternion
  70426. */
  70427. Quaternion.prototype.normalize = function () {
  70428. var length = 1.0 / this.length();
  70429. this.x *= length;
  70430. this.y *= length;
  70431. this.z *= length;
  70432. this.w *= length;
  70433. return this;
  70434. };
  70435. /**
  70436. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70437. * @param order is a reserved parameter and is ignore for now
  70438. * @returns a new Vector3 containing the Euler angles
  70439. */
  70440. Quaternion.prototype.toEulerAngles = function (order) {
  70441. if (order === void 0) { order = "YZX"; }
  70442. var result = Vector3.Zero();
  70443. this.toEulerAnglesToRef(result);
  70444. return result;
  70445. };
  70446. /**
  70447. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70448. * @param result defines the vector which will be filled with the Euler angles
  70449. * @param order is a reserved parameter and is ignore for now
  70450. * @returns the current unchanged quaternion
  70451. */
  70452. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  70453. var qz = this.z;
  70454. var qx = this.x;
  70455. var qy = this.y;
  70456. var qw = this.w;
  70457. var sqw = qw * qw;
  70458. var sqz = qz * qz;
  70459. var sqx = qx * qx;
  70460. var sqy = qy * qy;
  70461. var zAxisY = qy * qz - qx * qw;
  70462. var limit = .4999999;
  70463. if (zAxisY < -limit) {
  70464. result.y = 2 * Math.atan2(qy, qw);
  70465. result.x = Math.PI / 2;
  70466. result.z = 0;
  70467. }
  70468. else if (zAxisY > limit) {
  70469. result.y = 2 * Math.atan2(qy, qw);
  70470. result.x = -Math.PI / 2;
  70471. result.z = 0;
  70472. }
  70473. else {
  70474. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  70475. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  70476. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  70477. }
  70478. return this;
  70479. };
  70480. /**
  70481. * Updates the given rotation matrix with the current quaternion values
  70482. * @param result defines the target matrix
  70483. * @returns the current unchanged quaternion
  70484. */
  70485. Quaternion.prototype.toRotationMatrix = function (result) {
  70486. Matrix.FromQuaternionToRef(this, result);
  70487. return this;
  70488. };
  70489. /**
  70490. * Updates the current quaternion from the given rotation matrix values
  70491. * @param matrix defines the source matrix
  70492. * @returns the current updated quaternion
  70493. */
  70494. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  70495. Quaternion.FromRotationMatrixToRef(matrix, this);
  70496. return this;
  70497. };
  70498. // Statics
  70499. /**
  70500. * Creates a new quaternion from a rotation matrix
  70501. * @param matrix defines the source matrix
  70502. * @returns a new quaternion created from the given rotation matrix values
  70503. */
  70504. Quaternion.FromRotationMatrix = function (matrix) {
  70505. var result = new Quaternion();
  70506. Quaternion.FromRotationMatrixToRef(matrix, result);
  70507. return result;
  70508. };
  70509. /**
  70510. * Updates the given quaternion with the given rotation matrix values
  70511. * @param matrix defines the source matrix
  70512. * @param result defines the target quaternion
  70513. */
  70514. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  70515. var data = matrix.m;
  70516. var m11 = data[0], m12 = data[4], m13 = data[8];
  70517. var m21 = data[1], m22 = data[5], m23 = data[9];
  70518. var m31 = data[2], m32 = data[6], m33 = data[10];
  70519. var trace = m11 + m22 + m33;
  70520. var s;
  70521. if (trace > 0) {
  70522. s = 0.5 / Math.sqrt(trace + 1.0);
  70523. result.w = 0.25 / s;
  70524. result.x = (m32 - m23) * s;
  70525. result.y = (m13 - m31) * s;
  70526. result.z = (m21 - m12) * s;
  70527. }
  70528. else if (m11 > m22 && m11 > m33) {
  70529. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  70530. result.w = (m32 - m23) / s;
  70531. result.x = 0.25 * s;
  70532. result.y = (m12 + m21) / s;
  70533. result.z = (m13 + m31) / s;
  70534. }
  70535. else if (m22 > m33) {
  70536. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  70537. result.w = (m13 - m31) / s;
  70538. result.x = (m12 + m21) / s;
  70539. result.y = 0.25 * s;
  70540. result.z = (m23 + m32) / s;
  70541. }
  70542. else {
  70543. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  70544. result.w = (m21 - m12) / s;
  70545. result.x = (m13 + m31) / s;
  70546. result.y = (m23 + m32) / s;
  70547. result.z = 0.25 * s;
  70548. }
  70549. };
  70550. /**
  70551. * Returns the dot product (float) between the quaternions "left" and "right"
  70552. * @param left defines the left operand
  70553. * @param right defines the right operand
  70554. * @returns the dot product
  70555. */
  70556. Quaternion.Dot = function (left, right) {
  70557. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  70558. };
  70559. /**
  70560. * Checks if the two quaternions are close to each other
  70561. * @param quat0 defines the first quaternion to check
  70562. * @param quat1 defines the second quaternion to check
  70563. * @returns true if the two quaternions are close to each other
  70564. */
  70565. Quaternion.AreClose = function (quat0, quat1) {
  70566. var dot = Quaternion.Dot(quat0, quat1);
  70567. return dot >= 0;
  70568. };
  70569. /**
  70570. * Creates an empty quaternion
  70571. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70572. */
  70573. Quaternion.Zero = function () {
  70574. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  70575. };
  70576. /**
  70577. * Inverse a given quaternion
  70578. * @param q defines the source quaternion
  70579. * @returns a new quaternion as the inverted current quaternion
  70580. */
  70581. Quaternion.Inverse = function (q) {
  70582. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  70583. };
  70584. /**
  70585. * Inverse a given quaternion
  70586. * @param q defines the source quaternion
  70587. * @param result the quaternion the result will be stored in
  70588. * @returns the result quaternion
  70589. */
  70590. Quaternion.InverseToRef = function (q, result) {
  70591. result.set(-q.x, -q.y, -q.z, q.w);
  70592. return result;
  70593. };
  70594. /**
  70595. * Creates an identity quaternion
  70596. * @returns the identity quaternion
  70597. */
  70598. Quaternion.Identity = function () {
  70599. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  70600. };
  70601. /**
  70602. * Gets a boolean indicating if the given quaternion is identity
  70603. * @param quaternion defines the quaternion to check
  70604. * @returns true if the quaternion is identity
  70605. */
  70606. Quaternion.IsIdentity = function (quaternion) {
  70607. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  70608. };
  70609. /**
  70610. * Creates a quaternion from a rotation around an axis
  70611. * @param axis defines the axis to use
  70612. * @param angle defines the angle to use
  70613. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70614. */
  70615. Quaternion.RotationAxis = function (axis, angle) {
  70616. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  70617. };
  70618. /**
  70619. * Creates a rotation around an axis and stores it into the given quaternion
  70620. * @param axis defines the axis to use
  70621. * @param angle defines the angle to use
  70622. * @param result defines the target quaternion
  70623. * @returns the target quaternion
  70624. */
  70625. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  70626. var sin = Math.sin(angle / 2);
  70627. axis.normalize();
  70628. result.w = Math.cos(angle / 2);
  70629. result.x = axis.x * sin;
  70630. result.y = axis.y * sin;
  70631. result.z = axis.z * sin;
  70632. return result;
  70633. };
  70634. /**
  70635. * Creates a new quaternion from data stored into an array
  70636. * @param array defines the data source
  70637. * @param offset defines the offset in the source array where the data starts
  70638. * @returns a new quaternion
  70639. */
  70640. Quaternion.FromArray = function (array, offset) {
  70641. if (!offset) {
  70642. offset = 0;
  70643. }
  70644. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70645. };
  70646. /**
  70647. * Create a quaternion from Euler rotation angles
  70648. * @param x Pitch
  70649. * @param y Yaw
  70650. * @param z Roll
  70651. * @returns the new Quaternion
  70652. */
  70653. Quaternion.FromEulerAngles = function (x, y, z) {
  70654. var q = new Quaternion();
  70655. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  70656. return q;
  70657. };
  70658. /**
  70659. * Updates a quaternion from Euler rotation angles
  70660. * @param x Pitch
  70661. * @param y Yaw
  70662. * @param z Roll
  70663. * @param result the quaternion to store the result
  70664. * @returns the updated quaternion
  70665. */
  70666. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  70667. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  70668. return result;
  70669. };
  70670. /**
  70671. * Create a quaternion from Euler rotation vector
  70672. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70673. * @returns the new Quaternion
  70674. */
  70675. Quaternion.FromEulerVector = function (vec) {
  70676. var q = new Quaternion();
  70677. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  70678. return q;
  70679. };
  70680. /**
  70681. * Updates a quaternion from Euler rotation vector
  70682. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70683. * @param result the quaternion to store the result
  70684. * @returns the updated quaternion
  70685. */
  70686. Quaternion.FromEulerVectorToRef = function (vec, result) {
  70687. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  70688. return result;
  70689. };
  70690. /**
  70691. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70692. * @param yaw defines the rotation around Y axis
  70693. * @param pitch defines the rotation around X axis
  70694. * @param roll defines the rotation around Z axis
  70695. * @returns the new quaternion
  70696. */
  70697. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  70698. var q = new Quaternion();
  70699. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  70700. return q;
  70701. };
  70702. /**
  70703. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70704. * @param yaw defines the rotation around Y axis
  70705. * @param pitch defines the rotation around X axis
  70706. * @param roll defines the rotation around Z axis
  70707. * @param result defines the target quaternion
  70708. */
  70709. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  70710. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  70711. var halfRoll = roll * 0.5;
  70712. var halfPitch = pitch * 0.5;
  70713. var halfYaw = yaw * 0.5;
  70714. var sinRoll = Math.sin(halfRoll);
  70715. var cosRoll = Math.cos(halfRoll);
  70716. var sinPitch = Math.sin(halfPitch);
  70717. var cosPitch = Math.cos(halfPitch);
  70718. var sinYaw = Math.sin(halfYaw);
  70719. var cosYaw = Math.cos(halfYaw);
  70720. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  70721. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  70722. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  70723. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  70724. };
  70725. /**
  70726. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70727. * @param alpha defines the rotation around first axis
  70728. * @param beta defines the rotation around second axis
  70729. * @param gamma defines the rotation around third axis
  70730. * @returns the new quaternion
  70731. */
  70732. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  70733. var result = new Quaternion();
  70734. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  70735. return result;
  70736. };
  70737. /**
  70738. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70739. * @param alpha defines the rotation around first axis
  70740. * @param beta defines the rotation around second axis
  70741. * @param gamma defines the rotation around third axis
  70742. * @param result defines the target quaternion
  70743. */
  70744. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  70745. // Produces a quaternion from Euler angles in the z-x-z orientation
  70746. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  70747. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  70748. var halfBeta = beta * 0.5;
  70749. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  70750. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  70751. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  70752. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  70753. };
  70754. /**
  70755. * 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)
  70756. * @param axis1 defines the first axis
  70757. * @param axis2 defines the second axis
  70758. * @param axis3 defines the third axis
  70759. * @returns the new quaternion
  70760. */
  70761. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  70762. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  70763. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70764. return quat;
  70765. };
  70766. /**
  70767. * 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
  70768. * @param axis1 defines the first axis
  70769. * @param axis2 defines the second axis
  70770. * @param axis3 defines the third axis
  70771. * @param ref defines the target quaternion
  70772. */
  70773. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70774. var rotMat = MathTmp.Matrix[0];
  70775. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  70776. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  70777. };
  70778. /**
  70779. * Interpolates between two quaternions
  70780. * @param left defines first quaternion
  70781. * @param right defines second quaternion
  70782. * @param amount defines the gradient to use
  70783. * @returns the new interpolated quaternion
  70784. */
  70785. Quaternion.Slerp = function (left, right, amount) {
  70786. var result = Quaternion.Identity();
  70787. Quaternion.SlerpToRef(left, right, amount, result);
  70788. return result;
  70789. };
  70790. /**
  70791. * Interpolates between two quaternions and stores it into a target quaternion
  70792. * @param left defines first quaternion
  70793. * @param right defines second quaternion
  70794. * @param amount defines the gradient to use
  70795. * @param result defines the target quaternion
  70796. */
  70797. Quaternion.SlerpToRef = function (left, right, amount, result) {
  70798. var num2;
  70799. var num3;
  70800. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  70801. var flag = false;
  70802. if (num4 < 0) {
  70803. flag = true;
  70804. num4 = -num4;
  70805. }
  70806. if (num4 > 0.999999) {
  70807. num3 = 1 - amount;
  70808. num2 = flag ? -amount : amount;
  70809. }
  70810. else {
  70811. var num5 = Math.acos(num4);
  70812. var num6 = (1.0 / Math.sin(num5));
  70813. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  70814. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  70815. }
  70816. result.x = (num3 * left.x) + (num2 * right.x);
  70817. result.y = (num3 * left.y) + (num2 * right.y);
  70818. result.z = (num3 * left.z) + (num2 * right.z);
  70819. result.w = (num3 * left.w) + (num2 * right.w);
  70820. };
  70821. /**
  70822. * Interpolate between two quaternions using Hermite interpolation
  70823. * @param value1 defines first quaternion
  70824. * @param tangent1 defines the incoming tangent
  70825. * @param value2 defines second quaternion
  70826. * @param tangent2 defines the outgoing tangent
  70827. * @param amount defines the target quaternion
  70828. * @returns the new interpolated quaternion
  70829. */
  70830. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70831. var squared = amount * amount;
  70832. var cubed = amount * squared;
  70833. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70834. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70835. var part3 = (cubed - (2.0 * squared)) + amount;
  70836. var part4 = cubed - squared;
  70837. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70838. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70839. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70840. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  70841. return new Quaternion(x, y, z, w);
  70842. };
  70843. return Quaternion;
  70844. }());
  70845. /**
  70846. * Class used to store matrix data (4x4)
  70847. */
  70848. var Matrix = /** @class */ (function () {
  70849. /**
  70850. * Creates an empty matrix (filled with zeros)
  70851. */
  70852. function Matrix() {
  70853. this._isIdentity = false;
  70854. this._isIdentityDirty = true;
  70855. this._isIdentity3x2 = true;
  70856. this._isIdentity3x2Dirty = true;
  70857. this._m = new Float32Array(16);
  70858. this._updateIdentityStatus(false);
  70859. }
  70860. Object.defineProperty(Matrix.prototype, "m", {
  70861. /**
  70862. * Gets the internal data of the matrix
  70863. */
  70864. get: function () { return this._m; },
  70865. enumerable: true,
  70866. configurable: true
  70867. });
  70868. /** @hidden */
  70869. Matrix.prototype._markAsUpdated = function () {
  70870. this.updateFlag = Matrix._updateFlagSeed++;
  70871. this._isIdentity = false;
  70872. this._isIdentity3x2 = false;
  70873. this._isIdentityDirty = true;
  70874. this._isIdentity3x2Dirty = true;
  70875. };
  70876. /** @hidden */
  70877. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  70878. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  70879. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  70880. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  70881. this.updateFlag = Matrix._updateFlagSeed++;
  70882. this._isIdentity = isIdentity;
  70883. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  70884. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  70885. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  70886. };
  70887. // Properties
  70888. /**
  70889. * Check if the current matrix is identity
  70890. * @returns true is the matrix is the identity matrix
  70891. */
  70892. Matrix.prototype.isIdentity = function () {
  70893. if (this._isIdentityDirty) {
  70894. this._isIdentityDirty = false;
  70895. var m = this._m;
  70896. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  70897. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  70898. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  70899. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  70900. }
  70901. return this._isIdentity;
  70902. };
  70903. /**
  70904. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70905. * @returns true is the matrix is the identity matrix
  70906. */
  70907. Matrix.prototype.isIdentityAs3x2 = function () {
  70908. if (this._isIdentity3x2Dirty) {
  70909. this._isIdentity3x2Dirty = false;
  70910. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  70911. this._isIdentity3x2 = false;
  70912. }
  70913. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  70914. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  70915. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  70916. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  70917. this._isIdentity3x2 = false;
  70918. }
  70919. else {
  70920. this._isIdentity3x2 = true;
  70921. }
  70922. }
  70923. return this._isIdentity3x2;
  70924. };
  70925. /**
  70926. * Gets the determinant of the matrix
  70927. * @returns the matrix determinant
  70928. */
  70929. Matrix.prototype.determinant = function () {
  70930. if (this._isIdentity === true) {
  70931. return 1;
  70932. }
  70933. var m = this._m;
  70934. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  70935. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  70936. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  70937. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  70938. // https://en.wikipedia.org/wiki/Laplace_expansion
  70939. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  70940. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  70941. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  70942. // where
  70943. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  70944. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  70945. //
  70946. // Here we do that for the 1st row.
  70947. var det_22_33 = m22 * m33 - m32 * m23;
  70948. var det_21_33 = m21 * m33 - m31 * m23;
  70949. var det_21_32 = m21 * m32 - m31 * m22;
  70950. var det_20_33 = m20 * m33 - m30 * m23;
  70951. var det_20_32 = m20 * m32 - m22 * m30;
  70952. var det_20_31 = m20 * m31 - m30 * m21;
  70953. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  70954. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  70955. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  70956. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  70957. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  70958. };
  70959. // Methods
  70960. /**
  70961. * Returns the matrix as a Float32Array
  70962. * @returns the matrix underlying array
  70963. */
  70964. Matrix.prototype.toArray = function () {
  70965. return this._m;
  70966. };
  70967. /**
  70968. * Returns the matrix as a Float32Array
  70969. * @returns the matrix underlying array.
  70970. */
  70971. Matrix.prototype.asArray = function () {
  70972. return this._m;
  70973. };
  70974. /**
  70975. * Inverts the current matrix in place
  70976. * @returns the current inverted matrix
  70977. */
  70978. Matrix.prototype.invert = function () {
  70979. this.invertToRef(this);
  70980. return this;
  70981. };
  70982. /**
  70983. * Sets all the matrix elements to zero
  70984. * @returns the current matrix
  70985. */
  70986. Matrix.prototype.reset = function () {
  70987. 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);
  70988. this._updateIdentityStatus(false);
  70989. return this;
  70990. };
  70991. /**
  70992. * Adds the current matrix with a second one
  70993. * @param other defines the matrix to add
  70994. * @returns a new matrix as the addition of the current matrix and the given one
  70995. */
  70996. Matrix.prototype.add = function (other) {
  70997. var result = new Matrix();
  70998. this.addToRef(other, result);
  70999. return result;
  71000. };
  71001. /**
  71002. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71003. * @param other defines the matrix to add
  71004. * @param result defines the target matrix
  71005. * @returns the current matrix
  71006. */
  71007. Matrix.prototype.addToRef = function (other, result) {
  71008. var m = this._m;
  71009. var resultM = result._m;
  71010. var otherM = other.m;
  71011. for (var index = 0; index < 16; index++) {
  71012. resultM[index] = m[index] + otherM[index];
  71013. }
  71014. result._markAsUpdated();
  71015. return this;
  71016. };
  71017. /**
  71018. * Adds in place the given matrix to the current matrix
  71019. * @param other defines the second operand
  71020. * @returns the current updated matrix
  71021. */
  71022. Matrix.prototype.addToSelf = function (other) {
  71023. var m = this._m;
  71024. var otherM = other.m;
  71025. for (var index = 0; index < 16; index++) {
  71026. m[index] += otherM[index];
  71027. }
  71028. this._markAsUpdated();
  71029. return this;
  71030. };
  71031. /**
  71032. * Sets the given matrix to the current inverted Matrix
  71033. * @param other defines the target matrix
  71034. * @returns the unmodified current matrix
  71035. */
  71036. Matrix.prototype.invertToRef = function (other) {
  71037. if (this._isIdentity === true) {
  71038. Matrix.IdentityToRef(other);
  71039. return this;
  71040. }
  71041. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  71042. var m = this._m;
  71043. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71044. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71045. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71046. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71047. var det_22_33 = m22 * m33 - m32 * m23;
  71048. var det_21_33 = m21 * m33 - m31 * m23;
  71049. var det_21_32 = m21 * m32 - m31 * m22;
  71050. var det_20_33 = m20 * m33 - m30 * m23;
  71051. var det_20_32 = m20 * m32 - m22 * m30;
  71052. var det_20_31 = m20 * m31 - m30 * m21;
  71053. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71054. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71055. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71056. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71057. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71058. if (det === 0) {
  71059. // not invertible
  71060. other.copyFrom(this);
  71061. return this;
  71062. }
  71063. var detInv = 1 / det;
  71064. var det_12_33 = m12 * m33 - m32 * m13;
  71065. var det_11_33 = m11 * m33 - m31 * m13;
  71066. var det_11_32 = m11 * m32 - m31 * m12;
  71067. var det_10_33 = m10 * m33 - m30 * m13;
  71068. var det_10_32 = m10 * m32 - m30 * m12;
  71069. var det_10_31 = m10 * m31 - m30 * m11;
  71070. var det_12_23 = m12 * m23 - m22 * m13;
  71071. var det_11_23 = m11 * m23 - m21 * m13;
  71072. var det_11_22 = m11 * m22 - m21 * m12;
  71073. var det_10_23 = m10 * m23 - m20 * m13;
  71074. var det_10_22 = m10 * m22 - m20 * m12;
  71075. var det_10_21 = m10 * m21 - m20 * m11;
  71076. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  71077. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  71078. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  71079. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  71080. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  71081. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  71082. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  71083. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  71084. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  71085. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  71086. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  71087. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  71088. 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);
  71089. return this;
  71090. };
  71091. /**
  71092. * add a value at the specified position in the current Matrix
  71093. * @param index the index of the value within the matrix. between 0 and 15.
  71094. * @param value the value to be added
  71095. * @returns the current updated matrix
  71096. */
  71097. Matrix.prototype.addAtIndex = function (index, value) {
  71098. this._m[index] += value;
  71099. this._markAsUpdated();
  71100. return this;
  71101. };
  71102. /**
  71103. * mutiply the specified position in the current Matrix by a value
  71104. * @param index the index of the value within the matrix. between 0 and 15.
  71105. * @param value the value to be added
  71106. * @returns the current updated matrix
  71107. */
  71108. Matrix.prototype.multiplyAtIndex = function (index, value) {
  71109. this._m[index] *= value;
  71110. this._markAsUpdated();
  71111. return this;
  71112. };
  71113. /**
  71114. * Inserts the translation vector (using 3 floats) in the current matrix
  71115. * @param x defines the 1st component of the translation
  71116. * @param y defines the 2nd component of the translation
  71117. * @param z defines the 3rd component of the translation
  71118. * @returns the current updated matrix
  71119. */
  71120. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  71121. this._m[12] = x;
  71122. this._m[13] = y;
  71123. this._m[14] = z;
  71124. this._markAsUpdated();
  71125. return this;
  71126. };
  71127. /**
  71128. * Inserts the translation vector in the current matrix
  71129. * @param vector3 defines the translation to insert
  71130. * @returns the current updated matrix
  71131. */
  71132. Matrix.prototype.setTranslation = function (vector3) {
  71133. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  71134. };
  71135. /**
  71136. * Gets the translation value of the current matrix
  71137. * @returns a new Vector3 as the extracted translation from the matrix
  71138. */
  71139. Matrix.prototype.getTranslation = function () {
  71140. return new Vector3(this._m[12], this._m[13], this._m[14]);
  71141. };
  71142. /**
  71143. * Fill a Vector3 with the extracted translation from the matrix
  71144. * @param result defines the Vector3 where to store the translation
  71145. * @returns the current matrix
  71146. */
  71147. Matrix.prototype.getTranslationToRef = function (result) {
  71148. result.x = this._m[12];
  71149. result.y = this._m[13];
  71150. result.z = this._m[14];
  71151. return this;
  71152. };
  71153. /**
  71154. * Remove rotation and scaling part from the matrix
  71155. * @returns the updated matrix
  71156. */
  71157. Matrix.prototype.removeRotationAndScaling = function () {
  71158. var m = this.m;
  71159. 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);
  71160. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  71161. return this;
  71162. };
  71163. /**
  71164. * Multiply two matrices
  71165. * @param other defines the second operand
  71166. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71167. */
  71168. Matrix.prototype.multiply = function (other) {
  71169. var result = new Matrix();
  71170. this.multiplyToRef(other, result);
  71171. return result;
  71172. };
  71173. /**
  71174. * Copy the current matrix from the given one
  71175. * @param other defines the source matrix
  71176. * @returns the current updated matrix
  71177. */
  71178. Matrix.prototype.copyFrom = function (other) {
  71179. other.copyToArray(this._m);
  71180. var o = other;
  71181. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  71182. return this;
  71183. };
  71184. /**
  71185. * Populates the given array from the starting index with the current matrix values
  71186. * @param array defines the target array
  71187. * @param offset defines the offset in the target array where to start storing values
  71188. * @returns the current matrix
  71189. */
  71190. Matrix.prototype.copyToArray = function (array, offset) {
  71191. if (offset === void 0) { offset = 0; }
  71192. for (var index = 0; index < 16; index++) {
  71193. array[offset + index] = this._m[index];
  71194. }
  71195. return this;
  71196. };
  71197. /**
  71198. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71199. * @param other defines the second operand
  71200. * @param result defines the matrix where to store the multiplication
  71201. * @returns the current matrix
  71202. */
  71203. Matrix.prototype.multiplyToRef = function (other, result) {
  71204. if (this._isIdentity) {
  71205. result.copyFrom(other);
  71206. return this;
  71207. }
  71208. if (other._isIdentity) {
  71209. result.copyFrom(this);
  71210. return this;
  71211. }
  71212. this.multiplyToArray(other, result._m, 0);
  71213. result._markAsUpdated();
  71214. return this;
  71215. };
  71216. /**
  71217. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71218. * @param other defines the second operand
  71219. * @param result defines the array where to store the multiplication
  71220. * @param offset defines the offset in the target array where to start storing values
  71221. * @returns the current matrix
  71222. */
  71223. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  71224. var m = this._m;
  71225. var otherM = other.m;
  71226. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  71227. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  71228. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  71229. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  71230. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  71231. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  71232. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  71233. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  71234. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  71235. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  71236. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  71237. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  71238. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  71239. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  71240. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  71241. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  71242. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  71243. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  71244. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  71245. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  71246. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  71247. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  71248. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  71249. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  71250. return this;
  71251. };
  71252. /**
  71253. * Check equality between this matrix and a second one
  71254. * @param value defines the second matrix to compare
  71255. * @returns true is the current matrix and the given one values are strictly equal
  71256. */
  71257. Matrix.prototype.equals = function (value) {
  71258. var other = value;
  71259. if (!other) {
  71260. return false;
  71261. }
  71262. if (this._isIdentity || other._isIdentity) {
  71263. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  71264. return this._isIdentity && other._isIdentity;
  71265. }
  71266. }
  71267. var m = this.m;
  71268. var om = other.m;
  71269. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  71270. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  71271. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  71272. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  71273. };
  71274. /**
  71275. * Clone the current matrix
  71276. * @returns a new matrix from the current matrix
  71277. */
  71278. Matrix.prototype.clone = function () {
  71279. var matrix = new Matrix();
  71280. matrix.copyFrom(this);
  71281. return matrix;
  71282. };
  71283. /**
  71284. * Returns the name of the current matrix class
  71285. * @returns the string "Matrix"
  71286. */
  71287. Matrix.prototype.getClassName = function () {
  71288. return "Matrix";
  71289. };
  71290. /**
  71291. * Gets the hash code of the current matrix
  71292. * @returns the hash code
  71293. */
  71294. Matrix.prototype.getHashCode = function () {
  71295. var hash = this._m[0] || 0;
  71296. for (var i = 1; i < 16; i++) {
  71297. hash = (hash * 397) ^ (this._m[i] || 0);
  71298. }
  71299. return hash;
  71300. };
  71301. /**
  71302. * Decomposes the current Matrix into a translation, rotation and scaling components
  71303. * @param scale defines the scale vector3 given as a reference to update
  71304. * @param rotation defines the rotation quaternion given as a reference to update
  71305. * @param translation defines the translation vector3 given as a reference to update
  71306. * @returns true if operation was successful
  71307. */
  71308. Matrix.prototype.decompose = function (scale, rotation, translation) {
  71309. if (this._isIdentity) {
  71310. if (translation) {
  71311. translation.setAll(0);
  71312. }
  71313. if (scale) {
  71314. scale.setAll(1);
  71315. }
  71316. if (rotation) {
  71317. rotation.copyFromFloats(0, 0, 0, 1);
  71318. }
  71319. return true;
  71320. }
  71321. var m = this._m;
  71322. if (translation) {
  71323. translation.copyFromFloats(m[12], m[13], m[14]);
  71324. }
  71325. scale = scale || MathTmp.Vector3[0];
  71326. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  71327. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  71328. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  71329. if (this.determinant() <= 0) {
  71330. scale.y *= -1;
  71331. }
  71332. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  71333. if (rotation) {
  71334. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  71335. }
  71336. return false;
  71337. }
  71338. if (rotation) {
  71339. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71340. 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]);
  71341. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  71342. }
  71343. return true;
  71344. };
  71345. /**
  71346. * Gets specific row of the matrix
  71347. * @param index defines the number of the row to get
  71348. * @returns the index-th row of the current matrix as a new Vector4
  71349. */
  71350. Matrix.prototype.getRow = function (index) {
  71351. if (index < 0 || index > 3) {
  71352. return null;
  71353. }
  71354. var i = index * 4;
  71355. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  71356. };
  71357. /**
  71358. * Sets the index-th row of the current matrix to the vector4 values
  71359. * @param index defines the number of the row to set
  71360. * @param row defines the target vector4
  71361. * @returns the updated current matrix
  71362. */
  71363. Matrix.prototype.setRow = function (index, row) {
  71364. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  71365. };
  71366. /**
  71367. * Compute the transpose of the matrix
  71368. * @returns the new transposed matrix
  71369. */
  71370. Matrix.prototype.transpose = function () {
  71371. return Matrix.Transpose(this);
  71372. };
  71373. /**
  71374. * Compute the transpose of the matrix and store it in a given matrix
  71375. * @param result defines the target matrix
  71376. * @returns the current matrix
  71377. */
  71378. Matrix.prototype.transposeToRef = function (result) {
  71379. Matrix.TransposeToRef(this, result);
  71380. return this;
  71381. };
  71382. /**
  71383. * Sets the index-th row of the current matrix with the given 4 x float values
  71384. * @param index defines the row index
  71385. * @param x defines the x component to set
  71386. * @param y defines the y component to set
  71387. * @param z defines the z component to set
  71388. * @param w defines the w component to set
  71389. * @returns the updated current matrix
  71390. */
  71391. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  71392. if (index < 0 || index > 3) {
  71393. return this;
  71394. }
  71395. var i = index * 4;
  71396. this._m[i + 0] = x;
  71397. this._m[i + 1] = y;
  71398. this._m[i + 2] = z;
  71399. this._m[i + 3] = w;
  71400. this._markAsUpdated();
  71401. return this;
  71402. };
  71403. /**
  71404. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71405. * @param scale defines the scale factor
  71406. * @returns a new matrix
  71407. */
  71408. Matrix.prototype.scale = function (scale) {
  71409. var result = new Matrix();
  71410. this.scaleToRef(scale, result);
  71411. return result;
  71412. };
  71413. /**
  71414. * Scale the current matrix values by a factor to a given result matrix
  71415. * @param scale defines the scale factor
  71416. * @param result defines the matrix to store the result
  71417. * @returns the current matrix
  71418. */
  71419. Matrix.prototype.scaleToRef = function (scale, result) {
  71420. for (var index = 0; index < 16; index++) {
  71421. result._m[index] = this._m[index] * scale;
  71422. }
  71423. result._markAsUpdated();
  71424. return this;
  71425. };
  71426. /**
  71427. * Scale the current matrix values by a factor and add the result to a given matrix
  71428. * @param scale defines the scale factor
  71429. * @param result defines the Matrix to store the result
  71430. * @returns the current matrix
  71431. */
  71432. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  71433. for (var index = 0; index < 16; index++) {
  71434. result._m[index] += this._m[index] * scale;
  71435. }
  71436. result._markAsUpdated();
  71437. return this;
  71438. };
  71439. /**
  71440. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71441. * @param ref matrix to store the result
  71442. */
  71443. Matrix.prototype.toNormalMatrix = function (ref) {
  71444. var tmp = MathTmp.Matrix[0];
  71445. this.invertToRef(tmp);
  71446. tmp.transposeToRef(ref);
  71447. var m = ref._m;
  71448. 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);
  71449. };
  71450. /**
  71451. * Gets only rotation part of the current matrix
  71452. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71453. */
  71454. Matrix.prototype.getRotationMatrix = function () {
  71455. var result = new Matrix();
  71456. this.getRotationMatrixToRef(result);
  71457. return result;
  71458. };
  71459. /**
  71460. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71461. * @param result defines the target matrix to store data to
  71462. * @returns the current matrix
  71463. */
  71464. Matrix.prototype.getRotationMatrixToRef = function (result) {
  71465. var scale = MathTmp.Vector3[0];
  71466. if (!this.decompose(scale)) {
  71467. Matrix.IdentityToRef(result);
  71468. return this;
  71469. }
  71470. var m = this._m;
  71471. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71472. 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);
  71473. return this;
  71474. };
  71475. /**
  71476. * Toggles model matrix from being right handed to left handed in place and vice versa
  71477. */
  71478. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  71479. var m = this._m;
  71480. m[2] *= -1;
  71481. m[6] *= -1;
  71482. m[8] *= -1;
  71483. m[9] *= -1;
  71484. m[14] *= -1;
  71485. this._markAsUpdated();
  71486. };
  71487. /**
  71488. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71489. */
  71490. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  71491. var m = this._m;
  71492. m[8] *= -1;
  71493. m[9] *= -1;
  71494. m[10] *= -1;
  71495. m[11] *= -1;
  71496. this._markAsUpdated();
  71497. };
  71498. // Statics
  71499. /**
  71500. * Creates a matrix from an array
  71501. * @param array defines the source array
  71502. * @param offset defines an offset in the source array
  71503. * @returns a new Matrix set from the starting index of the given array
  71504. */
  71505. Matrix.FromArray = function (array, offset) {
  71506. if (offset === void 0) { offset = 0; }
  71507. var result = new Matrix();
  71508. Matrix.FromArrayToRef(array, offset, result);
  71509. return result;
  71510. };
  71511. /**
  71512. * Copy the content of an array into a given matrix
  71513. * @param array defines the source array
  71514. * @param offset defines an offset in the source array
  71515. * @param result defines the target matrix
  71516. */
  71517. Matrix.FromArrayToRef = function (array, offset, result) {
  71518. for (var index = 0; index < 16; index++) {
  71519. result._m[index] = array[index + offset];
  71520. }
  71521. result._markAsUpdated();
  71522. };
  71523. /**
  71524. * Stores an array into a matrix after having multiplied each component by a given factor
  71525. * @param array defines the source array
  71526. * @param offset defines the offset in the source array
  71527. * @param scale defines the scaling factor
  71528. * @param result defines the target matrix
  71529. */
  71530. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  71531. for (var index = 0; index < 16; index++) {
  71532. result._m[index] = array[index + offset] * scale;
  71533. }
  71534. result._markAsUpdated();
  71535. };
  71536. Object.defineProperty(Matrix, "IdentityReadOnly", {
  71537. /**
  71538. * Gets an identity matrix that must not be updated
  71539. */
  71540. get: function () {
  71541. return Matrix._identityReadOnly;
  71542. },
  71543. enumerable: true,
  71544. configurable: true
  71545. });
  71546. /**
  71547. * Stores a list of values (16) inside a given matrix
  71548. * @param initialM11 defines 1st value of 1st row
  71549. * @param initialM12 defines 2nd value of 1st row
  71550. * @param initialM13 defines 3rd value of 1st row
  71551. * @param initialM14 defines 4th value of 1st row
  71552. * @param initialM21 defines 1st value of 2nd row
  71553. * @param initialM22 defines 2nd value of 2nd row
  71554. * @param initialM23 defines 3rd value of 2nd row
  71555. * @param initialM24 defines 4th value of 2nd row
  71556. * @param initialM31 defines 1st value of 3rd row
  71557. * @param initialM32 defines 2nd value of 3rd row
  71558. * @param initialM33 defines 3rd value of 3rd row
  71559. * @param initialM34 defines 4th value of 3rd row
  71560. * @param initialM41 defines 1st value of 4th row
  71561. * @param initialM42 defines 2nd value of 4th row
  71562. * @param initialM43 defines 3rd value of 4th row
  71563. * @param initialM44 defines 4th value of 4th row
  71564. * @param result defines the target matrix
  71565. */
  71566. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  71567. var m = result._m;
  71568. m[0] = initialM11;
  71569. m[1] = initialM12;
  71570. m[2] = initialM13;
  71571. m[3] = initialM14;
  71572. m[4] = initialM21;
  71573. m[5] = initialM22;
  71574. m[6] = initialM23;
  71575. m[7] = initialM24;
  71576. m[8] = initialM31;
  71577. m[9] = initialM32;
  71578. m[10] = initialM33;
  71579. m[11] = initialM34;
  71580. m[12] = initialM41;
  71581. m[13] = initialM42;
  71582. m[14] = initialM43;
  71583. m[15] = initialM44;
  71584. result._markAsUpdated();
  71585. };
  71586. /**
  71587. * Creates new matrix from a list of values (16)
  71588. * @param initialM11 defines 1st value of 1st row
  71589. * @param initialM12 defines 2nd value of 1st row
  71590. * @param initialM13 defines 3rd value of 1st row
  71591. * @param initialM14 defines 4th value of 1st row
  71592. * @param initialM21 defines 1st value of 2nd row
  71593. * @param initialM22 defines 2nd value of 2nd row
  71594. * @param initialM23 defines 3rd value of 2nd row
  71595. * @param initialM24 defines 4th value of 2nd row
  71596. * @param initialM31 defines 1st value of 3rd row
  71597. * @param initialM32 defines 2nd value of 3rd row
  71598. * @param initialM33 defines 3rd value of 3rd row
  71599. * @param initialM34 defines 4th value of 3rd row
  71600. * @param initialM41 defines 1st value of 4th row
  71601. * @param initialM42 defines 2nd value of 4th row
  71602. * @param initialM43 defines 3rd value of 4th row
  71603. * @param initialM44 defines 4th value of 4th row
  71604. * @returns the new matrix
  71605. */
  71606. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  71607. var result = new Matrix();
  71608. var m = result._m;
  71609. m[0] = initialM11;
  71610. m[1] = initialM12;
  71611. m[2] = initialM13;
  71612. m[3] = initialM14;
  71613. m[4] = initialM21;
  71614. m[5] = initialM22;
  71615. m[6] = initialM23;
  71616. m[7] = initialM24;
  71617. m[8] = initialM31;
  71618. m[9] = initialM32;
  71619. m[10] = initialM33;
  71620. m[11] = initialM34;
  71621. m[12] = initialM41;
  71622. m[13] = initialM42;
  71623. m[14] = initialM43;
  71624. m[15] = initialM44;
  71625. result._markAsUpdated();
  71626. return result;
  71627. };
  71628. /**
  71629. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71630. * @param scale defines the scale vector3
  71631. * @param rotation defines the rotation quaternion
  71632. * @param translation defines the translation vector3
  71633. * @returns a new matrix
  71634. */
  71635. Matrix.Compose = function (scale, rotation, translation) {
  71636. var result = new Matrix();
  71637. Matrix.ComposeToRef(scale, rotation, translation, result);
  71638. return result;
  71639. };
  71640. /**
  71641. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71642. * @param scale defines the scale vector3
  71643. * @param rotation defines the rotation quaternion
  71644. * @param translation defines the translation vector3
  71645. * @param result defines the target matrix
  71646. */
  71647. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  71648. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  71649. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  71650. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  71651. result.setTranslation(translation);
  71652. };
  71653. /**
  71654. * Creates a new identity matrix
  71655. * @returns a new identity matrix
  71656. */
  71657. Matrix.Identity = function () {
  71658. 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);
  71659. identity._updateIdentityStatus(true);
  71660. return identity;
  71661. };
  71662. /**
  71663. * Creates a new identity matrix and stores the result in a given matrix
  71664. * @param result defines the target matrix
  71665. */
  71666. Matrix.IdentityToRef = function (result) {
  71667. 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);
  71668. result._updateIdentityStatus(true);
  71669. };
  71670. /**
  71671. * Creates a new zero matrix
  71672. * @returns a new zero matrix
  71673. */
  71674. Matrix.Zero = function () {
  71675. 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);
  71676. zero._updateIdentityStatus(false);
  71677. return zero;
  71678. };
  71679. /**
  71680. * Creates a new rotation matrix for "angle" radians around the X axis
  71681. * @param angle defines the angle (in radians) to use
  71682. * @return the new matrix
  71683. */
  71684. Matrix.RotationX = function (angle) {
  71685. var result = new Matrix();
  71686. Matrix.RotationXToRef(angle, result);
  71687. return result;
  71688. };
  71689. /**
  71690. * Creates a new matrix as the invert of a given matrix
  71691. * @param source defines the source matrix
  71692. * @returns the new matrix
  71693. */
  71694. Matrix.Invert = function (source) {
  71695. var result = new Matrix();
  71696. source.invertToRef(result);
  71697. return result;
  71698. };
  71699. /**
  71700. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71701. * @param angle defines the angle (in radians) to use
  71702. * @param result defines the target matrix
  71703. */
  71704. Matrix.RotationXToRef = function (angle, result) {
  71705. var s = Math.sin(angle);
  71706. var c = Math.cos(angle);
  71707. 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);
  71708. result._updateIdentityStatus(c === 1 && s === 0);
  71709. };
  71710. /**
  71711. * Creates a new rotation matrix for "angle" radians around the Y axis
  71712. * @param angle defines the angle (in radians) to use
  71713. * @return the new matrix
  71714. */
  71715. Matrix.RotationY = function (angle) {
  71716. var result = new Matrix();
  71717. Matrix.RotationYToRef(angle, result);
  71718. return result;
  71719. };
  71720. /**
  71721. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71722. * @param angle defines the angle (in radians) to use
  71723. * @param result defines the target matrix
  71724. */
  71725. Matrix.RotationYToRef = function (angle, result) {
  71726. var s = Math.sin(angle);
  71727. var c = Math.cos(angle);
  71728. 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);
  71729. result._updateIdentityStatus(c === 1 && s === 0);
  71730. };
  71731. /**
  71732. * Creates a new rotation matrix for "angle" radians around the Z axis
  71733. * @param angle defines the angle (in radians) to use
  71734. * @return the new matrix
  71735. */
  71736. Matrix.RotationZ = function (angle) {
  71737. var result = new Matrix();
  71738. Matrix.RotationZToRef(angle, result);
  71739. return result;
  71740. };
  71741. /**
  71742. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71743. * @param angle defines the angle (in radians) to use
  71744. * @param result defines the target matrix
  71745. */
  71746. Matrix.RotationZToRef = function (angle, result) {
  71747. var s = Math.sin(angle);
  71748. var c = Math.cos(angle);
  71749. 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);
  71750. result._updateIdentityStatus(c === 1 && s === 0);
  71751. };
  71752. /**
  71753. * Creates a new rotation matrix for "angle" radians around the given axis
  71754. * @param axis defines the axis to use
  71755. * @param angle defines the angle (in radians) to use
  71756. * @return the new matrix
  71757. */
  71758. Matrix.RotationAxis = function (axis, angle) {
  71759. var result = new Matrix();
  71760. Matrix.RotationAxisToRef(axis, angle, result);
  71761. return result;
  71762. };
  71763. /**
  71764. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71765. * @param axis defines the axis to use
  71766. * @param angle defines the angle (in radians) to use
  71767. * @param result defines the target matrix
  71768. */
  71769. Matrix.RotationAxisToRef = function (axis, angle, result) {
  71770. var s = Math.sin(-angle);
  71771. var c = Math.cos(-angle);
  71772. var c1 = 1 - c;
  71773. axis.normalize();
  71774. var m = result._m;
  71775. m[0] = (axis.x * axis.x) * c1 + c;
  71776. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  71777. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  71778. m[3] = 0.0;
  71779. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  71780. m[5] = (axis.y * axis.y) * c1 + c;
  71781. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  71782. m[7] = 0.0;
  71783. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  71784. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  71785. m[10] = (axis.z * axis.z) * c1 + c;
  71786. m[11] = 0.0;
  71787. m[12] = 0.0;
  71788. m[13] = 0.0;
  71789. m[14] = 0.0;
  71790. m[15] = 1.0;
  71791. result._markAsUpdated();
  71792. };
  71793. /**
  71794. * Creates a rotation matrix
  71795. * @param yaw defines the yaw angle in radians (Y axis)
  71796. * @param pitch defines the pitch angle in radians (X axis)
  71797. * @param roll defines the roll angle in radians (X axis)
  71798. * @returns the new rotation matrix
  71799. */
  71800. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71801. var result = new Matrix();
  71802. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  71803. return result;
  71804. };
  71805. /**
  71806. * Creates a rotation matrix and stores it in a given matrix
  71807. * @param yaw defines the yaw angle in radians (Y axis)
  71808. * @param pitch defines the pitch angle in radians (X axis)
  71809. * @param roll defines the roll angle in radians (X axis)
  71810. * @param result defines the target matrix
  71811. */
  71812. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71813. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  71814. MathTmp.Quaternion[0].toRotationMatrix(result);
  71815. };
  71816. /**
  71817. * Creates a scaling matrix
  71818. * @param x defines the scale factor on X axis
  71819. * @param y defines the scale factor on Y axis
  71820. * @param z defines the scale factor on Z axis
  71821. * @returns the new matrix
  71822. */
  71823. Matrix.Scaling = function (x, y, z) {
  71824. var result = new Matrix();
  71825. Matrix.ScalingToRef(x, y, z, result);
  71826. return result;
  71827. };
  71828. /**
  71829. * Creates a scaling matrix and stores it in a given matrix
  71830. * @param x defines the scale factor on X axis
  71831. * @param y defines the scale factor on Y axis
  71832. * @param z defines the scale factor on Z axis
  71833. * @param result defines the target matrix
  71834. */
  71835. Matrix.ScalingToRef = function (x, y, z, result) {
  71836. 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);
  71837. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  71838. };
  71839. /**
  71840. * Creates a translation matrix
  71841. * @param x defines the translation on X axis
  71842. * @param y defines the translation on Y axis
  71843. * @param z defines the translationon Z axis
  71844. * @returns the new matrix
  71845. */
  71846. Matrix.Translation = function (x, y, z) {
  71847. var result = new Matrix();
  71848. Matrix.TranslationToRef(x, y, z, result);
  71849. return result;
  71850. };
  71851. /**
  71852. * Creates a translation matrix and stores it in a given matrix
  71853. * @param x defines the translation on X axis
  71854. * @param y defines the translation on Y axis
  71855. * @param z defines the translationon Z axis
  71856. * @param result defines the target matrix
  71857. */
  71858. Matrix.TranslationToRef = function (x, y, z, result) {
  71859. 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);
  71860. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  71861. };
  71862. /**
  71863. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71864. * @param startValue defines the start value
  71865. * @param endValue defines the end value
  71866. * @param gradient defines the gradient factor
  71867. * @returns the new matrix
  71868. */
  71869. Matrix.Lerp = function (startValue, endValue, gradient) {
  71870. var result = new Matrix();
  71871. Matrix.LerpToRef(startValue, endValue, gradient, result);
  71872. return result;
  71873. };
  71874. /**
  71875. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71876. * @param startValue defines the start value
  71877. * @param endValue defines the end value
  71878. * @param gradient defines the gradient factor
  71879. * @param result defines the Matrix object where to store data
  71880. */
  71881. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  71882. var resultM = result._m;
  71883. var startM = startValue.m;
  71884. var endM = endValue.m;
  71885. for (var index = 0; index < 16; index++) {
  71886. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  71887. }
  71888. result._markAsUpdated();
  71889. };
  71890. /**
  71891. * Builds a new matrix whose values are computed by:
  71892. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71893. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71894. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71895. * @param startValue defines the first matrix
  71896. * @param endValue defines the second matrix
  71897. * @param gradient defines the gradient between the two matrices
  71898. * @returns the new matrix
  71899. */
  71900. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  71901. var result = new Matrix();
  71902. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  71903. return result;
  71904. };
  71905. /**
  71906. * Update a matrix to values which are computed by:
  71907. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71908. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71909. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71910. * @param startValue defines the first matrix
  71911. * @param endValue defines the second matrix
  71912. * @param gradient defines the gradient between the two matrices
  71913. * @param result defines the target matrix
  71914. */
  71915. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  71916. var startScale = MathTmp.Vector3[0];
  71917. var startRotation = MathTmp.Quaternion[0];
  71918. var startTranslation = MathTmp.Vector3[1];
  71919. startValue.decompose(startScale, startRotation, startTranslation);
  71920. var endScale = MathTmp.Vector3[2];
  71921. var endRotation = MathTmp.Quaternion[1];
  71922. var endTranslation = MathTmp.Vector3[3];
  71923. endValue.decompose(endScale, endRotation, endTranslation);
  71924. var resultScale = MathTmp.Vector3[4];
  71925. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  71926. var resultRotation = MathTmp.Quaternion[2];
  71927. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  71928. var resultTranslation = MathTmp.Vector3[5];
  71929. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  71930. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  71931. };
  71932. /**
  71933. * 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"
  71934. * This function works in left handed mode
  71935. * @param eye defines the final position of the entity
  71936. * @param target defines where the entity should look at
  71937. * @param up defines the up vector for the entity
  71938. * @returns the new matrix
  71939. */
  71940. Matrix.LookAtLH = function (eye, target, up) {
  71941. var result = new Matrix();
  71942. Matrix.LookAtLHToRef(eye, target, up, result);
  71943. return result;
  71944. };
  71945. /**
  71946. * 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".
  71947. * This function works in left handed mode
  71948. * @param eye defines the final position of the entity
  71949. * @param target defines where the entity should look at
  71950. * @param up defines the up vector for the entity
  71951. * @param result defines the target matrix
  71952. */
  71953. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  71954. var xAxis = MathTmp.Vector3[0];
  71955. var yAxis = MathTmp.Vector3[1];
  71956. var zAxis = MathTmp.Vector3[2];
  71957. // Z axis
  71958. target.subtractToRef(eye, zAxis);
  71959. zAxis.normalize();
  71960. // X axis
  71961. Vector3.CrossToRef(up, zAxis, xAxis);
  71962. var xSquareLength = xAxis.lengthSquared();
  71963. if (xSquareLength === 0) {
  71964. xAxis.x = 1.0;
  71965. }
  71966. else {
  71967. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  71968. }
  71969. // Y axis
  71970. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  71971. yAxis.normalize();
  71972. // Eye angles
  71973. var ex = -Vector3.Dot(xAxis, eye);
  71974. var ey = -Vector3.Dot(yAxis, eye);
  71975. var ez = -Vector3.Dot(zAxis, eye);
  71976. 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);
  71977. };
  71978. /**
  71979. * 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"
  71980. * This function works in right handed mode
  71981. * @param eye defines the final position of the entity
  71982. * @param target defines where the entity should look at
  71983. * @param up defines the up vector for the entity
  71984. * @returns the new matrix
  71985. */
  71986. Matrix.LookAtRH = function (eye, target, up) {
  71987. var result = new Matrix();
  71988. Matrix.LookAtRHToRef(eye, target, up, result);
  71989. return result;
  71990. };
  71991. /**
  71992. * 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".
  71993. * This function works in right handed mode
  71994. * @param eye defines the final position of the entity
  71995. * @param target defines where the entity should look at
  71996. * @param up defines the up vector for the entity
  71997. * @param result defines the target matrix
  71998. */
  71999. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  72000. var xAxis = MathTmp.Vector3[0];
  72001. var yAxis = MathTmp.Vector3[1];
  72002. var zAxis = MathTmp.Vector3[2];
  72003. // Z axis
  72004. eye.subtractToRef(target, zAxis);
  72005. zAxis.normalize();
  72006. // X axis
  72007. Vector3.CrossToRef(up, zAxis, xAxis);
  72008. var xSquareLength = xAxis.lengthSquared();
  72009. if (xSquareLength === 0) {
  72010. xAxis.x = 1.0;
  72011. }
  72012. else {
  72013. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72014. }
  72015. // Y axis
  72016. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72017. yAxis.normalize();
  72018. // Eye angles
  72019. var ex = -Vector3.Dot(xAxis, eye);
  72020. var ey = -Vector3.Dot(yAxis, eye);
  72021. var ez = -Vector3.Dot(zAxis, eye);
  72022. 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);
  72023. };
  72024. /**
  72025. * Create a left-handed orthographic projection matrix
  72026. * @param width defines the viewport width
  72027. * @param height defines the viewport height
  72028. * @param znear defines the near clip plane
  72029. * @param zfar defines the far clip plane
  72030. * @returns a new matrix as a left-handed orthographic projection matrix
  72031. */
  72032. Matrix.OrthoLH = function (width, height, znear, zfar) {
  72033. var matrix = new Matrix();
  72034. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  72035. return matrix;
  72036. };
  72037. /**
  72038. * Store a left-handed orthographic projection to a given matrix
  72039. * @param width defines the viewport width
  72040. * @param height defines the viewport height
  72041. * @param znear defines the near clip plane
  72042. * @param zfar defines the far clip plane
  72043. * @param result defines the target matrix
  72044. */
  72045. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  72046. var n = znear;
  72047. var f = zfar;
  72048. var a = 2.0 / width;
  72049. var b = 2.0 / height;
  72050. var c = 2.0 / (f - n);
  72051. var d = -(f + n) / (f - n);
  72052. 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);
  72053. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  72054. };
  72055. /**
  72056. * Create a left-handed orthographic projection matrix
  72057. * @param left defines the viewport left coordinate
  72058. * @param right defines the viewport right coordinate
  72059. * @param bottom defines the viewport bottom coordinate
  72060. * @param top defines the viewport top coordinate
  72061. * @param znear defines the near clip plane
  72062. * @param zfar defines the far clip plane
  72063. * @returns a new matrix as a left-handed orthographic projection matrix
  72064. */
  72065. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  72066. var matrix = new Matrix();
  72067. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  72068. return matrix;
  72069. };
  72070. /**
  72071. * Stores a left-handed orthographic projection into a given matrix
  72072. * @param left defines the viewport left coordinate
  72073. * @param right defines the viewport right coordinate
  72074. * @param bottom defines the viewport bottom coordinate
  72075. * @param top defines the viewport top coordinate
  72076. * @param znear defines the near clip plane
  72077. * @param zfar defines the far clip plane
  72078. * @param result defines the target matrix
  72079. */
  72080. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72081. var n = znear;
  72082. var f = zfar;
  72083. var a = 2.0 / (right - left);
  72084. var b = 2.0 / (top - bottom);
  72085. var c = 2.0 / (f - n);
  72086. var d = -(f + n) / (f - n);
  72087. var i0 = (left + right) / (left - right);
  72088. var i1 = (top + bottom) / (bottom - top);
  72089. 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);
  72090. result._markAsUpdated();
  72091. };
  72092. /**
  72093. * Creates a right-handed orthographic projection matrix
  72094. * @param left defines the viewport left coordinate
  72095. * @param right defines the viewport right coordinate
  72096. * @param bottom defines the viewport bottom coordinate
  72097. * @param top defines the viewport top coordinate
  72098. * @param znear defines the near clip plane
  72099. * @param zfar defines the far clip plane
  72100. * @returns a new matrix as a right-handed orthographic projection matrix
  72101. */
  72102. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  72103. var matrix = new Matrix();
  72104. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  72105. return matrix;
  72106. };
  72107. /**
  72108. * Stores a right-handed orthographic projection into a given matrix
  72109. * @param left defines the viewport left coordinate
  72110. * @param right defines the viewport right coordinate
  72111. * @param bottom defines the viewport bottom coordinate
  72112. * @param top defines the viewport top coordinate
  72113. * @param znear defines the near clip plane
  72114. * @param zfar defines the far clip plane
  72115. * @param result defines the target matrix
  72116. */
  72117. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72118. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  72119. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  72120. };
  72121. /**
  72122. * Creates a left-handed perspective projection matrix
  72123. * @param width defines the viewport width
  72124. * @param height defines the viewport height
  72125. * @param znear defines the near clip plane
  72126. * @param zfar defines the far clip plane
  72127. * @returns a new matrix as a left-handed perspective projection matrix
  72128. */
  72129. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  72130. var matrix = new Matrix();
  72131. var n = znear;
  72132. var f = zfar;
  72133. var a = 2.0 * n / width;
  72134. var b = 2.0 * n / height;
  72135. var c = (f + n) / (f - n);
  72136. var d = -2.0 * f * n / (f - n);
  72137. 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);
  72138. matrix._updateIdentityStatus(false);
  72139. return matrix;
  72140. };
  72141. /**
  72142. * Creates a left-handed perspective projection matrix
  72143. * @param fov defines the horizontal field of view
  72144. * @param aspect defines the aspect ratio
  72145. * @param znear defines the near clip plane
  72146. * @param zfar defines the far clip plane
  72147. * @returns a new matrix as a left-handed perspective projection matrix
  72148. */
  72149. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  72150. var matrix = new Matrix();
  72151. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  72152. return matrix;
  72153. };
  72154. /**
  72155. * Stores a left-handed perspective projection into a given matrix
  72156. * @param fov defines the horizontal field of view
  72157. * @param aspect defines the aspect ratio
  72158. * @param znear defines the near clip plane
  72159. * @param zfar defines the far clip plane
  72160. * @param result defines the target matrix
  72161. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72162. */
  72163. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72164. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72165. var n = znear;
  72166. var f = zfar;
  72167. var t = 1.0 / (Math.tan(fov * 0.5));
  72168. var a = isVerticalFovFixed ? (t / aspect) : t;
  72169. var b = isVerticalFovFixed ? t : (t * aspect);
  72170. var c = (f + n) / (f - n);
  72171. var d = -2.0 * f * n / (f - n);
  72172. 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);
  72173. result._updateIdentityStatus(false);
  72174. };
  72175. /**
  72176. * Creates a right-handed perspective projection matrix
  72177. * @param fov defines the horizontal field of view
  72178. * @param aspect defines the aspect ratio
  72179. * @param znear defines the near clip plane
  72180. * @param zfar defines the far clip plane
  72181. * @returns a new matrix as a right-handed perspective projection matrix
  72182. */
  72183. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  72184. var matrix = new Matrix();
  72185. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  72186. return matrix;
  72187. };
  72188. /**
  72189. * Stores a right-handed perspective projection into a given matrix
  72190. * @param fov defines the horizontal field of view
  72191. * @param aspect defines the aspect ratio
  72192. * @param znear defines the near clip plane
  72193. * @param zfar defines the far clip plane
  72194. * @param result defines the target matrix
  72195. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72196. */
  72197. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72198. //alternatively this could be expressed as:
  72199. // m = PerspectiveFovLHToRef
  72200. // m[10] *= -1.0;
  72201. // m[11] *= -1.0;
  72202. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72203. var n = znear;
  72204. var f = zfar;
  72205. var t = 1.0 / (Math.tan(fov * 0.5));
  72206. var a = isVerticalFovFixed ? (t / aspect) : t;
  72207. var b = isVerticalFovFixed ? t : (t * aspect);
  72208. var c = -(f + n) / (f - n);
  72209. var d = -2 * f * n / (f - n);
  72210. 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);
  72211. result._updateIdentityStatus(false);
  72212. };
  72213. /**
  72214. * Stores a perspective projection for WebVR info a given matrix
  72215. * @param fov defines the field of view
  72216. * @param znear defines the near clip plane
  72217. * @param zfar defines the far clip plane
  72218. * @param result defines the target matrix
  72219. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72220. */
  72221. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  72222. if (rightHanded === void 0) { rightHanded = false; }
  72223. var rightHandedFactor = rightHanded ? -1 : 1;
  72224. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  72225. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  72226. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  72227. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  72228. var xScale = 2.0 / (leftTan + rightTan);
  72229. var yScale = 2.0 / (upTan + downTan);
  72230. var m = result._m;
  72231. m[0] = xScale;
  72232. m[1] = m[2] = m[3] = m[4] = 0.0;
  72233. m[5] = yScale;
  72234. m[6] = m[7] = 0.0;
  72235. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  72236. m[9] = -((upTan - downTan) * yScale * 0.5);
  72237. m[10] = -zfar / (znear - zfar);
  72238. m[11] = 1.0 * rightHandedFactor;
  72239. m[12] = m[13] = m[15] = 0.0;
  72240. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  72241. result._markAsUpdated();
  72242. };
  72243. /**
  72244. * Computes a complete transformation matrix
  72245. * @param viewport defines the viewport to use
  72246. * @param world defines the world matrix
  72247. * @param view defines the view matrix
  72248. * @param projection defines the projection matrix
  72249. * @param zmin defines the near clip plane
  72250. * @param zmax defines the far clip plane
  72251. * @returns the transformation matrix
  72252. */
  72253. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  72254. var cw = viewport.width;
  72255. var ch = viewport.height;
  72256. var cx = viewport.x;
  72257. var cy = viewport.y;
  72258. 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);
  72259. var matrix = MathTmp.Matrix[0];
  72260. world.multiplyToRef(view, matrix);
  72261. matrix.multiplyToRef(projection, matrix);
  72262. return matrix.multiply(viewportMatrix);
  72263. };
  72264. /**
  72265. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72266. * @param matrix defines the matrix to use
  72267. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72268. */
  72269. Matrix.GetAsMatrix2x2 = function (matrix) {
  72270. var m = matrix.m;
  72271. return new Float32Array([m[0], m[1], m[4], m[5]]);
  72272. };
  72273. /**
  72274. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72275. * @param matrix defines the matrix to use
  72276. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72277. */
  72278. Matrix.GetAsMatrix3x3 = function (matrix) {
  72279. var m = matrix.m;
  72280. return new Float32Array([
  72281. m[0], m[1], m[2],
  72282. m[4], m[5], m[6],
  72283. m[8], m[9], m[10]
  72284. ]);
  72285. };
  72286. /**
  72287. * Compute the transpose of a given matrix
  72288. * @param matrix defines the matrix to transpose
  72289. * @returns the new matrix
  72290. */
  72291. Matrix.Transpose = function (matrix) {
  72292. var result = new Matrix();
  72293. Matrix.TransposeToRef(matrix, result);
  72294. return result;
  72295. };
  72296. /**
  72297. * Compute the transpose of a matrix and store it in a target matrix
  72298. * @param matrix defines the matrix to transpose
  72299. * @param result defines the target matrix
  72300. */
  72301. Matrix.TransposeToRef = function (matrix, result) {
  72302. var rm = result._m;
  72303. var mm = matrix.m;
  72304. rm[0] = mm[0];
  72305. rm[1] = mm[4];
  72306. rm[2] = mm[8];
  72307. rm[3] = mm[12];
  72308. rm[4] = mm[1];
  72309. rm[5] = mm[5];
  72310. rm[6] = mm[9];
  72311. rm[7] = mm[13];
  72312. rm[8] = mm[2];
  72313. rm[9] = mm[6];
  72314. rm[10] = mm[10];
  72315. rm[11] = mm[14];
  72316. rm[12] = mm[3];
  72317. rm[13] = mm[7];
  72318. rm[14] = mm[11];
  72319. rm[15] = mm[15];
  72320. // identity-ness does not change when transposing
  72321. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  72322. };
  72323. /**
  72324. * Computes a reflection matrix from a plane
  72325. * @param plane defines the reflection plane
  72326. * @returns a new matrix
  72327. */
  72328. Matrix.Reflection = function (plane) {
  72329. var matrix = new Matrix();
  72330. Matrix.ReflectionToRef(plane, matrix);
  72331. return matrix;
  72332. };
  72333. /**
  72334. * Computes a reflection matrix from a plane
  72335. * @param plane defines the reflection plane
  72336. * @param result defines the target matrix
  72337. */
  72338. Matrix.ReflectionToRef = function (plane, result) {
  72339. plane.normalize();
  72340. var x = plane.normal.x;
  72341. var y = plane.normal.y;
  72342. var z = plane.normal.z;
  72343. var temp = -2 * x;
  72344. var temp2 = -2 * y;
  72345. var temp3 = -2 * z;
  72346. 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);
  72347. };
  72348. /**
  72349. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72350. * @param xaxis defines the value of the 1st axis
  72351. * @param yaxis defines the value of the 2nd axis
  72352. * @param zaxis defines the value of the 3rd axis
  72353. * @param result defines the target matrix
  72354. */
  72355. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  72356. 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);
  72357. };
  72358. /**
  72359. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72360. * @param quat defines the quaternion to use
  72361. * @param result defines the target matrix
  72362. */
  72363. Matrix.FromQuaternionToRef = function (quat, result) {
  72364. var xx = quat.x * quat.x;
  72365. var yy = quat.y * quat.y;
  72366. var zz = quat.z * quat.z;
  72367. var xy = quat.x * quat.y;
  72368. var zw = quat.z * quat.w;
  72369. var zx = quat.z * quat.x;
  72370. var yw = quat.y * quat.w;
  72371. var yz = quat.y * quat.z;
  72372. var xw = quat.x * quat.w;
  72373. result._m[0] = 1.0 - (2.0 * (yy + zz));
  72374. result._m[1] = 2.0 * (xy + zw);
  72375. result._m[2] = 2.0 * (zx - yw);
  72376. result._m[3] = 0.0;
  72377. result._m[4] = 2.0 * (xy - zw);
  72378. result._m[5] = 1.0 - (2.0 * (zz + xx));
  72379. result._m[6] = 2.0 * (yz + xw);
  72380. result._m[7] = 0.0;
  72381. result._m[8] = 2.0 * (zx + yw);
  72382. result._m[9] = 2.0 * (yz - xw);
  72383. result._m[10] = 1.0 - (2.0 * (yy + xx));
  72384. result._m[11] = 0.0;
  72385. result._m[12] = 0.0;
  72386. result._m[13] = 0.0;
  72387. result._m[14] = 0.0;
  72388. result._m[15] = 1.0;
  72389. result._markAsUpdated();
  72390. };
  72391. Matrix._updateFlagSeed = 0;
  72392. Matrix._identityReadOnly = Matrix.Identity();
  72393. return Matrix;
  72394. }());
  72395. /**
  72396. * Represens a plane by the equation ax + by + cz + d = 0
  72397. */
  72398. var Plane = /** @class */ (function () {
  72399. /**
  72400. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72401. * @param a a component of the plane
  72402. * @param b b component of the plane
  72403. * @param c c component of the plane
  72404. * @param d d component of the plane
  72405. */
  72406. function Plane(a, b, c, d) {
  72407. this.normal = new Vector3(a, b, c);
  72408. this.d = d;
  72409. }
  72410. /**
  72411. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72412. */
  72413. Plane.prototype.asArray = function () {
  72414. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  72415. };
  72416. // Methods
  72417. /**
  72418. * @returns a new plane copied from the current Plane.
  72419. */
  72420. Plane.prototype.clone = function () {
  72421. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  72422. };
  72423. /**
  72424. * @returns the string "Plane".
  72425. */
  72426. Plane.prototype.getClassName = function () {
  72427. return "Plane";
  72428. };
  72429. /**
  72430. * @returns the Plane hash code.
  72431. */
  72432. Plane.prototype.getHashCode = function () {
  72433. var hash = this.normal.getHashCode();
  72434. hash = (hash * 397) ^ (this.d || 0);
  72435. return hash;
  72436. };
  72437. /**
  72438. * Normalize the current Plane in place.
  72439. * @returns the updated Plane.
  72440. */
  72441. Plane.prototype.normalize = function () {
  72442. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  72443. var magnitude = 0.0;
  72444. if (norm !== 0) {
  72445. magnitude = 1.0 / norm;
  72446. }
  72447. this.normal.x *= magnitude;
  72448. this.normal.y *= magnitude;
  72449. this.normal.z *= magnitude;
  72450. this.d *= magnitude;
  72451. return this;
  72452. };
  72453. /**
  72454. * Applies a transformation the plane and returns the result
  72455. * @param transformation the transformation matrix to be applied to the plane
  72456. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72457. */
  72458. Plane.prototype.transform = function (transformation) {
  72459. var transposedMatrix = MathTmp.Matrix[0];
  72460. Matrix.TransposeToRef(transformation, transposedMatrix);
  72461. var m = transposedMatrix.m;
  72462. var x = this.normal.x;
  72463. var y = this.normal.y;
  72464. var z = this.normal.z;
  72465. var d = this.d;
  72466. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  72467. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  72468. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  72469. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  72470. return new Plane(normalX, normalY, normalZ, finalD);
  72471. };
  72472. /**
  72473. * Calcualtte the dot product between the point and the plane normal
  72474. * @param point point to calculate the dot product with
  72475. * @returns the dot product (float) of the point coordinates and the plane normal.
  72476. */
  72477. Plane.prototype.dotCoordinate = function (point) {
  72478. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  72479. };
  72480. /**
  72481. * Updates the current Plane from the plane defined by the three given points.
  72482. * @param point1 one of the points used to contruct the plane
  72483. * @param point2 one of the points used to contruct the plane
  72484. * @param point3 one of the points used to contruct the plane
  72485. * @returns the updated Plane.
  72486. */
  72487. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  72488. var x1 = point2.x - point1.x;
  72489. var y1 = point2.y - point1.y;
  72490. var z1 = point2.z - point1.z;
  72491. var x2 = point3.x - point1.x;
  72492. var y2 = point3.y - point1.y;
  72493. var z2 = point3.z - point1.z;
  72494. var yz = (y1 * z2) - (z1 * y2);
  72495. var xz = (z1 * x2) - (x1 * z2);
  72496. var xy = (x1 * y2) - (y1 * x2);
  72497. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  72498. var invPyth;
  72499. if (pyth !== 0) {
  72500. invPyth = 1.0 / pyth;
  72501. }
  72502. else {
  72503. invPyth = 0.0;
  72504. }
  72505. this.normal.x = yz * invPyth;
  72506. this.normal.y = xz * invPyth;
  72507. this.normal.z = xy * invPyth;
  72508. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  72509. return this;
  72510. };
  72511. /**
  72512. * Checks if the plane is facing a given direction
  72513. * @param direction the direction to check if the plane is facing
  72514. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72515. * @returns True is the vector "direction" is the same side than the plane normal.
  72516. */
  72517. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  72518. var dot = Vector3.Dot(this.normal, direction);
  72519. return (dot <= epsilon);
  72520. };
  72521. /**
  72522. * Calculates the distance to a point
  72523. * @param point point to calculate distance to
  72524. * @returns the signed distance (float) from the given point to the Plane.
  72525. */
  72526. Plane.prototype.signedDistanceTo = function (point) {
  72527. return Vector3.Dot(point, this.normal) + this.d;
  72528. };
  72529. // Statics
  72530. /**
  72531. * Creates a plane from an array
  72532. * @param array the array to create a plane from
  72533. * @returns a new Plane from the given array.
  72534. */
  72535. Plane.FromArray = function (array) {
  72536. return new Plane(array[0], array[1], array[2], array[3]);
  72537. };
  72538. /**
  72539. * Creates a plane from three points
  72540. * @param point1 point used to create the plane
  72541. * @param point2 point used to create the plane
  72542. * @param point3 point used to create the plane
  72543. * @returns a new Plane defined by the three given points.
  72544. */
  72545. Plane.FromPoints = function (point1, point2, point3) {
  72546. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72547. result.copyFromPoints(point1, point2, point3);
  72548. return result;
  72549. };
  72550. /**
  72551. * Creates a plane from an origin point and a normal
  72552. * @param origin origin of the plane to be constructed
  72553. * @param normal normal of the plane to be constructed
  72554. * @returns a new Plane the normal vector to this plane at the given origin point.
  72555. * Note : the vector "normal" is updated because normalized.
  72556. */
  72557. Plane.FromPositionAndNormal = function (origin, normal) {
  72558. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72559. normal.normalize();
  72560. result.normal = normal;
  72561. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72562. return result;
  72563. };
  72564. /**
  72565. * Calculates the distance from a plane and a point
  72566. * @param origin origin of the plane to be constructed
  72567. * @param normal normal of the plane to be constructed
  72568. * @param point point to calculate distance to
  72569. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72570. */
  72571. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  72572. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72573. return Vector3.Dot(point, normal) + d;
  72574. };
  72575. return Plane;
  72576. }());
  72577. /**
  72578. * Class used to represent a viewport on screen
  72579. */
  72580. var Viewport = /** @class */ (function () {
  72581. /**
  72582. * Creates a Viewport object located at (x, y) and sized (width, height)
  72583. * @param x defines viewport left coordinate
  72584. * @param y defines viewport top coordinate
  72585. * @param width defines the viewport width
  72586. * @param height defines the viewport height
  72587. */
  72588. function Viewport(
  72589. /** viewport left coordinate */
  72590. x,
  72591. /** viewport top coordinate */
  72592. y,
  72593. /**viewport width */
  72594. width,
  72595. /** viewport height */
  72596. height) {
  72597. this.x = x;
  72598. this.y = y;
  72599. this.width = width;
  72600. this.height = height;
  72601. }
  72602. /**
  72603. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72604. * @param renderWidth defines the rendering width
  72605. * @param renderHeight defines the rendering height
  72606. * @returns a new Viewport
  72607. */
  72608. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  72609. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  72610. };
  72611. /**
  72612. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72613. * @param renderWidth defines the rendering width
  72614. * @param renderHeight defines the rendering height
  72615. * @param ref defines the target viewport
  72616. * @returns the current viewport
  72617. */
  72618. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  72619. ref.x = this.x * renderWidth;
  72620. ref.y = this.y * renderHeight;
  72621. ref.width = this.width * renderWidth;
  72622. ref.height = this.height * renderHeight;
  72623. return this;
  72624. };
  72625. /**
  72626. * Returns a new Viewport copied from the current one
  72627. * @returns a new Viewport
  72628. */
  72629. Viewport.prototype.clone = function () {
  72630. return new Viewport(this.x, this.y, this.width, this.height);
  72631. };
  72632. return Viewport;
  72633. }());
  72634. /**
  72635. * Reprasents a camera frustum
  72636. */
  72637. var Frustum = /** @class */ (function () {
  72638. function Frustum() {
  72639. }
  72640. /**
  72641. * Gets the planes representing the frustum
  72642. * @param transform matrix to be applied to the returned planes
  72643. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  72644. */
  72645. Frustum.GetPlanes = function (transform) {
  72646. var frustumPlanes = [];
  72647. for (var index = 0; index < 6; index++) {
  72648. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  72649. }
  72650. Frustum.GetPlanesToRef(transform, frustumPlanes);
  72651. return frustumPlanes;
  72652. };
  72653. /**
  72654. * Gets the near frustum plane transformed by the transform matrix
  72655. * @param transform transformation matrix to be applied to the resulting frustum plane
  72656. * @param frustumPlane the resuling frustum plane
  72657. */
  72658. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  72659. var m = transform.m;
  72660. frustumPlane.normal.x = m[3] + m[2];
  72661. frustumPlane.normal.y = m[7] + m[6];
  72662. frustumPlane.normal.z = m[11] + m[10];
  72663. frustumPlane.d = m[15] + m[14];
  72664. frustumPlane.normalize();
  72665. };
  72666. /**
  72667. * Gets the far frustum plane transformed by the transform matrix
  72668. * @param transform transformation matrix to be applied to the resulting frustum plane
  72669. * @param frustumPlane the resuling frustum plane
  72670. */
  72671. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  72672. var m = transform.m;
  72673. frustumPlane.normal.x = m[3] - m[2];
  72674. frustumPlane.normal.y = m[7] - m[6];
  72675. frustumPlane.normal.z = m[11] - m[10];
  72676. frustumPlane.d = m[15] - m[14];
  72677. frustumPlane.normalize();
  72678. };
  72679. /**
  72680. * Gets the left frustum plane transformed by the transform matrix
  72681. * @param transform transformation matrix to be applied to the resulting frustum plane
  72682. * @param frustumPlane the resuling frustum plane
  72683. */
  72684. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  72685. var m = transform.m;
  72686. frustumPlane.normal.x = m[3] + m[0];
  72687. frustumPlane.normal.y = m[7] + m[4];
  72688. frustumPlane.normal.z = m[11] + m[8];
  72689. frustumPlane.d = m[15] + m[12];
  72690. frustumPlane.normalize();
  72691. };
  72692. /**
  72693. * Gets the right frustum plane transformed by the transform matrix
  72694. * @param transform transformation matrix to be applied to the resulting frustum plane
  72695. * @param frustumPlane the resuling frustum plane
  72696. */
  72697. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  72698. var m = transform.m;
  72699. frustumPlane.normal.x = m[3] - m[0];
  72700. frustumPlane.normal.y = m[7] - m[4];
  72701. frustumPlane.normal.z = m[11] - m[8];
  72702. frustumPlane.d = m[15] - m[12];
  72703. frustumPlane.normalize();
  72704. };
  72705. /**
  72706. * Gets the top frustum plane transformed by the transform matrix
  72707. * @param transform transformation matrix to be applied to the resulting frustum plane
  72708. * @param frustumPlane the resuling frustum plane
  72709. */
  72710. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  72711. var m = transform.m;
  72712. frustumPlane.normal.x = m[3] - m[1];
  72713. frustumPlane.normal.y = m[7] - m[5];
  72714. frustumPlane.normal.z = m[11] - m[9];
  72715. frustumPlane.d = m[15] - m[13];
  72716. frustumPlane.normalize();
  72717. };
  72718. /**
  72719. * Gets the bottom frustum plane transformed by the transform matrix
  72720. * @param transform transformation matrix to be applied to the resulting frustum plane
  72721. * @param frustumPlane the resuling frustum plane
  72722. */
  72723. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  72724. var m = transform.m;
  72725. frustumPlane.normal.x = m[3] + m[1];
  72726. frustumPlane.normal.y = m[7] + m[5];
  72727. frustumPlane.normal.z = m[11] + m[9];
  72728. frustumPlane.d = m[15] + m[13];
  72729. frustumPlane.normalize();
  72730. };
  72731. /**
  72732. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  72733. * @param transform transformation matrix to be applied to the resulting frustum planes
  72734. * @param frustumPlanes the resuling frustum planes
  72735. */
  72736. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  72737. // Near
  72738. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  72739. // Far
  72740. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  72741. // Left
  72742. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  72743. // Right
  72744. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  72745. // Top
  72746. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  72747. // Bottom
  72748. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  72749. };
  72750. return Frustum;
  72751. }());
  72752. /** Defines supported spaces */
  72753. var Space;
  72754. (function (Space) {
  72755. /** Local (object) space */
  72756. Space[Space["LOCAL"] = 0] = "LOCAL";
  72757. /** World space */
  72758. Space[Space["WORLD"] = 1] = "WORLD";
  72759. /** Bone space */
  72760. Space[Space["BONE"] = 2] = "BONE";
  72761. })(Space || (Space = {}));
  72762. /** Defines the 3 main axes */
  72763. var Axis = /** @class */ (function () {
  72764. function Axis() {
  72765. }
  72766. /** X axis */
  72767. Axis.X = new Vector3(1.0, 0.0, 0.0);
  72768. /** Y axis */
  72769. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  72770. /** Z axis */
  72771. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  72772. return Axis;
  72773. }());
  72774. /** Class used to represent a Bezier curve */
  72775. var BezierCurve = /** @class */ (function () {
  72776. function BezierCurve() {
  72777. }
  72778. /**
  72779. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72780. * @param t defines the time
  72781. * @param x1 defines the left coordinate on X axis
  72782. * @param y1 defines the left coordinate on Y axis
  72783. * @param x2 defines the right coordinate on X axis
  72784. * @param y2 defines the right coordinate on Y axis
  72785. * @returns the interpolated value
  72786. */
  72787. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  72788. // Extract X (which is equal to time here)
  72789. var f0 = 1 - 3 * x2 + 3 * x1;
  72790. var f1 = 3 * x2 - 6 * x1;
  72791. var f2 = 3 * x1;
  72792. var refinedT = t;
  72793. for (var i = 0; i < 5; i++) {
  72794. var refinedT2 = refinedT * refinedT;
  72795. var refinedT3 = refinedT2 * refinedT;
  72796. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  72797. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  72798. refinedT -= (x - t) * slope;
  72799. refinedT = Math.min(1, Math.max(0, refinedT));
  72800. }
  72801. // Resolve cubic bezier for the given x
  72802. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  72803. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  72804. Math.pow(refinedT, 3);
  72805. };
  72806. return BezierCurve;
  72807. }());
  72808. /**
  72809. * Defines potential orientation for back face culling
  72810. */
  72811. var Orientation;
  72812. (function (Orientation) {
  72813. /**
  72814. * Clockwise
  72815. */
  72816. Orientation[Orientation["CW"] = 0] = "CW";
  72817. /** Counter clockwise */
  72818. Orientation[Orientation["CCW"] = 1] = "CCW";
  72819. })(Orientation || (Orientation = {}));
  72820. /**
  72821. * Defines angle representation
  72822. */
  72823. var Angle = /** @class */ (function () {
  72824. /**
  72825. * Creates an Angle object of "radians" radians (float).
  72826. */
  72827. function Angle(radians) {
  72828. this._radians = radians;
  72829. if (this._radians < 0.0) {
  72830. this._radians += (2.0 * Math.PI);
  72831. }
  72832. }
  72833. /**
  72834. * Get value in degrees
  72835. * @returns the Angle value in degrees (float)
  72836. */
  72837. Angle.prototype.degrees = function () {
  72838. return this._radians * 180.0 / Math.PI;
  72839. };
  72840. /**
  72841. * Get value in radians
  72842. * @returns the Angle value in radians (float)
  72843. */
  72844. Angle.prototype.radians = function () {
  72845. return this._radians;
  72846. };
  72847. /**
  72848. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72849. * @param a defines first vector
  72850. * @param b defines second vector
  72851. * @returns a new Angle
  72852. */
  72853. Angle.BetweenTwoPoints = function (a, b) {
  72854. var delta = b.subtract(a);
  72855. var theta = Math.atan2(delta.y, delta.x);
  72856. return new Angle(theta);
  72857. };
  72858. /**
  72859. * Gets a new Angle object from the given float in radians
  72860. * @param radians defines the angle value in radians
  72861. * @returns a new Angle
  72862. */
  72863. Angle.FromRadians = function (radians) {
  72864. return new Angle(radians);
  72865. };
  72866. /**
  72867. * Gets a new Angle object from the given float in degrees
  72868. * @param degrees defines the angle value in degrees
  72869. * @returns a new Angle
  72870. */
  72871. Angle.FromDegrees = function (degrees) {
  72872. return new Angle(degrees * Math.PI / 180.0);
  72873. };
  72874. return Angle;
  72875. }());
  72876. /**
  72877. * This represents an arc in a 2d space.
  72878. */
  72879. var Arc2 = /** @class */ (function () {
  72880. /**
  72881. * Creates an Arc object from the three given points : start, middle and end.
  72882. * @param startPoint Defines the start point of the arc
  72883. * @param midPoint Defines the midlle point of the arc
  72884. * @param endPoint Defines the end point of the arc
  72885. */
  72886. function Arc2(
  72887. /** Defines the start point of the arc */
  72888. startPoint,
  72889. /** Defines the mid point of the arc */
  72890. midPoint,
  72891. /** Defines the end point of the arc */
  72892. endPoint) {
  72893. this.startPoint = startPoint;
  72894. this.midPoint = midPoint;
  72895. this.endPoint = endPoint;
  72896. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  72897. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  72898. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  72899. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  72900. 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);
  72901. this.radius = this.centerPoint.subtract(this.startPoint).length();
  72902. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  72903. var a1 = this.startAngle.degrees();
  72904. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  72905. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  72906. // angles correction
  72907. if (a2 - a1 > +180.0) {
  72908. a2 -= 360.0;
  72909. }
  72910. if (a2 - a1 < -180.0) {
  72911. a2 += 360.0;
  72912. }
  72913. if (a3 - a2 > +180.0) {
  72914. a3 -= 360.0;
  72915. }
  72916. if (a3 - a2 < -180.0) {
  72917. a3 += 360.0;
  72918. }
  72919. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  72920. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  72921. }
  72922. return Arc2;
  72923. }());
  72924. /**
  72925. * Represents a 2D path made up of multiple 2D points
  72926. */
  72927. var Path2 = /** @class */ (function () {
  72928. /**
  72929. * Creates a Path2 object from the starting 2D coordinates x and y.
  72930. * @param x the starting points x value
  72931. * @param y the starting points y value
  72932. */
  72933. function Path2(x, y) {
  72934. this._points = new Array();
  72935. this._length = 0.0;
  72936. /**
  72937. * If the path start and end point are the same
  72938. */
  72939. this.closed = false;
  72940. this._points.push(new Vector2(x, y));
  72941. }
  72942. /**
  72943. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72944. * @param x the added points x value
  72945. * @param y the added points y value
  72946. * @returns the updated Path2.
  72947. */
  72948. Path2.prototype.addLineTo = function (x, y) {
  72949. if (this.closed) {
  72950. return this;
  72951. }
  72952. var newPoint = new Vector2(x, y);
  72953. var previousPoint = this._points[this._points.length - 1];
  72954. this._points.push(newPoint);
  72955. this._length += newPoint.subtract(previousPoint).length();
  72956. return this;
  72957. };
  72958. /**
  72959. * 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.
  72960. * @param midX middle point x value
  72961. * @param midY middle point y value
  72962. * @param endX end point x value
  72963. * @param endY end point y value
  72964. * @param numberOfSegments (default: 36)
  72965. * @returns the updated Path2.
  72966. */
  72967. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  72968. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  72969. if (this.closed) {
  72970. return this;
  72971. }
  72972. var startPoint = this._points[this._points.length - 1];
  72973. var midPoint = new Vector2(midX, midY);
  72974. var endPoint = new Vector2(endX, endY);
  72975. var arc = new Arc2(startPoint, midPoint, endPoint);
  72976. var increment = arc.angle.radians() / numberOfSegments;
  72977. if (arc.orientation === Orientation.CW) {
  72978. increment *= -1;
  72979. }
  72980. var currentAngle = arc.startAngle.radians() + increment;
  72981. for (var i = 0; i < numberOfSegments; i++) {
  72982. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  72983. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  72984. this.addLineTo(x, y);
  72985. currentAngle += increment;
  72986. }
  72987. return this;
  72988. };
  72989. /**
  72990. * Closes the Path2.
  72991. * @returns the Path2.
  72992. */
  72993. Path2.prototype.close = function () {
  72994. this.closed = true;
  72995. return this;
  72996. };
  72997. /**
  72998. * Gets the sum of the distance between each sequential point in the path
  72999. * @returns the Path2 total length (float).
  73000. */
  73001. Path2.prototype.length = function () {
  73002. var result = this._length;
  73003. if (!this.closed) {
  73004. var lastPoint = this._points[this._points.length - 1];
  73005. var firstPoint = this._points[0];
  73006. result += (firstPoint.subtract(lastPoint).length());
  73007. }
  73008. return result;
  73009. };
  73010. /**
  73011. * Gets the points which construct the path
  73012. * @returns the Path2 internal array of points.
  73013. */
  73014. Path2.prototype.getPoints = function () {
  73015. return this._points;
  73016. };
  73017. /**
  73018. * Retreives the point at the distance aways from the starting point
  73019. * @param normalizedLengthPosition the length along the path to retreive the point from
  73020. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73021. */
  73022. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  73023. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  73024. return Vector2.Zero();
  73025. }
  73026. var lengthPosition = normalizedLengthPosition * this.length();
  73027. var previousOffset = 0;
  73028. for (var i = 0; i < this._points.length; i++) {
  73029. var j = (i + 1) % this._points.length;
  73030. var a = this._points[i];
  73031. var b = this._points[j];
  73032. var bToA = b.subtract(a);
  73033. var nextOffset = (bToA.length() + previousOffset);
  73034. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  73035. var dir = bToA.normalize();
  73036. var localOffset = lengthPosition - previousOffset;
  73037. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  73038. }
  73039. previousOffset = nextOffset;
  73040. }
  73041. return Vector2.Zero();
  73042. };
  73043. /**
  73044. * Creates a new path starting from an x and y position
  73045. * @param x starting x value
  73046. * @param y starting y value
  73047. * @returns a new Path2 starting at the coordinates (x, y).
  73048. */
  73049. Path2.StartingAt = function (x, y) {
  73050. return new Path2(x, y);
  73051. };
  73052. return Path2;
  73053. }());
  73054. /**
  73055. * Represents a 3D path made up of multiple 3D points
  73056. */
  73057. var Path3D = /** @class */ (function () {
  73058. /**
  73059. * new Path3D(path, normal, raw)
  73060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73062. * @param path an array of Vector3, the curve axis of the Path3D
  73063. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73065. */
  73066. function Path3D(
  73067. /**
  73068. * an array of Vector3, the curve axis of the Path3D
  73069. */
  73070. path, firstNormal, raw) {
  73071. if (firstNormal === void 0) { firstNormal = null; }
  73072. this.path = path;
  73073. this._curve = new Array();
  73074. this._distances = new Array();
  73075. this._tangents = new Array();
  73076. this._normals = new Array();
  73077. this._binormals = new Array();
  73078. for (var p = 0; p < path.length; p++) {
  73079. this._curve[p] = path[p].clone(); // hard copy
  73080. }
  73081. this._raw = raw || false;
  73082. this._compute(firstNormal);
  73083. }
  73084. /**
  73085. * Returns the Path3D array of successive Vector3 designing its curve.
  73086. * @returns the Path3D array of successive Vector3 designing its curve.
  73087. */
  73088. Path3D.prototype.getCurve = function () {
  73089. return this._curve;
  73090. };
  73091. /**
  73092. * Returns an array populated with tangent vectors on each Path3D curve point.
  73093. * @returns an array populated with tangent vectors on each Path3D curve point.
  73094. */
  73095. Path3D.prototype.getTangents = function () {
  73096. return this._tangents;
  73097. };
  73098. /**
  73099. * Returns an array populated with normal vectors on each Path3D curve point.
  73100. * @returns an array populated with normal vectors on each Path3D curve point.
  73101. */
  73102. Path3D.prototype.getNormals = function () {
  73103. return this._normals;
  73104. };
  73105. /**
  73106. * Returns an array populated with binormal vectors on each Path3D curve point.
  73107. * @returns an array populated with binormal vectors on each Path3D curve point.
  73108. */
  73109. Path3D.prototype.getBinormals = function () {
  73110. return this._binormals;
  73111. };
  73112. /**
  73113. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73114. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73115. */
  73116. Path3D.prototype.getDistances = function () {
  73117. return this._distances;
  73118. };
  73119. /**
  73120. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73121. * @param path path which all values are copied into the curves points
  73122. * @param firstNormal which should be projected onto the curve
  73123. * @returns the same object updated.
  73124. */
  73125. Path3D.prototype.update = function (path, firstNormal) {
  73126. if (firstNormal === void 0) { firstNormal = null; }
  73127. for (var p = 0; p < path.length; p++) {
  73128. this._curve[p].x = path[p].x;
  73129. this._curve[p].y = path[p].y;
  73130. this._curve[p].z = path[p].z;
  73131. }
  73132. this._compute(firstNormal);
  73133. return this;
  73134. };
  73135. // private function compute() : computes tangents, normals and binormals
  73136. Path3D.prototype._compute = function (firstNormal) {
  73137. var l = this._curve.length;
  73138. // first and last tangents
  73139. this._tangents[0] = this._getFirstNonNullVector(0);
  73140. if (!this._raw) {
  73141. this._tangents[0].normalize();
  73142. }
  73143. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  73144. if (!this._raw) {
  73145. this._tangents[l - 1].normalize();
  73146. }
  73147. // normals and binormals at first point : arbitrary vector with _normalVector()
  73148. var tg0 = this._tangents[0];
  73149. var pp0 = this._normalVector(tg0, firstNormal);
  73150. this._normals[0] = pp0;
  73151. if (!this._raw) {
  73152. this._normals[0].normalize();
  73153. }
  73154. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  73155. if (!this._raw) {
  73156. this._binormals[0].normalize();
  73157. }
  73158. this._distances[0] = 0.0;
  73159. // normals and binormals : next points
  73160. var prev; // previous vector (segment)
  73161. var cur; // current vector (segment)
  73162. var curTang; // current tangent
  73163. // previous normal
  73164. var prevBinor; // previous binormal
  73165. for (var i = 1; i < l; i++) {
  73166. // tangents
  73167. prev = this._getLastNonNullVector(i);
  73168. if (i < l - 1) {
  73169. cur = this._getFirstNonNullVector(i);
  73170. this._tangents[i] = prev.add(cur);
  73171. this._tangents[i].normalize();
  73172. }
  73173. this._distances[i] = this._distances[i - 1] + prev.length();
  73174. // normals and binormals
  73175. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  73176. curTang = this._tangents[i];
  73177. prevBinor = this._binormals[i - 1];
  73178. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  73179. if (!this._raw) {
  73180. this._normals[i].normalize();
  73181. }
  73182. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  73183. if (!this._raw) {
  73184. this._binormals[i].normalize();
  73185. }
  73186. }
  73187. };
  73188. // private function getFirstNonNullVector(index)
  73189. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  73190. Path3D.prototype._getFirstNonNullVector = function (index) {
  73191. var i = 1;
  73192. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  73193. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  73194. i++;
  73195. nNVector = this._curve[index + i].subtract(this._curve[index]);
  73196. }
  73197. return nNVector;
  73198. };
  73199. // private function getLastNonNullVector(index)
  73200. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  73201. Path3D.prototype._getLastNonNullVector = function (index) {
  73202. var i = 1;
  73203. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  73204. while (nLVector.length() === 0 && index > i + 1) {
  73205. i++;
  73206. nLVector = this._curve[index].subtract(this._curve[index - i]);
  73207. }
  73208. return nLVector;
  73209. };
  73210. // private function normalVector(v0, vt, va) :
  73211. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  73212. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  73213. Path3D.prototype._normalVector = function (vt, va) {
  73214. var normal0;
  73215. var tgl = vt.length();
  73216. if (tgl === 0.0) {
  73217. tgl = 1.0;
  73218. }
  73219. if (va === undefined || va === null) {
  73220. var point;
  73221. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  73222. point = new Vector3(0.0, -1.0, 0.0);
  73223. }
  73224. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  73225. point = new Vector3(1.0, 0.0, 0.0);
  73226. }
  73227. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  73228. point = new Vector3(0.0, 0.0, 1.0);
  73229. }
  73230. else {
  73231. point = Vector3.Zero();
  73232. }
  73233. normal0 = Vector3.Cross(vt, point);
  73234. }
  73235. else {
  73236. normal0 = Vector3.Cross(vt, va);
  73237. Vector3.CrossToRef(normal0, vt, normal0);
  73238. }
  73239. normal0.normalize();
  73240. return normal0;
  73241. };
  73242. return Path3D;
  73243. }());
  73244. /**
  73245. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73246. * A Curve3 is designed from a series of successive Vector3.
  73247. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73248. */
  73249. var Curve3 = /** @class */ (function () {
  73250. /**
  73251. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73252. * A Curve3 is designed from a series of successive Vector3.
  73253. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73254. * @param points points which make up the curve
  73255. */
  73256. function Curve3(points) {
  73257. this._length = 0.0;
  73258. this._points = points;
  73259. this._length = this._computeLength(points);
  73260. }
  73261. /**
  73262. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73263. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73264. * @param v1 (Vector3) the control point
  73265. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73266. * @param nbPoints (integer) the wanted number of points in the curve
  73267. * @returns the created Curve3
  73268. */
  73269. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  73270. nbPoints = nbPoints > 2 ? nbPoints : 3;
  73271. var bez = new Array();
  73272. var equation = function (t, val0, val1, val2) {
  73273. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  73274. return res;
  73275. };
  73276. for (var i = 0; i <= nbPoints; i++) {
  73277. 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)));
  73278. }
  73279. return new Curve3(bez);
  73280. };
  73281. /**
  73282. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73283. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73284. * @param v1 (Vector3) the first control point
  73285. * @param v2 (Vector3) the second control point
  73286. * @param v3 (Vector3) the end point of the Cubic Bezier
  73287. * @param nbPoints (integer) the wanted number of points in the curve
  73288. * @returns the created Curve3
  73289. */
  73290. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  73291. nbPoints = nbPoints > 3 ? nbPoints : 4;
  73292. var bez = new Array();
  73293. var equation = function (t, val0, val1, val2, val3) {
  73294. 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;
  73295. return res;
  73296. };
  73297. for (var i = 0; i <= nbPoints; i++) {
  73298. 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)));
  73299. }
  73300. return new Curve3(bez);
  73301. };
  73302. /**
  73303. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73304. * @param p1 (Vector3) the origin point of the Hermite Spline
  73305. * @param t1 (Vector3) the tangent vector at the origin point
  73306. * @param p2 (Vector3) the end point of the Hermite Spline
  73307. * @param t2 (Vector3) the tangent vector at the end point
  73308. * @param nbPoints (integer) the wanted number of points in the curve
  73309. * @returns the created Curve3
  73310. */
  73311. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  73312. var hermite = new Array();
  73313. var step = 1.0 / nbPoints;
  73314. for (var i = 0; i <= nbPoints; i++) {
  73315. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  73316. }
  73317. return new Curve3(hermite);
  73318. };
  73319. /**
  73320. * Returns a Curve3 object along a CatmullRom Spline curve :
  73321. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73322. * @param nbPoints (integer) the wanted number of points between each curve control points
  73323. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73324. * @returns the created Curve3
  73325. */
  73326. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  73327. var catmullRom = new Array();
  73328. var step = 1.0 / nbPoints;
  73329. var amount = 0.0;
  73330. if (closed) {
  73331. var pointsCount = points.length;
  73332. for (var i = 0; i < pointsCount; i++) {
  73333. amount = 0;
  73334. for (var c = 0; c < nbPoints; c++) {
  73335. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  73336. amount += step;
  73337. }
  73338. }
  73339. catmullRom.push(catmullRom[0]);
  73340. }
  73341. else {
  73342. var totalPoints = new Array();
  73343. totalPoints.push(points[0].clone());
  73344. Array.prototype.push.apply(totalPoints, points);
  73345. totalPoints.push(points[points.length - 1].clone());
  73346. for (var i = 0; i < totalPoints.length - 3; i++) {
  73347. amount = 0;
  73348. for (var c = 0; c < nbPoints; c++) {
  73349. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73350. amount += step;
  73351. }
  73352. }
  73353. i--;
  73354. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73355. }
  73356. return new Curve3(catmullRom);
  73357. };
  73358. /**
  73359. * @returns the Curve3 stored array of successive Vector3
  73360. */
  73361. Curve3.prototype.getPoints = function () {
  73362. return this._points;
  73363. };
  73364. /**
  73365. * @returns the computed length (float) of the curve.
  73366. */
  73367. Curve3.prototype.length = function () {
  73368. return this._length;
  73369. };
  73370. /**
  73371. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73372. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73373. * curveA and curveB keep unchanged.
  73374. * @param curve the curve to continue from this curve
  73375. * @returns the newly constructed curve
  73376. */
  73377. Curve3.prototype.continue = function (curve) {
  73378. var lastPoint = this._points[this._points.length - 1];
  73379. var continuedPoints = this._points.slice();
  73380. var curvePoints = curve.getPoints();
  73381. for (var i = 1; i < curvePoints.length; i++) {
  73382. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  73383. }
  73384. var continuedCurve = new Curve3(continuedPoints);
  73385. return continuedCurve;
  73386. };
  73387. Curve3.prototype._computeLength = function (path) {
  73388. var l = 0;
  73389. for (var i = 1; i < path.length; i++) {
  73390. l += (path[i].subtract(path[i - 1])).length();
  73391. }
  73392. return l;
  73393. };
  73394. return Curve3;
  73395. }());
  73396. // Vertex formats
  73397. /**
  73398. * Contains position and normal vectors for a vertex
  73399. */
  73400. var PositionNormalVertex = /** @class */ (function () {
  73401. /**
  73402. * Creates a PositionNormalVertex
  73403. * @param position the position of the vertex (defaut: 0,0,0)
  73404. * @param normal the normal of the vertex (defaut: 0,1,0)
  73405. */
  73406. function PositionNormalVertex(
  73407. /** the position of the vertex (defaut: 0,0,0) */
  73408. position,
  73409. /** the normal of the vertex (defaut: 0,1,0) */
  73410. normal) {
  73411. if (position === void 0) { position = Vector3.Zero(); }
  73412. if (normal === void 0) { normal = Vector3.Up(); }
  73413. this.position = position;
  73414. this.normal = normal;
  73415. }
  73416. /**
  73417. * Clones the PositionNormalVertex
  73418. * @returns the cloned PositionNormalVertex
  73419. */
  73420. PositionNormalVertex.prototype.clone = function () {
  73421. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  73422. };
  73423. return PositionNormalVertex;
  73424. }());
  73425. /**
  73426. * Contains position, normal and uv vectors for a vertex
  73427. */
  73428. var PositionNormalTextureVertex = /** @class */ (function () {
  73429. /**
  73430. * Creates a PositionNormalTextureVertex
  73431. * @param position the position of the vertex (defaut: 0,0,0)
  73432. * @param normal the normal of the vertex (defaut: 0,1,0)
  73433. * @param uv the uv of the vertex (default: 0,0)
  73434. */
  73435. function PositionNormalTextureVertex(
  73436. /** the position of the vertex (defaut: 0,0,0) */
  73437. position,
  73438. /** the normal of the vertex (defaut: 0,1,0) */
  73439. normal,
  73440. /** the uv of the vertex (default: 0,0) */
  73441. uv) {
  73442. if (position === void 0) { position = Vector3.Zero(); }
  73443. if (normal === void 0) { normal = Vector3.Up(); }
  73444. if (uv === void 0) { uv = Vector2.Zero(); }
  73445. this.position = position;
  73446. this.normal = normal;
  73447. this.uv = uv;
  73448. }
  73449. /**
  73450. * Clones the PositionNormalTextureVertex
  73451. * @returns the cloned PositionNormalTextureVertex
  73452. */
  73453. PositionNormalTextureVertex.prototype.clone = function () {
  73454. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  73455. };
  73456. return PositionNormalTextureVertex;
  73457. }());
  73458. // Temporary pre-allocated objects for engine internal use
  73459. // usage in any internal function :
  73460. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  73461. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  73462. /**
  73463. * @hidden
  73464. */
  73465. var Tmp = /** @class */ (function () {
  73466. function Tmp() {
  73467. }
  73468. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  73469. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  73470. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  73471. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  73472. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  73473. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  73474. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  73475. return Tmp;
  73476. }());
  73477. /**
  73478. * @hidden
  73479. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  73480. */
  73481. var MathTmp = /** @class */ (function () {
  73482. function MathTmp() {
  73483. }
  73484. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  73485. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  73486. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  73487. return MathTmp;
  73488. }());
  73489. /***/ }),
  73490. /***/ "./Maths/sphericalPolynomial.ts":
  73491. /*!**************************************!*\
  73492. !*** ./Maths/sphericalPolynomial.ts ***!
  73493. \**************************************/
  73494. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  73495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73496. "use strict";
  73497. __webpack_require__.r(__webpack_exports__);
  73498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  73499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  73500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  73501. /**
  73502. * Class representing spherical polynomial coefficients to the 3rd degree
  73503. */
  73504. var SphericalPolynomial = /** @class */ (function () {
  73505. function SphericalPolynomial() {
  73506. /**
  73507. * The x coefficients of the spherical polynomial
  73508. */
  73509. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73510. /**
  73511. * The y coefficients of the spherical polynomial
  73512. */
  73513. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73514. /**
  73515. * The z coefficients of the spherical polynomial
  73516. */
  73517. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73518. /**
  73519. * The xx coefficients of the spherical polynomial
  73520. */
  73521. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73522. /**
  73523. * The yy coefficients of the spherical polynomial
  73524. */
  73525. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73526. /**
  73527. * The zz coefficients of the spherical polynomial
  73528. */
  73529. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73530. /**
  73531. * The xy coefficients of the spherical polynomial
  73532. */
  73533. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73534. /**
  73535. * The yz coefficients of the spherical polynomial
  73536. */
  73537. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73538. /**
  73539. * The zx coefficients of the spherical polynomial
  73540. */
  73541. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73542. }
  73543. /**
  73544. * Adds an ambient color to the spherical polynomial
  73545. * @param color the color to add
  73546. */
  73547. SphericalPolynomial.prototype.addAmbient = function (color) {
  73548. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73549. this.xx = this.xx.add(colorVector);
  73550. this.yy = this.yy.add(colorVector);
  73551. this.zz = this.zz.add(colorVector);
  73552. };
  73553. /**
  73554. * Scales the spherical polynomial by the given amount
  73555. * @param scale the amount to scale
  73556. */
  73557. SphericalPolynomial.prototype.scale = function (scale) {
  73558. this.x = this.x.scale(scale);
  73559. this.y = this.y.scale(scale);
  73560. this.z = this.z.scale(scale);
  73561. this.xx = this.xx.scale(scale);
  73562. this.yy = this.yy.scale(scale);
  73563. this.zz = this.zz.scale(scale);
  73564. this.yz = this.yz.scale(scale);
  73565. this.zx = this.zx.scale(scale);
  73566. this.xy = this.xy.scale(scale);
  73567. };
  73568. /**
  73569. * Gets the spherical polynomial from harmonics
  73570. * @param harmonics the spherical harmonics
  73571. * @returns the spherical polynomial
  73572. */
  73573. SphericalPolynomial.FromHarmonics = function (harmonics) {
  73574. var result = new SphericalPolynomial();
  73575. result.x = harmonics.l11.scale(1.02333);
  73576. result.y = harmonics.l1_1.scale(1.02333);
  73577. result.z = harmonics.l10.scale(1.02333);
  73578. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  73579. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  73580. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  73581. result.yz = harmonics.l2_1.scale(0.858086);
  73582. result.zx = harmonics.l21.scale(0.858086);
  73583. result.xy = harmonics.l2_2.scale(0.858086);
  73584. result.scale(1.0 / Math.PI);
  73585. return result;
  73586. };
  73587. /**
  73588. * Constructs a spherical polynomial from an array.
  73589. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  73590. * @returns the spherical polynomial
  73591. */
  73592. SphericalPolynomial.FromArray = function (data) {
  73593. var sp = new SphericalPolynomial();
  73594. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  73595. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  73596. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  73597. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  73598. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  73599. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  73600. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  73601. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  73602. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  73603. return sp;
  73604. };
  73605. return SphericalPolynomial;
  73606. }());
  73607. /**
  73608. * Class representing spherical harmonics coefficients to the 3rd degree
  73609. */
  73610. var SphericalHarmonics = /** @class */ (function () {
  73611. function SphericalHarmonics() {
  73612. /**
  73613. * The l0,0 coefficients of the spherical harmonics
  73614. */
  73615. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73616. /**
  73617. * The l1,-1 coefficients of the spherical harmonics
  73618. */
  73619. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73620. /**
  73621. * The l1,0 coefficients of the spherical harmonics
  73622. */
  73623. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73624. /**
  73625. * The l1,1 coefficients of the spherical harmonics
  73626. */
  73627. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73628. /**
  73629. * The l2,-2 coefficients of the spherical harmonics
  73630. */
  73631. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73632. /**
  73633. * The l2,-1 coefficients of the spherical harmonics
  73634. */
  73635. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73636. /**
  73637. * The l2,0 coefficients of the spherical harmonics
  73638. */
  73639. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73640. /**
  73641. * The l2,1 coefficients of the spherical harmonics
  73642. */
  73643. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73644. /**
  73645. * The l2,2 coefficients of the spherical harmonics
  73646. */
  73647. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73648. }
  73649. /**
  73650. * Adds a light to the spherical harmonics
  73651. * @param direction the direction of the light
  73652. * @param color the color of the light
  73653. * @param deltaSolidAngle the delta solid angle of the light
  73654. */
  73655. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  73656. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73657. var c = colorVector.scale(deltaSolidAngle);
  73658. this.l00 = this.l00.add(c.scale(0.282095));
  73659. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  73660. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  73661. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  73662. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  73663. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  73664. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  73665. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  73666. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  73667. };
  73668. /**
  73669. * Scales the spherical harmonics by the given amount
  73670. * @param scale the amount to scale
  73671. */
  73672. SphericalHarmonics.prototype.scale = function (scale) {
  73673. this.l00 = this.l00.scale(scale);
  73674. this.l1_1 = this.l1_1.scale(scale);
  73675. this.l10 = this.l10.scale(scale);
  73676. this.l11 = this.l11.scale(scale);
  73677. this.l2_2 = this.l2_2.scale(scale);
  73678. this.l2_1 = this.l2_1.scale(scale);
  73679. this.l20 = this.l20.scale(scale);
  73680. this.l21 = this.l21.scale(scale);
  73681. this.lL22 = this.lL22.scale(scale);
  73682. };
  73683. /**
  73684. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  73685. *
  73686. * ```
  73687. * E_lm = A_l * L_lm
  73688. * ```
  73689. *
  73690. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  73691. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  73692. * the scaling factors are given in equation 9.
  73693. */
  73694. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  73695. // Constant (Band 0)
  73696. this.l00 = this.l00.scale(3.141593);
  73697. // Linear (Band 1)
  73698. this.l1_1 = this.l1_1.scale(2.094395);
  73699. this.l10 = this.l10.scale(2.094395);
  73700. this.l11 = this.l11.scale(2.094395);
  73701. // Quadratic (Band 2)
  73702. this.l2_2 = this.l2_2.scale(0.785398);
  73703. this.l2_1 = this.l2_1.scale(0.785398);
  73704. this.l20 = this.l20.scale(0.785398);
  73705. this.l21 = this.l21.scale(0.785398);
  73706. this.lL22 = this.lL22.scale(0.785398);
  73707. };
  73708. /**
  73709. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  73710. *
  73711. * ```
  73712. * L = (1/pi) * E * rho
  73713. * ```
  73714. *
  73715. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  73716. */
  73717. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  73718. this.scale(1.0 / Math.PI);
  73719. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  73720. // (The pixel shader must apply albedo after texture fetches, etc).
  73721. };
  73722. /**
  73723. * Gets the spherical harmonics from polynomial
  73724. * @param polynomial the spherical polynomial
  73725. * @returns the spherical harmonics
  73726. */
  73727. SphericalHarmonics.FromPolynomial = function (polynomial) {
  73728. var result = new SphericalHarmonics();
  73729. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  73730. result.l1_1 = polynomial.y.scale(0.977204);
  73731. result.l10 = polynomial.z.scale(0.977204);
  73732. result.l11 = polynomial.x.scale(0.977204);
  73733. result.l2_2 = polynomial.xy.scale(1.16538);
  73734. result.l2_1 = polynomial.yz.scale(1.16538);
  73735. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  73736. result.l21 = polynomial.zx.scale(1.16538);
  73737. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  73738. result.scale(Math.PI);
  73739. return result;
  73740. };
  73741. /**
  73742. * Constructs a spherical harmonics from an array.
  73743. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  73744. * @returns the spherical harmonics
  73745. */
  73746. SphericalHarmonics.FromArray = function (data) {
  73747. var sh = new SphericalHarmonics();
  73748. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  73749. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  73750. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  73751. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  73752. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  73753. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  73754. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  73755. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  73756. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  73757. return sh;
  73758. };
  73759. return SphericalHarmonics;
  73760. }());
  73761. /***/ }),
  73762. /***/ "./Meshes/Compression/dracoCompression.ts":
  73763. /*!************************************************!*\
  73764. !*** ./Meshes/Compression/dracoCompression.ts ***!
  73765. \************************************************/
  73766. /*! exports provided: DracoCompression */
  73767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73768. "use strict";
  73769. __webpack_require__.r(__webpack_exports__);
  73770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  73771. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  73772. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  73773. /**
  73774. * Draco compression (https://google.github.io/draco/)
  73775. *
  73776. * This class wraps the Draco module.
  73777. *
  73778. * **Encoder**
  73779. *
  73780. * The encoder is not currently implemented.
  73781. *
  73782. * **Decoder**
  73783. *
  73784. * 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.
  73785. *
  73786. * To update the configuration, use the following code:
  73787. * ```javascript
  73788. * DracoCompression.Configuration = {
  73789. * decoder: {
  73790. * wasmUrl: "<url to the WebAssembly library>",
  73791. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  73792. * fallbackUrl: "<url to the fallback JavaScript library>",
  73793. * }
  73794. * };
  73795. * ```
  73796. *
  73797. * 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.
  73798. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  73799. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  73800. *
  73801. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  73802. * ```javascript
  73803. * var dracoCompression = new DracoCompression();
  73804. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  73805. * [VertexBuffer.PositionKind]: 0
  73806. * });
  73807. * ```
  73808. *
  73809. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  73810. */
  73811. var DracoCompression = /** @class */ (function () {
  73812. /**
  73813. * Constructor
  73814. */
  73815. function DracoCompression() {
  73816. }
  73817. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  73818. /**
  73819. * Returns true if the decoder is available.
  73820. */
  73821. get: function () {
  73822. if (typeof DracoDecoderModule !== "undefined") {
  73823. return true;
  73824. }
  73825. var decoder = DracoCompression.Configuration.decoder;
  73826. if (decoder) {
  73827. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  73828. return true;
  73829. }
  73830. if (decoder.fallbackUrl) {
  73831. return true;
  73832. }
  73833. }
  73834. return false;
  73835. },
  73836. enumerable: true,
  73837. configurable: true
  73838. });
  73839. /**
  73840. * Stop all async operations and release resources.
  73841. */
  73842. DracoCompression.prototype.dispose = function () {
  73843. };
  73844. /**
  73845. * Decode Draco compressed mesh data to vertex data.
  73846. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  73847. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  73848. * @returns A promise that resolves with the decoded vertex data
  73849. */
  73850. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  73851. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  73852. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  73853. var module = wrappedModule.module;
  73854. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  73855. var buffer = new module.DecoderBuffer();
  73856. buffer.Init(dataView, dataView.byteLength);
  73857. var decoder = new module.Decoder();
  73858. var geometry;
  73859. var status;
  73860. try {
  73861. var type = decoder.GetEncodedGeometryType(buffer);
  73862. switch (type) {
  73863. case module.TRIANGULAR_MESH:
  73864. geometry = new module.Mesh();
  73865. status = decoder.DecodeBufferToMesh(buffer, geometry);
  73866. break;
  73867. case module.POINT_CLOUD:
  73868. geometry = new module.PointCloud();
  73869. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  73870. break;
  73871. default:
  73872. throw new Error("Invalid geometry type " + type);
  73873. }
  73874. if (!status.ok() || !geometry.ptr) {
  73875. throw new Error(status.error_msg());
  73876. }
  73877. var numPoints = geometry.num_points();
  73878. if (type === module.TRIANGULAR_MESH) {
  73879. var numFaces = geometry.num_faces();
  73880. var faceIndices = new module.DracoInt32Array();
  73881. try {
  73882. var indices = new Uint32Array(numFaces * 3);
  73883. for (var i = 0; i < numFaces; i++) {
  73884. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  73885. var offset = i * 3;
  73886. indices[offset + 0] = faceIndices.GetValue(0);
  73887. indices[offset + 1] = faceIndices.GetValue(1);
  73888. indices[offset + 2] = faceIndices.GetValue(2);
  73889. }
  73890. vertexData.indices = indices;
  73891. }
  73892. finally {
  73893. module.destroy(faceIndices);
  73894. }
  73895. }
  73896. for (var kind in attributes) {
  73897. var uniqueId = attributes[kind];
  73898. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  73899. var dracoData = new module.DracoFloat32Array();
  73900. try {
  73901. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  73902. var babylonData = new Float32Array(numPoints * attribute.num_components());
  73903. for (var i = 0; i < babylonData.length; i++) {
  73904. babylonData[i] = dracoData.GetValue(i);
  73905. }
  73906. vertexData.set(babylonData, kind);
  73907. }
  73908. finally {
  73909. module.destroy(dracoData);
  73910. }
  73911. }
  73912. }
  73913. finally {
  73914. if (geometry) {
  73915. module.destroy(geometry);
  73916. }
  73917. module.destroy(decoder);
  73918. module.destroy(buffer);
  73919. }
  73920. return vertexData;
  73921. });
  73922. };
  73923. DracoCompression._GetDecoderModule = function () {
  73924. if (!DracoCompression._DecoderModulePromise) {
  73925. var promise = null;
  73926. var config_1 = {};
  73927. if (typeof DracoDecoderModule !== "undefined") {
  73928. promise = Promise.resolve();
  73929. }
  73930. else {
  73931. var decoder = DracoCompression.Configuration.decoder;
  73932. if (decoder) {
  73933. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  73934. promise = Promise.all([
  73935. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  73936. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  73937. config_1.wasmBinary = data;
  73938. })
  73939. ]);
  73940. }
  73941. else if (decoder.fallbackUrl) {
  73942. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  73943. }
  73944. }
  73945. }
  73946. if (!promise) {
  73947. throw new Error("Draco decoder module is not available");
  73948. }
  73949. DracoCompression._DecoderModulePromise = promise.then(function () {
  73950. return new Promise(function (resolve) {
  73951. config_1.onModuleLoaded = function (decoderModule) {
  73952. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  73953. resolve({ module: decoderModule });
  73954. };
  73955. DracoDecoderModule(config_1);
  73956. });
  73957. });
  73958. }
  73959. return DracoCompression._DecoderModulePromise;
  73960. };
  73961. DracoCompression._LoadScriptAsync = function (url) {
  73962. return new Promise(function (resolve, reject) {
  73963. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  73964. resolve();
  73965. }, function (message) {
  73966. reject(new Error(message));
  73967. });
  73968. });
  73969. };
  73970. DracoCompression._LoadFileAsync = function (url) {
  73971. return new Promise(function (resolve, reject) {
  73972. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  73973. resolve(data);
  73974. }, undefined, undefined, true, function (request, exception) {
  73975. reject(exception);
  73976. });
  73977. });
  73978. };
  73979. /**
  73980. * The configuration. Defaults to the following urls:
  73981. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  73982. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  73983. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  73984. */
  73985. DracoCompression.Configuration = {
  73986. decoder: {
  73987. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  73988. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  73989. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  73990. }
  73991. };
  73992. return DracoCompression;
  73993. }());
  73994. /***/ }),
  73995. /***/ "./Meshes/Compression/index.ts":
  73996. /*!*************************************!*\
  73997. !*** ./Meshes/Compression/index.ts ***!
  73998. \*************************************/
  73999. /*! exports provided: DracoCompression */
  74000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74001. "use strict";
  74002. __webpack_require__.r(__webpack_exports__);
  74003. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  74004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  74005. /***/ }),
  74006. /***/ "./Meshes/abstractMesh.ts":
  74007. /*!********************************!*\
  74008. !*** ./Meshes/abstractMesh.ts ***!
  74009. \********************************/
  74010. /*! exports provided: AbstractMesh */
  74011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74012. "use strict";
  74013. __webpack_require__.r(__webpack_exports__);
  74014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  74015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  74016. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  74017. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  74018. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74019. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  74020. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  74021. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74022. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  74023. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  74024. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  74025. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  74026. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  74027. /** @hidden */
  74028. var _FacetDataStorage = /** @class */ (function () {
  74029. function _FacetDataStorage() {
  74030. this.facetNb = 0; // facet number
  74031. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  74032. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  74033. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  74034. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  74035. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  74036. this.subDiv = {
  74037. max: 1,
  74038. X: 1,
  74039. Y: 1,
  74040. Z: 1
  74041. };
  74042. this.facetDepthSort = false; // is the facet depth sort to be computed
  74043. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  74044. }
  74045. return _FacetDataStorage;
  74046. }());
  74047. /**
  74048. * Class used to store all common mesh properties
  74049. */
  74050. var AbstractMesh = /** @class */ (function (_super) {
  74051. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  74052. // Constructor
  74053. /**
  74054. * Creates a new AbstractMesh
  74055. * @param name defines the name of the mesh
  74056. * @param scene defines the hosting scene
  74057. */
  74058. function AbstractMesh(name, scene) {
  74059. if (scene === void 0) { scene = null; }
  74060. var _this = _super.call(this, name, scene, false) || this;
  74061. _this._facetData = new _FacetDataStorage();
  74062. /**
  74063. * The culling strategy to use to check whether the mesh must be rendered or not.
  74064. * This value can be changed at any time and will be used on the next render mesh selection.
  74065. * The possible values are :
  74066. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  74067. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  74068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  74069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  74070. * Please read each static variable documentation to get details about the culling process.
  74071. * */
  74072. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  74073. // Events
  74074. /**
  74075. * An event triggered when this mesh collides with another one
  74076. */
  74077. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74078. /**
  74079. * An event triggered when the collision's position changes
  74080. */
  74081. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74082. /**
  74083. * An event triggered when material is changed
  74084. */
  74085. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74086. // Properties
  74087. /**
  74088. * Gets or sets the orientation for POV movement & rotation
  74089. */
  74090. _this.definedFacingForward = true;
  74091. _this._visibility = 1.0;
  74092. /** Gets or sets the alpha index used to sort transparent meshes
  74093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  74094. */
  74095. _this.alphaIndex = Number.MAX_VALUE;
  74096. /**
  74097. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  74098. */
  74099. _this.isVisible = true;
  74100. /**
  74101. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74102. */
  74103. _this.isPickable = true;
  74104. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  74105. _this.showSubMeshesBoundingBox = false;
  74106. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  74107. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  74108. */
  74109. _this.isBlocker = false;
  74110. /**
  74111. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  74112. */
  74113. _this.enablePointerMoveEvents = false;
  74114. /**
  74115. * Specifies the rendering group id for this mesh (0 by default)
  74116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74117. */
  74118. _this.renderingGroupId = 0;
  74119. _this._receiveShadows = false;
  74120. /** Defines color to use when rendering outline */
  74121. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74122. /** Define width to use when rendering outline */
  74123. _this.outlineWidth = 0.02;
  74124. /** Defines color to use when rendering overlay */
  74125. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74126. /** Defines alpha to use when rendering overlay */
  74127. _this.overlayAlpha = 0.5;
  74128. _this._hasVertexAlpha = false;
  74129. _this._useVertexColors = true;
  74130. _this._computeBonesUsingShaders = true;
  74131. _this._numBoneInfluencers = 4;
  74132. _this._applyFog = true;
  74133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  74134. _this.useOctreeForRenderingSelection = true;
  74135. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  74136. _this.useOctreeForPicking = true;
  74137. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  74138. _this.useOctreeForCollisions = true;
  74139. _this._layerMask = 0x0FFFFFFF;
  74140. /**
  74141. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  74142. */
  74143. _this.alwaysSelectAsActiveMesh = false;
  74144. /**
  74145. * Gets or sets the current action manager
  74146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74147. */
  74148. _this.actionManager = null;
  74149. // Collisions
  74150. _this._checkCollisions = false;
  74151. _this._collisionMask = -1;
  74152. _this._collisionGroup = -1;
  74153. /**
  74154. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  74155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74156. */
  74157. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  74158. /**
  74159. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  74160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74161. */
  74162. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74163. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74164. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74165. // Edges
  74166. /**
  74167. * Defines edge width used when edgesRenderer is enabled
  74168. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74169. */
  74170. _this.edgesWidth = 1;
  74171. /**
  74172. * Defines edge color used when edgesRenderer is enabled
  74173. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74174. */
  74175. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  74176. /** @hidden */
  74177. _this._renderId = 0;
  74178. /** @hidden */
  74179. _this._intersectionsInProgress = new Array();
  74180. /** @hidden */
  74181. _this._unIndexed = false;
  74182. /** @hidden */
  74183. _this._lightSources = new Array();
  74184. /**
  74185. * An event triggered when the mesh is rebuilt.
  74186. */
  74187. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74188. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  74189. if (collidedMesh === void 0) { collidedMesh = null; }
  74190. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  74191. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  74192. _this.position.addInPlace(_this._diffPositionForCollisions);
  74193. }
  74194. if (collidedMesh) {
  74195. _this.onCollideObservable.notifyObservers(collidedMesh);
  74196. }
  74197. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  74198. };
  74199. _this.getScene().addMesh(_this);
  74200. _this._resyncLightSources();
  74201. return _this;
  74202. }
  74203. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  74204. /**
  74205. * No billboard
  74206. */
  74207. get: function () {
  74208. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  74209. },
  74210. enumerable: true,
  74211. configurable: true
  74212. });
  74213. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  74214. /** Billboard on X axis */
  74215. get: function () {
  74216. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  74217. },
  74218. enumerable: true,
  74219. configurable: true
  74220. });
  74221. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  74222. /** Billboard on Y axis */
  74223. get: function () {
  74224. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  74225. },
  74226. enumerable: true,
  74227. configurable: true
  74228. });
  74229. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  74230. /** Billboard on Z axis */
  74231. get: function () {
  74232. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  74233. },
  74234. enumerable: true,
  74235. configurable: true
  74236. });
  74237. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  74238. /** Billboard on all axes */
  74239. get: function () {
  74240. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  74241. },
  74242. enumerable: true,
  74243. configurable: true
  74244. });
  74245. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  74246. /**
  74247. * Gets the number of facets in the mesh
  74248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74249. */
  74250. get: function () {
  74251. return this._facetData.facetNb;
  74252. },
  74253. enumerable: true,
  74254. configurable: true
  74255. });
  74256. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  74257. /**
  74258. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  74259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74260. */
  74261. get: function () {
  74262. return this._facetData.partitioningSubdivisions;
  74263. },
  74264. set: function (nb) {
  74265. this._facetData.partitioningSubdivisions = nb;
  74266. },
  74267. enumerable: true,
  74268. configurable: true
  74269. });
  74270. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  74271. /**
  74272. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  74273. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  74274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74275. */
  74276. get: function () {
  74277. return this._facetData.partitioningBBoxRatio;
  74278. },
  74279. set: function (ratio) {
  74280. this._facetData.partitioningBBoxRatio = ratio;
  74281. },
  74282. enumerable: true,
  74283. configurable: true
  74284. });
  74285. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  74286. /**
  74287. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  74288. * Works only for updatable meshes.
  74289. * Doesn't work with multi-materials
  74290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74291. */
  74292. get: function () {
  74293. return this._facetData.facetDepthSort;
  74294. },
  74295. set: function (sort) {
  74296. this._facetData.facetDepthSort = sort;
  74297. },
  74298. enumerable: true,
  74299. configurable: true
  74300. });
  74301. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  74302. /**
  74303. * The location (Vector3) where the facet depth sort must be computed from.
  74304. * By default, the active camera position.
  74305. * Used only when facet depth sort is enabled
  74306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74307. */
  74308. get: function () {
  74309. return this._facetData.facetDepthSortFrom;
  74310. },
  74311. set: function (location) {
  74312. this._facetData.facetDepthSortFrom = location;
  74313. },
  74314. enumerable: true,
  74315. configurable: true
  74316. });
  74317. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  74318. /**
  74319. * gets a boolean indicating if facetData is enabled
  74320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74321. */
  74322. get: function () {
  74323. return this._facetData.facetDataEnabled;
  74324. },
  74325. enumerable: true,
  74326. configurable: true
  74327. });
  74328. /** @hidden */
  74329. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  74330. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  74331. return false;
  74332. }
  74333. this._markSubMeshesAsMiscDirty();
  74334. return true;
  74335. };
  74336. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  74337. /** Set a function to call when this mesh collides with another one */
  74338. set: function (callback) {
  74339. if (this._onCollideObserver) {
  74340. this.onCollideObservable.remove(this._onCollideObserver);
  74341. }
  74342. this._onCollideObserver = this.onCollideObservable.add(callback);
  74343. },
  74344. enumerable: true,
  74345. configurable: true
  74346. });
  74347. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  74348. /** Set a function to call when the collision's position changes */
  74349. set: function (callback) {
  74350. if (this._onCollisionPositionChangeObserver) {
  74351. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  74352. }
  74353. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  74354. },
  74355. enumerable: true,
  74356. configurable: true
  74357. });
  74358. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  74359. /**
  74360. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74361. */
  74362. get: function () {
  74363. return this._visibility;
  74364. },
  74365. /**
  74366. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74367. */
  74368. set: function (value) {
  74369. if (this._visibility === value) {
  74370. return;
  74371. }
  74372. this._visibility = value;
  74373. this._markSubMeshesAsMiscDirty();
  74374. },
  74375. enumerable: true,
  74376. configurable: true
  74377. });
  74378. Object.defineProperty(AbstractMesh.prototype, "material", {
  74379. /** Gets or sets current material */
  74380. get: function () {
  74381. return this._material;
  74382. },
  74383. set: function (value) {
  74384. if (this._material === value) {
  74385. return;
  74386. }
  74387. // remove from material mesh map id needed
  74388. if (this._material && this._material.meshMap) {
  74389. this._material.meshMap[this.uniqueId] = undefined;
  74390. }
  74391. this._material = value;
  74392. if (value && value.meshMap) {
  74393. value.meshMap[this.uniqueId] = this;
  74394. }
  74395. if (this.onMaterialChangedObservable.hasObservers) {
  74396. this.onMaterialChangedObservable.notifyObservers(this);
  74397. }
  74398. if (!this.subMeshes) {
  74399. return;
  74400. }
  74401. this._unBindEffect();
  74402. },
  74403. enumerable: true,
  74404. configurable: true
  74405. });
  74406. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  74407. /**
  74408. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  74409. * @see http://doc.babylonjs.com/babylon101/shadows
  74410. */
  74411. get: function () {
  74412. return this._receiveShadows;
  74413. },
  74414. set: function (value) {
  74415. if (this._receiveShadows === value) {
  74416. return;
  74417. }
  74418. this._receiveShadows = value;
  74419. this._markSubMeshesAsLightDirty();
  74420. },
  74421. enumerable: true,
  74422. configurable: true
  74423. });
  74424. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  74425. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  74426. get: function () {
  74427. return this._hasVertexAlpha;
  74428. },
  74429. set: function (value) {
  74430. if (this._hasVertexAlpha === value) {
  74431. return;
  74432. }
  74433. this._hasVertexAlpha = value;
  74434. this._markSubMeshesAsAttributesDirty();
  74435. this._markSubMeshesAsMiscDirty();
  74436. },
  74437. enumerable: true,
  74438. configurable: true
  74439. });
  74440. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  74441. /** 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) */
  74442. get: function () {
  74443. return this._useVertexColors;
  74444. },
  74445. set: function (value) {
  74446. if (this._useVertexColors === value) {
  74447. return;
  74448. }
  74449. this._useVertexColors = value;
  74450. this._markSubMeshesAsAttributesDirty();
  74451. },
  74452. enumerable: true,
  74453. configurable: true
  74454. });
  74455. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  74456. /**
  74457. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  74458. */
  74459. get: function () {
  74460. return this._computeBonesUsingShaders;
  74461. },
  74462. set: function (value) {
  74463. if (this._computeBonesUsingShaders === value) {
  74464. return;
  74465. }
  74466. this._computeBonesUsingShaders = value;
  74467. this._markSubMeshesAsAttributesDirty();
  74468. },
  74469. enumerable: true,
  74470. configurable: true
  74471. });
  74472. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  74473. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  74474. get: function () {
  74475. return this._numBoneInfluencers;
  74476. },
  74477. set: function (value) {
  74478. if (this._numBoneInfluencers === value) {
  74479. return;
  74480. }
  74481. this._numBoneInfluencers = value;
  74482. this._markSubMeshesAsAttributesDirty();
  74483. },
  74484. enumerable: true,
  74485. configurable: true
  74486. });
  74487. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  74488. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  74489. get: function () {
  74490. return this._applyFog;
  74491. },
  74492. set: function (value) {
  74493. if (this._applyFog === value) {
  74494. return;
  74495. }
  74496. this._applyFog = value;
  74497. this._markSubMeshesAsMiscDirty();
  74498. },
  74499. enumerable: true,
  74500. configurable: true
  74501. });
  74502. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  74503. /**
  74504. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  74505. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  74506. */
  74507. get: function () {
  74508. return this._layerMask;
  74509. },
  74510. set: function (value) {
  74511. if (value === this._layerMask) {
  74512. return;
  74513. }
  74514. this._layerMask = value;
  74515. this._resyncLightSources();
  74516. },
  74517. enumerable: true,
  74518. configurable: true
  74519. });
  74520. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  74521. /**
  74522. * Gets or sets a collision mask used to mask collisions (default is -1).
  74523. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74524. */
  74525. get: function () {
  74526. return this._collisionMask;
  74527. },
  74528. set: function (mask) {
  74529. this._collisionMask = !isNaN(mask) ? mask : -1;
  74530. },
  74531. enumerable: true,
  74532. configurable: true
  74533. });
  74534. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  74535. /**
  74536. * Gets or sets the current collision group mask (-1 by default).
  74537. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74538. */
  74539. get: function () {
  74540. return this._collisionGroup;
  74541. },
  74542. set: function (mask) {
  74543. this._collisionGroup = !isNaN(mask) ? mask : -1;
  74544. },
  74545. enumerable: true,
  74546. configurable: true
  74547. });
  74548. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  74549. /** @hidden */
  74550. get: function () {
  74551. return null;
  74552. },
  74553. enumerable: true,
  74554. configurable: true
  74555. });
  74556. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  74557. get: function () {
  74558. return this._skeleton;
  74559. },
  74560. /**
  74561. * Gets or sets a skeleton to apply skining transformations
  74562. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  74563. */
  74564. set: function (value) {
  74565. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  74566. this._skeleton._unregisterMeshWithPoseMatrix(this);
  74567. }
  74568. if (value && value.needInitialSkinMatrix) {
  74569. value._registerMeshWithPoseMatrix(this);
  74570. }
  74571. this._skeleton = value;
  74572. if (!this._skeleton) {
  74573. this._bonesTransformMatrices = null;
  74574. }
  74575. this._markSubMeshesAsAttributesDirty();
  74576. },
  74577. enumerable: true,
  74578. configurable: true
  74579. });
  74580. /**
  74581. * Returns the string "AbstractMesh"
  74582. * @returns "AbstractMesh"
  74583. */
  74584. AbstractMesh.prototype.getClassName = function () {
  74585. return "AbstractMesh";
  74586. };
  74587. /**
  74588. * Gets a string representation of the current mesh
  74589. * @param fullDetails defines a boolean indicating if full details must be included
  74590. * @returns a string representation of the current mesh
  74591. */
  74592. AbstractMesh.prototype.toString = function (fullDetails) {
  74593. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  74594. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  74595. if (this._skeleton) {
  74596. ret += ", skeleton: " + this._skeleton.name;
  74597. }
  74598. if (fullDetails) {
  74599. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  74600. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  74601. }
  74602. return ret;
  74603. };
  74604. /** @hidden */
  74605. AbstractMesh.prototype._rebuild = function () {
  74606. this.onRebuildObservable.notifyObservers(this);
  74607. if (this._occlusionQuery) {
  74608. this._occlusionQuery = null;
  74609. }
  74610. if (!this.subMeshes) {
  74611. return;
  74612. }
  74613. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74614. var subMesh = _a[_i];
  74615. subMesh._rebuild();
  74616. }
  74617. };
  74618. /** @hidden */
  74619. AbstractMesh.prototype._resyncLightSources = function () {
  74620. this._lightSources.length = 0;
  74621. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  74622. var light = _a[_i];
  74623. if (!light.isEnabled()) {
  74624. continue;
  74625. }
  74626. if (light.canAffectMesh(this)) {
  74627. this._lightSources.push(light);
  74628. }
  74629. }
  74630. this._markSubMeshesAsLightDirty();
  74631. };
  74632. /** @hidden */
  74633. AbstractMesh.prototype._resyncLighSource = function (light) {
  74634. var isIn = light.isEnabled() && light.canAffectMesh(this);
  74635. var index = this._lightSources.indexOf(light);
  74636. if (index === -1) {
  74637. if (!isIn) {
  74638. return;
  74639. }
  74640. this._lightSources.push(light);
  74641. }
  74642. else {
  74643. if (isIn) {
  74644. return;
  74645. }
  74646. this._lightSources.splice(index, 1);
  74647. }
  74648. this._markSubMeshesAsLightDirty();
  74649. };
  74650. /** @hidden */
  74651. AbstractMesh.prototype._unBindEffect = function () {
  74652. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74653. var subMesh = _a[_i];
  74654. subMesh.setEffect(null);
  74655. }
  74656. };
  74657. /** @hidden */
  74658. AbstractMesh.prototype._removeLightSource = function (light) {
  74659. var index = this._lightSources.indexOf(light);
  74660. if (index === -1) {
  74661. return;
  74662. }
  74663. this._lightSources.splice(index, 1);
  74664. this._markSubMeshesAsLightDirty();
  74665. };
  74666. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  74667. if (!this.subMeshes) {
  74668. return;
  74669. }
  74670. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74671. var subMesh = _a[_i];
  74672. if (subMesh._materialDefines) {
  74673. func(subMesh._materialDefines);
  74674. }
  74675. }
  74676. };
  74677. /** @hidden */
  74678. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  74679. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  74680. };
  74681. /** @hidden */
  74682. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  74683. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  74684. };
  74685. /** @hidden */
  74686. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  74687. if (!this.subMeshes) {
  74688. return;
  74689. }
  74690. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74691. var subMesh = _a[_i];
  74692. var material = subMesh.getMaterial();
  74693. if (material) {
  74694. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MATERIAL_MiscDirtyFlag);
  74695. }
  74696. }
  74697. };
  74698. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  74699. /**
  74700. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  74701. */
  74702. get: function () {
  74703. return this._scaling;
  74704. },
  74705. set: function (newScaling) {
  74706. this._scaling = newScaling;
  74707. if (this.physicsImpostor) {
  74708. this.physicsImpostor.forceUpdate();
  74709. }
  74710. },
  74711. enumerable: true,
  74712. configurable: true
  74713. });
  74714. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  74715. // Methods
  74716. /**
  74717. * Returns true if the mesh is blocked. Implemented by child classes
  74718. */
  74719. get: function () {
  74720. return false;
  74721. },
  74722. enumerable: true,
  74723. configurable: true
  74724. });
  74725. /**
  74726. * Returns the mesh itself by default. Implemented by child classes
  74727. * @param camera defines the camera to use to pick the right LOD level
  74728. * @returns the currentAbstractMesh
  74729. */
  74730. AbstractMesh.prototype.getLOD = function (camera) {
  74731. return this;
  74732. };
  74733. /**
  74734. * Returns 0 by default. Implemented by child classes
  74735. * @returns an integer
  74736. */
  74737. AbstractMesh.prototype.getTotalVertices = function () {
  74738. return 0;
  74739. };
  74740. /**
  74741. * Returns a positive integer : the total number of indices in this mesh geometry.
  74742. * @returns the numner of indices or zero if the mesh has no geometry.
  74743. */
  74744. AbstractMesh.prototype.getTotalIndices = function () {
  74745. return 0;
  74746. };
  74747. /**
  74748. * Returns null by default. Implemented by child classes
  74749. * @returns null
  74750. */
  74751. AbstractMesh.prototype.getIndices = function () {
  74752. return null;
  74753. };
  74754. /**
  74755. * Returns the array of the requested vertex data kind. Implemented by child classes
  74756. * @param kind defines the vertex data kind to use
  74757. * @returns null
  74758. */
  74759. AbstractMesh.prototype.getVerticesData = function (kind) {
  74760. return null;
  74761. };
  74762. /**
  74763. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74764. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74765. * Note that a new underlying VertexBuffer object is created each call.
  74766. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74767. * @param kind defines vertex data kind:
  74768. * * VertexBuffer.PositionKind
  74769. * * VertexBuffer.UVKind
  74770. * * VertexBuffer.UV2Kind
  74771. * * VertexBuffer.UV3Kind
  74772. * * VertexBuffer.UV4Kind
  74773. * * VertexBuffer.UV5Kind
  74774. * * VertexBuffer.UV6Kind
  74775. * * VertexBuffer.ColorKind
  74776. * * VertexBuffer.MatricesIndicesKind
  74777. * * VertexBuffer.MatricesIndicesExtraKind
  74778. * * VertexBuffer.MatricesWeightsKind
  74779. * * VertexBuffer.MatricesWeightsExtraKind
  74780. * @param data defines the data source
  74781. * @param updatable defines if the data must be flagged as updatable (or static)
  74782. * @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
  74783. * @returns the current mesh
  74784. */
  74785. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  74786. return this;
  74787. };
  74788. /**
  74789. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74790. * If the mesh has no geometry, it is simply returned as it is.
  74791. * @param kind defines vertex data kind:
  74792. * * VertexBuffer.PositionKind
  74793. * * VertexBuffer.UVKind
  74794. * * VertexBuffer.UV2Kind
  74795. * * VertexBuffer.UV3Kind
  74796. * * VertexBuffer.UV4Kind
  74797. * * VertexBuffer.UV5Kind
  74798. * * VertexBuffer.UV6Kind
  74799. * * VertexBuffer.ColorKind
  74800. * * VertexBuffer.MatricesIndicesKind
  74801. * * VertexBuffer.MatricesIndicesExtraKind
  74802. * * VertexBuffer.MatricesWeightsKind
  74803. * * VertexBuffer.MatricesWeightsExtraKind
  74804. * @param data defines the data source
  74805. * @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
  74806. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  74807. * @returns the current mesh
  74808. */
  74809. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  74810. return this;
  74811. };
  74812. /**
  74813. * Sets the mesh indices,
  74814. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74815. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  74816. * @param totalVertices Defines the total number of vertices
  74817. * @returns the current mesh
  74818. */
  74819. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  74820. return this;
  74821. };
  74822. /**
  74823. * Gets a boolean indicating if specific vertex data is present
  74824. * @param kind defines the vertex data kind to use
  74825. * @returns true is data kind is present
  74826. */
  74827. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  74828. return false;
  74829. };
  74830. /**
  74831. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  74832. * @returns a BoundingInfo
  74833. */
  74834. AbstractMesh.prototype.getBoundingInfo = function () {
  74835. if (this._masterMesh) {
  74836. return this._masterMesh.getBoundingInfo();
  74837. }
  74838. if (!this._boundingInfo) {
  74839. // this._boundingInfo is being created here
  74840. this._updateBoundingInfo();
  74841. }
  74842. // cannot be null.
  74843. return this._boundingInfo;
  74844. };
  74845. /**
  74846. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  74847. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  74848. * @returns the current mesh
  74849. */
  74850. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  74851. if (includeDescendants === void 0) { includeDescendants = true; }
  74852. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  74853. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  74854. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  74855. if (maxDimension === 0) {
  74856. return this;
  74857. }
  74858. var scale = 1 / maxDimension;
  74859. this.scaling.scaleInPlace(scale);
  74860. return this;
  74861. };
  74862. /**
  74863. * Overwrite the current bounding info
  74864. * @param boundingInfo defines the new bounding info
  74865. * @returns the current mesh
  74866. */
  74867. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  74868. this._boundingInfo = boundingInfo;
  74869. return this;
  74870. };
  74871. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  74872. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  74873. get: function () {
  74874. 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));
  74875. },
  74876. enumerable: true,
  74877. configurable: true
  74878. });
  74879. /** @hidden */
  74880. AbstractMesh.prototype._preActivate = function () {
  74881. };
  74882. /** @hidden */
  74883. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  74884. };
  74885. /** @hidden */
  74886. AbstractMesh.prototype._activate = function (renderId) {
  74887. this._renderId = renderId;
  74888. };
  74889. /**
  74890. * Gets the current world matrix
  74891. * @returns a Matrix
  74892. */
  74893. AbstractMesh.prototype.getWorldMatrix = function () {
  74894. if (this._masterMesh) {
  74895. return this._masterMesh.getWorldMatrix();
  74896. }
  74897. return _super.prototype.getWorldMatrix.call(this);
  74898. };
  74899. /** @hidden */
  74900. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  74901. if (this._masterMesh) {
  74902. return this._masterMesh._getWorldMatrixDeterminant();
  74903. }
  74904. return _super.prototype._getWorldMatrixDeterminant.call(this);
  74905. };
  74906. // ================================== Point of View Movement =================================
  74907. /**
  74908. * Perform relative position change from the point of view of behind the front of the mesh.
  74909. * This is performed taking into account the meshes current rotation, so you do not have to care.
  74910. * Supports definition of mesh facing forward or backward
  74911. * @param amountRight defines the distance on the right axis
  74912. * @param amountUp defines the distance on the up axis
  74913. * @param amountForward defines the distance on the forward axis
  74914. * @returns the current mesh
  74915. */
  74916. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  74917. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  74918. return this;
  74919. };
  74920. /**
  74921. * Calculate relative position change from the point of view of behind the front of the mesh.
  74922. * This is performed taking into account the meshes current rotation, so you do not have to care.
  74923. * Supports definition of mesh facing forward or backward
  74924. * @param amountRight defines the distance on the right axis
  74925. * @param amountUp defines the distance on the up axis
  74926. * @param amountForward defines the distance on the forward axis
  74927. * @returns the new displacement vector
  74928. */
  74929. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  74930. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  74931. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  74932. rotQuaternion.toRotationMatrix(rotMatrix);
  74933. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  74934. var defForwardMult = this.definedFacingForward ? -1 : 1;
  74935. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  74936. return translationDelta;
  74937. };
  74938. // ================================== Point of View Rotation =================================
  74939. /**
  74940. * Perform relative rotation change from the point of view of behind the front of the mesh.
  74941. * Supports definition of mesh facing forward or backward
  74942. * @param flipBack defines the flip
  74943. * @param twirlClockwise defines the twirl
  74944. * @param tiltRight defines the tilt
  74945. * @returns the current mesh
  74946. */
  74947. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  74948. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  74949. return this;
  74950. };
  74951. /**
  74952. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  74953. * Supports definition of mesh facing forward or backward.
  74954. * @param flipBack defines the flip
  74955. * @param twirlClockwise defines the twirl
  74956. * @param tiltRight defines the tilt
  74957. * @returns the new rotation vector
  74958. */
  74959. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  74960. var defForwardMult = this.definedFacingForward ? 1 : -1;
  74961. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  74962. };
  74963. /**
  74964. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  74965. * @param includeDescendants Include bounding info from descendants as well (true by default)
  74966. * @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
  74967. * @returns the new bounding vectors
  74968. */
  74969. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  74970. if (includeDescendants === void 0) { includeDescendants = true; }
  74971. if (predicate === void 0) { predicate = null; }
  74972. // Ensures that all world matrix will be recomputed.
  74973. this.getScene().incrementRenderId();
  74974. this.computeWorldMatrix(true);
  74975. var min;
  74976. var max;
  74977. var boundingInfo = this.getBoundingInfo();
  74978. if (!this.subMeshes) {
  74979. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  74980. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  74981. }
  74982. else {
  74983. min = boundingInfo.boundingBox.minimumWorld;
  74984. max = boundingInfo.boundingBox.maximumWorld;
  74985. }
  74986. if (includeDescendants) {
  74987. var descendants = this.getDescendants(false);
  74988. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  74989. var descendant = descendants_1[_i];
  74990. var childMesh = descendant;
  74991. childMesh.computeWorldMatrix(true);
  74992. // Filters meshes based on custom predicate function.
  74993. if (predicate && !predicate(childMesh)) {
  74994. continue;
  74995. }
  74996. //make sure we have the needed params to get mix and max
  74997. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  74998. continue;
  74999. }
  75000. var childBoundingInfo = childMesh.getBoundingInfo();
  75001. var boundingBox = childBoundingInfo.boundingBox;
  75002. var minBox = boundingBox.minimumWorld;
  75003. var maxBox = boundingBox.maximumWorld;
  75004. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  75005. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  75006. }
  75007. }
  75008. return {
  75009. min: min,
  75010. max: max
  75011. };
  75012. };
  75013. /**
  75014. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75015. * This means the mesh underlying bounding box and sphere are recomputed.
  75016. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75017. * @returns the current mesh
  75018. */
  75019. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  75020. if (applySkeleton === void 0) { applySkeleton = false; }
  75021. if (this._boundingInfo && this._boundingInfo.isLocked) {
  75022. return this;
  75023. }
  75024. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  75025. return this;
  75026. };
  75027. /** @hidden */
  75028. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  75029. if (data) {
  75030. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  75031. if (this._boundingInfo) {
  75032. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  75033. }
  75034. else {
  75035. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](extend.minimum, extend.maximum);
  75036. }
  75037. }
  75038. if (this.subMeshes) {
  75039. for (var index = 0; index < this.subMeshes.length; index++) {
  75040. this.subMeshes[index].refreshBoundingInfo();
  75041. }
  75042. }
  75043. this._updateBoundingInfo();
  75044. };
  75045. /** @hidden */
  75046. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  75047. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75048. if (data && applySkeleton && this.skeleton) {
  75049. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  75050. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  75051. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  75052. if (matricesWeightsData && matricesIndicesData) {
  75053. var needExtras = this.numBoneInfluencers > 4;
  75054. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  75055. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  75056. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  75057. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75058. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75059. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75060. var matWeightIdx = 0;
  75061. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  75062. finalMatrix.reset();
  75063. var inf;
  75064. var weight;
  75065. for (inf = 0; inf < 4; inf++) {
  75066. weight = matricesWeightsData[matWeightIdx + inf];
  75067. if (weight > 0) {
  75068. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75069. finalMatrix.addToSelf(tempMatrix);
  75070. }
  75071. }
  75072. if (needExtras) {
  75073. for (inf = 0; inf < 4; inf++) {
  75074. weight = matricesWeightsExtraData[matWeightIdx + inf];
  75075. if (weight > 0) {
  75076. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75077. finalMatrix.addToSelf(tempMatrix);
  75078. }
  75079. }
  75080. }
  75081. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  75082. tempVector.toArray(data, index);
  75083. }
  75084. }
  75085. }
  75086. return data;
  75087. };
  75088. /** @hidden */
  75089. AbstractMesh.prototype._updateBoundingInfo = function () {
  75090. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  75091. if (this._boundingInfo) {
  75092. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  75093. }
  75094. else {
  75095. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  75096. }
  75097. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  75098. return this;
  75099. };
  75100. /** @hidden */
  75101. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  75102. if (!this.subMeshes) {
  75103. return this;
  75104. }
  75105. var count = this.subMeshes.length;
  75106. for (var subIndex = 0; subIndex < count; subIndex++) {
  75107. var subMesh = this.subMeshes[subIndex];
  75108. if (count > 1 || !subMesh.IsGlobal) {
  75109. subMesh.updateBoundingInfo(matrix);
  75110. }
  75111. }
  75112. return this;
  75113. };
  75114. /** @hidden */
  75115. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  75116. // Bounding info
  75117. this._updateBoundingInfo();
  75118. };
  75119. /**
  75120. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75121. * A mesh is in the frustum if its bounding box intersects the frustum
  75122. * @param frustumPlanes defines the frustum to test
  75123. * @returns true if the mesh is in the frustum planes
  75124. */
  75125. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  75126. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  75127. };
  75128. /**
  75129. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  75130. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  75131. * @param frustumPlanes defines the frustum to test
  75132. * @returns true if the mesh is completely in the frustum planes
  75133. */
  75134. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  75135. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  75136. };
  75137. /**
  75138. * True if the mesh intersects another mesh or a SolidParticle object
  75139. * @param mesh defines a target mesh or SolidParticle to test
  75140. * @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)
  75141. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  75142. * @returns true if there is an intersection
  75143. */
  75144. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  75145. if (precise === void 0) { precise = false; }
  75146. if (!this._boundingInfo || !mesh._boundingInfo) {
  75147. return false;
  75148. }
  75149. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  75150. return true;
  75151. }
  75152. if (includeDescendants) {
  75153. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  75154. var child = _a[_i];
  75155. if (child.intersectsMesh(mesh, precise, true)) {
  75156. return true;
  75157. }
  75158. }
  75159. }
  75160. return false;
  75161. };
  75162. /**
  75163. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  75164. * @param point defines the point to test
  75165. * @returns true if there is an intersection
  75166. */
  75167. AbstractMesh.prototype.intersectsPoint = function (point) {
  75168. if (!this._boundingInfo) {
  75169. return false;
  75170. }
  75171. return this._boundingInfo.intersectsPoint(point);
  75172. };
  75173. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  75174. // Collisions
  75175. /**
  75176. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  75177. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75178. */
  75179. get: function () {
  75180. return this._checkCollisions;
  75181. },
  75182. set: function (collisionEnabled) {
  75183. this._checkCollisions = collisionEnabled;
  75184. },
  75185. enumerable: true,
  75186. configurable: true
  75187. });
  75188. Object.defineProperty(AbstractMesh.prototype, "collider", {
  75189. /**
  75190. * Gets Collider object used to compute collisions (not physics)
  75191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75192. */
  75193. get: function () {
  75194. return this._collider;
  75195. },
  75196. enumerable: true,
  75197. configurable: true
  75198. });
  75199. /**
  75200. * Move the mesh using collision engine
  75201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75202. * @param displacement defines the requested displacement vector
  75203. * @returns the current mesh
  75204. */
  75205. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  75206. var globalPosition = this.getAbsolutePosition();
  75207. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  75208. if (!this._collider) {
  75209. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  75210. }
  75211. this._collider._radius = this.ellipsoid;
  75212. this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  75213. return this;
  75214. };
  75215. // Collisions
  75216. /** @hidden */
  75217. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  75218. this._generatePointsArray();
  75219. if (!this._positions) {
  75220. return this;
  75221. }
  75222. // Transformation
  75223. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  75224. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  75225. subMesh._lastColliderWorldVertices = [];
  75226. subMesh._trianglePlanes = [];
  75227. var start = subMesh.verticesStart;
  75228. var end = (subMesh.verticesStart + subMesh.verticesCount);
  75229. for (var i = start; i < end; i++) {
  75230. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  75231. }
  75232. }
  75233. // Collide
  75234. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  75235. if (collider.collisionFound) {
  75236. collider.collidedMesh = this;
  75237. }
  75238. return this;
  75239. };
  75240. /** @hidden */
  75241. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  75242. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  75243. var len = subMeshes.length;
  75244. for (var index = 0; index < len; index++) {
  75245. var subMesh = subMeshes.data[index];
  75246. // Bounding test
  75247. if (len > 1 && !subMesh._checkCollision(collider)) {
  75248. continue;
  75249. }
  75250. this._collideForSubMesh(subMesh, transformMatrix, collider);
  75251. }
  75252. return this;
  75253. };
  75254. /** @hidden */
  75255. AbstractMesh.prototype._checkCollision = function (collider) {
  75256. // Bounding box test
  75257. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  75258. return this;
  75259. }
  75260. // Transformation matrix
  75261. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75262. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75263. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  75264. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  75265. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  75266. return this;
  75267. };
  75268. // Picking
  75269. /** @hidden */
  75270. AbstractMesh.prototype._generatePointsArray = function () {
  75271. return false;
  75272. };
  75273. /**
  75274. * Checks if the passed Ray intersects with the mesh
  75275. * @param ray defines the ray to use
  75276. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  75277. * @returns the picking info
  75278. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75279. */
  75280. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  75281. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  75282. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  75283. var boundingInfo = this._boundingInfo;
  75284. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  75285. return pickingInfo;
  75286. }
  75287. if (!this._generatePointsArray()) {
  75288. return pickingInfo;
  75289. }
  75290. var intersectInfo = null;
  75291. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  75292. var len = subMeshes.length;
  75293. for (var index = 0; index < len; index++) {
  75294. var subMesh = subMeshes.data[index];
  75295. // Bounding test
  75296. if (len > 1 && !subMesh.canIntersects(ray)) {
  75297. continue;
  75298. }
  75299. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  75300. if (currentIntersectInfo) {
  75301. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  75302. intersectInfo = currentIntersectInfo;
  75303. intersectInfo.subMeshId = index;
  75304. if (fastCheck) {
  75305. break;
  75306. }
  75307. }
  75308. }
  75309. }
  75310. if (intersectInfo) {
  75311. // Get picked point
  75312. var world = this.getWorldMatrix();
  75313. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75314. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  75315. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  75316. ray.direction.scaleToRef(intersectInfo.distance, direction);
  75317. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  75318. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  75319. // Return result
  75320. pickingInfo.hit = true;
  75321. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  75322. pickingInfo.pickedPoint = pickedPoint;
  75323. pickingInfo.pickedMesh = this;
  75324. pickingInfo.bu = intersectInfo.bu || 0;
  75325. pickingInfo.bv = intersectInfo.bv || 0;
  75326. pickingInfo.faceId = intersectInfo.faceId;
  75327. pickingInfo.subMeshId = intersectInfo.subMeshId;
  75328. return pickingInfo;
  75329. }
  75330. return pickingInfo;
  75331. };
  75332. /**
  75333. * Clones the current mesh
  75334. * @param name defines the mesh name
  75335. * @param newParent defines the new mesh parent
  75336. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  75337. * @returns the new mesh
  75338. */
  75339. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  75340. return null;
  75341. };
  75342. /**
  75343. * Disposes all the submeshes of the current meshnp
  75344. * @returns the current mesh
  75345. */
  75346. AbstractMesh.prototype.releaseSubMeshes = function () {
  75347. if (this.subMeshes) {
  75348. while (this.subMeshes.length) {
  75349. this.subMeshes[0].dispose();
  75350. }
  75351. }
  75352. else {
  75353. this.subMeshes = new Array();
  75354. }
  75355. return this;
  75356. };
  75357. /**
  75358. * Releases resources associated with this abstract mesh.
  75359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75361. */
  75362. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  75363. var _this = this;
  75364. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  75365. var index;
  75366. // Smart Array Retainers.
  75367. this.getScene().freeActiveMeshes();
  75368. this.getScene().freeRenderingGroups();
  75369. // Action manager
  75370. if (this.actionManager !== undefined && this.actionManager !== null) {
  75371. this.actionManager.dispose();
  75372. this.actionManager = null;
  75373. }
  75374. // Skeleton
  75375. this._skeleton = null;
  75376. // Intersections in progress
  75377. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  75378. var other = this._intersectionsInProgress[index];
  75379. var pos = other._intersectionsInProgress.indexOf(this);
  75380. other._intersectionsInProgress.splice(pos, 1);
  75381. }
  75382. this._intersectionsInProgress = [];
  75383. // Lights
  75384. var lights = this.getScene().lights;
  75385. lights.forEach(function (light) {
  75386. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  75387. if (meshIndex !== -1) {
  75388. light.includedOnlyMeshes.splice(meshIndex, 1);
  75389. }
  75390. meshIndex = light.excludedMeshes.indexOf(_this);
  75391. if (meshIndex !== -1) {
  75392. light.excludedMeshes.splice(meshIndex, 1);
  75393. }
  75394. // Shadow generators
  75395. var generator = light.getShadowGenerator();
  75396. if (generator) {
  75397. var shadowMap = generator.getShadowMap();
  75398. if (shadowMap && shadowMap.renderList) {
  75399. meshIndex = shadowMap.renderList.indexOf(_this);
  75400. if (meshIndex !== -1) {
  75401. shadowMap.renderList.splice(meshIndex, 1);
  75402. }
  75403. }
  75404. }
  75405. });
  75406. // SubMeshes
  75407. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  75408. this.releaseSubMeshes();
  75409. }
  75410. // Query
  75411. var engine = this.getScene().getEngine();
  75412. if (this._occlusionQuery) {
  75413. this.isOcclusionQueryInProgress = false;
  75414. engine.deleteQuery(this._occlusionQuery);
  75415. this._occlusionQuery = null;
  75416. }
  75417. // Engine
  75418. engine.wipeCaches();
  75419. // Remove from scene
  75420. this.getScene().removeMesh(this);
  75421. if (disposeMaterialAndTextures) {
  75422. if (this.material) {
  75423. this.material.dispose(false, true);
  75424. }
  75425. }
  75426. if (!doNotRecurse) {
  75427. // Particles
  75428. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  75429. if (this.getScene().particleSystems[index].emitter === this) {
  75430. this.getScene().particleSystems[index].dispose();
  75431. index--;
  75432. }
  75433. }
  75434. }
  75435. // facet data
  75436. if (this._facetData.facetDataEnabled) {
  75437. this.disableFacetData();
  75438. }
  75439. this.onAfterWorldMatrixUpdateObservable.clear();
  75440. this.onCollideObservable.clear();
  75441. this.onCollisionPositionChangeObservable.clear();
  75442. this.onRebuildObservable.clear();
  75443. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  75444. };
  75445. /**
  75446. * Adds the passed mesh as a child to the current mesh
  75447. * @param mesh defines the child mesh
  75448. * @returns the current mesh
  75449. */
  75450. AbstractMesh.prototype.addChild = function (mesh) {
  75451. mesh.setParent(this);
  75452. return this;
  75453. };
  75454. /**
  75455. * Removes the passed mesh from the current mesh children list
  75456. * @param mesh defines the child mesh
  75457. * @returns the current mesh
  75458. */
  75459. AbstractMesh.prototype.removeChild = function (mesh) {
  75460. mesh.setParent(null);
  75461. return this;
  75462. };
  75463. // Facet data
  75464. /** @hidden */
  75465. AbstractMesh.prototype._initFacetData = function () {
  75466. var data = this._facetData;
  75467. if (!data.facetNormals) {
  75468. data.facetNormals = new Array();
  75469. }
  75470. if (!data.facetPositions) {
  75471. data.facetPositions = new Array();
  75472. }
  75473. if (!data.facetPartitioning) {
  75474. data.facetPartitioning = new Array();
  75475. }
  75476. data.facetNb = (this.getIndices().length / 3) | 0;
  75477. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  75478. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  75479. for (var f = 0; f < data.facetNb; f++) {
  75480. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75481. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75482. }
  75483. data.facetDataEnabled = true;
  75484. return this;
  75485. };
  75486. /**
  75487. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  75488. * This method can be called within the render loop.
  75489. * 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
  75490. * @returns the current mesh
  75491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75492. */
  75493. AbstractMesh.prototype.updateFacetData = function () {
  75494. var data = this._facetData;
  75495. if (!data.facetDataEnabled) {
  75496. this._initFacetData();
  75497. }
  75498. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75499. var indices = this.getIndices();
  75500. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  75501. var bInfo = this.getBoundingInfo();
  75502. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  75503. // init arrays, matrix and sort function on first call
  75504. data.facetDepthSortEnabled = true;
  75505. if (indices instanceof Uint16Array) {
  75506. data.depthSortedIndices = new Uint16Array(indices);
  75507. }
  75508. else if (indices instanceof Uint32Array) {
  75509. data.depthSortedIndices = new Uint32Array(indices);
  75510. }
  75511. else {
  75512. var needs32bits = false;
  75513. for (var i = 0; i < indices.length; i++) {
  75514. if (indices[i] > 65535) {
  75515. needs32bits = true;
  75516. break;
  75517. }
  75518. }
  75519. if (needs32bits) {
  75520. data.depthSortedIndices = new Uint32Array(indices);
  75521. }
  75522. else {
  75523. data.depthSortedIndices = new Uint16Array(indices);
  75524. }
  75525. }
  75526. data.facetDepthSortFunction = function (f1, f2) {
  75527. return (f2.sqDistance - f1.sqDistance);
  75528. };
  75529. if (!data.facetDepthSortFrom) {
  75530. var camera = this.getScene().activeCamera;
  75531. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75532. }
  75533. data.depthSortedFacets = [];
  75534. for (var f = 0; f < data.facetNb; f++) {
  75535. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  75536. data.depthSortedFacets.push(depthSortedFacet);
  75537. }
  75538. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  75539. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75540. }
  75541. 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"];
  75542. 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"];
  75543. 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"];
  75544. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  75545. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  75546. data.subDiv.max = data.partitioningSubdivisions;
  75547. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  75548. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  75549. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  75550. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  75551. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  75552. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  75553. // set the parameters for ComputeNormals()
  75554. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  75555. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  75556. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  75557. data.facetParameters.bInfo = bInfo;
  75558. data.facetParameters.bbSize = data.bbSize;
  75559. data.facetParameters.subDiv = data.subDiv;
  75560. data.facetParameters.ratio = this.partitioningBBoxRatio;
  75561. data.facetParameters.depthSort = data.facetDepthSort;
  75562. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75563. this.computeWorldMatrix(true);
  75564. this._worldMatrix.invertToRef(data.invertedMatrix);
  75565. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  75566. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  75567. }
  75568. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  75569. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  75570. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75571. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  75572. var l = (data.depthSortedIndices.length / 3) | 0;
  75573. for (var f = 0; f < l; f++) {
  75574. var sind = data.depthSortedFacets[f].ind;
  75575. data.depthSortedIndices[f * 3] = indices[sind];
  75576. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  75577. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  75578. }
  75579. this.updateIndices(data.depthSortedIndices);
  75580. }
  75581. return this;
  75582. };
  75583. /**
  75584. * Returns the facetLocalNormals array.
  75585. * The normals are expressed in the mesh local spac
  75586. * @returns an array of Vector3
  75587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75588. */
  75589. AbstractMesh.prototype.getFacetLocalNormals = function () {
  75590. if (!this._facetData.facetNormals) {
  75591. this.updateFacetData();
  75592. }
  75593. return this._facetData.facetNormals;
  75594. };
  75595. /**
  75596. * Returns the facetLocalPositions array.
  75597. * The facet positions are expressed in the mesh local space
  75598. * @returns an array of Vector3
  75599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75600. */
  75601. AbstractMesh.prototype.getFacetLocalPositions = function () {
  75602. if (!this._facetData.facetPositions) {
  75603. this.updateFacetData();
  75604. }
  75605. return this._facetData.facetPositions;
  75606. };
  75607. /**
  75608. * Returns the facetLocalPartioning array
  75609. * @returns an array of array of numbers
  75610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75611. */
  75612. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  75613. if (!this._facetData.facetPartitioning) {
  75614. this.updateFacetData();
  75615. }
  75616. return this._facetData.facetPartitioning;
  75617. };
  75618. /**
  75619. * Returns the i-th facet position in the world system.
  75620. * This method allocates a new Vector3 per call
  75621. * @param i defines the facet index
  75622. * @returns a new Vector3
  75623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75624. */
  75625. AbstractMesh.prototype.getFacetPosition = function (i) {
  75626. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75627. this.getFacetPositionToRef(i, pos);
  75628. return pos;
  75629. };
  75630. /**
  75631. * Sets the reference Vector3 with the i-th facet position in the world system
  75632. * @param i defines the facet index
  75633. * @param ref defines the target vector
  75634. * @returns the current mesh
  75635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75636. */
  75637. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  75638. var localPos = (this.getFacetLocalPositions())[i];
  75639. var world = this.getWorldMatrix();
  75640. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  75641. return this;
  75642. };
  75643. /**
  75644. * Returns the i-th facet normal in the world system.
  75645. * This method allocates a new Vector3 per call
  75646. * @param i defines the facet index
  75647. * @returns a new Vector3
  75648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75649. */
  75650. AbstractMesh.prototype.getFacetNormal = function (i) {
  75651. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75652. this.getFacetNormalToRef(i, norm);
  75653. return norm;
  75654. };
  75655. /**
  75656. * Sets the reference Vector3 with the i-th facet normal in the world system
  75657. * @param i defines the facet index
  75658. * @param ref defines the target vector
  75659. * @returns the current mesh
  75660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75661. */
  75662. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  75663. var localNorm = (this.getFacetLocalNormals())[i];
  75664. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  75665. return this;
  75666. };
  75667. /**
  75668. * 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)
  75669. * @param x defines x coordinate
  75670. * @param y defines y coordinate
  75671. * @param z defines z coordinate
  75672. * @returns the array of facet indexes
  75673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75674. */
  75675. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  75676. var bInfo = this.getBoundingInfo();
  75677. var data = this._facetData;
  75678. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  75679. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  75680. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  75681. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  75682. return null;
  75683. }
  75684. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  75685. };
  75686. /**
  75687. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  75688. * @param projected sets as the (x,y,z) world projection on the facet
  75689. * @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
  75690. * @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
  75691. * @param x defines x coordinate
  75692. * @param y defines y coordinate
  75693. * @param z defines z coordinate
  75694. * @returns the face index if found (or null instead)
  75695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75696. */
  75697. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  75698. if (checkFace === void 0) { checkFace = false; }
  75699. if (facing === void 0) { facing = true; }
  75700. var world = this.getWorldMatrix();
  75701. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  75702. world.invertToRef(invMat);
  75703. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  75704. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  75705. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  75706. if (projected) {
  75707. // tranform the local computed projected vector to world coordinates
  75708. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  75709. }
  75710. return closest;
  75711. };
  75712. /**
  75713. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  75714. * @param projected sets as the (x,y,z) local projection on the facet
  75715. * @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
  75716. * @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
  75717. * @param x defines x coordinate
  75718. * @param y defines y coordinate
  75719. * @param z defines z coordinate
  75720. * @returns the face index if found (or null instead)
  75721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75722. */
  75723. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  75724. if (checkFace === void 0) { checkFace = false; }
  75725. if (facing === void 0) { facing = true; }
  75726. var closest = null;
  75727. var tmpx = 0.0;
  75728. var tmpy = 0.0;
  75729. var tmpz = 0.0;
  75730. var d = 0.0; // tmp dot facet normal * facet position
  75731. var t0 = 0.0;
  75732. var projx = 0.0;
  75733. var projy = 0.0;
  75734. var projz = 0.0;
  75735. // Get all the facets in the same partitioning block than (x, y, z)
  75736. var facetPositions = this.getFacetLocalPositions();
  75737. var facetNormals = this.getFacetLocalNormals();
  75738. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  75739. if (!facetsInBlock) {
  75740. return null;
  75741. }
  75742. // Get the closest facet to (x, y, z)
  75743. var shortest = Number.MAX_VALUE; // init distance vars
  75744. var tmpDistance = shortest;
  75745. var fib; // current facet in the block
  75746. var norm; // current facet normal
  75747. var p0; // current facet barycenter position
  75748. // loop on all the facets in the current partitioning block
  75749. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  75750. fib = facetsInBlock[idx];
  75751. norm = facetNormals[fib];
  75752. p0 = facetPositions[fib];
  75753. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  75754. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  75755. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  75756. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  75757. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  75758. projx = x + norm.x * t0;
  75759. projy = y + norm.y * t0;
  75760. projz = z + norm.z * t0;
  75761. tmpx = projx - x;
  75762. tmpy = projy - y;
  75763. tmpz = projz - z;
  75764. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  75765. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  75766. shortest = tmpDistance;
  75767. closest = fib;
  75768. if (projected) {
  75769. projected.x = projx;
  75770. projected.y = projy;
  75771. projected.z = projz;
  75772. }
  75773. }
  75774. }
  75775. }
  75776. return closest;
  75777. };
  75778. /**
  75779. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  75780. * @returns the parameters
  75781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75782. */
  75783. AbstractMesh.prototype.getFacetDataParameters = function () {
  75784. return this._facetData.facetParameters;
  75785. };
  75786. /**
  75787. * Disables the feature FacetData and frees the related memory
  75788. * @returns the current mesh
  75789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75790. */
  75791. AbstractMesh.prototype.disableFacetData = function () {
  75792. if (this._facetData.facetDataEnabled) {
  75793. this._facetData.facetDataEnabled = false;
  75794. this._facetData.facetPositions = new Array();
  75795. this._facetData.facetNormals = new Array();
  75796. this._facetData.facetPartitioning = new Array();
  75797. this._facetData.facetParameters = null;
  75798. this._facetData.depthSortedIndices = new Uint32Array(0);
  75799. }
  75800. return this;
  75801. };
  75802. /**
  75803. * Updates the AbstractMesh indices array
  75804. * @param indices defines the data source
  75805. * @returns the current mesh
  75806. */
  75807. AbstractMesh.prototype.updateIndices = function (indices) {
  75808. return this;
  75809. };
  75810. /**
  75811. * Creates new normals data for the mesh
  75812. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  75813. * @returns the current mesh
  75814. */
  75815. AbstractMesh.prototype.createNormals = function (updatable) {
  75816. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75817. var indices = this.getIndices();
  75818. var normals;
  75819. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  75820. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  75821. }
  75822. else {
  75823. normals = [];
  75824. }
  75825. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  75826. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  75827. return this;
  75828. };
  75829. /**
  75830. * Align the mesh with a normal
  75831. * @param normal defines the normal to use
  75832. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  75833. * @returns the current mesh
  75834. */
  75835. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  75836. if (!upDirection) {
  75837. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  75838. }
  75839. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75840. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  75841. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  75842. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  75843. if (this.rotationQuaternion) {
  75844. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  75845. }
  75846. else {
  75847. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  75848. }
  75849. return this;
  75850. };
  75851. /** @hidden */
  75852. AbstractMesh.prototype._checkOcclusionQuery = function () {
  75853. return false;
  75854. };
  75855. /** No occlusion */
  75856. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  75857. /** Occlusion set to optimisitic */
  75858. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  75859. /** Occlusion set to strict */
  75860. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  75861. /** Use an accurante occlusion algorithm */
  75862. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  75863. /** Use a conservative occlusion algorithm */
  75864. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  75865. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75866. * Test order :
  75867. * Is the bounding sphere outside the frustum ?
  75868. * If not, are the bounding box vertices outside the frustum ?
  75869. * It not, then the cullable object is in the frustum.
  75870. */
  75871. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  75872. /** Culling strategy : Bounding Sphere Only.
  75873. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75874. * It's also less accurate than the standard because some not visible objects can still be selected.
  75875. * Test : is the bounding sphere outside the frustum ?
  75876. * If not, then the cullable object is in the frustum.
  75877. */
  75878. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  75879. /** Culling strategy : Optimistic Inclusion.
  75880. * This in an inclusion test first, then the standard exclusion test.
  75881. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75882. * 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.
  75883. * Anyway, it's as accurate as the standard strategy.
  75884. * Test :
  75885. * Is the cullable object bounding sphere center in the frustum ?
  75886. * If not, apply the default culling strategy.
  75887. */
  75888. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  75889. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75890. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75891. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75892. * 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.
  75893. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75894. * Test :
  75895. * Is the cullable object bounding sphere center in the frustum ?
  75896. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75897. */
  75898. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  75899. return AbstractMesh;
  75900. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  75901. /***/ }),
  75902. /***/ "./Meshes/buffer.ts":
  75903. /*!**************************!*\
  75904. !*** ./Meshes/buffer.ts ***!
  75905. \**************************/
  75906. /*! exports provided: Buffer, VertexBuffer */
  75907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75908. "use strict";
  75909. __webpack_require__.r(__webpack_exports__);
  75910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  75911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  75912. /**
  75913. * Class used to store data that will be store in GPU memory
  75914. */
  75915. var Buffer = /** @class */ (function () {
  75916. /**
  75917. * Constructor
  75918. * @param engine the engine
  75919. * @param data the data to use for this buffer
  75920. * @param updatable whether the data is updatable
  75921. * @param stride the stride (optional)
  75922. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75923. * @param instanced whether the buffer is instanced (optional)
  75924. * @param useBytes set to true if the stride in in bytes (optional)
  75925. */
  75926. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  75927. if (stride === void 0) { stride = 0; }
  75928. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  75929. if (instanced === void 0) { instanced = false; }
  75930. if (useBytes === void 0) { useBytes = false; }
  75931. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  75932. this._engine = engine.getScene().getEngine();
  75933. }
  75934. else {
  75935. this._engine = engine;
  75936. }
  75937. this._updatable = updatable;
  75938. this._instanced = instanced;
  75939. this._data = data;
  75940. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  75941. if (!postponeInternalCreation) { // by default
  75942. this.create();
  75943. }
  75944. }
  75945. /**
  75946. * Create a new VertexBuffer based on the current buffer
  75947. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75948. * @param offset defines offset in the buffer (0 by default)
  75949. * @param size defines the size in floats of attributes (position is 3 for instance)
  75950. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75951. * @param instanced defines if the vertex buffer contains indexed data
  75952. * @param useBytes defines if the offset and stride are in bytes
  75953. * @returns the new vertex buffer
  75954. */
  75955. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  75956. if (useBytes === void 0) { useBytes = false; }
  75957. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  75958. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  75959. // a lot of these parameters are ignored as they are overriden by the buffer
  75960. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  75961. };
  75962. // Properties
  75963. /**
  75964. * Gets a boolean indicating if the Buffer is updatable?
  75965. * @returns true if the buffer is updatable
  75966. */
  75967. Buffer.prototype.isUpdatable = function () {
  75968. return this._updatable;
  75969. };
  75970. /**
  75971. * Gets current buffer's data
  75972. * @returns a DataArray or null
  75973. */
  75974. Buffer.prototype.getData = function () {
  75975. return this._data;
  75976. };
  75977. /**
  75978. * Gets underlying native buffer
  75979. * @returns underlying native buffer
  75980. */
  75981. Buffer.prototype.getBuffer = function () {
  75982. return this._buffer;
  75983. };
  75984. /**
  75985. * Gets the stride in float32 units (i.e. byte stride / 4).
  75986. * May not be an integer if the byte stride is not divisible by 4.
  75987. * DEPRECATED. Use byteStride instead.
  75988. * @returns the stride in float32 units
  75989. */
  75990. Buffer.prototype.getStrideSize = function () {
  75991. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  75992. };
  75993. // Methods
  75994. /**
  75995. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75996. * @param data defines the data to store
  75997. */
  75998. Buffer.prototype.create = function (data) {
  75999. if (data === void 0) { data = null; }
  76000. if (!data && this._buffer) {
  76001. return; // nothing to do
  76002. }
  76003. data = data || this._data;
  76004. if (!data) {
  76005. return;
  76006. }
  76007. if (!this._buffer) { // create buffer
  76008. if (this._updatable) {
  76009. this._buffer = this._engine.createDynamicVertexBuffer(data);
  76010. this._data = data;
  76011. }
  76012. else {
  76013. this._buffer = this._engine.createVertexBuffer(data);
  76014. }
  76015. }
  76016. else if (this._updatable) { // update buffer
  76017. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  76018. this._data = data;
  76019. }
  76020. };
  76021. /** @hidden */
  76022. Buffer.prototype._rebuild = function () {
  76023. this._buffer = null;
  76024. this.create(this._data);
  76025. };
  76026. /**
  76027. * Update current buffer data
  76028. * @param data defines the data to store
  76029. */
  76030. Buffer.prototype.update = function (data) {
  76031. this.create(data);
  76032. };
  76033. /**
  76034. * Updates the data directly.
  76035. * @param data the new data
  76036. * @param offset the new offset
  76037. * @param vertexCount the vertex count (optional)
  76038. * @param useBytes set to true if the offset is in bytes
  76039. */
  76040. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  76041. if (useBytes === void 0) { useBytes = false; }
  76042. if (!this._buffer) {
  76043. return;
  76044. }
  76045. if (this._updatable) { // update buffer
  76046. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  76047. this._data = null;
  76048. }
  76049. };
  76050. /**
  76051. * Release all resources
  76052. */
  76053. Buffer.prototype.dispose = function () {
  76054. if (!this._buffer) {
  76055. return;
  76056. }
  76057. if (this._engine._releaseBuffer(this._buffer)) {
  76058. this._buffer = null;
  76059. }
  76060. };
  76061. return Buffer;
  76062. }());
  76063. /**
  76064. * Specialized buffer used to store vertex data
  76065. */
  76066. var VertexBuffer = /** @class */ (function () {
  76067. /**
  76068. * Constructor
  76069. * @param engine the engine
  76070. * @param data the data to use for this vertex buffer
  76071. * @param kind the vertex buffer kind
  76072. * @param updatable whether the data is updatable
  76073. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76074. * @param stride the stride (optional)
  76075. * @param instanced whether the buffer is instanced (optional)
  76076. * @param offset the offset of the data (optional)
  76077. * @param size the number of components (optional)
  76078. * @param type the type of the component (optional)
  76079. * @param normalized whether the data contains normalized data (optional)
  76080. * @param useBytes set to true if stride and offset are in bytes (optional)
  76081. */
  76082. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  76083. if (normalized === void 0) { normalized = false; }
  76084. if (useBytes === void 0) { useBytes = false; }
  76085. if (data instanceof Buffer) {
  76086. this._buffer = data;
  76087. this._ownsBuffer = false;
  76088. }
  76089. else {
  76090. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  76091. this._ownsBuffer = true;
  76092. }
  76093. this._kind = kind;
  76094. if (type == undefined) {
  76095. var data_1 = this.getData();
  76096. this.type = VertexBuffer.FLOAT;
  76097. if (data_1 instanceof Int8Array) {
  76098. this.type = VertexBuffer.BYTE;
  76099. }
  76100. else if (data_1 instanceof Uint8Array) {
  76101. this.type = VertexBuffer.UNSIGNED_BYTE;
  76102. }
  76103. else if (data_1 instanceof Int16Array) {
  76104. this.type = VertexBuffer.SHORT;
  76105. }
  76106. else if (data_1 instanceof Uint16Array) {
  76107. this.type = VertexBuffer.UNSIGNED_SHORT;
  76108. }
  76109. else if (data_1 instanceof Int32Array) {
  76110. this.type = VertexBuffer.INT;
  76111. }
  76112. else if (data_1 instanceof Uint32Array) {
  76113. this.type = VertexBuffer.UNSIGNED_INT;
  76114. }
  76115. }
  76116. else {
  76117. this.type = type;
  76118. }
  76119. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  76120. if (useBytes) {
  76121. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  76122. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  76123. this.byteOffset = offset || 0;
  76124. }
  76125. else {
  76126. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  76127. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  76128. this.byteOffset = (offset || 0) * typeByteLength;
  76129. }
  76130. this.normalized = normalized;
  76131. this._instanced = instanced !== undefined ? instanced : false;
  76132. this._instanceDivisor = instanced ? 1 : 0;
  76133. }
  76134. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  76135. /**
  76136. * Gets or sets the instance divisor when in instanced mode
  76137. */
  76138. get: function () {
  76139. return this._instanceDivisor;
  76140. },
  76141. set: function (value) {
  76142. this._instanceDivisor = value;
  76143. if (value == 0) {
  76144. this._instanced = false;
  76145. }
  76146. else {
  76147. this._instanced = true;
  76148. }
  76149. },
  76150. enumerable: true,
  76151. configurable: true
  76152. });
  76153. /** @hidden */
  76154. VertexBuffer.prototype._rebuild = function () {
  76155. if (!this._buffer) {
  76156. return;
  76157. }
  76158. this._buffer._rebuild();
  76159. };
  76160. /**
  76161. * Returns the kind of the VertexBuffer (string)
  76162. * @returns a string
  76163. */
  76164. VertexBuffer.prototype.getKind = function () {
  76165. return this._kind;
  76166. };
  76167. // Properties
  76168. /**
  76169. * Gets a boolean indicating if the VertexBuffer is updatable?
  76170. * @returns true if the buffer is updatable
  76171. */
  76172. VertexBuffer.prototype.isUpdatable = function () {
  76173. return this._buffer.isUpdatable();
  76174. };
  76175. /**
  76176. * Gets current buffer's data
  76177. * @returns a DataArray or null
  76178. */
  76179. VertexBuffer.prototype.getData = function () {
  76180. return this._buffer.getData();
  76181. };
  76182. /**
  76183. * Gets underlying native buffer
  76184. * @returns underlying native buffer
  76185. */
  76186. VertexBuffer.prototype.getBuffer = function () {
  76187. return this._buffer.getBuffer();
  76188. };
  76189. /**
  76190. * Gets the stride in float32 units (i.e. byte stride / 4).
  76191. * May not be an integer if the byte stride is not divisible by 4.
  76192. * DEPRECATED. Use byteStride instead.
  76193. * @returns the stride in float32 units
  76194. */
  76195. VertexBuffer.prototype.getStrideSize = function () {
  76196. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  76197. };
  76198. /**
  76199. * Returns the offset as a multiple of the type byte length.
  76200. * DEPRECATED. Use byteOffset instead.
  76201. * @returns the offset in bytes
  76202. */
  76203. VertexBuffer.prototype.getOffset = function () {
  76204. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  76205. };
  76206. /**
  76207. * Returns the number of components per vertex attribute (integer)
  76208. * @returns the size in float
  76209. */
  76210. VertexBuffer.prototype.getSize = function () {
  76211. return this._size;
  76212. };
  76213. /**
  76214. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  76215. * @returns true if this buffer is instanced
  76216. */
  76217. VertexBuffer.prototype.getIsInstanced = function () {
  76218. return this._instanced;
  76219. };
  76220. /**
  76221. * Returns the instancing divisor, zero for non-instanced (integer).
  76222. * @returns a number
  76223. */
  76224. VertexBuffer.prototype.getInstanceDivisor = function () {
  76225. return this._instanceDivisor;
  76226. };
  76227. // Methods
  76228. /**
  76229. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76230. * @param data defines the data to store
  76231. */
  76232. VertexBuffer.prototype.create = function (data) {
  76233. this._buffer.create(data);
  76234. };
  76235. /**
  76236. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  76237. * This function will create a new buffer if the current one is not updatable
  76238. * @param data defines the data to store
  76239. */
  76240. VertexBuffer.prototype.update = function (data) {
  76241. this._buffer.update(data);
  76242. };
  76243. /**
  76244. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  76245. * Returns the directly updated WebGLBuffer.
  76246. * @param data the new data
  76247. * @param offset the new offset
  76248. * @param useBytes set to true if the offset is in bytes
  76249. */
  76250. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  76251. if (useBytes === void 0) { useBytes = false; }
  76252. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  76253. };
  76254. /**
  76255. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  76256. */
  76257. VertexBuffer.prototype.dispose = function () {
  76258. if (this._ownsBuffer) {
  76259. this._buffer.dispose();
  76260. }
  76261. };
  76262. /**
  76263. * Enumerates each value of this vertex buffer as numbers.
  76264. * @param count the number of values to enumerate
  76265. * @param callback the callback function called for each value
  76266. */
  76267. VertexBuffer.prototype.forEach = function (count, callback) {
  76268. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  76269. };
  76270. /**
  76271. * Deduces the stride given a kind.
  76272. * @param kind The kind string to deduce
  76273. * @returns The deduced stride
  76274. */
  76275. VertexBuffer.DeduceStride = function (kind) {
  76276. switch (kind) {
  76277. case VertexBuffer.UVKind:
  76278. case VertexBuffer.UV2Kind:
  76279. case VertexBuffer.UV3Kind:
  76280. case VertexBuffer.UV4Kind:
  76281. case VertexBuffer.UV5Kind:
  76282. case VertexBuffer.UV6Kind:
  76283. return 2;
  76284. case VertexBuffer.NormalKind:
  76285. case VertexBuffer.PositionKind:
  76286. return 3;
  76287. case VertexBuffer.ColorKind:
  76288. case VertexBuffer.MatricesIndicesKind:
  76289. case VertexBuffer.MatricesIndicesExtraKind:
  76290. case VertexBuffer.MatricesWeightsKind:
  76291. case VertexBuffer.MatricesWeightsExtraKind:
  76292. case VertexBuffer.TangentKind:
  76293. return 4;
  76294. default:
  76295. throw new Error("Invalid kind '" + kind + "'");
  76296. }
  76297. };
  76298. /**
  76299. * Gets the byte length of the given type.
  76300. * @param type the type
  76301. * @returns the number of bytes
  76302. */
  76303. VertexBuffer.GetTypeByteLength = function (type) {
  76304. switch (type) {
  76305. case VertexBuffer.BYTE:
  76306. case VertexBuffer.UNSIGNED_BYTE:
  76307. return 1;
  76308. case VertexBuffer.SHORT:
  76309. case VertexBuffer.UNSIGNED_SHORT:
  76310. return 2;
  76311. case VertexBuffer.INT:
  76312. case VertexBuffer.FLOAT:
  76313. return 4;
  76314. default:
  76315. throw new Error("Invalid type '" + type + "'");
  76316. }
  76317. };
  76318. /**
  76319. * Enumerates each value of the given parameters as numbers.
  76320. * @param data the data to enumerate
  76321. * @param byteOffset the byte offset of the data
  76322. * @param byteStride the byte stride of the data
  76323. * @param componentCount the number of components per element
  76324. * @param componentType the type of the component
  76325. * @param count the total number of components
  76326. * @param normalized whether the data is normalized
  76327. * @param callback the callback function called for each value
  76328. */
  76329. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  76330. if (data instanceof Array) {
  76331. var offset = byteOffset / 4;
  76332. var stride = byteStride / 4;
  76333. for (var index = 0; index < count; index += componentCount) {
  76334. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76335. callback(data[offset + componentIndex], index + componentIndex);
  76336. }
  76337. offset += stride;
  76338. }
  76339. }
  76340. else {
  76341. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  76342. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  76343. for (var index = 0; index < count; index += componentCount) {
  76344. var componentByteOffset = byteOffset;
  76345. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76346. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  76347. callback(value, index + componentIndex);
  76348. componentByteOffset += componentByteLength;
  76349. }
  76350. byteOffset += byteStride;
  76351. }
  76352. }
  76353. };
  76354. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  76355. switch (type) {
  76356. case VertexBuffer.BYTE: {
  76357. var value = dataView.getInt8(byteOffset);
  76358. if (normalized) {
  76359. value = Math.max(value / 127, -1);
  76360. }
  76361. return value;
  76362. }
  76363. case VertexBuffer.UNSIGNED_BYTE: {
  76364. var value = dataView.getUint8(byteOffset);
  76365. if (normalized) {
  76366. value = value / 255;
  76367. }
  76368. return value;
  76369. }
  76370. case VertexBuffer.SHORT: {
  76371. var value = dataView.getInt16(byteOffset, true);
  76372. if (normalized) {
  76373. value = Math.max(value / 16383, -1);
  76374. }
  76375. return value;
  76376. }
  76377. case VertexBuffer.UNSIGNED_SHORT: {
  76378. var value = dataView.getUint16(byteOffset, true);
  76379. if (normalized) {
  76380. value = value / 65535;
  76381. }
  76382. return value;
  76383. }
  76384. case VertexBuffer.FLOAT: {
  76385. return dataView.getFloat32(byteOffset, true);
  76386. }
  76387. default: {
  76388. throw new Error("Invalid component type " + type);
  76389. }
  76390. }
  76391. };
  76392. /**
  76393. * The byte type.
  76394. */
  76395. VertexBuffer.BYTE = 5120;
  76396. /**
  76397. * The unsigned byte type.
  76398. */
  76399. VertexBuffer.UNSIGNED_BYTE = 5121;
  76400. /**
  76401. * The short type.
  76402. */
  76403. VertexBuffer.SHORT = 5122;
  76404. /**
  76405. * The unsigned short type.
  76406. */
  76407. VertexBuffer.UNSIGNED_SHORT = 5123;
  76408. /**
  76409. * The integer type.
  76410. */
  76411. VertexBuffer.INT = 5124;
  76412. /**
  76413. * The unsigned integer type.
  76414. */
  76415. VertexBuffer.UNSIGNED_INT = 5125;
  76416. /**
  76417. * The float type.
  76418. */
  76419. VertexBuffer.FLOAT = 5126;
  76420. // Enums
  76421. /**
  76422. * Positions
  76423. */
  76424. VertexBuffer.PositionKind = "position";
  76425. /**
  76426. * Normals
  76427. */
  76428. VertexBuffer.NormalKind = "normal";
  76429. /**
  76430. * Tangents
  76431. */
  76432. VertexBuffer.TangentKind = "tangent";
  76433. /**
  76434. * Texture coordinates
  76435. */
  76436. VertexBuffer.UVKind = "uv";
  76437. /**
  76438. * Texture coordinates 2
  76439. */
  76440. VertexBuffer.UV2Kind = "uv2";
  76441. /**
  76442. * Texture coordinates 3
  76443. */
  76444. VertexBuffer.UV3Kind = "uv3";
  76445. /**
  76446. * Texture coordinates 4
  76447. */
  76448. VertexBuffer.UV4Kind = "uv4";
  76449. /**
  76450. * Texture coordinates 5
  76451. */
  76452. VertexBuffer.UV5Kind = "uv5";
  76453. /**
  76454. * Texture coordinates 6
  76455. */
  76456. VertexBuffer.UV6Kind = "uv6";
  76457. /**
  76458. * Colors
  76459. */
  76460. VertexBuffer.ColorKind = "color";
  76461. /**
  76462. * Matrix indices (for bones)
  76463. */
  76464. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  76465. /**
  76466. * Matrix weights (for bones)
  76467. */
  76468. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  76469. /**
  76470. * Additional matrix indices (for bones)
  76471. */
  76472. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  76473. /**
  76474. * Additional matrix weights (for bones)
  76475. */
  76476. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  76477. return VertexBuffer;
  76478. }());
  76479. /***/ }),
  76480. /***/ "./Meshes/csg.ts":
  76481. /*!***********************!*\
  76482. !*** ./Meshes/csg.ts ***!
  76483. \***********************/
  76484. /*! exports provided: CSG */
  76485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76486. "use strict";
  76487. __webpack_require__.r(__webpack_exports__);
  76488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  76489. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76490. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  76491. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  76492. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  76493. /**
  76494. * Unique ID when we import meshes from Babylon to CSG
  76495. */
  76496. var currentCSGMeshId = 0;
  76497. /**
  76498. * Represents a vertex of a polygon. Use your own vertex class instead of this
  76499. * one to provide additional features like texture coordinates and vertex
  76500. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  76501. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  76502. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  76503. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  76504. * is not used anywhere else.
  76505. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  76506. */
  76507. var Vertex = /** @class */ (function () {
  76508. /**
  76509. * Initializes the vertex
  76510. * @param pos The position of the vertex
  76511. * @param normal The normal of the vertex
  76512. * @param uv The texture coordinate of the vertex
  76513. */
  76514. function Vertex(
  76515. /**
  76516. * The position of the vertex
  76517. */
  76518. pos,
  76519. /**
  76520. * The normal of the vertex
  76521. */
  76522. normal,
  76523. /**
  76524. * The texture coordinate of the vertex
  76525. */
  76526. uv) {
  76527. this.pos = pos;
  76528. this.normal = normal;
  76529. this.uv = uv;
  76530. }
  76531. /**
  76532. * Make a clone, or deep copy, of the vertex
  76533. * @returns A new Vertex
  76534. */
  76535. Vertex.prototype.clone = function () {
  76536. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  76537. };
  76538. /**
  76539. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  76540. * orientation of a polygon is flipped.
  76541. */
  76542. Vertex.prototype.flip = function () {
  76543. this.normal = this.normal.scale(-1);
  76544. };
  76545. /**
  76546. * Create a new vertex between this vertex and `other` by linearly
  76547. * interpolating all properties using a parameter of `t`. Subclasses should
  76548. * override this to interpolate additional properties.
  76549. * @param other the vertex to interpolate against
  76550. * @param t The factor used to linearly interpolate between the vertices
  76551. */
  76552. Vertex.prototype.interpolate = function (other, t) {
  76553. 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));
  76554. };
  76555. return Vertex;
  76556. }());
  76557. /**
  76558. * Represents a plane in 3D space.
  76559. */
  76560. var Plane = /** @class */ (function () {
  76561. /**
  76562. * Initializes the plane
  76563. * @param normal The normal for the plane
  76564. * @param w
  76565. */
  76566. function Plane(normal, w) {
  76567. this.normal = normal;
  76568. this.w = w;
  76569. }
  76570. /**
  76571. * Construct a plane from three points
  76572. * @param a Point a
  76573. * @param b Point b
  76574. * @param c Point c
  76575. */
  76576. Plane.FromPoints = function (a, b, c) {
  76577. var v0 = c.subtract(a);
  76578. var v1 = b.subtract(a);
  76579. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  76580. return null;
  76581. }
  76582. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  76583. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  76584. };
  76585. /**
  76586. * Clone, or make a deep copy of the plane
  76587. * @returns a new Plane
  76588. */
  76589. Plane.prototype.clone = function () {
  76590. return new Plane(this.normal.clone(), this.w);
  76591. };
  76592. /**
  76593. * Flip the face of the plane
  76594. */
  76595. Plane.prototype.flip = function () {
  76596. this.normal.scaleInPlace(-1);
  76597. this.w = -this.w;
  76598. };
  76599. /**
  76600. * Split `polygon` by this plane if needed, then put the polygon or polygon
  76601. * fragments in the appropriate lists. Coplanar polygons go into either
  76602. `* coplanarFront` or `coplanarBack` depending on their orientation with
  76603. * respect to this plane. Polygons in front or in back of this plane go into
  76604. * either `front` or `back`
  76605. * @param polygon The polygon to be split
  76606. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  76607. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  76608. * @param front Will contain the polygons in front of the plane
  76609. * @param back Will contain the polygons begind the plane
  76610. */
  76611. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  76612. var COPLANAR = 0;
  76613. var FRONT = 1;
  76614. var BACK = 2;
  76615. var SPANNING = 3;
  76616. // Classify each point as well as the entire polygon into one of the above
  76617. // four classes.
  76618. var polygonType = 0;
  76619. var types = [];
  76620. var i;
  76621. var t;
  76622. for (i = 0; i < polygon.vertices.length; i++) {
  76623. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  76624. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  76625. polygonType |= type;
  76626. types.push(type);
  76627. }
  76628. // Put the polygon in the correct list, splitting it when necessary
  76629. switch (polygonType) {
  76630. case COPLANAR:
  76631. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  76632. break;
  76633. case FRONT:
  76634. front.push(polygon);
  76635. break;
  76636. case BACK:
  76637. back.push(polygon);
  76638. break;
  76639. case SPANNING:
  76640. var f = [], b = [];
  76641. for (i = 0; i < polygon.vertices.length; i++) {
  76642. var j = (i + 1) % polygon.vertices.length;
  76643. var ti = types[i], tj = types[j];
  76644. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  76645. if (ti !== BACK) {
  76646. f.push(vi);
  76647. }
  76648. if (ti !== FRONT) {
  76649. b.push(ti !== BACK ? vi.clone() : vi);
  76650. }
  76651. if ((ti | tj) === SPANNING) {
  76652. 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));
  76653. var v = vi.interpolate(vj, t);
  76654. f.push(v);
  76655. b.push(v.clone());
  76656. }
  76657. }
  76658. var poly;
  76659. if (f.length >= 3) {
  76660. poly = new Polygon(f, polygon.shared);
  76661. if (poly.plane) {
  76662. front.push(poly);
  76663. }
  76664. }
  76665. if (b.length >= 3) {
  76666. poly = new Polygon(b, polygon.shared);
  76667. if (poly.plane) {
  76668. back.push(poly);
  76669. }
  76670. }
  76671. break;
  76672. }
  76673. };
  76674. /**
  76675. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  76676. * point is on the plane
  76677. */
  76678. Plane.EPSILON = 1e-5;
  76679. return Plane;
  76680. }());
  76681. /**
  76682. * Represents a convex polygon. The vertices used to initialize a polygon must
  76683. * be coplanar and form a convex loop.
  76684. *
  76685. * Each convex polygon has a `shared` property, which is shared between all
  76686. * polygons that are clones of each other or were split from the same polygon.
  76687. * This can be used to define per-polygon properties (such as surface color)
  76688. */
  76689. var Polygon = /** @class */ (function () {
  76690. /**
  76691. * Initializes the polygon
  76692. * @param vertices The vertices of the polygon
  76693. * @param shared The properties shared across all polygons
  76694. */
  76695. function Polygon(vertices, shared) {
  76696. this.vertices = vertices;
  76697. this.shared = shared;
  76698. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  76699. }
  76700. /**
  76701. * Clones, or makes a deep copy, or the polygon
  76702. */
  76703. Polygon.prototype.clone = function () {
  76704. var vertices = this.vertices.map(function (v) { return v.clone(); });
  76705. return new Polygon(vertices, this.shared);
  76706. };
  76707. /**
  76708. * Flips the faces of the polygon
  76709. */
  76710. Polygon.prototype.flip = function () {
  76711. this.vertices.reverse().map(function (v) { v.flip(); });
  76712. this.plane.flip();
  76713. };
  76714. return Polygon;
  76715. }());
  76716. /**
  76717. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  76718. * by picking a polygon to split along. That polygon (and all other coplanar
  76719. * polygons) are added directly to that node and the other polygons are added to
  76720. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  76721. * no distinction between internal and leaf nodes
  76722. */
  76723. var Node = /** @class */ (function () {
  76724. /**
  76725. * Initializes the node
  76726. * @param polygons A collection of polygons held in the node
  76727. */
  76728. function Node(polygons) {
  76729. this.plane = null;
  76730. this.front = null;
  76731. this.back = null;
  76732. this.polygons = new Array();
  76733. if (polygons) {
  76734. this.build(polygons);
  76735. }
  76736. }
  76737. /**
  76738. * Clones, or makes a deep copy, of the node
  76739. * @returns The cloned node
  76740. */
  76741. Node.prototype.clone = function () {
  76742. var node = new Node();
  76743. node.plane = this.plane && this.plane.clone();
  76744. node.front = this.front && this.front.clone();
  76745. node.back = this.back && this.back.clone();
  76746. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  76747. return node;
  76748. };
  76749. /**
  76750. * Convert solid space to empty space and empty space to solid space
  76751. */
  76752. Node.prototype.invert = function () {
  76753. for (var i = 0; i < this.polygons.length; i++) {
  76754. this.polygons[i].flip();
  76755. }
  76756. if (this.plane) {
  76757. this.plane.flip();
  76758. }
  76759. if (this.front) {
  76760. this.front.invert();
  76761. }
  76762. if (this.back) {
  76763. this.back.invert();
  76764. }
  76765. var temp = this.front;
  76766. this.front = this.back;
  76767. this.back = temp;
  76768. };
  76769. /**
  76770. * Recursively remove all polygons in `polygons` that are inside this BSP
  76771. * tree.
  76772. * @param polygons Polygons to remove from the BSP
  76773. * @returns Polygons clipped from the BSP
  76774. */
  76775. Node.prototype.clipPolygons = function (polygons) {
  76776. if (!this.plane) {
  76777. return polygons.slice();
  76778. }
  76779. var front = new Array(), back = new Array();
  76780. for (var i = 0; i < polygons.length; i++) {
  76781. this.plane.splitPolygon(polygons[i], front, back, front, back);
  76782. }
  76783. if (this.front) {
  76784. front = this.front.clipPolygons(front);
  76785. }
  76786. if (this.back) {
  76787. back = this.back.clipPolygons(back);
  76788. }
  76789. else {
  76790. back = [];
  76791. }
  76792. return front.concat(back);
  76793. };
  76794. /**
  76795. * Remove all polygons in this BSP tree that are inside the other BSP tree
  76796. * `bsp`.
  76797. * @param bsp BSP containing polygons to remove from this BSP
  76798. */
  76799. Node.prototype.clipTo = function (bsp) {
  76800. this.polygons = bsp.clipPolygons(this.polygons);
  76801. if (this.front) {
  76802. this.front.clipTo(bsp);
  76803. }
  76804. if (this.back) {
  76805. this.back.clipTo(bsp);
  76806. }
  76807. };
  76808. /**
  76809. * Return a list of all polygons in this BSP tree
  76810. * @returns List of all polygons in this BSP tree
  76811. */
  76812. Node.prototype.allPolygons = function () {
  76813. var polygons = this.polygons.slice();
  76814. if (this.front) {
  76815. polygons = polygons.concat(this.front.allPolygons());
  76816. }
  76817. if (this.back) {
  76818. polygons = polygons.concat(this.back.allPolygons());
  76819. }
  76820. return polygons;
  76821. };
  76822. /**
  76823. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  76824. * new polygons are filtered down to the bottom of the tree and become new
  76825. * nodes there. Each set of polygons is partitioned using the first polygon
  76826. * (no heuristic is used to pick a good split)
  76827. * @param polygons Polygons used to construct the BSP tree
  76828. */
  76829. Node.prototype.build = function (polygons) {
  76830. if (!polygons.length) {
  76831. return;
  76832. }
  76833. if (!this.plane) {
  76834. this.plane = polygons[0].plane.clone();
  76835. }
  76836. var front = new Array(), back = new Array();
  76837. for (var i = 0; i < polygons.length; i++) {
  76838. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  76839. }
  76840. if (front.length) {
  76841. if (!this.front) {
  76842. this.front = new Node();
  76843. }
  76844. this.front.build(front);
  76845. }
  76846. if (back.length) {
  76847. if (!this.back) {
  76848. this.back = new Node();
  76849. }
  76850. this.back.build(back);
  76851. }
  76852. };
  76853. return Node;
  76854. }());
  76855. /**
  76856. * Class for building Constructive Solid Geometry
  76857. */
  76858. var CSG = /** @class */ (function () {
  76859. function CSG() {
  76860. this.polygons = new Array();
  76861. }
  76862. /**
  76863. * Convert the Mesh to CSG
  76864. * @param mesh The Mesh to convert to CSG
  76865. * @returns A new CSG from the Mesh
  76866. */
  76867. CSG.FromMesh = function (mesh) {
  76868. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  76869. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  76870. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  76871. mesh.computeWorldMatrix(true);
  76872. matrix = mesh.getWorldMatrix();
  76873. meshPosition = mesh.position.clone();
  76874. meshRotation = mesh.rotation.clone();
  76875. if (mesh.rotationQuaternion) {
  76876. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  76877. }
  76878. meshScaling = mesh.scaling.clone();
  76879. }
  76880. else {
  76881. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  76882. }
  76883. 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);
  76884. var subMeshes = mesh.subMeshes;
  76885. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  76886. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  76887. vertices = [];
  76888. for (var j = 0; j < 3; j++) {
  76889. 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]);
  76890. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  76891. 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]);
  76892. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  76893. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  76894. vertex = new Vertex(position, normal, uv);
  76895. vertices.push(vertex);
  76896. }
  76897. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  76898. // To handle the case of degenerated triangle
  76899. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  76900. if (polygon.plane) {
  76901. polygons.push(polygon);
  76902. }
  76903. }
  76904. }
  76905. var csg = CSG.FromPolygons(polygons);
  76906. csg.matrix = matrix;
  76907. csg.position = meshPosition;
  76908. csg.rotation = meshRotation;
  76909. csg.scaling = meshScaling;
  76910. csg.rotationQuaternion = meshRotationQuaternion;
  76911. currentCSGMeshId++;
  76912. return csg;
  76913. };
  76914. /**
  76915. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  76916. * @param polygons Polygons used to construct a CSG solid
  76917. */
  76918. CSG.FromPolygons = function (polygons) {
  76919. var csg = new CSG();
  76920. csg.polygons = polygons;
  76921. return csg;
  76922. };
  76923. /**
  76924. * Clones, or makes a deep copy, of the CSG
  76925. * @returns A new CSG
  76926. */
  76927. CSG.prototype.clone = function () {
  76928. var csg = new CSG();
  76929. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  76930. csg.copyTransformAttributes(this);
  76931. return csg;
  76932. };
  76933. /**
  76934. * Unions this CSG with another CSG
  76935. * @param csg The CSG to union against this CSG
  76936. * @returns The unioned CSG
  76937. */
  76938. CSG.prototype.union = function (csg) {
  76939. var a = new Node(this.clone().polygons);
  76940. var b = new Node(csg.clone().polygons);
  76941. a.clipTo(b);
  76942. b.clipTo(a);
  76943. b.invert();
  76944. b.clipTo(a);
  76945. b.invert();
  76946. a.build(b.allPolygons());
  76947. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  76948. };
  76949. /**
  76950. * Unions this CSG with another CSG in place
  76951. * @param csg The CSG to union against this CSG
  76952. */
  76953. CSG.prototype.unionInPlace = function (csg) {
  76954. var a = new Node(this.polygons);
  76955. var b = new Node(csg.polygons);
  76956. a.clipTo(b);
  76957. b.clipTo(a);
  76958. b.invert();
  76959. b.clipTo(a);
  76960. b.invert();
  76961. a.build(b.allPolygons());
  76962. this.polygons = a.allPolygons();
  76963. };
  76964. /**
  76965. * Subtracts this CSG with another CSG
  76966. * @param csg The CSG to subtract against this CSG
  76967. * @returns A new CSG
  76968. */
  76969. CSG.prototype.subtract = function (csg) {
  76970. var a = new Node(this.clone().polygons);
  76971. var b = new Node(csg.clone().polygons);
  76972. a.invert();
  76973. a.clipTo(b);
  76974. b.clipTo(a);
  76975. b.invert();
  76976. b.clipTo(a);
  76977. b.invert();
  76978. a.build(b.allPolygons());
  76979. a.invert();
  76980. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  76981. };
  76982. /**
  76983. * Subtracts this CSG with another CSG in place
  76984. * @param csg The CSG to subtact against this CSG
  76985. */
  76986. CSG.prototype.subtractInPlace = function (csg) {
  76987. var a = new Node(this.polygons);
  76988. var b = new Node(csg.polygons);
  76989. a.invert();
  76990. a.clipTo(b);
  76991. b.clipTo(a);
  76992. b.invert();
  76993. b.clipTo(a);
  76994. b.invert();
  76995. a.build(b.allPolygons());
  76996. a.invert();
  76997. this.polygons = a.allPolygons();
  76998. };
  76999. /**
  77000. * Intersect this CSG with another CSG
  77001. * @param csg The CSG to intersect against this CSG
  77002. * @returns A new CSG
  77003. */
  77004. CSG.prototype.intersect = function (csg) {
  77005. var a = new Node(this.clone().polygons);
  77006. var b = new Node(csg.clone().polygons);
  77007. a.invert();
  77008. b.clipTo(a);
  77009. b.invert();
  77010. a.clipTo(b);
  77011. b.clipTo(a);
  77012. a.build(b.allPolygons());
  77013. a.invert();
  77014. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77015. };
  77016. /**
  77017. * Intersects this CSG with another CSG in place
  77018. * @param csg The CSG to intersect against this CSG
  77019. */
  77020. CSG.prototype.intersectInPlace = function (csg) {
  77021. var a = new Node(this.polygons);
  77022. var b = new Node(csg.polygons);
  77023. a.invert();
  77024. b.clipTo(a);
  77025. b.invert();
  77026. a.clipTo(b);
  77027. b.clipTo(a);
  77028. a.build(b.allPolygons());
  77029. a.invert();
  77030. this.polygons = a.allPolygons();
  77031. };
  77032. /**
  77033. * Return a new CSG solid with solid and empty space switched. This solid is
  77034. * not modified.
  77035. * @returns A new CSG solid with solid and empty space switched
  77036. */
  77037. CSG.prototype.inverse = function () {
  77038. var csg = this.clone();
  77039. csg.inverseInPlace();
  77040. return csg;
  77041. };
  77042. /**
  77043. * Inverses the CSG in place
  77044. */
  77045. CSG.prototype.inverseInPlace = function () {
  77046. this.polygons.map(function (p) { p.flip(); });
  77047. };
  77048. /**
  77049. * This is used to keep meshes transformations so they can be restored
  77050. * when we build back a Babylon Mesh
  77051. * NB : All CSG operations are performed in world coordinates
  77052. * @param csg The CSG to copy the transform attributes from
  77053. * @returns This CSG
  77054. */
  77055. CSG.prototype.copyTransformAttributes = function (csg) {
  77056. this.matrix = csg.matrix;
  77057. this.position = csg.position;
  77058. this.rotation = csg.rotation;
  77059. this.scaling = csg.scaling;
  77060. this.rotationQuaternion = csg.rotationQuaternion;
  77061. return this;
  77062. };
  77063. /**
  77064. * Build Raw mesh from CSG
  77065. * Coordinates here are in world space
  77066. * @param name The name of the mesh geometry
  77067. * @param scene The Scene
  77068. * @param keepSubMeshes Specifies if the submeshes should be kept
  77069. * @returns A new Mesh
  77070. */
  77071. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  77072. var matrix = this.matrix.clone();
  77073. matrix.invert();
  77074. 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;
  77075. if (keepSubMeshes) {
  77076. // Sort Polygons, since subMeshes are indices range
  77077. polygons.sort(function (a, b) {
  77078. if (a.shared.meshId === b.shared.meshId) {
  77079. return a.shared.subMeshId - b.shared.subMeshId;
  77080. }
  77081. else {
  77082. return a.shared.meshId - b.shared.meshId;
  77083. }
  77084. });
  77085. }
  77086. for (var i = 0, il = polygons.length; i < il; i++) {
  77087. polygon = polygons[i];
  77088. // Building SubMeshes
  77089. if (!subMesh_dict[polygon.shared.meshId]) {
  77090. subMesh_dict[polygon.shared.meshId] = {};
  77091. }
  77092. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  77093. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  77094. indexStart: +Infinity,
  77095. indexEnd: -Infinity,
  77096. materialIndex: polygon.shared.materialIndex
  77097. };
  77098. }
  77099. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  77100. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  77101. polygonIndices[0] = 0;
  77102. polygonIndices[1] = j - 1;
  77103. polygonIndices[2] = j;
  77104. for (var k = 0; k < 3; k++) {
  77105. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  77106. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  77107. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  77108. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  77109. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  77110. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  77111. // Check if 2 points can be merged
  77112. if (!(typeof vertex_idx !== 'undefined' &&
  77113. normals[vertex_idx * 3] === localNormal.x &&
  77114. normals[vertex_idx * 3 + 1] === localNormal.y &&
  77115. normals[vertex_idx * 3 + 2] === localNormal.z &&
  77116. uvs[vertex_idx * 2] === uv.x &&
  77117. uvs[vertex_idx * 2 + 1] === uv.y)) {
  77118. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  77119. uvs.push(uv.x, uv.y);
  77120. normals.push(normal.x, normal.y, normal.z);
  77121. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  77122. }
  77123. indices.push(vertex_idx);
  77124. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  77125. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  77126. currentIndex++;
  77127. }
  77128. }
  77129. }
  77130. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  77131. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  77132. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  77133. mesh.setIndices(indices, null);
  77134. if (keepSubMeshes) {
  77135. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  77136. var materialIndexOffset = 0, materialMaxIndex;
  77137. mesh.subMeshes = new Array();
  77138. for (var m in subMesh_dict) {
  77139. materialMaxIndex = -1;
  77140. for (var sm in subMesh_dict[m]) {
  77141. subMesh_obj = subMesh_dict[m][sm];
  77142. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  77143. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  77144. }
  77145. materialIndexOffset += ++materialMaxIndex;
  77146. }
  77147. }
  77148. return mesh;
  77149. };
  77150. /**
  77151. * Build Mesh from CSG taking material and transforms into account
  77152. * @param name The name of the Mesh
  77153. * @param material The material of the Mesh
  77154. * @param scene The Scene
  77155. * @param keepSubMeshes Specifies if submeshes should be kept
  77156. * @returns The new Mesh
  77157. */
  77158. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  77159. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  77160. mesh.material = material;
  77161. mesh.position.copyFrom(this.position);
  77162. mesh.rotation.copyFrom(this.rotation);
  77163. if (this.rotationQuaternion) {
  77164. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  77165. }
  77166. mesh.scaling.copyFrom(this.scaling);
  77167. mesh.computeWorldMatrix(true);
  77168. return mesh;
  77169. };
  77170. return CSG;
  77171. }());
  77172. /***/ }),
  77173. /***/ "./Meshes/geometry.ts":
  77174. /*!****************************!*\
  77175. !*** ./Meshes/geometry.ts ***!
  77176. \****************************/
  77177. /*! exports provided: Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry */
  77178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77179. "use strict";
  77180. __webpack_require__.r(__webpack_exports__);
  77181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  77182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _PrimitiveGeometry; });
  77183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return RibbonGeometry; });
  77184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return BoxGeometry; });
  77185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return SphereGeometry; });
  77186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return DiscGeometry; });
  77187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return CylinderGeometry; });
  77188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return TorusGeometry; });
  77189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return GroundGeometry; });
  77190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return TiledGroundGeometry; });
  77191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return PlaneGeometry; });
  77192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return TorusKnotGeometry; });
  77193. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  77194. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77195. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77196. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  77197. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  77198. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  77199. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77200. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  77201. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  77202. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  77203. /**
  77204. * Class used to store geometry data (vertex buffers + index buffer)
  77205. */
  77206. var Geometry = /** @class */ (function () {
  77207. /**
  77208. * Creates a new geometry
  77209. * @param id defines the unique ID
  77210. * @param scene defines the hosting scene
  77211. * @param vertexData defines the VertexData used to get geometry data
  77212. * @param updatable defines if geometry must be updatable (false by default)
  77213. * @param mesh defines the mesh that will be associated with the geometry
  77214. */
  77215. function Geometry(id, scene, vertexData, updatable, mesh) {
  77216. if (updatable === void 0) { updatable = false; }
  77217. if (mesh === void 0) { mesh = null; }
  77218. /**
  77219. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77220. */
  77221. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77222. this._totalVertices = 0;
  77223. this._isDisposed = false;
  77224. this._indexBufferIsUpdatable = false;
  77225. this.id = id;
  77226. this.uniqueId = scene.getUniqueId();
  77227. this._engine = scene.getEngine();
  77228. this._meshes = [];
  77229. this._scene = scene;
  77230. //Init vertex buffer cache
  77231. this._vertexBuffers = {};
  77232. this._indices = [];
  77233. this._updatable = updatable;
  77234. // vertexData
  77235. if (vertexData) {
  77236. this.setAllVerticesData(vertexData, updatable);
  77237. }
  77238. else {
  77239. this._totalVertices = 0;
  77240. this._indices = [];
  77241. }
  77242. if (this._engine.getCaps().vertexArrayObject) {
  77243. this._vertexArrayObjects = {};
  77244. }
  77245. // applyToMesh
  77246. if (mesh) {
  77247. this.applyToMesh(mesh);
  77248. mesh.computeWorldMatrix(true);
  77249. }
  77250. }
  77251. Object.defineProperty(Geometry.prototype, "boundingBias", {
  77252. /**
  77253. * 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
  77254. */
  77255. get: function () {
  77256. return this._boundingBias;
  77257. },
  77258. /**
  77259. * 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
  77260. */
  77261. set: function (value) {
  77262. if (this._boundingBias) {
  77263. this._boundingBias.copyFrom(value);
  77264. }
  77265. else {
  77266. this._boundingBias = value.clone();
  77267. }
  77268. this._updateBoundingInfo(true, null);
  77269. },
  77270. enumerable: true,
  77271. configurable: true
  77272. });
  77273. /**
  77274. * Static function used to attach a new empty geometry to a mesh
  77275. * @param mesh defines the mesh to attach the geometry to
  77276. * @returns the new Geometry
  77277. */
  77278. Geometry.CreateGeometryForMesh = function (mesh) {
  77279. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  77280. geometry.applyToMesh(mesh);
  77281. return geometry;
  77282. };
  77283. Object.defineProperty(Geometry.prototype, "extend", {
  77284. /**
  77285. * Gets the current extend of the geometry
  77286. */
  77287. get: function () {
  77288. return this._extend;
  77289. },
  77290. enumerable: true,
  77291. configurable: true
  77292. });
  77293. /**
  77294. * Gets the hosting scene
  77295. * @returns the hosting Scene
  77296. */
  77297. Geometry.prototype.getScene = function () {
  77298. return this._scene;
  77299. };
  77300. /**
  77301. * Gets the hosting engine
  77302. * @returns the hosting Engine
  77303. */
  77304. Geometry.prototype.getEngine = function () {
  77305. return this._engine;
  77306. };
  77307. /**
  77308. * Defines if the geometry is ready to use
  77309. * @returns true if the geometry is ready to be used
  77310. */
  77311. Geometry.prototype.isReady = function () {
  77312. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77313. };
  77314. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  77315. /**
  77316. * Gets a value indicating that the geometry should not be serialized
  77317. */
  77318. get: function () {
  77319. for (var index = 0; index < this._meshes.length; index++) {
  77320. if (!this._meshes[index].doNotSerialize) {
  77321. return false;
  77322. }
  77323. }
  77324. return true;
  77325. },
  77326. enumerable: true,
  77327. configurable: true
  77328. });
  77329. /** @hidden */
  77330. Geometry.prototype._rebuild = function () {
  77331. if (this._vertexArrayObjects) {
  77332. this._vertexArrayObjects = {};
  77333. }
  77334. // Index buffer
  77335. if (this._meshes.length !== 0 && this._indices) {
  77336. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  77337. }
  77338. // Vertex buffers
  77339. for (var key in this._vertexBuffers) {
  77340. var vertexBuffer = this._vertexBuffers[key];
  77341. vertexBuffer._rebuild();
  77342. }
  77343. };
  77344. /**
  77345. * Affects all geometry data in one call
  77346. * @param vertexData defines the geometry data
  77347. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77348. */
  77349. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  77350. vertexData.applyToGeometry(this, updatable);
  77351. this.notifyUpdate();
  77352. };
  77353. /**
  77354. * Set specific vertex data
  77355. * @param kind defines the data kind (Position, normal, etc...)
  77356. * @param data defines the vertex data to use
  77357. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77358. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77359. */
  77360. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  77361. if (updatable === void 0) { updatable = false; }
  77362. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  77363. this.setVerticesBuffer(buffer);
  77364. };
  77365. /**
  77366. * Removes a specific vertex data
  77367. * @param kind defines the data kind (Position, normal, etc...)
  77368. */
  77369. Geometry.prototype.removeVerticesData = function (kind) {
  77370. if (this._vertexBuffers[kind]) {
  77371. this._vertexBuffers[kind].dispose();
  77372. delete this._vertexBuffers[kind];
  77373. }
  77374. };
  77375. /**
  77376. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77377. * @param buffer defines the vertex buffer to use
  77378. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77379. */
  77380. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  77381. if (totalVertices === void 0) { totalVertices = null; }
  77382. var kind = buffer.getKind();
  77383. if (this._vertexBuffers[kind]) {
  77384. this._vertexBuffers[kind].dispose();
  77385. }
  77386. this._vertexBuffers[kind] = buffer;
  77387. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77388. var data = buffer.getData();
  77389. if (totalVertices != null) {
  77390. this._totalVertices = totalVertices;
  77391. }
  77392. else {
  77393. if (data != null) {
  77394. this._totalVertices = data.length / (buffer.byteStride / 4);
  77395. }
  77396. }
  77397. this._updateExtend(data);
  77398. this._resetPointsArrayCache();
  77399. var meshes = this._meshes;
  77400. var numOfMeshes = meshes.length;
  77401. for (var index = 0; index < numOfMeshes; index++) {
  77402. var mesh = meshes[index];
  77403. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77404. mesh._createGlobalSubMesh(false);
  77405. mesh.computeWorldMatrix(true);
  77406. }
  77407. }
  77408. this.notifyUpdate(kind);
  77409. if (this._vertexArrayObjects) {
  77410. this._disposeVertexArrayObjects();
  77411. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  77412. }
  77413. };
  77414. /**
  77415. * Update a specific vertex buffer
  77416. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77417. * It will do nothing if the buffer is not updatable
  77418. * @param kind defines the data kind (Position, normal, etc...)
  77419. * @param data defines the data to use
  77420. * @param offset defines the offset in the target buffer where to store the data
  77421. * @param useBytes set to true if the offset is in bytes
  77422. */
  77423. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  77424. if (useBytes === void 0) { useBytes = false; }
  77425. var vertexBuffer = this.getVertexBuffer(kind);
  77426. if (!vertexBuffer) {
  77427. return;
  77428. }
  77429. vertexBuffer.updateDirectly(data, offset, useBytes);
  77430. this.notifyUpdate(kind);
  77431. };
  77432. /**
  77433. * Update a specific vertex buffer
  77434. * This function will create a new buffer if the current one is not updatable
  77435. * @param kind defines the data kind (Position, normal, etc...)
  77436. * @param data defines the data to use
  77437. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77438. */
  77439. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  77440. if (updateExtends === void 0) { updateExtends = false; }
  77441. var vertexBuffer = this.getVertexBuffer(kind);
  77442. if (!vertexBuffer) {
  77443. return;
  77444. }
  77445. vertexBuffer.update(data);
  77446. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77447. this._updateBoundingInfo(updateExtends, data);
  77448. }
  77449. this.notifyUpdate(kind);
  77450. };
  77451. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  77452. if (updateExtends) {
  77453. this._updateExtend(data);
  77454. }
  77455. this._resetPointsArrayCache();
  77456. if (updateExtends) {
  77457. var meshes = this._meshes;
  77458. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  77459. var mesh = meshes_1[_i];
  77460. if (mesh._boundingInfo) {
  77461. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  77462. }
  77463. else {
  77464. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77465. }
  77466. var subMeshes = mesh.subMeshes;
  77467. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  77468. var subMesh = subMeshes_1[_a];
  77469. subMesh.refreshBoundingInfo();
  77470. }
  77471. }
  77472. }
  77473. };
  77474. /** @hidden */
  77475. Geometry.prototype._bind = function (effect, indexToBind) {
  77476. if (!effect) {
  77477. return;
  77478. }
  77479. if (indexToBind === undefined) {
  77480. indexToBind = this._indexBuffer;
  77481. }
  77482. var vbs = this.getVertexBuffers();
  77483. if (!vbs) {
  77484. return;
  77485. }
  77486. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  77487. this._engine.bindBuffers(vbs, indexToBind, effect);
  77488. return;
  77489. }
  77490. // Using VAO
  77491. if (!this._vertexArrayObjects[effect.key]) {
  77492. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  77493. }
  77494. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  77495. };
  77496. /**
  77497. * Gets total number of vertices
  77498. * @returns the total number of vertices
  77499. */
  77500. Geometry.prototype.getTotalVertices = function () {
  77501. if (!this.isReady()) {
  77502. return 0;
  77503. }
  77504. return this._totalVertices;
  77505. };
  77506. /**
  77507. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77508. * @param kind defines the data kind (Position, normal, etc...)
  77509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77511. * @returns a float array containing vertex data
  77512. */
  77513. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  77514. var vertexBuffer = this.getVertexBuffer(kind);
  77515. if (!vertexBuffer) {
  77516. return null;
  77517. }
  77518. var data = vertexBuffer.getData();
  77519. if (!data) {
  77520. return null;
  77521. }
  77522. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  77523. var count = this._totalVertices * vertexBuffer.getSize();
  77524. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  77525. var copy_1 = [];
  77526. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  77527. return copy_1;
  77528. }
  77529. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  77530. if (data instanceof Array) {
  77531. var offset = vertexBuffer.byteOffset / 4;
  77532. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data, offset, offset + count);
  77533. }
  77534. else if (data instanceof ArrayBuffer) {
  77535. return new Float32Array(data, vertexBuffer.byteOffset, count);
  77536. }
  77537. else {
  77538. var offset = data.byteOffset + vertexBuffer.byteOffset;
  77539. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77540. var result = new Float32Array(count);
  77541. var source = new Float32Array(data.buffer, offset, count);
  77542. result.set(source);
  77543. return result;
  77544. }
  77545. return new Float32Array(data.buffer, offset, count);
  77546. }
  77547. }
  77548. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77549. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data);
  77550. }
  77551. return data;
  77552. };
  77553. /**
  77554. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77555. * @param kind defines the data kind (Position, normal, etc...)
  77556. * @returns true if the vertex buffer with the specified kind is updatable
  77557. */
  77558. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  77559. var vb = this._vertexBuffers[kind];
  77560. if (!vb) {
  77561. return false;
  77562. }
  77563. return vb.isUpdatable();
  77564. };
  77565. /**
  77566. * Gets a specific vertex buffer
  77567. * @param kind defines the data kind (Position, normal, etc...)
  77568. * @returns a VertexBuffer
  77569. */
  77570. Geometry.prototype.getVertexBuffer = function (kind) {
  77571. if (!this.isReady()) {
  77572. return null;
  77573. }
  77574. return this._vertexBuffers[kind];
  77575. };
  77576. /**
  77577. * Returns all vertex buffers
  77578. * @return an object holding all vertex buffers indexed by kind
  77579. */
  77580. Geometry.prototype.getVertexBuffers = function () {
  77581. if (!this.isReady()) {
  77582. return null;
  77583. }
  77584. return this._vertexBuffers;
  77585. };
  77586. /**
  77587. * Gets a boolean indicating if specific vertex buffer is present
  77588. * @param kind defines the data kind (Position, normal, etc...)
  77589. * @returns true if data is present
  77590. */
  77591. Geometry.prototype.isVerticesDataPresent = function (kind) {
  77592. if (!this._vertexBuffers) {
  77593. if (this._delayInfo) {
  77594. return this._delayInfo.indexOf(kind) !== -1;
  77595. }
  77596. return false;
  77597. }
  77598. return this._vertexBuffers[kind] !== undefined;
  77599. };
  77600. /**
  77601. * Gets a list of all attached data kinds (Position, normal, etc...)
  77602. * @returns a list of string containing all kinds
  77603. */
  77604. Geometry.prototype.getVerticesDataKinds = function () {
  77605. var result = [];
  77606. var kind;
  77607. if (!this._vertexBuffers && this._delayInfo) {
  77608. for (kind in this._delayInfo) {
  77609. result.push(kind);
  77610. }
  77611. }
  77612. else {
  77613. for (kind in this._vertexBuffers) {
  77614. result.push(kind);
  77615. }
  77616. }
  77617. return result;
  77618. };
  77619. /**
  77620. * Update index buffer
  77621. * @param indices defines the indices to store in the index buffer
  77622. * @param offset defines the offset in the target buffer where to store the data
  77623. */
  77624. Geometry.prototype.updateIndices = function (indices, offset) {
  77625. if (!this._indexBuffer) {
  77626. return;
  77627. }
  77628. if (!this._indexBufferIsUpdatable) {
  77629. this.setIndices(indices, null, true);
  77630. }
  77631. else {
  77632. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  77633. this._indices = indices;
  77634. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  77635. if (needToUpdateSubMeshes) {
  77636. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77637. var mesh = _a[_i];
  77638. mesh._createGlobalSubMesh(true);
  77639. }
  77640. }
  77641. }
  77642. };
  77643. /**
  77644. * Creates a new index buffer
  77645. * @param indices defines the indices to store in the index buffer
  77646. * @param totalVertices defines the total number of vertices (could be null)
  77647. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77648. */
  77649. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  77650. if (totalVertices === void 0) { totalVertices = null; }
  77651. if (updatable === void 0) { updatable = false; }
  77652. if (this._indexBuffer) {
  77653. this._engine._releaseBuffer(this._indexBuffer);
  77654. }
  77655. this._disposeVertexArrayObjects();
  77656. this._indices = indices;
  77657. this._indexBufferIsUpdatable = updatable;
  77658. if (this._meshes.length !== 0 && this._indices) {
  77659. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  77660. }
  77661. if (totalVertices != undefined) { // including null and undefined
  77662. this._totalVertices = totalVertices;
  77663. }
  77664. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77665. var mesh = _a[_i];
  77666. mesh._createGlobalSubMesh(true);
  77667. }
  77668. this.notifyUpdate();
  77669. };
  77670. /**
  77671. * Return the total number of indices
  77672. * @returns the total number of indices
  77673. */
  77674. Geometry.prototype.getTotalIndices = function () {
  77675. if (!this.isReady()) {
  77676. return 0;
  77677. }
  77678. return this._indices.length;
  77679. };
  77680. /**
  77681. * Gets the index buffer array
  77682. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77683. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77684. * @returns the index buffer array
  77685. */
  77686. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  77687. if (!this.isReady()) {
  77688. return null;
  77689. }
  77690. var orig = this._indices;
  77691. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  77692. return orig;
  77693. }
  77694. else {
  77695. var len = orig.length;
  77696. var copy = [];
  77697. for (var i = 0; i < len; i++) {
  77698. copy.push(orig[i]);
  77699. }
  77700. return copy;
  77701. }
  77702. };
  77703. /**
  77704. * Gets the index buffer
  77705. * @return the index buffer
  77706. */
  77707. Geometry.prototype.getIndexBuffer = function () {
  77708. if (!this.isReady()) {
  77709. return null;
  77710. }
  77711. return this._indexBuffer;
  77712. };
  77713. /** @hidden */
  77714. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  77715. if (effect === void 0) { effect = null; }
  77716. if (!effect || !this._vertexArrayObjects) {
  77717. return;
  77718. }
  77719. if (this._vertexArrayObjects[effect.key]) {
  77720. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  77721. delete this._vertexArrayObjects[effect.key];
  77722. }
  77723. };
  77724. /**
  77725. * Release the associated resources for a specific mesh
  77726. * @param mesh defines the source mesh
  77727. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77728. */
  77729. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  77730. var meshes = this._meshes;
  77731. var index = meshes.indexOf(mesh);
  77732. if (index === -1) {
  77733. return;
  77734. }
  77735. meshes.splice(index, 1);
  77736. mesh._geometry = null;
  77737. if (meshes.length === 0 && shouldDispose) {
  77738. this.dispose();
  77739. }
  77740. };
  77741. /**
  77742. * Apply current geometry to a given mesh
  77743. * @param mesh defines the mesh to apply geometry to
  77744. */
  77745. Geometry.prototype.applyToMesh = function (mesh) {
  77746. if (mesh._geometry === this) {
  77747. return;
  77748. }
  77749. var previousGeometry = mesh._geometry;
  77750. if (previousGeometry) {
  77751. previousGeometry.releaseForMesh(mesh);
  77752. }
  77753. var meshes = this._meshes;
  77754. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  77755. mesh._geometry = this;
  77756. this._scene.pushGeometry(this);
  77757. meshes.push(mesh);
  77758. if (this.isReady()) {
  77759. this._applyToMesh(mesh);
  77760. }
  77761. else {
  77762. mesh._boundingInfo = this._boundingInfo;
  77763. }
  77764. };
  77765. Geometry.prototype._updateExtend = function (data) {
  77766. if (data === void 0) { data = null; }
  77767. if (!data) {
  77768. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  77769. }
  77770. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  77771. };
  77772. Geometry.prototype._applyToMesh = function (mesh) {
  77773. var numOfMeshes = this._meshes.length;
  77774. // vertexBuffers
  77775. for (var kind in this._vertexBuffers) {
  77776. if (numOfMeshes === 1) {
  77777. this._vertexBuffers[kind].create();
  77778. }
  77779. var buffer = this._vertexBuffers[kind].getBuffer();
  77780. if (buffer) {
  77781. buffer.references = numOfMeshes;
  77782. }
  77783. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77784. if (!this._extend) {
  77785. this._updateExtend();
  77786. }
  77787. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77788. mesh._createGlobalSubMesh(false);
  77789. //bounding info was just created again, world matrix should be applied again.
  77790. mesh._updateBoundingInfo();
  77791. }
  77792. }
  77793. // indexBuffer
  77794. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  77795. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  77796. }
  77797. if (this._indexBuffer) {
  77798. this._indexBuffer.references = numOfMeshes;
  77799. }
  77800. // morphTargets
  77801. mesh._syncGeometryWithMorphTargetManager();
  77802. // instances
  77803. mesh.synchronizeInstances();
  77804. };
  77805. Geometry.prototype.notifyUpdate = function (kind) {
  77806. if (this.onGeometryUpdated) {
  77807. this.onGeometryUpdated(this, kind);
  77808. }
  77809. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77810. var mesh = _a[_i];
  77811. mesh._markSubMeshesAsAttributesDirty();
  77812. }
  77813. };
  77814. /**
  77815. * Load the geometry if it was flagged as delay loaded
  77816. * @param scene defines the hosting scene
  77817. * @param onLoaded defines a callback called when the geometry is loaded
  77818. */
  77819. Geometry.prototype.load = function (scene, onLoaded) {
  77820. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING) {
  77821. return;
  77822. }
  77823. if (this.isReady()) {
  77824. if (onLoaded) {
  77825. onLoaded();
  77826. }
  77827. return;
  77828. }
  77829. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING;
  77830. this._queueLoad(scene, onLoaded);
  77831. };
  77832. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  77833. var _this = this;
  77834. if (!this.delayLoadingFile) {
  77835. return;
  77836. }
  77837. scene._addPendingData(this);
  77838. scene._loadFile(this.delayLoadingFile, function (data) {
  77839. if (!_this._delayLoadingFunction) {
  77840. return;
  77841. }
  77842. _this._delayLoadingFunction(JSON.parse(data), _this);
  77843. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  77844. _this._delayInfo = [];
  77845. scene._removePendingData(_this);
  77846. var meshes = _this._meshes;
  77847. var numOfMeshes = meshes.length;
  77848. for (var index = 0; index < numOfMeshes; index++) {
  77849. _this._applyToMesh(meshes[index]);
  77850. }
  77851. if (onLoaded) {
  77852. onLoaded();
  77853. }
  77854. }, undefined, true);
  77855. };
  77856. /**
  77857. * Invert the geometry to move from a right handed system to a left handed one.
  77858. */
  77859. Geometry.prototype.toLeftHanded = function () {
  77860. // Flip faces
  77861. var tIndices = this.getIndices(false);
  77862. if (tIndices != null && tIndices.length > 0) {
  77863. for (var i = 0; i < tIndices.length; i += 3) {
  77864. var tTemp = tIndices[i + 0];
  77865. tIndices[i + 0] = tIndices[i + 2];
  77866. tIndices[i + 2] = tTemp;
  77867. }
  77868. this.setIndices(tIndices);
  77869. }
  77870. // Negate position.z
  77871. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false);
  77872. if (tPositions != null && tPositions.length > 0) {
  77873. for (var i = 0; i < tPositions.length; i += 3) {
  77874. tPositions[i + 2] = -tPositions[i + 2];
  77875. }
  77876. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, tPositions, false);
  77877. }
  77878. // Negate normal.z
  77879. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, false);
  77880. if (tNormals != null && tNormals.length > 0) {
  77881. for (var i = 0; i < tNormals.length; i += 3) {
  77882. tNormals[i + 2] = -tNormals[i + 2];
  77883. }
  77884. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, tNormals, false);
  77885. }
  77886. };
  77887. // Cache
  77888. /** @hidden */
  77889. Geometry.prototype._resetPointsArrayCache = function () {
  77890. this._positions = null;
  77891. };
  77892. /** @hidden */
  77893. Geometry.prototype._generatePointsArray = function () {
  77894. if (this._positions) {
  77895. return true;
  77896. }
  77897. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  77898. if (!data || data.length === 0) {
  77899. return false;
  77900. }
  77901. this._positions = [];
  77902. for (var index = 0; index < data.length; index += 3) {
  77903. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(data, index));
  77904. }
  77905. return true;
  77906. };
  77907. /**
  77908. * Gets a value indicating if the geometry is disposed
  77909. * @returns true if the geometry was disposed
  77910. */
  77911. Geometry.prototype.isDisposed = function () {
  77912. return this._isDisposed;
  77913. };
  77914. Geometry.prototype._disposeVertexArrayObjects = function () {
  77915. if (this._vertexArrayObjects) {
  77916. for (var kind in this._vertexArrayObjects) {
  77917. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  77918. }
  77919. this._vertexArrayObjects = {};
  77920. }
  77921. };
  77922. /**
  77923. * Free all associated resources
  77924. */
  77925. Geometry.prototype.dispose = function () {
  77926. var meshes = this._meshes;
  77927. var numOfMeshes = meshes.length;
  77928. var index;
  77929. for (index = 0; index < numOfMeshes; index++) {
  77930. this.releaseForMesh(meshes[index]);
  77931. }
  77932. this._meshes = [];
  77933. this._disposeVertexArrayObjects();
  77934. for (var kind in this._vertexBuffers) {
  77935. this._vertexBuffers[kind].dispose();
  77936. }
  77937. this._vertexBuffers = {};
  77938. this._totalVertices = 0;
  77939. if (this._indexBuffer) {
  77940. this._engine._releaseBuffer(this._indexBuffer);
  77941. }
  77942. this._indexBuffer = null;
  77943. this._indices = [];
  77944. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77945. this.delayLoadingFile = null;
  77946. this._delayLoadingFunction = null;
  77947. this._delayInfo = [];
  77948. this._boundingInfo = null;
  77949. this._scene.removeGeometry(this);
  77950. this._isDisposed = true;
  77951. };
  77952. /**
  77953. * Clone the current geometry into a new geometry
  77954. * @param id defines the unique ID of the new geometry
  77955. * @returns a new geometry object
  77956. */
  77957. Geometry.prototype.copy = function (id) {
  77958. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77959. vertexData.indices = [];
  77960. var indices = this.getIndices();
  77961. if (indices) {
  77962. for (var index = 0; index < indices.length; index++) {
  77963. vertexData.indices.push(indices[index]);
  77964. }
  77965. }
  77966. var updatable = false;
  77967. var stopChecking = false;
  77968. var kind;
  77969. for (kind in this._vertexBuffers) {
  77970. // using slice() to make a copy of the array and not just reference it
  77971. var data = this.getVerticesData(kind);
  77972. if (data) {
  77973. if (data instanceof Float32Array) {
  77974. vertexData.set(new Float32Array(data), kind);
  77975. }
  77976. else {
  77977. vertexData.set(data.slice(0), kind);
  77978. }
  77979. if (!stopChecking) {
  77980. var vb = this.getVertexBuffer(kind);
  77981. if (vb) {
  77982. updatable = vb.isUpdatable();
  77983. stopChecking = !updatable;
  77984. }
  77985. }
  77986. }
  77987. }
  77988. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  77989. geometry.delayLoadState = this.delayLoadState;
  77990. geometry.delayLoadingFile = this.delayLoadingFile;
  77991. geometry._delayLoadingFunction = this._delayLoadingFunction;
  77992. for (kind in this._delayInfo) {
  77993. geometry._delayInfo = geometry._delayInfo || [];
  77994. geometry._delayInfo.push(kind);
  77995. }
  77996. // Bounding info
  77997. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77998. return geometry;
  77999. };
  78000. /**
  78001. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78002. * @return a JSON representation of the current geometry data (without the vertices data)
  78003. */
  78004. Geometry.prototype.serialize = function () {
  78005. var serializationObject = {};
  78006. serializationObject.id = this.id;
  78007. serializationObject.updatable = this._updatable;
  78008. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].HasTags(this)) {
  78009. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].GetTags(this);
  78010. }
  78011. return serializationObject;
  78012. };
  78013. Geometry.prototype.toNumberArray = function (origin) {
  78014. if (Array.isArray(origin)) {
  78015. return origin;
  78016. }
  78017. else {
  78018. return Array.prototype.slice.call(origin);
  78019. }
  78020. };
  78021. /**
  78022. * Serialize all vertices data into a JSON oject
  78023. * @returns a JSON representation of the current geometry data
  78024. */
  78025. Geometry.prototype.serializeVerticeData = function () {
  78026. var serializationObject = this.serialize();
  78027. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78028. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  78029. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78030. serializationObject.positions._updatable = true;
  78031. }
  78032. }
  78033. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78034. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  78035. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78036. serializationObject.normals._updatable = true;
  78037. }
  78038. }
  78039. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78040. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  78041. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78042. serializationObject.tangets._updatable = true;
  78043. }
  78044. }
  78045. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78046. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind));
  78047. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78048. serializationObject.uvs._updatable = true;
  78049. }
  78050. }
  78051. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78052. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind));
  78053. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78054. serializationObject.uv2s._updatable = true;
  78055. }
  78056. }
  78057. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78058. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind));
  78059. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78060. serializationObject.uv3s._updatable = true;
  78061. }
  78062. }
  78063. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78064. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind));
  78065. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78066. serializationObject.uv4s._updatable = true;
  78067. }
  78068. }
  78069. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78070. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind));
  78071. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78072. serializationObject.uv5s._updatable = true;
  78073. }
  78074. }
  78075. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78076. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind));
  78077. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78078. serializationObject.uv6s._updatable = true;
  78079. }
  78080. }
  78081. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78082. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind));
  78083. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78084. serializationObject.colors._updatable = true;
  78085. }
  78086. }
  78087. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78088. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind));
  78089. serializationObject.matricesIndices._isExpanded = true;
  78090. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78091. serializationObject.matricesIndices._updatable = true;
  78092. }
  78093. }
  78094. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78095. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind));
  78096. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78097. serializationObject.matricesWeights._updatable = true;
  78098. }
  78099. }
  78100. serializationObject.indices = this.toNumberArray(this.getIndices());
  78101. return serializationObject;
  78102. };
  78103. // Statics
  78104. /**
  78105. * Extracts a clone of a mesh geometry
  78106. * @param mesh defines the source mesh
  78107. * @param id defines the unique ID of the new geometry object
  78108. * @returns the new geometry object
  78109. */
  78110. Geometry.ExtractFromMesh = function (mesh, id) {
  78111. var geometry = mesh._geometry;
  78112. if (!geometry) {
  78113. return null;
  78114. }
  78115. return geometry.copy(id);
  78116. };
  78117. /**
  78118. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78119. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78120. * Be aware Math.random() could cause collisions, but:
  78121. * "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"
  78122. * @returns a string containing a new GUID
  78123. */
  78124. Geometry.RandomId = function () {
  78125. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].RandomId();
  78126. };
  78127. /** @hidden */
  78128. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  78129. var scene = mesh.getScene();
  78130. // Geometry
  78131. var geometryId = parsedGeometry.geometryId;
  78132. if (geometryId) {
  78133. var geometry = scene.getGeometryByID(geometryId);
  78134. if (geometry) {
  78135. geometry.applyToMesh(mesh);
  78136. }
  78137. }
  78138. else if (parsedGeometry instanceof ArrayBuffer) {
  78139. var binaryInfo = mesh._binaryInfo;
  78140. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  78141. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  78142. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positionsData, false);
  78143. }
  78144. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  78145. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  78146. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normalsData, false);
  78147. }
  78148. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  78149. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  78150. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, tangentsData, false);
  78151. }
  78152. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  78153. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  78154. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvsData, false);
  78155. }
  78156. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  78157. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  78158. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, uvs2Data, false);
  78159. }
  78160. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  78161. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  78162. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, uvs3Data, false);
  78163. }
  78164. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  78165. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  78166. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, uvs4Data, false);
  78167. }
  78168. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  78169. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  78170. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, uvs5Data, false);
  78171. }
  78172. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  78173. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  78174. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, uvs6Data, false);
  78175. }
  78176. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  78177. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  78178. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  78179. }
  78180. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  78181. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  78182. var floatIndices = [];
  78183. for (var i = 0; i < matricesIndicesData.length; i++) {
  78184. var index = matricesIndicesData[i];
  78185. floatIndices.push(index & 0x000000FF);
  78186. floatIndices.push((index & 0x0000FF00) >> 8);
  78187. floatIndices.push((index & 0x00FF0000) >> 16);
  78188. floatIndices.push(index >> 24);
  78189. }
  78190. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  78191. }
  78192. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  78193. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  78194. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  78195. }
  78196. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  78197. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  78198. mesh.setIndices(indicesData, null);
  78199. }
  78200. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  78201. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  78202. mesh.subMeshes = [];
  78203. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  78204. var materialIndex = subMeshesData[(i * 5) + 0];
  78205. var verticesStart = subMeshesData[(i * 5) + 1];
  78206. var verticesCount = subMeshesData[(i * 5) + 2];
  78207. var indexStart = subMeshesData[(i * 5) + 3];
  78208. var indexCount = subMeshesData[(i * 5) + 4];
  78209. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  78210. }
  78211. }
  78212. }
  78213. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  78214. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  78215. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  78216. if (parsedGeometry.tangents) {
  78217. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  78218. }
  78219. if (parsedGeometry.uvs) {
  78220. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  78221. }
  78222. if (parsedGeometry.uvs2) {
  78223. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  78224. }
  78225. if (parsedGeometry.uvs3) {
  78226. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  78227. }
  78228. if (parsedGeometry.uvs4) {
  78229. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  78230. }
  78231. if (parsedGeometry.uvs5) {
  78232. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  78233. }
  78234. if (parsedGeometry.uvs6) {
  78235. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  78236. }
  78237. if (parsedGeometry.colors) {
  78238. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  78239. }
  78240. if (parsedGeometry.matricesIndices) {
  78241. if (!parsedGeometry.matricesIndices._isExpanded) {
  78242. var floatIndices = [];
  78243. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  78244. var matricesIndex = parsedGeometry.matricesIndices[i];
  78245. floatIndices.push(matricesIndex & 0x000000FF);
  78246. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78247. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78248. floatIndices.push(matricesIndex >> 24);
  78249. }
  78250. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  78251. }
  78252. else {
  78253. delete parsedGeometry.matricesIndices._isExpanded;
  78254. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  78255. }
  78256. }
  78257. if (parsedGeometry.matricesIndicesExtra) {
  78258. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  78259. var floatIndices = [];
  78260. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  78261. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  78262. floatIndices.push(matricesIndex & 0x000000FF);
  78263. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78264. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78265. floatIndices.push(matricesIndex >> 24);
  78266. }
  78267. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  78268. }
  78269. else {
  78270. delete parsedGeometry.matricesIndices._isExpanded;
  78271. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  78272. }
  78273. }
  78274. if (parsedGeometry.matricesWeights) {
  78275. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  78276. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  78277. }
  78278. if (parsedGeometry.matricesWeightsExtra) {
  78279. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  78280. }
  78281. mesh.setIndices(parsedGeometry.indices, null);
  78282. }
  78283. // SubMeshes
  78284. if (parsedGeometry.subMeshes) {
  78285. mesh.subMeshes = [];
  78286. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  78287. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  78288. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  78289. }
  78290. }
  78291. // Flat shading
  78292. if (mesh._shouldGenerateFlatShading) {
  78293. mesh.convertToFlatShadedMesh();
  78294. delete mesh._shouldGenerateFlatShading;
  78295. }
  78296. // Update
  78297. mesh.computeWorldMatrix(true);
  78298. scene.onMeshImportedObservable.notifyObservers(mesh);
  78299. };
  78300. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  78301. var epsilon = 1e-3;
  78302. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  78303. return;
  78304. }
  78305. var noInfluenceBoneIndex = 0.0;
  78306. if (parsedGeometry.skeletonId > -1) {
  78307. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  78308. if (!skeleton) {
  78309. return;
  78310. }
  78311. noInfluenceBoneIndex = skeleton.bones.length;
  78312. }
  78313. else {
  78314. return;
  78315. }
  78316. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78317. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  78318. var matricesWeights = parsedGeometry.matricesWeights;
  78319. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  78320. var influencers = parsedGeometry.numBoneInfluencer;
  78321. var size = matricesWeights.length;
  78322. for (var i = 0; i < size; i += 4) {
  78323. var weight = 0.0;
  78324. var firstZeroWeight = -1;
  78325. for (var j = 0; j < 4; j++) {
  78326. var w = matricesWeights[i + j];
  78327. weight += w;
  78328. if (w < epsilon && firstZeroWeight < 0) {
  78329. firstZeroWeight = j;
  78330. }
  78331. }
  78332. if (matricesWeightsExtra) {
  78333. for (var j = 0; j < 4; j++) {
  78334. var w = matricesWeightsExtra[i + j];
  78335. weight += w;
  78336. if (w < epsilon && firstZeroWeight < 0) {
  78337. firstZeroWeight = j + 4;
  78338. }
  78339. }
  78340. }
  78341. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  78342. firstZeroWeight = influencers - 1;
  78343. }
  78344. if (weight > epsilon) {
  78345. var mweight = 1.0 / weight;
  78346. for (var j = 0; j < 4; j++) {
  78347. matricesWeights[i + j] *= mweight;
  78348. }
  78349. if (matricesWeightsExtra) {
  78350. for (var j = 0; j < 4; j++) {
  78351. matricesWeightsExtra[i + j] *= mweight;
  78352. }
  78353. }
  78354. }
  78355. else {
  78356. if (firstZeroWeight >= 4) {
  78357. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  78358. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  78359. }
  78360. else {
  78361. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  78362. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  78363. }
  78364. }
  78365. }
  78366. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  78367. if (parsedGeometry.matricesWeightsExtra) {
  78368. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  78369. }
  78370. };
  78371. /**
  78372. * Create a new geometry from persisted data (Using .babylon file format)
  78373. * @param parsedVertexData defines the persisted data
  78374. * @param scene defines the hosting scene
  78375. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78376. * @returns the new geometry object
  78377. */
  78378. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  78379. if (scene.getGeometryByID(parsedVertexData.id)) {
  78380. return null; // null since geometry could be something else than a box...
  78381. }
  78382. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  78383. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78384. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  78385. }
  78386. if (parsedVertexData.delayLoadingFile) {
  78387. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  78388. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  78389. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  78390. geometry._delayInfo = [];
  78391. if (parsedVertexData.hasUVs) {
  78392. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  78393. }
  78394. if (parsedVertexData.hasUVs2) {
  78395. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  78396. }
  78397. if (parsedVertexData.hasUVs3) {
  78398. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind);
  78399. }
  78400. if (parsedVertexData.hasUVs4) {
  78401. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind);
  78402. }
  78403. if (parsedVertexData.hasUVs5) {
  78404. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind);
  78405. }
  78406. if (parsedVertexData.hasUVs6) {
  78407. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind);
  78408. }
  78409. if (parsedVertexData.hasColors) {
  78410. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  78411. }
  78412. if (parsedVertexData.hasMatricesIndices) {
  78413. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78414. }
  78415. if (parsedVertexData.hasMatricesWeights) {
  78416. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  78417. }
  78418. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData;
  78419. }
  78420. else {
  78421. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  78422. }
  78423. scene.pushGeometry(geometry, true);
  78424. return geometry;
  78425. };
  78426. return Geometry;
  78427. }());
  78428. // Primitives
  78429. /// Abstract class
  78430. /**
  78431. * Abstract class used to provide common services for all typed geometries
  78432. * @hidden
  78433. */
  78434. var _PrimitiveGeometry = /** @class */ (function (_super) {
  78435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_PrimitiveGeometry, _super);
  78436. /**
  78437. * Creates a new typed geometry
  78438. * @param id defines the unique ID of the geometry
  78439. * @param scene defines the hosting scene
  78440. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78441. * @param mesh defines the hosting mesh (can be null)
  78442. */
  78443. function _PrimitiveGeometry(id, scene, _canBeRegenerated, mesh) {
  78444. if (_canBeRegenerated === void 0) { _canBeRegenerated = false; }
  78445. if (mesh === void 0) { mesh = null; }
  78446. var _this = _super.call(this, id, scene, undefined, false, mesh) || this;
  78447. _this._canBeRegenerated = _canBeRegenerated;
  78448. _this._beingRegenerated = true;
  78449. _this.regenerate();
  78450. _this._beingRegenerated = false;
  78451. return _this;
  78452. }
  78453. /**
  78454. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  78455. * @returns true if the geometry can be regenerated
  78456. */
  78457. _PrimitiveGeometry.prototype.canBeRegenerated = function () {
  78458. return this._canBeRegenerated;
  78459. };
  78460. /**
  78461. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  78462. */
  78463. _PrimitiveGeometry.prototype.regenerate = function () {
  78464. if (!this._canBeRegenerated) {
  78465. return;
  78466. }
  78467. this._beingRegenerated = true;
  78468. this.setAllVerticesData(this._regenerateVertexData(), false);
  78469. this._beingRegenerated = false;
  78470. };
  78471. /**
  78472. * Clone the geometry
  78473. * @param id defines the unique ID of the new geometry
  78474. * @returns the new geometry
  78475. */
  78476. _PrimitiveGeometry.prototype.asNewGeometry = function (id) {
  78477. return _super.prototype.copy.call(this, id);
  78478. };
  78479. // overrides
  78480. _PrimitiveGeometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  78481. if (!this._beingRegenerated) {
  78482. return;
  78483. }
  78484. _super.prototype.setAllVerticesData.call(this, vertexData, false);
  78485. };
  78486. _PrimitiveGeometry.prototype.setVerticesData = function (kind, data, updatable) {
  78487. if (!this._beingRegenerated) {
  78488. return;
  78489. }
  78490. _super.prototype.setVerticesData.call(this, kind, data, false);
  78491. };
  78492. // to override
  78493. /** @hidden */
  78494. _PrimitiveGeometry.prototype._regenerateVertexData = function () {
  78495. throw new Error("Abstract method");
  78496. };
  78497. _PrimitiveGeometry.prototype.copy = function (id) {
  78498. throw new Error("Must be overriden in sub-classes.");
  78499. };
  78500. _PrimitiveGeometry.prototype.serialize = function () {
  78501. var serializationObject = _super.prototype.serialize.call(this);
  78502. serializationObject.canBeRegenerated = this.canBeRegenerated();
  78503. return serializationObject;
  78504. };
  78505. return _PrimitiveGeometry;
  78506. }(Geometry));
  78507. /**
  78508. * Creates a ribbon geometry
  78509. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  78510. */
  78511. var RibbonGeometry = /** @class */ (function (_super) {
  78512. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RibbonGeometry, _super);
  78513. /**
  78514. * Creates a ribbon geometry
  78515. * @param id defines the unique ID of the geometry
  78516. * @param scene defines the hosting scene
  78517. * @param pathArray defines the array of paths to use
  78518. * @param closeArray defines if the last path and the first path must be joined
  78519. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  78520. * @param offset defines the offset between points
  78521. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78522. * @param mesh defines the hosting mesh (can be null)
  78523. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78524. */
  78525. function RibbonGeometry(id, scene,
  78526. /**
  78527. * Defines the array of paths to use
  78528. */
  78529. pathArray,
  78530. /**
  78531. * Defines if the last and first points of each path in your pathArray must be joined
  78532. */
  78533. closeArray,
  78534. /**
  78535. * Defines if the last and first points of each path in your pathArray must be joined
  78536. */
  78537. closePath,
  78538. /**
  78539. * Defines the offset between points
  78540. */
  78541. offset, canBeRegenerated, mesh,
  78542. /**
  78543. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78544. */
  78545. side) {
  78546. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78547. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78548. _this.pathArray = pathArray;
  78549. _this.closeArray = closeArray;
  78550. _this.closePath = closePath;
  78551. _this.offset = offset;
  78552. _this.side = side;
  78553. return _this;
  78554. }
  78555. /** @hidden */
  78556. RibbonGeometry.prototype._regenerateVertexData = function () {
  78557. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateRibbon({ pathArray: this.pathArray, closeArray: this.closeArray, closePath: this.closePath, offset: this.offset, sideOrientation: this.side });
  78558. };
  78559. RibbonGeometry.prototype.copy = function (id) {
  78560. return new RibbonGeometry(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
  78561. };
  78562. return RibbonGeometry;
  78563. }(_PrimitiveGeometry));
  78564. /**
  78565. * Creates a box geometry
  78566. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  78567. */
  78568. var BoxGeometry = /** @class */ (function (_super) {
  78569. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoxGeometry, _super);
  78570. /**
  78571. * Creates a box geometry
  78572. * @param id defines the unique ID of the geometry
  78573. * @param scene defines the hosting scene
  78574. * @param size defines the zise of the box (width, height and depth are the same)
  78575. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78576. * @param mesh defines the hosting mesh (can be null)
  78577. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78578. */
  78579. function BoxGeometry(id, scene,
  78580. /**
  78581. * Defines the zise of the box (width, height and depth are the same)
  78582. */
  78583. size, canBeRegenerated, mesh,
  78584. /**
  78585. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78586. */
  78587. side) {
  78588. if (mesh === void 0) { mesh = null; }
  78589. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78590. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78591. _this.size = size;
  78592. _this.side = side;
  78593. return _this;
  78594. }
  78595. /** @hidden */
  78596. BoxGeometry.prototype._regenerateVertexData = function () {
  78597. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox({ size: this.size, sideOrientation: this.side });
  78598. };
  78599. BoxGeometry.prototype.copy = function (id) {
  78600. return new BoxGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
  78601. };
  78602. BoxGeometry.prototype.serialize = function () {
  78603. var serializationObject = _super.prototype.serialize.call(this);
  78604. serializationObject.size = this.size;
  78605. return serializationObject;
  78606. };
  78607. BoxGeometry.Parse = function (parsedBox, scene) {
  78608. if (scene.getGeometryByID(parsedBox.id)) {
  78609. return null; // null since geometry could be something else than a box...
  78610. }
  78611. var box = new BoxGeometry(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
  78612. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78613. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(box, parsedBox.tags);
  78614. }
  78615. scene.pushGeometry(box, true);
  78616. return box;
  78617. };
  78618. return BoxGeometry;
  78619. }(_PrimitiveGeometry));
  78620. /**
  78621. * Creates a sphere geometry
  78622. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  78623. */
  78624. var SphereGeometry = /** @class */ (function (_super) {
  78625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereGeometry, _super);
  78626. /**
  78627. * Create a new sphere geometry
  78628. * @param id defines the unique ID of the geometry
  78629. * @param scene defines the hosting scene
  78630. * @param segments defines the number of segments to use to create the sphere
  78631. * @param diameter defines the diameter of the sphere
  78632. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78633. * @param mesh defines the hosting mesh (can be null)
  78634. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78635. */
  78636. function SphereGeometry(id, scene,
  78637. /**
  78638. * Defines the number of segments to use to create the sphere
  78639. */
  78640. segments,
  78641. /**
  78642. * Defines the diameter of the sphere
  78643. */
  78644. diameter, canBeRegenerated, mesh,
  78645. /**
  78646. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78647. */
  78648. side) {
  78649. if (mesh === void 0) { mesh = null; }
  78650. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78651. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78652. _this.segments = segments;
  78653. _this.diameter = diameter;
  78654. _this.side = side;
  78655. return _this;
  78656. }
  78657. /** @hidden */
  78658. SphereGeometry.prototype._regenerateVertexData = function () {
  78659. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
  78660. };
  78661. SphereGeometry.prototype.copy = function (id) {
  78662. return new SphereGeometry(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
  78663. };
  78664. SphereGeometry.prototype.serialize = function () {
  78665. var serializationObject = _super.prototype.serialize.call(this);
  78666. serializationObject.segments = this.segments;
  78667. serializationObject.diameter = this.diameter;
  78668. return serializationObject;
  78669. };
  78670. SphereGeometry.Parse = function (parsedSphere, scene) {
  78671. if (scene.getGeometryByID(parsedSphere.id)) {
  78672. return null; // null since geometry could be something else than a sphere...
  78673. }
  78674. var sphere = new SphereGeometry(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
  78675. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78676. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(sphere, parsedSphere.tags);
  78677. }
  78678. scene.pushGeometry(sphere, true);
  78679. return sphere;
  78680. };
  78681. return SphereGeometry;
  78682. }(_PrimitiveGeometry));
  78683. /**
  78684. * Creates a disc geometry
  78685. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78686. */
  78687. var DiscGeometry = /** @class */ (function (_super) {
  78688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DiscGeometry, _super);
  78689. /**
  78690. * Creates a new disc geometry
  78691. * @param id defines the unique ID of the geometry
  78692. * @param scene defines the hosting scene
  78693. * @param radius defines the radius of the disc
  78694. * @param tessellation defines the tesselation factor to apply to the disc
  78695. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78696. * @param mesh defines the hosting mesh (can be null)
  78697. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78698. */
  78699. function DiscGeometry(id, scene,
  78700. /**
  78701. * Defines the radius of the disc
  78702. */
  78703. radius,
  78704. /**
  78705. * Defines the tesselation factor to apply to the disc
  78706. */
  78707. tessellation, canBeRegenerated, mesh,
  78708. /**
  78709. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78710. */
  78711. side) {
  78712. if (mesh === void 0) { mesh = null; }
  78713. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78714. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78715. _this.radius = radius;
  78716. _this.tessellation = tessellation;
  78717. _this.side = side;
  78718. return _this;
  78719. }
  78720. /** @hidden */
  78721. DiscGeometry.prototype._regenerateVertexData = function () {
  78722. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
  78723. };
  78724. DiscGeometry.prototype.copy = function (id) {
  78725. return new DiscGeometry(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
  78726. };
  78727. return DiscGeometry;
  78728. }(_PrimitiveGeometry));
  78729. /**
  78730. * Creates a new cylinder geometry
  78731. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  78732. */
  78733. var CylinderGeometry = /** @class */ (function (_super) {
  78734. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderGeometry, _super);
  78735. /**
  78736. * Creates a new cylinder geometry
  78737. * @param id defines the unique ID of the geometry
  78738. * @param scene defines the hosting scene
  78739. * @param height defines the height of the cylinder
  78740. * @param diameterTop defines the diameter of the cylinder's top cap
  78741. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  78742. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  78743. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  78744. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78745. * @param mesh defines the hosting mesh (can be null)
  78746. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78747. */
  78748. function CylinderGeometry(id, scene,
  78749. /**
  78750. * Defines the height of the cylinder
  78751. */
  78752. height,
  78753. /**
  78754. * Defines the diameter of the cylinder's top cap
  78755. */
  78756. diameterTop,
  78757. /**
  78758. * Defines the diameter of the cylinder's bottom cap
  78759. */
  78760. diameterBottom,
  78761. /**
  78762. * Defines the tessellation factor to apply to the cylinder
  78763. */
  78764. tessellation,
  78765. /**
  78766. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  78767. */
  78768. subdivisions, canBeRegenerated, mesh,
  78769. /**
  78770. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78771. */
  78772. side) {
  78773. if (subdivisions === void 0) { subdivisions = 1; }
  78774. if (mesh === void 0) { mesh = null; }
  78775. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78776. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78777. _this.height = height;
  78778. _this.diameterTop = diameterTop;
  78779. _this.diameterBottom = diameterBottom;
  78780. _this.tessellation = tessellation;
  78781. _this.subdivisions = subdivisions;
  78782. _this.side = side;
  78783. return _this;
  78784. }
  78785. /** @hidden */
  78786. CylinderGeometry.prototype._regenerateVertexData = function () {
  78787. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder({ height: this.height, diameterTop: this.diameterTop, diameterBottom: this.diameterBottom, tessellation: this.tessellation, subdivisions: this.subdivisions, sideOrientation: this.side });
  78788. };
  78789. CylinderGeometry.prototype.copy = function (id) {
  78790. return new CylinderGeometry(id, this.getScene(), this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.canBeRegenerated(), null, this.side);
  78791. };
  78792. CylinderGeometry.prototype.serialize = function () {
  78793. var serializationObject = _super.prototype.serialize.call(this);
  78794. serializationObject.height = this.height;
  78795. serializationObject.diameterTop = this.diameterTop;
  78796. serializationObject.diameterBottom = this.diameterBottom;
  78797. serializationObject.tessellation = this.tessellation;
  78798. return serializationObject;
  78799. };
  78800. CylinderGeometry.Parse = function (parsedCylinder, scene) {
  78801. if (scene.getGeometryByID(parsedCylinder.id)) {
  78802. return null; // null since geometry could be something else than a cylinder...
  78803. }
  78804. var cylinder = new CylinderGeometry(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
  78805. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78806. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(cylinder, parsedCylinder.tags);
  78807. }
  78808. scene.pushGeometry(cylinder, true);
  78809. return cylinder;
  78810. };
  78811. return CylinderGeometry;
  78812. }(_PrimitiveGeometry));
  78813. /**
  78814. * Creates a new torus geometry
  78815. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  78816. */
  78817. var TorusGeometry = /** @class */ (function (_super) {
  78818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusGeometry, _super);
  78819. /**
  78820. * Creates a new torus geometry
  78821. * @param id defines the unique ID of the geometry
  78822. * @param scene defines the hosting scene
  78823. * @param diameter defines the diameter of the torus
  78824. * @param thickness defines the thickness of the torus (ie. internal diameter)
  78825. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  78826. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78827. * @param mesh defines the hosting mesh (can be null)
  78828. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78829. */
  78830. function TorusGeometry(id, scene,
  78831. /**
  78832. * Defines the diameter of the torus
  78833. */
  78834. diameter,
  78835. /**
  78836. * Defines the thickness of the torus (ie. internal diameter)
  78837. */
  78838. thickness,
  78839. /**
  78840. * Defines the tesselation factor to apply to the torus
  78841. */
  78842. tessellation, canBeRegenerated, mesh,
  78843. /**
  78844. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78845. */
  78846. side) {
  78847. if (mesh === void 0) { mesh = null; }
  78848. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78849. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78850. _this.diameter = diameter;
  78851. _this.thickness = thickness;
  78852. _this.tessellation = tessellation;
  78853. _this.side = side;
  78854. return _this;
  78855. }
  78856. /** @hidden */
  78857. TorusGeometry.prototype._regenerateVertexData = function () {
  78858. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
  78859. };
  78860. TorusGeometry.prototype.copy = function (id) {
  78861. return new TorusGeometry(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
  78862. };
  78863. TorusGeometry.prototype.serialize = function () {
  78864. var serializationObject = _super.prototype.serialize.call(this);
  78865. serializationObject.diameter = this.diameter;
  78866. serializationObject.thickness = this.thickness;
  78867. serializationObject.tessellation = this.tessellation;
  78868. return serializationObject;
  78869. };
  78870. TorusGeometry.Parse = function (parsedTorus, scene) {
  78871. if (scene.getGeometryByID(parsedTorus.id)) {
  78872. return null; // null since geometry could be something else than a torus...
  78873. }
  78874. var torus = new TorusGeometry(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
  78875. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78876. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torus, parsedTorus.tags);
  78877. }
  78878. scene.pushGeometry(torus, true);
  78879. return torus;
  78880. };
  78881. return TorusGeometry;
  78882. }(_PrimitiveGeometry));
  78883. /**
  78884. * Creates a new ground geometry
  78885. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  78886. */
  78887. var GroundGeometry = /** @class */ (function (_super) {
  78888. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundGeometry, _super);
  78889. /**
  78890. * Creates a new ground geometry
  78891. * @param id defines the unique ID of the geometry
  78892. * @param scene defines the hosting scene
  78893. * @param width defines the width of the ground
  78894. * @param height defines the height of the ground
  78895. * @param subdivisions defines the subdivisions to apply to the ground
  78896. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78897. * @param mesh defines the hosting mesh (can be null)
  78898. */
  78899. function GroundGeometry(id, scene,
  78900. /**
  78901. * Defines the width of the ground
  78902. */
  78903. width,
  78904. /**
  78905. * Defines the height of the ground
  78906. */
  78907. height,
  78908. /**
  78909. * Defines the subdivisions to apply to the ground
  78910. */
  78911. subdivisions, canBeRegenerated, mesh) {
  78912. if (mesh === void 0) { mesh = null; }
  78913. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78914. _this.width = width;
  78915. _this.height = height;
  78916. _this.subdivisions = subdivisions;
  78917. return _this;
  78918. }
  78919. /** @hidden */
  78920. GroundGeometry.prototype._regenerateVertexData = function () {
  78921. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
  78922. };
  78923. GroundGeometry.prototype.copy = function (id) {
  78924. return new GroundGeometry(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
  78925. };
  78926. GroundGeometry.prototype.serialize = function () {
  78927. var serializationObject = _super.prototype.serialize.call(this);
  78928. serializationObject.width = this.width;
  78929. serializationObject.height = this.height;
  78930. serializationObject.subdivisions = this.subdivisions;
  78931. return serializationObject;
  78932. };
  78933. GroundGeometry.Parse = function (parsedGround, scene) {
  78934. if (scene.getGeometryByID(parsedGround.id)) {
  78935. return null; // null since geometry could be something else than a ground...
  78936. }
  78937. var ground = new GroundGeometry(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
  78938. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78939. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(ground, parsedGround.tags);
  78940. }
  78941. scene.pushGeometry(ground, true);
  78942. return ground;
  78943. };
  78944. return GroundGeometry;
  78945. }(_PrimitiveGeometry));
  78946. /**
  78947. * Creates a tiled ground geometry
  78948. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  78949. */
  78950. var TiledGroundGeometry = /** @class */ (function (_super) {
  78951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TiledGroundGeometry, _super);
  78952. /**
  78953. * Creates a tiled ground geometry
  78954. * @param id defines the unique ID of the geometry
  78955. * @param scene defines the hosting scene
  78956. * @param xmin defines the minimum value on X axis
  78957. * @param zmin defines the minimum value on Z axis
  78958. * @param xmax defines the maximum value on X axis
  78959. * @param zmax defines the maximum value on Z axis
  78960. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  78961. * @param precision defines the precision to use when computing the tiles
  78962. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78963. * @param mesh defines the hosting mesh (can be null)
  78964. */
  78965. function TiledGroundGeometry(id, scene,
  78966. /**
  78967. * Defines the minimum value on X axis
  78968. */
  78969. xmin,
  78970. /**
  78971. * Defines the minimum value on Z axis
  78972. */
  78973. zmin,
  78974. /**
  78975. * Defines the maximum value on X axis
  78976. */
  78977. xmax,
  78978. /**
  78979. * Defines the maximum value on Z axis
  78980. */
  78981. zmax,
  78982. /**
  78983. * Defines the subdivisions to apply to the ground
  78984. */
  78985. subdivisions,
  78986. /**
  78987. * Defines the precision to use when computing the tiles
  78988. */
  78989. precision, canBeRegenerated, mesh) {
  78990. if (mesh === void 0) { mesh = null; }
  78991. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78992. _this.xmin = xmin;
  78993. _this.zmin = zmin;
  78994. _this.xmax = xmax;
  78995. _this.zmax = zmax;
  78996. _this.subdivisions = subdivisions;
  78997. _this.precision = precision;
  78998. return _this;
  78999. }
  79000. /** @hidden */
  79001. TiledGroundGeometry.prototype._regenerateVertexData = function () {
  79002. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround({ xmin: this.xmin, zmin: this.zmin, xmax: this.xmax, zmax: this.zmax, subdivisions: this.subdivisions, precision: this.precision });
  79003. };
  79004. TiledGroundGeometry.prototype.copy = function (id) {
  79005. return new TiledGroundGeometry(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
  79006. };
  79007. return TiledGroundGeometry;
  79008. }(_PrimitiveGeometry));
  79009. /**
  79010. * Creates a plane geometry
  79011. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  79012. */
  79013. var PlaneGeometry = /** @class */ (function (_super) {
  79014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneGeometry, _super);
  79015. /**
  79016. * Creates a plane geometry
  79017. * @param id defines the unique ID of the geometry
  79018. * @param scene defines the hosting scene
  79019. * @param size defines the size of the plane (width === height)
  79020. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79021. * @param mesh defines the hosting mesh (can be null)
  79022. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79023. */
  79024. function PlaneGeometry(id, scene,
  79025. /**
  79026. * Defines the size of the plane (width === height)
  79027. */
  79028. size, canBeRegenerated, mesh,
  79029. /**
  79030. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79031. */
  79032. side) {
  79033. if (mesh === void 0) { mesh = null; }
  79034. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79035. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79036. _this.size = size;
  79037. _this.side = side;
  79038. return _this;
  79039. }
  79040. /** @hidden */
  79041. PlaneGeometry.prototype._regenerateVertexData = function () {
  79042. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePlane({ size: this.size, sideOrientation: this.side });
  79043. };
  79044. PlaneGeometry.prototype.copy = function (id) {
  79045. return new PlaneGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
  79046. };
  79047. PlaneGeometry.prototype.serialize = function () {
  79048. var serializationObject = _super.prototype.serialize.call(this);
  79049. serializationObject.size = this.size;
  79050. return serializationObject;
  79051. };
  79052. PlaneGeometry.Parse = function (parsedPlane, scene) {
  79053. if (scene.getGeometryByID(parsedPlane.id)) {
  79054. return null; // null since geometry could be something else than a ground...
  79055. }
  79056. var plane = new PlaneGeometry(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
  79057. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79058. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(plane, parsedPlane.tags);
  79059. }
  79060. scene.pushGeometry(plane, true);
  79061. return plane;
  79062. };
  79063. return PlaneGeometry;
  79064. }(_PrimitiveGeometry));
  79065. /**
  79066. * Creates a torus knot geometry
  79067. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79068. */
  79069. var TorusKnotGeometry = /** @class */ (function (_super) {
  79070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusKnotGeometry, _super);
  79071. /**
  79072. * Creates a torus knot geometry
  79073. * @param id defines the unique ID of the geometry
  79074. * @param scene defines the hosting scene
  79075. * @param radius defines the radius of the torus knot
  79076. * @param tube defines the thickness of the torus knot tube
  79077. * @param radialSegments defines the number of radial segments
  79078. * @param tubularSegments defines the number of tubular segments
  79079. * @param p defines the first number of windings
  79080. * @param q defines the second number of windings
  79081. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79082. * @param mesh defines the hosting mesh (can be null)
  79083. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79084. */
  79085. function TorusKnotGeometry(id, scene,
  79086. /**
  79087. * Defines the radius of the torus knot
  79088. */
  79089. radius,
  79090. /**
  79091. * Defines the thickness of the torus knot tube
  79092. */
  79093. tube,
  79094. /**
  79095. * Defines the number of radial segments
  79096. */
  79097. radialSegments,
  79098. /**
  79099. * Defines the number of tubular segments
  79100. */
  79101. tubularSegments,
  79102. /**
  79103. * Defines the first number of windings
  79104. */
  79105. p,
  79106. /**
  79107. * Defines the second number of windings
  79108. */
  79109. q, canBeRegenerated, mesh,
  79110. /**
  79111. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79112. */
  79113. side) {
  79114. if (mesh === void 0) { mesh = null; }
  79115. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79116. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79117. _this.radius = radius;
  79118. _this.tube = tube;
  79119. _this.radialSegments = radialSegments;
  79120. _this.tubularSegments = tubularSegments;
  79121. _this.p = p;
  79122. _this.q = q;
  79123. _this.side = side;
  79124. return _this;
  79125. }
  79126. /** @hidden */
  79127. TorusKnotGeometry.prototype._regenerateVertexData = function () {
  79128. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot({ radius: this.radius, tube: this.tube, radialSegments: this.radialSegments, tubularSegments: this.tubularSegments, p: this.p, q: this.q, sideOrientation: this.side });
  79129. };
  79130. TorusKnotGeometry.prototype.copy = function (id) {
  79131. return new TorusKnotGeometry(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
  79132. };
  79133. TorusKnotGeometry.prototype.serialize = function () {
  79134. var serializationObject = _super.prototype.serialize.call(this);
  79135. serializationObject.radius = this.radius;
  79136. serializationObject.tube = this.tube;
  79137. serializationObject.radialSegments = this.radialSegments;
  79138. serializationObject.tubularSegments = this.tubularSegments;
  79139. serializationObject.p = this.p;
  79140. serializationObject.q = this.q;
  79141. return serializationObject;
  79142. };
  79143. TorusKnotGeometry.Parse = function (parsedTorusKnot, scene) {
  79144. if (scene.getGeometryByID(parsedTorusKnot.id)) {
  79145. return null; // null since geometry could be something else than a ground...
  79146. }
  79147. var torusKnot = new TorusKnotGeometry(parsedTorusKnot.id, scene, parsedTorusKnot.radius, parsedTorusKnot.tube, parsedTorusKnot.radialSegments, parsedTorusKnot.tubularSegments, parsedTorusKnot.p, parsedTorusKnot.q, parsedTorusKnot.canBeRegenerated, null);
  79148. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79149. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torusKnot, parsedTorusKnot.tags);
  79150. }
  79151. scene.pushGeometry(torusKnot, true);
  79152. return torusKnot;
  79153. };
  79154. return TorusKnotGeometry;
  79155. }(_PrimitiveGeometry));
  79156. //}
  79157. /***/ }),
  79158. /***/ "./Meshes/groundMesh.ts":
  79159. /*!******************************!*\
  79160. !*** ./Meshes/groundMesh.ts ***!
  79161. \******************************/
  79162. /*! exports provided: GroundMesh */
  79163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79164. "use strict";
  79165. __webpack_require__.r(__webpack_exports__);
  79166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  79167. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79168. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79169. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  79170. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79171. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  79172. return GroundMesh.Parse(parsedMesh, scene);
  79173. };
  79174. /**
  79175. * Mesh representing the gorund
  79176. */
  79177. var GroundMesh = /** @class */ (function (_super) {
  79178. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  79179. function GroundMesh(name, scene) {
  79180. var _this = _super.call(this, name, scene) || this;
  79181. /** If octree should be generated */
  79182. _this.generateOctree = false;
  79183. return _this;
  79184. }
  79185. /**
  79186. * "GroundMesh"
  79187. * @returns "GroundMesh"
  79188. */
  79189. GroundMesh.prototype.getClassName = function () {
  79190. return "GroundMesh";
  79191. };
  79192. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  79193. /**
  79194. * The minimum of x and y subdivisions
  79195. */
  79196. get: function () {
  79197. return Math.min(this._subdivisionsX, this._subdivisionsY);
  79198. },
  79199. enumerable: true,
  79200. configurable: true
  79201. });
  79202. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  79203. /**
  79204. * X subdivisions
  79205. */
  79206. get: function () {
  79207. return this._subdivisionsX;
  79208. },
  79209. enumerable: true,
  79210. configurable: true
  79211. });
  79212. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  79213. /**
  79214. * Y subdivisions
  79215. */
  79216. get: function () {
  79217. return this._subdivisionsY;
  79218. },
  79219. enumerable: true,
  79220. configurable: true
  79221. });
  79222. /**
  79223. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79224. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79225. * @param chunksCount the number of subdivisions for x and y
  79226. * @param octreeBlocksSize (Default: 32)
  79227. */
  79228. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  79229. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  79230. this._subdivisionsX = chunksCount;
  79231. this._subdivisionsY = chunksCount;
  79232. this.subdivide(chunksCount);
  79233. // Call the octree system optimization if it is defined.
  79234. var thisAsAny = this;
  79235. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  79236. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  79237. }
  79238. };
  79239. /**
  79240. * Returns a height (y) value in the Worl system :
  79241. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79242. * @param x x coordinate
  79243. * @param z z coordinate
  79244. * @returns the ground y position if (x, z) are outside the ground surface.
  79245. */
  79246. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  79247. var world = this.getWorldMatrix();
  79248. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79249. world.invertToRef(invMat);
  79250. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  79252. x = tmpVect.x;
  79253. z = tmpVect.z;
  79254. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79255. return this.position.y;
  79256. }
  79257. if (!this._heightQuads || this._heightQuads.length == 0) {
  79258. this._initHeightQuads();
  79259. this._computeHeightQuads();
  79260. }
  79261. var facet = this._getFacetAt(x, z);
  79262. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  79263. // return y in the World system
  79264. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  79265. return tmpVect.y;
  79266. };
  79267. /**
  79268. * Returns a normalized vector (Vector3) orthogonal to the ground
  79269. * at the ground coordinates (x, z) expressed in the World system.
  79270. * @param x x coordinate
  79271. * @param z z coordinate
  79272. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79273. */
  79274. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  79275. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  79276. this.getNormalAtCoordinatesToRef(x, z, normal);
  79277. return normal;
  79278. };
  79279. /**
  79280. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79281. * at the ground coordinates (x, z) expressed in the World system.
  79282. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79283. * @param x x coordinate
  79284. * @param z z coordinate
  79285. * @param ref vector to store the result
  79286. * @returns the GroundMesh.
  79287. */
  79288. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  79289. var world = this.getWorldMatrix();
  79290. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79291. world.invertToRef(tmpMat);
  79292. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79293. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  79294. x = tmpVect.x;
  79295. z = tmpVect.z;
  79296. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79297. return this;
  79298. }
  79299. if (!this._heightQuads || this._heightQuads.length == 0) {
  79300. this._initHeightQuads();
  79301. this._computeHeightQuads();
  79302. }
  79303. var facet = this._getFacetAt(x, z);
  79304. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  79305. return this;
  79306. };
  79307. /**
  79308. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79309. * if the ground has been updated.
  79310. * This can be used in the render loop.
  79311. * @returns the GroundMesh.
  79312. */
  79313. GroundMesh.prototype.updateCoordinateHeights = function () {
  79314. if (!this._heightQuads || this._heightQuads.length == 0) {
  79315. this._initHeightQuads();
  79316. }
  79317. this._computeHeightQuads();
  79318. return this;
  79319. };
  79320. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  79321. GroundMesh.prototype._getFacetAt = function (x, z) {
  79322. // retrieve col and row from x, z coordinates in the ground local system
  79323. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  79324. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  79325. var quad = this._heightQuads[row * this._subdivisionsX + col];
  79326. var facet;
  79327. if (z < quad.slope.x * x + quad.slope.y) {
  79328. facet = quad.facet1;
  79329. }
  79330. else {
  79331. facet = quad.facet2;
  79332. }
  79333. return facet;
  79334. };
  79335. // Creates and populates the heightMap array with "facet" elements :
  79336. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  79337. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79338. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79339. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79340. // Returns the GroundMesh.
  79341. GroundMesh.prototype._initHeightQuads = function () {
  79342. var subdivisionsX = this._subdivisionsX;
  79343. var subdivisionsY = this._subdivisionsY;
  79344. this._heightQuads = new Array();
  79345. for (var row = 0; row < subdivisionsY; row++) {
  79346. for (var col = 0; col < subdivisionsX; col++) {
  79347. 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) };
  79348. this._heightQuads[row * subdivisionsX + col] = quad;
  79349. }
  79350. }
  79351. return this;
  79352. };
  79353. // Compute each quad element values and update the the heightMap array :
  79354. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79355. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79356. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79357. // Returns the GroundMesh.
  79358. GroundMesh.prototype._computeHeightQuads = function () {
  79359. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79360. if (!positions) {
  79361. return this;
  79362. }
  79363. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  79364. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  79365. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  79366. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  79367. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  79368. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  79369. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  79370. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  79371. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79372. var i = 0;
  79373. var j = 0;
  79374. var k = 0;
  79375. var cd = 0; // 2D slope coefficient : z = cd * x + h
  79376. var h = 0;
  79377. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  79378. var d2 = 0;
  79379. var subdivisionsX = this._subdivisionsX;
  79380. var subdivisionsY = this._subdivisionsY;
  79381. for (var row = 0; row < subdivisionsY; row++) {
  79382. for (var col = 0; col < subdivisionsX; col++) {
  79383. i = col * 3;
  79384. j = row * (subdivisionsX + 1) * 3;
  79385. k = (row + 1) * (subdivisionsX + 1) * 3;
  79386. v1.x = positions[j + i];
  79387. v1.y = positions[j + i + 1];
  79388. v1.z = positions[j + i + 2];
  79389. v2.x = positions[j + i + 3];
  79390. v2.y = positions[j + i + 4];
  79391. v2.z = positions[j + i + 5];
  79392. v3.x = positions[k + i];
  79393. v3.y = positions[k + i + 1];
  79394. v3.z = positions[k + i + 2];
  79395. v4.x = positions[k + i + 3];
  79396. v4.y = positions[k + i + 4];
  79397. v4.z = positions[k + i + 5];
  79398. // 2D slope V1V4
  79399. cd = (v4.z - v1.z) / (v4.x - v1.x);
  79400. h = v1.z - cd * v1.x; // v1 belongs to the slope
  79401. // facet equations :
  79402. // we compute each facet normal vector
  79403. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  79404. // we compute the value d by applying the equation to v1 which belongs to the plane
  79405. // then we store the facet equation in a Vector4
  79406. v2.subtractToRef(v1, v1v2);
  79407. v3.subtractToRef(v1, v1v3);
  79408. v4.subtractToRef(v1, v1v4);
  79409. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  79410. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  79411. norm1.normalize();
  79412. norm2.normalize();
  79413. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  79414. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  79415. var quad = this._heightQuads[row * subdivisionsX + col];
  79416. quad.slope.copyFromFloats(cd, h);
  79417. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  79418. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  79419. }
  79420. }
  79421. return this;
  79422. };
  79423. /**
  79424. * Serializes this ground mesh
  79425. * @param serializationObject object to write serialization to
  79426. */
  79427. GroundMesh.prototype.serialize = function (serializationObject) {
  79428. _super.prototype.serialize.call(this, serializationObject);
  79429. serializationObject.subdivisionsX = this._subdivisionsX;
  79430. serializationObject.subdivisionsY = this._subdivisionsY;
  79431. serializationObject.minX = this._minX;
  79432. serializationObject.maxX = this._maxX;
  79433. serializationObject.minZ = this._minZ;
  79434. serializationObject.maxZ = this._maxZ;
  79435. serializationObject.width = this._width;
  79436. serializationObject.height = this._height;
  79437. };
  79438. /**
  79439. * Parses a serialized ground mesh
  79440. * @param parsedMesh the serialized mesh
  79441. * @param scene the scene to create the ground mesh in
  79442. * @returns the created ground mesh
  79443. */
  79444. GroundMesh.Parse = function (parsedMesh, scene) {
  79445. var result = new GroundMesh(parsedMesh.name, scene);
  79446. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  79447. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  79448. result._minX = parsedMesh.minX;
  79449. result._maxX = parsedMesh.maxX;
  79450. result._minZ = parsedMesh.minZ;
  79451. result._maxZ = parsedMesh.maxZ;
  79452. result._width = parsedMesh.width;
  79453. result._height = parsedMesh.height;
  79454. return result;
  79455. };
  79456. return GroundMesh;
  79457. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  79458. /***/ }),
  79459. /***/ "./Meshes/index.ts":
  79460. /*!*************************!*\
  79461. !*** ./Meshes/index.ts ***!
  79462. \*************************/
  79463. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, DracoCompression */
  79464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79465. "use strict";
  79466. __webpack_require__.r(__webpack_exports__);
  79467. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  79468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  79469. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  79470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  79471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  79472. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  79473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  79474. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  79475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  79476. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  79477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  79478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["_PrimitiveGeometry"]; });
  79479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["RibbonGeometry"]; });
  79480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"]; });
  79481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"]; });
  79482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["DiscGeometry"]; });
  79483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"]; });
  79484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"]; });
  79485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"]; });
  79486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TiledGroundGeometry"]; });
  79487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"]; });
  79488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"]; });
  79489. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  79490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  79491. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  79492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  79493. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  79494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  79495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  79496. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  79497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  79498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  79499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  79500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  79501. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  79503. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  79504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  79505. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  79506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  79507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  79508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  79509. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  79510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  79511. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  79512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  79513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  79514. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  79515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  79516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  79517. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  79518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  79519. /***/ }),
  79520. /***/ "./Meshes/instancedMesh.ts":
  79521. /*!*********************************!*\
  79522. !*** ./Meshes/instancedMesh.ts ***!
  79523. \*********************************/
  79524. /*! exports provided: InstancedMesh */
  79525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79526. "use strict";
  79527. __webpack_require__.r(__webpack_exports__);
  79528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  79529. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79530. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  79531. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  79532. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79533. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  79534. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  79535. return new InstancedMesh(name, mesh);
  79536. };
  79537. /**
  79538. * Creates an instance based on a source mesh.
  79539. */
  79540. var InstancedMesh = /** @class */ (function (_super) {
  79541. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  79542. function InstancedMesh(name, source) {
  79543. var _this = _super.call(this, name, source.getScene()) || this;
  79544. /** @hidden */
  79545. _this._indexInSourceMeshInstanceArray = -1;
  79546. source.addInstance(_this);
  79547. _this._sourceMesh = source;
  79548. _this.position.copyFrom(source.position);
  79549. _this.rotation.copyFrom(source.rotation);
  79550. _this.scaling.copyFrom(source.scaling);
  79551. if (source.rotationQuaternion) {
  79552. _this.rotationQuaternion = source.rotationQuaternion.clone();
  79553. }
  79554. _this.infiniteDistance = source.infiniteDistance;
  79555. _this.setPivotMatrix(source.getPivotMatrix());
  79556. _this.refreshBoundingInfo();
  79557. _this._syncSubMeshes();
  79558. return _this;
  79559. }
  79560. /**
  79561. * Returns the string "InstancedMesh".
  79562. */
  79563. InstancedMesh.prototype.getClassName = function () {
  79564. return "InstancedMesh";
  79565. };
  79566. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  79567. // Methods
  79568. /**
  79569. * If the source mesh receives shadows
  79570. */
  79571. get: function () {
  79572. return this._sourceMesh.receiveShadows;
  79573. },
  79574. enumerable: true,
  79575. configurable: true
  79576. });
  79577. Object.defineProperty(InstancedMesh.prototype, "material", {
  79578. /**
  79579. * The material of the source mesh
  79580. */
  79581. get: function () {
  79582. return this._sourceMesh.material;
  79583. },
  79584. enumerable: true,
  79585. configurable: true
  79586. });
  79587. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  79588. /**
  79589. * Visibility of the source mesh
  79590. */
  79591. get: function () {
  79592. return this._sourceMesh.visibility;
  79593. },
  79594. enumerable: true,
  79595. configurable: true
  79596. });
  79597. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  79598. /**
  79599. * Skeleton of the source mesh
  79600. */
  79601. get: function () {
  79602. return this._sourceMesh.skeleton;
  79603. },
  79604. enumerable: true,
  79605. configurable: true
  79606. });
  79607. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  79608. /**
  79609. * Rendering ground id of the source mesh
  79610. */
  79611. get: function () {
  79612. return this._sourceMesh.renderingGroupId;
  79613. },
  79614. set: function (value) {
  79615. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  79616. return;
  79617. }
  79618. //no-op with warning
  79619. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  79620. },
  79621. enumerable: true,
  79622. configurable: true
  79623. });
  79624. /**
  79625. * Returns the total number of vertices (integer).
  79626. */
  79627. InstancedMesh.prototype.getTotalVertices = function () {
  79628. return this._sourceMesh.getTotalVertices();
  79629. };
  79630. /**
  79631. * Returns a positive integer : the total number of indices in this mesh geometry.
  79632. * @returns the numner of indices or zero if the mesh has no geometry.
  79633. */
  79634. InstancedMesh.prototype.getTotalIndices = function () {
  79635. return this._sourceMesh.getTotalIndices();
  79636. };
  79637. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  79638. /**
  79639. * The source mesh of the instance
  79640. */
  79641. get: function () {
  79642. return this._sourceMesh;
  79643. },
  79644. enumerable: true,
  79645. configurable: true
  79646. });
  79647. /**
  79648. * Is this node ready to be used/rendered
  79649. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79650. * @return {boolean} is it ready
  79651. */
  79652. InstancedMesh.prototype.isReady = function (completeCheck) {
  79653. if (completeCheck === void 0) { completeCheck = false; }
  79654. return this._sourceMesh.isReady(completeCheck, true);
  79655. };
  79656. /**
  79657. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79658. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79659. * @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.
  79660. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79661. */
  79662. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  79663. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  79664. };
  79665. /**
  79666. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79667. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79668. * The `data` are either a numeric array either a Float32Array.
  79669. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79670. * 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).
  79671. * Note that a new underlying VertexBuffer object is created each call.
  79672. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79673. *
  79674. * Possible `kind` values :
  79675. * - VertexBuffer.PositionKind
  79676. * - VertexBuffer.UVKind
  79677. * - VertexBuffer.UV2Kind
  79678. * - VertexBuffer.UV3Kind
  79679. * - VertexBuffer.UV4Kind
  79680. * - VertexBuffer.UV5Kind
  79681. * - VertexBuffer.UV6Kind
  79682. * - VertexBuffer.ColorKind
  79683. * - VertexBuffer.MatricesIndicesKind
  79684. * - VertexBuffer.MatricesIndicesExtraKind
  79685. * - VertexBuffer.MatricesWeightsKind
  79686. * - VertexBuffer.MatricesWeightsExtraKind
  79687. *
  79688. * Returns the Mesh.
  79689. */
  79690. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79691. if (this.sourceMesh) {
  79692. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  79693. }
  79694. return this.sourceMesh;
  79695. };
  79696. /**
  79697. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79698. * If the mesh has no geometry, it is simply returned as it is.
  79699. * The `data` are either a numeric array either a Float32Array.
  79700. * No new underlying VertexBuffer object is created.
  79701. * 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.
  79702. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  79703. *
  79704. * Possible `kind` values :
  79705. * - VertexBuffer.PositionKind
  79706. * - VertexBuffer.UVKind
  79707. * - VertexBuffer.UV2Kind
  79708. * - VertexBuffer.UV3Kind
  79709. * - VertexBuffer.UV4Kind
  79710. * - VertexBuffer.UV5Kind
  79711. * - VertexBuffer.UV6Kind
  79712. * - VertexBuffer.ColorKind
  79713. * - VertexBuffer.MatricesIndicesKind
  79714. * - VertexBuffer.MatricesIndicesExtraKind
  79715. * - VertexBuffer.MatricesWeightsKind
  79716. * - VertexBuffer.MatricesWeightsExtraKind
  79717. *
  79718. * Returns the Mesh.
  79719. */
  79720. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79721. if (this.sourceMesh) {
  79722. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  79723. }
  79724. return this.sourceMesh;
  79725. };
  79726. /**
  79727. * Sets the mesh indices.
  79728. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  79729. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79730. * This method creates a new index buffer each call.
  79731. * Returns the Mesh.
  79732. */
  79733. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  79734. if (totalVertices === void 0) { totalVertices = null; }
  79735. if (this.sourceMesh) {
  79736. this.sourceMesh.setIndices(indices, totalVertices);
  79737. }
  79738. return this.sourceMesh;
  79739. };
  79740. /**
  79741. * Boolean : True if the mesh owns the requested kind of data.
  79742. */
  79743. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  79744. return this._sourceMesh.isVerticesDataPresent(kind);
  79745. };
  79746. /**
  79747. * Returns an array of indices (IndicesArray).
  79748. */
  79749. InstancedMesh.prototype.getIndices = function () {
  79750. return this._sourceMesh.getIndices();
  79751. };
  79752. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  79753. get: function () {
  79754. return this._sourceMesh._positions;
  79755. },
  79756. enumerable: true,
  79757. configurable: true
  79758. });
  79759. /**
  79760. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79761. * This means the mesh underlying bounding box and sphere are recomputed.
  79762. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79763. * @returns the current mesh
  79764. */
  79765. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79766. if (applySkeleton === void 0) { applySkeleton = false; }
  79767. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79768. return this;
  79769. }
  79770. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  79771. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  79772. return this;
  79773. };
  79774. /** @hidden */
  79775. InstancedMesh.prototype._preActivate = function () {
  79776. if (this._currentLOD) {
  79777. this._currentLOD._preActivate();
  79778. }
  79779. return this;
  79780. };
  79781. /** @hidden */
  79782. InstancedMesh.prototype._activate = function (renderId) {
  79783. if (this._currentLOD) {
  79784. this._currentLOD._registerInstanceForRenderId(this, renderId);
  79785. }
  79786. return this;
  79787. };
  79788. /**
  79789. * Returns the current associated LOD AbstractMesh.
  79790. */
  79791. InstancedMesh.prototype.getLOD = function (camera) {
  79792. if (!camera) {
  79793. return this;
  79794. }
  79795. var boundingInfo = this.getBoundingInfo();
  79796. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  79797. if (this._currentLOD === this.sourceMesh) {
  79798. return this;
  79799. }
  79800. return this._currentLOD;
  79801. };
  79802. /** @hidden */
  79803. InstancedMesh.prototype._syncSubMeshes = function () {
  79804. this.releaseSubMeshes();
  79805. if (this._sourceMesh.subMeshes) {
  79806. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  79807. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  79808. }
  79809. }
  79810. return this;
  79811. };
  79812. /** @hidden */
  79813. InstancedMesh.prototype._generatePointsArray = function () {
  79814. return this._sourceMesh._generatePointsArray();
  79815. };
  79816. /**
  79817. * Creates a new InstancedMesh from the current mesh.
  79818. * - name (string) : the cloned mesh name
  79819. * - newParent (optional Node) : the optional Node to parent the clone to.
  79820. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  79821. *
  79822. * Returns the clone.
  79823. */
  79824. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79825. var result = this._sourceMesh.createInstance(name);
  79826. // Deep copy
  79827. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  79828. // Bounding info
  79829. this.refreshBoundingInfo();
  79830. // Parent
  79831. if (newParent) {
  79832. result.parent = newParent;
  79833. }
  79834. if (!doNotCloneChildren) {
  79835. // Children
  79836. for (var index = 0; index < this.getScene().meshes.length; index++) {
  79837. var mesh = this.getScene().meshes[index];
  79838. if (mesh.parent === this) {
  79839. mesh.clone(mesh.name, result);
  79840. }
  79841. }
  79842. }
  79843. result.computeWorldMatrix(true);
  79844. return result;
  79845. };
  79846. /**
  79847. * Disposes the InstancedMesh.
  79848. * Returns nothing.
  79849. */
  79850. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79851. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79852. // Remove from mesh
  79853. this._sourceMesh.removeInstance(this);
  79854. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79855. };
  79856. return InstancedMesh;
  79857. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  79858. /***/ }),
  79859. /***/ "./Meshes/linesMesh.ts":
  79860. /*!*****************************!*\
  79861. !*** ./Meshes/linesMesh.ts ***!
  79862. \*****************************/
  79863. /*! exports provided: LinesMesh, InstancedLinesMesh */
  79864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79865. "use strict";
  79866. __webpack_require__.r(__webpack_exports__);
  79867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  79868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  79869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79870. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79871. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  79872. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79873. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  79874. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  79875. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  79876. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  79877. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  79878. /**
  79879. * Line mesh
  79880. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79881. */
  79882. var LinesMesh = /** @class */ (function (_super) {
  79883. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  79884. /**
  79885. * Creates a new LinesMesh
  79886. * @param name defines the name
  79887. * @param scene defines the hosting scene
  79888. * @param parent defines the parent mesh if any
  79889. * @param source defines the optional source LinesMesh used to clone data from
  79890. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79891. * When false, achieved by calling a clone(), also passing False.
  79892. * This will make creation of children, recursive.
  79893. * @param useVertexColor defines if this LinesMesh supports vertex color
  79894. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79895. */
  79896. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  79897. /**
  79898. * If vertex color should be applied to the mesh
  79899. */
  79900. useVertexColor,
  79901. /**
  79902. * If vertex alpha should be applied to the mesh
  79903. */
  79904. useVertexAlpha) {
  79905. if (scene === void 0) { scene = null; }
  79906. if (parent === void 0) { parent = null; }
  79907. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  79908. _this.useVertexColor = useVertexColor;
  79909. _this.useVertexAlpha = useVertexAlpha;
  79910. /**
  79911. * Color of the line (Default: White)
  79912. */
  79913. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  79914. /**
  79915. * Alpha of the line (Default: 1)
  79916. */
  79917. _this.alpha = 1;
  79918. if (source) {
  79919. _this.color = source.color.clone();
  79920. _this.alpha = source.alpha;
  79921. _this.useVertexColor = source.useVertexColor;
  79922. _this.useVertexAlpha = source.useVertexAlpha;
  79923. }
  79924. _this.intersectionThreshold = 0.1;
  79925. var defines = [];
  79926. var options = {
  79927. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  79928. uniforms: ["world", "viewProjection"],
  79929. needAlphaBlending: true,
  79930. defines: defines
  79931. };
  79932. if (useVertexAlpha === false) {
  79933. options.needAlphaBlending = false;
  79934. }
  79935. if (!useVertexColor) {
  79936. options.uniforms.push("color");
  79937. }
  79938. else {
  79939. options.defines.push("#define VERTEXCOLOR");
  79940. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  79941. }
  79942. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  79943. return _this;
  79944. }
  79945. /**
  79946. * Returns the string "LineMesh"
  79947. */
  79948. LinesMesh.prototype.getClassName = function () {
  79949. return "LinesMesh";
  79950. };
  79951. Object.defineProperty(LinesMesh.prototype, "material", {
  79952. /**
  79953. * @hidden
  79954. */
  79955. get: function () {
  79956. return this._colorShader;
  79957. },
  79958. /**
  79959. * @hidden
  79960. */
  79961. set: function (value) {
  79962. // Do nothing
  79963. },
  79964. enumerable: true,
  79965. configurable: true
  79966. });
  79967. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  79968. /**
  79969. * @hidden
  79970. */
  79971. get: function () {
  79972. return false;
  79973. },
  79974. enumerable: true,
  79975. configurable: true
  79976. });
  79977. /** @hidden */
  79978. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  79979. if (!this._geometry) {
  79980. return this;
  79981. }
  79982. // VBOs
  79983. this._geometry._bind(this._colorShader.getEffect());
  79984. // Color
  79985. if (!this.useVertexColor) {
  79986. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  79987. }
  79988. return this;
  79989. };
  79990. /** @hidden */
  79991. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  79992. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  79993. return this;
  79994. }
  79995. var engine = this.getScene().getEngine();
  79996. // Draw order
  79997. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  79998. return this;
  79999. };
  80000. /**
  80001. * Disposes of the line mesh
  80002. * @param doNotRecurse If children should be disposed
  80003. */
  80004. LinesMesh.prototype.dispose = function (doNotRecurse) {
  80005. this._colorShader.dispose(false, false, true);
  80006. _super.prototype.dispose.call(this, doNotRecurse);
  80007. };
  80008. /**
  80009. * Returns a new LineMesh object cloned from the current one.
  80010. */
  80011. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  80012. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  80013. };
  80014. /**
  80015. * Creates a new InstancedLinesMesh object from the mesh model.
  80016. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80017. * @param name defines the name of the new instance
  80018. * @returns a new InstancedLinesMesh
  80019. */
  80020. LinesMesh.prototype.createInstance = function (name) {
  80021. return new InstancedLinesMesh(name, this);
  80022. };
  80023. return LinesMesh;
  80024. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  80025. /**
  80026. * Creates an instance based on a source LinesMesh
  80027. */
  80028. var InstancedLinesMesh = /** @class */ (function (_super) {
  80029. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  80030. function InstancedLinesMesh(name, source) {
  80031. var _this = _super.call(this, name, source) || this;
  80032. _this.intersectionThreshold = source.intersectionThreshold;
  80033. return _this;
  80034. }
  80035. /**
  80036. * Returns the string "InstancedLinesMesh".
  80037. */
  80038. InstancedLinesMesh.prototype.getClassName = function () {
  80039. return "InstancedLinesMesh";
  80040. };
  80041. return InstancedLinesMesh;
  80042. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  80043. /***/ }),
  80044. /***/ "./Meshes/mesh.ts":
  80045. /*!************************!*\
  80046. !*** ./Meshes/mesh.ts ***!
  80047. \************************/
  80048. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  80049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80050. "use strict";
  80051. __webpack_require__.r(__webpack_exports__);
  80052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  80053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  80054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  80055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  80056. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80057. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80058. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80059. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  80060. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  80061. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80062. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  80063. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  80064. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80065. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  80066. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  80067. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  80068. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80069. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  80070. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  80071. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  80072. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  80073. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80074. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  80075. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  80076. /**
  80077. * Class used to represent a specific level of detail of a mesh
  80078. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80079. */
  80080. var MeshLODLevel = /** @class */ (function () {
  80081. /**
  80082. * Creates a new LOD level
  80083. * @param distance defines the distance where this level should star being displayed
  80084. * @param mesh defines the mesh to use to render this level
  80085. */
  80086. function MeshLODLevel(
  80087. /** Defines the distance where this level should star being displayed */
  80088. distance,
  80089. /** Defines the mesh to use to render this level */
  80090. mesh) {
  80091. this.distance = distance;
  80092. this.mesh = mesh;
  80093. }
  80094. return MeshLODLevel;
  80095. }());
  80096. /**
  80097. * @hidden
  80098. **/
  80099. var _CreationDataStorage = /** @class */ (function () {
  80100. function _CreationDataStorage() {
  80101. }
  80102. return _CreationDataStorage;
  80103. }());
  80104. /**
  80105. * @hidden
  80106. **/
  80107. var _InstanceDataStorage = /** @class */ (function () {
  80108. function _InstanceDataStorage() {
  80109. this.visibleInstances = {};
  80110. this.renderIdForInstances = new Array();
  80111. this.batchCache = new _InstancesBatch();
  80112. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  80113. }
  80114. return _InstanceDataStorage;
  80115. }());
  80116. /**
  80117. * @hidden
  80118. **/
  80119. var _InstancesBatch = /** @class */ (function () {
  80120. function _InstancesBatch() {
  80121. this.mustReturn = false;
  80122. this.visibleInstances = new Array();
  80123. this.renderSelf = new Array();
  80124. }
  80125. return _InstancesBatch;
  80126. }());
  80127. /**
  80128. * Class used to represent renderable models
  80129. */
  80130. var Mesh = /** @class */ (function (_super) {
  80131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  80132. /**
  80133. * @constructor
  80134. * @param name The value used by scene.getMeshByName() to do a lookup.
  80135. * @param scene The scene to add this mesh to.
  80136. * @param parent The parent of this mesh, if it has one
  80137. * @param source An optional Mesh from which geometry is shared, cloned.
  80138. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80139. * When false, achieved by calling a clone(), also passing False.
  80140. * This will make creation of children, recursive.
  80141. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80142. */
  80143. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  80144. if (scene === void 0) { scene = null; }
  80145. if (parent === void 0) { parent = null; }
  80146. if (source === void 0) { source = null; }
  80147. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  80148. var _this = _super.call(this, name, scene) || this;
  80149. // Members
  80150. /**
  80151. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80152. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80153. */
  80154. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NONE;
  80155. /**
  80156. * Gets the list of instances created from this mesh
  80157. * it is not supposed to be modified manually.
  80158. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80159. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80160. */
  80161. _this.instances = new Array();
  80162. _this._LODLevels = new Array();
  80163. /** @hidden */
  80164. _this._instanceDataStorage = new _InstanceDataStorage();
  80165. // Use by builder only to know what orientation were the mesh build in.
  80166. /** @hidden */
  80167. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  80168. /**
  80169. * Use this property to change the original side orientation defined at construction time
  80170. */
  80171. _this.overrideMaterialSideOrientation = null;
  80172. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  80173. // Will be used to save a source mesh reference, If any
  80174. _this._source = null;
  80175. /** @hidden */
  80176. _this._isMesh = true;
  80177. scene = _this.getScene();
  80178. if (source) {
  80179. // Geometry
  80180. if (source._geometry) {
  80181. source._geometry.applyToMesh(_this);
  80182. }
  80183. // Deep copy
  80184. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  80185. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  80186. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  80187. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  80188. "onDisposeObservable"
  80189. ], ["_poseMatrix"]);
  80190. // Source mesh
  80191. _this._source = source;
  80192. if (scene.useClonedMeshhMap) {
  80193. if (!source.meshMap) {
  80194. source.meshMap = {};
  80195. }
  80196. source.meshMap[_this.uniqueId] = _this;
  80197. }
  80198. // Construction Params
  80199. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  80200. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  80201. _this._creationDataStorage = source._creationDataStorage;
  80202. // Animation ranges
  80203. if (_this._source._ranges) {
  80204. var ranges = _this._source._ranges;
  80205. for (var name in ranges) {
  80206. if (!ranges.hasOwnProperty(name)) {
  80207. continue;
  80208. }
  80209. if (!ranges[name]) {
  80210. continue;
  80211. }
  80212. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  80213. }
  80214. }
  80215. // Metadata
  80216. if (source.metadata && source.metadata.clone) {
  80217. _this.metadata = source.metadata.clone();
  80218. }
  80219. else {
  80220. _this.metadata = source.metadata;
  80221. }
  80222. // Tags
  80223. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  80224. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  80225. }
  80226. // Parent
  80227. _this.parent = source.parent;
  80228. // Pivot
  80229. _this.setPivotMatrix(source.getPivotMatrix());
  80230. _this.id = name + "." + source.id;
  80231. // Material
  80232. _this.material = source.material;
  80233. var index;
  80234. if (!doNotCloneChildren) {
  80235. // Children
  80236. var directDescendants = source.getDescendants(true);
  80237. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  80238. var child = directDescendants[index_1];
  80239. if (child.clone) {
  80240. child.clone(name + "." + child.name, _this);
  80241. }
  80242. }
  80243. }
  80244. // Physics clone
  80245. var physicsEngine = _this.getScene().getPhysicsEngine();
  80246. if (clonePhysicsImpostor && physicsEngine) {
  80247. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  80248. if (impostor) {
  80249. _this.physicsImpostor = impostor.clone(_this);
  80250. }
  80251. }
  80252. // Particles
  80253. for (index = 0; index < scene.particleSystems.length; index++) {
  80254. var system = scene.particleSystems[index];
  80255. if (system.emitter === source) {
  80256. system.clone(system.name, _this);
  80257. }
  80258. }
  80259. _this.refreshBoundingInfo();
  80260. _this.computeWorldMatrix(true);
  80261. }
  80262. // Parent
  80263. if (parent !== null) {
  80264. _this.parent = parent;
  80265. }
  80266. return _this;
  80267. }
  80268. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  80269. /**
  80270. * An event triggered before rendering the mesh
  80271. */
  80272. get: function () {
  80273. if (!this._onBeforeRenderObservable) {
  80274. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80275. }
  80276. return this._onBeforeRenderObservable;
  80277. },
  80278. enumerable: true,
  80279. configurable: true
  80280. });
  80281. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  80282. /**
  80283. * An event triggered after rendering the mesh
  80284. */
  80285. get: function () {
  80286. if (!this._onAfterRenderObservable) {
  80287. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80288. }
  80289. return this._onAfterRenderObservable;
  80290. },
  80291. enumerable: true,
  80292. configurable: true
  80293. });
  80294. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  80295. /**
  80296. * An event triggered before drawing the mesh
  80297. */
  80298. get: function () {
  80299. if (!this._onBeforeDrawObservable) {
  80300. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80301. }
  80302. return this._onBeforeDrawObservable;
  80303. },
  80304. enumerable: true,
  80305. configurable: true
  80306. });
  80307. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  80308. /**
  80309. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80310. */
  80311. set: function (callback) {
  80312. if (this._onBeforeDrawObserver) {
  80313. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  80314. }
  80315. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  80316. },
  80317. enumerable: true,
  80318. configurable: true
  80319. });
  80320. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  80321. /**
  80322. * Gets or sets the morph target manager
  80323. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80324. */
  80325. get: function () {
  80326. return this._morphTargetManager;
  80327. },
  80328. set: function (value) {
  80329. if (this._morphTargetManager === value) {
  80330. return;
  80331. }
  80332. this._morphTargetManager = value;
  80333. this._syncGeometryWithMorphTargetManager();
  80334. },
  80335. enumerable: true,
  80336. configurable: true
  80337. });
  80338. Object.defineProperty(Mesh.prototype, "source", {
  80339. /**
  80340. * Gets the source mesh (the one used to clone this one from)
  80341. */
  80342. get: function () {
  80343. return this._source;
  80344. },
  80345. enumerable: true,
  80346. configurable: true
  80347. });
  80348. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  80349. /**
  80350. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80351. */
  80352. get: function () {
  80353. return this._unIndexed;
  80354. },
  80355. set: function (value) {
  80356. if (this._unIndexed !== value) {
  80357. this._unIndexed = value;
  80358. this._markSubMeshesAsAttributesDirty();
  80359. }
  80360. },
  80361. enumerable: true,
  80362. configurable: true
  80363. });
  80364. // Methods
  80365. /**
  80366. * Gets the class name
  80367. * @returns the string "Mesh".
  80368. */
  80369. Mesh.prototype.getClassName = function () {
  80370. return "Mesh";
  80371. };
  80372. /**
  80373. * Returns a description of this mesh
  80374. * @param fullDetails define if full details about this mesh must be used
  80375. * @returns a descriptive string representing this mesh
  80376. */
  80377. Mesh.prototype.toString = function (fullDetails) {
  80378. var ret = _super.prototype.toString.call(this, fullDetails);
  80379. ret += ", n vertices: " + this.getTotalVertices();
  80380. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  80381. if (this.animations) {
  80382. for (var i = 0; i < this.animations.length; i++) {
  80383. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  80384. }
  80385. }
  80386. if (fullDetails) {
  80387. if (this._geometry) {
  80388. var ib = this.getIndices();
  80389. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  80390. if (vb && ib) {
  80391. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  80392. }
  80393. }
  80394. else {
  80395. ret += ", flat shading: UNKNOWN";
  80396. }
  80397. }
  80398. return ret;
  80399. };
  80400. /** @hidden */
  80401. Mesh.prototype._unBindEffect = function () {
  80402. _super.prototype._unBindEffect.call(this);
  80403. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  80404. var instance = _a[_i];
  80405. instance._unBindEffect();
  80406. }
  80407. };
  80408. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  80409. /**
  80410. * Gets a boolean indicating if this mesh has LOD
  80411. */
  80412. get: function () {
  80413. return this._LODLevels.length > 0;
  80414. },
  80415. enumerable: true,
  80416. configurable: true
  80417. });
  80418. /**
  80419. * Gets the list of MeshLODLevel associated with the current mesh
  80420. * @returns an array of MeshLODLevel
  80421. */
  80422. Mesh.prototype.getLODLevels = function () {
  80423. return this._LODLevels;
  80424. };
  80425. Mesh.prototype._sortLODLevels = function () {
  80426. this._LODLevels.sort(function (a, b) {
  80427. if (a.distance < b.distance) {
  80428. return 1;
  80429. }
  80430. if (a.distance > b.distance) {
  80431. return -1;
  80432. }
  80433. return 0;
  80434. });
  80435. };
  80436. /**
  80437. * Add a mesh as LOD level triggered at the given distance.
  80438. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80439. * @param distance The distance from the center of the object to show this level
  80440. * @param mesh The mesh to be added as LOD level (can be null)
  80441. * @return This mesh (for chaining)
  80442. */
  80443. Mesh.prototype.addLODLevel = function (distance, mesh) {
  80444. if (mesh && mesh._masterMesh) {
  80445. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  80446. return this;
  80447. }
  80448. var level = new MeshLODLevel(distance, mesh);
  80449. this._LODLevels.push(level);
  80450. if (mesh) {
  80451. mesh._masterMesh = this;
  80452. }
  80453. this._sortLODLevels();
  80454. return this;
  80455. };
  80456. /**
  80457. * Returns the LOD level mesh at the passed distance or null if not found.
  80458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80459. * @param distance The distance from the center of the object to show this level
  80460. * @returns a Mesh or `null`
  80461. */
  80462. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  80463. for (var index = 0; index < this._LODLevels.length; index++) {
  80464. var level = this._LODLevels[index];
  80465. if (level.distance === distance) {
  80466. return level.mesh;
  80467. }
  80468. }
  80469. return null;
  80470. };
  80471. /**
  80472. * Remove a mesh from the LOD array
  80473. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80474. * @param mesh defines the mesh to be removed
  80475. * @return This mesh (for chaining)
  80476. */
  80477. Mesh.prototype.removeLODLevel = function (mesh) {
  80478. for (var index = 0; index < this._LODLevels.length; index++) {
  80479. if (this._LODLevels[index].mesh === mesh) {
  80480. this._LODLevels.splice(index, 1);
  80481. if (mesh) {
  80482. mesh._masterMesh = null;
  80483. }
  80484. }
  80485. }
  80486. this._sortLODLevels();
  80487. return this;
  80488. };
  80489. /**
  80490. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80492. * @param camera defines the camera to use to compute distance
  80493. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80494. * @return This mesh (for chaining)
  80495. */
  80496. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  80497. if (!this._LODLevels || this._LODLevels.length === 0) {
  80498. return this;
  80499. }
  80500. var bSphere;
  80501. if (boundingSphere) {
  80502. bSphere = boundingSphere;
  80503. }
  80504. else {
  80505. var boundingInfo = this.getBoundingInfo();
  80506. bSphere = boundingInfo.boundingSphere;
  80507. }
  80508. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  80509. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  80510. if (this.onLODLevelSelection) {
  80511. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  80512. }
  80513. return this;
  80514. }
  80515. for (var index = 0; index < this._LODLevels.length; index++) {
  80516. var level = this._LODLevels[index];
  80517. if (level.distance < distanceToCamera) {
  80518. if (level.mesh) {
  80519. level.mesh._preActivate();
  80520. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  80521. }
  80522. if (this.onLODLevelSelection) {
  80523. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  80524. }
  80525. return level.mesh;
  80526. }
  80527. }
  80528. if (this.onLODLevelSelection) {
  80529. this.onLODLevelSelection(distanceToCamera, this, this);
  80530. }
  80531. return this;
  80532. };
  80533. Object.defineProperty(Mesh.prototype, "geometry", {
  80534. /**
  80535. * Gets the mesh internal Geometry object
  80536. */
  80537. get: function () {
  80538. return this._geometry;
  80539. },
  80540. enumerable: true,
  80541. configurable: true
  80542. });
  80543. /**
  80544. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80545. * @returns the total number of vertices
  80546. */
  80547. Mesh.prototype.getTotalVertices = function () {
  80548. if (this._geometry === null || this._geometry === undefined) {
  80549. return 0;
  80550. }
  80551. return this._geometry.getTotalVertices();
  80552. };
  80553. /**
  80554. * Returns the content of an associated vertex buffer
  80555. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80556. * - VertexBuffer.PositionKind
  80557. * - VertexBuffer.UVKind
  80558. * - VertexBuffer.UV2Kind
  80559. * - VertexBuffer.UV3Kind
  80560. * - VertexBuffer.UV4Kind
  80561. * - VertexBuffer.UV5Kind
  80562. * - VertexBuffer.UV6Kind
  80563. * - VertexBuffer.ColorKind
  80564. * - VertexBuffer.MatricesIndicesKind
  80565. * - VertexBuffer.MatricesIndicesExtraKind
  80566. * - VertexBuffer.MatricesWeightsKind
  80567. * - VertexBuffer.MatricesWeightsExtraKind
  80568. * @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
  80569. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80570. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80571. */
  80572. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  80573. if (!this._geometry) {
  80574. return null;
  80575. }
  80576. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  80577. };
  80578. /**
  80579. * Returns the mesh VertexBuffer object from the requested `kind`
  80580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80581. * - VertexBuffer.PositionKind
  80582. * - VertexBuffer.UVKind
  80583. * - VertexBuffer.UV2Kind
  80584. * - VertexBuffer.UV3Kind
  80585. * - VertexBuffer.UV4Kind
  80586. * - VertexBuffer.UV5Kind
  80587. * - VertexBuffer.UV6Kind
  80588. * - VertexBuffer.ColorKind
  80589. * - VertexBuffer.MatricesIndicesKind
  80590. * - VertexBuffer.MatricesIndicesExtraKind
  80591. * - VertexBuffer.MatricesWeightsKind
  80592. * - VertexBuffer.MatricesWeightsExtraKind
  80593. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80594. */
  80595. Mesh.prototype.getVertexBuffer = function (kind) {
  80596. if (!this._geometry) {
  80597. return null;
  80598. }
  80599. return this._geometry.getVertexBuffer(kind);
  80600. };
  80601. /**
  80602. * Tests if a specific vertex buffer is associated with this mesh
  80603. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80604. * - VertexBuffer.PositionKind
  80605. * - VertexBuffer.UVKind
  80606. * - VertexBuffer.UV2Kind
  80607. * - VertexBuffer.UV3Kind
  80608. * - VertexBuffer.UV4Kind
  80609. * - VertexBuffer.UV5Kind
  80610. * - VertexBuffer.UV6Kind
  80611. * - VertexBuffer.ColorKind
  80612. * - VertexBuffer.MatricesIndicesKind
  80613. * - VertexBuffer.MatricesIndicesExtraKind
  80614. * - VertexBuffer.MatricesWeightsKind
  80615. * - VertexBuffer.MatricesWeightsExtraKind
  80616. * @returns a boolean
  80617. */
  80618. Mesh.prototype.isVerticesDataPresent = function (kind) {
  80619. if (!this._geometry) {
  80620. if (this._delayInfo) {
  80621. return this._delayInfo.indexOf(kind) !== -1;
  80622. }
  80623. return false;
  80624. }
  80625. return this._geometry.isVerticesDataPresent(kind);
  80626. };
  80627. /**
  80628. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80629. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80630. * - VertexBuffer.PositionKind
  80631. * - VertexBuffer.UVKind
  80632. * - VertexBuffer.UV2Kind
  80633. * - VertexBuffer.UV3Kind
  80634. * - VertexBuffer.UV4Kind
  80635. * - VertexBuffer.UV5Kind
  80636. * - VertexBuffer.UV6Kind
  80637. * - VertexBuffer.ColorKind
  80638. * - VertexBuffer.MatricesIndicesKind
  80639. * - VertexBuffer.MatricesIndicesExtraKind
  80640. * - VertexBuffer.MatricesWeightsKind
  80641. * - VertexBuffer.MatricesWeightsExtraKind
  80642. * @returns a boolean
  80643. */
  80644. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  80645. if (!this._geometry) {
  80646. if (this._delayInfo) {
  80647. return this._delayInfo.indexOf(kind) !== -1;
  80648. }
  80649. return false;
  80650. }
  80651. return this._geometry.isVertexBufferUpdatable(kind);
  80652. };
  80653. /**
  80654. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80656. * - VertexBuffer.PositionKind
  80657. * - VertexBuffer.UVKind
  80658. * - VertexBuffer.UV2Kind
  80659. * - VertexBuffer.UV3Kind
  80660. * - VertexBuffer.UV4Kind
  80661. * - VertexBuffer.UV5Kind
  80662. * - VertexBuffer.UV6Kind
  80663. * - VertexBuffer.ColorKind
  80664. * - VertexBuffer.MatricesIndicesKind
  80665. * - VertexBuffer.MatricesIndicesExtraKind
  80666. * - VertexBuffer.MatricesWeightsKind
  80667. * - VertexBuffer.MatricesWeightsExtraKind
  80668. * @returns an array of strings
  80669. */
  80670. Mesh.prototype.getVerticesDataKinds = function () {
  80671. if (!this._geometry) {
  80672. var result = new Array();
  80673. if (this._delayInfo) {
  80674. this._delayInfo.forEach(function (kind) {
  80675. result.push(kind);
  80676. });
  80677. }
  80678. return result;
  80679. }
  80680. return this._geometry.getVerticesDataKinds();
  80681. };
  80682. /**
  80683. * Returns a positive integer : the total number of indices in this mesh geometry.
  80684. * @returns the numner of indices or zero if the mesh has no geometry.
  80685. */
  80686. Mesh.prototype.getTotalIndices = function () {
  80687. if (!this._geometry) {
  80688. return 0;
  80689. }
  80690. return this._geometry.getTotalIndices();
  80691. };
  80692. /**
  80693. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80694. * @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.
  80695. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80696. * @returns the indices array or an empty array if the mesh has no geometry
  80697. */
  80698. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  80699. if (!this._geometry) {
  80700. return [];
  80701. }
  80702. return this._geometry.getIndices(copyWhenShared, forceCopy);
  80703. };
  80704. Object.defineProperty(Mesh.prototype, "isBlocked", {
  80705. get: function () {
  80706. return this._masterMesh !== null && this._masterMesh !== undefined;
  80707. },
  80708. enumerable: true,
  80709. configurable: true
  80710. });
  80711. /**
  80712. * Determine if the current mesh is ready to be rendered
  80713. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80714. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80715. * @returns true if all associated assets are ready (material, textures, shaders)
  80716. */
  80717. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  80718. if (completeCheck === void 0) { completeCheck = false; }
  80719. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  80720. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  80721. return false;
  80722. }
  80723. if (!_super.prototype.isReady.call(this, completeCheck)) {
  80724. return false;
  80725. }
  80726. if (!this.subMeshes || this.subMeshes.length === 0) {
  80727. return true;
  80728. }
  80729. if (!completeCheck) {
  80730. return true;
  80731. }
  80732. var engine = this.getEngine();
  80733. var scene = this.getScene();
  80734. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  80735. this.computeWorldMatrix();
  80736. var mat = this.material || scene.defaultMaterial;
  80737. if (mat) {
  80738. if (mat._storeEffectOnSubMeshes) {
  80739. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80740. var subMesh = _a[_i];
  80741. var effectiveMaterial = subMesh.getMaterial();
  80742. if (effectiveMaterial) {
  80743. if (effectiveMaterial._storeEffectOnSubMeshes) {
  80744. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  80745. return false;
  80746. }
  80747. }
  80748. else {
  80749. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  80750. return false;
  80751. }
  80752. }
  80753. }
  80754. }
  80755. }
  80756. else {
  80757. if (!mat.isReady(this, hardwareInstancedRendering)) {
  80758. return false;
  80759. }
  80760. }
  80761. }
  80762. // Shadows
  80763. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  80764. var light = _c[_b];
  80765. var generator = light.getShadowGenerator();
  80766. if (generator) {
  80767. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  80768. var subMesh = _e[_d];
  80769. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  80770. return false;
  80771. }
  80772. }
  80773. }
  80774. }
  80775. // LOD
  80776. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  80777. var lod = _g[_f];
  80778. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  80779. return false;
  80780. }
  80781. }
  80782. return true;
  80783. };
  80784. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  80785. /**
  80786. * 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.
  80787. */
  80788. get: function () {
  80789. return this._areNormalsFrozen;
  80790. },
  80791. enumerable: true,
  80792. configurable: true
  80793. });
  80794. /**
  80795. * 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.
  80796. * @returns the current mesh
  80797. */
  80798. Mesh.prototype.freezeNormals = function () {
  80799. this._areNormalsFrozen = true;
  80800. return this;
  80801. };
  80802. /**
  80803. * 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
  80804. * @returns the current mesh
  80805. */
  80806. Mesh.prototype.unfreezeNormals = function () {
  80807. this._areNormalsFrozen = false;
  80808. return this;
  80809. };
  80810. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  80811. /**
  80812. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80813. */
  80814. set: function (count) {
  80815. this._instanceDataStorage.overridenInstanceCount = count;
  80816. },
  80817. enumerable: true,
  80818. configurable: true
  80819. });
  80820. // Methods
  80821. /** @hidden */
  80822. Mesh.prototype._preActivate = function () {
  80823. var sceneRenderId = this.getScene().getRenderId();
  80824. if (this._preActivateId === sceneRenderId) {
  80825. return this;
  80826. }
  80827. this._preActivateId = sceneRenderId;
  80828. this._instanceDataStorage.visibleInstances = null;
  80829. return this;
  80830. };
  80831. /** @hidden */
  80832. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  80833. if (this._instanceDataStorage.visibleInstances) {
  80834. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  80835. }
  80836. return this;
  80837. };
  80838. /** @hidden */
  80839. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  80840. if (!this._instanceDataStorage.visibleInstances) {
  80841. this._instanceDataStorage.visibleInstances = {
  80842. defaultRenderId: renderId,
  80843. selfDefaultRenderId: this._renderId
  80844. };
  80845. }
  80846. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  80847. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  80848. }
  80849. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  80850. return this;
  80851. };
  80852. /**
  80853. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80854. * This means the mesh underlying bounding box and sphere are recomputed.
  80855. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80856. * @returns the current mesh
  80857. */
  80858. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  80859. if (applySkeleton === void 0) { applySkeleton = false; }
  80860. if (this._boundingInfo && this._boundingInfo.isLocked) {
  80861. return this;
  80862. }
  80863. var bias = this.geometry ? this.geometry.boundingBias : null;
  80864. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  80865. return this;
  80866. };
  80867. /** @hidden */
  80868. Mesh.prototype._createGlobalSubMesh = function (force) {
  80869. var totalVertices = this.getTotalVertices();
  80870. if (!totalVertices || !this.getIndices()) {
  80871. return null;
  80872. }
  80873. // Check if we need to recreate the submeshes
  80874. if (this.subMeshes && this.subMeshes.length > 0) {
  80875. var ib = this.getIndices();
  80876. if (!ib) {
  80877. return null;
  80878. }
  80879. var totalIndices = ib.length;
  80880. var needToRecreate = false;
  80881. if (force) {
  80882. needToRecreate = true;
  80883. }
  80884. else {
  80885. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80886. var submesh = _a[_i];
  80887. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  80888. needToRecreate = true;
  80889. break;
  80890. }
  80891. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  80892. needToRecreate = true;
  80893. break;
  80894. }
  80895. }
  80896. }
  80897. if (!needToRecreate) {
  80898. return this.subMeshes[0];
  80899. }
  80900. }
  80901. this.releaseSubMeshes();
  80902. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  80903. };
  80904. /**
  80905. * This function will subdivide the mesh into multiple submeshes
  80906. * @param count defines the expected number of submeshes
  80907. */
  80908. Mesh.prototype.subdivide = function (count) {
  80909. if (count < 1) {
  80910. return;
  80911. }
  80912. var totalIndices = this.getTotalIndices();
  80913. var subdivisionSize = (totalIndices / count) | 0;
  80914. var offset = 0;
  80915. // Ensure that subdivisionSize is a multiple of 3
  80916. while (subdivisionSize % 3 !== 0) {
  80917. subdivisionSize++;
  80918. }
  80919. this.releaseSubMeshes();
  80920. for (var index = 0; index < count; index++) {
  80921. if (offset >= totalIndices) {
  80922. break;
  80923. }
  80924. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  80925. offset += subdivisionSize;
  80926. }
  80927. this.synchronizeInstances();
  80928. };
  80929. /**
  80930. * Copy a FloatArray into a specific associated vertex buffer
  80931. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80932. * - VertexBuffer.PositionKind
  80933. * - VertexBuffer.UVKind
  80934. * - VertexBuffer.UV2Kind
  80935. * - VertexBuffer.UV3Kind
  80936. * - VertexBuffer.UV4Kind
  80937. * - VertexBuffer.UV5Kind
  80938. * - VertexBuffer.UV6Kind
  80939. * - VertexBuffer.ColorKind
  80940. * - VertexBuffer.MatricesIndicesKind
  80941. * - VertexBuffer.MatricesIndicesExtraKind
  80942. * - VertexBuffer.MatricesWeightsKind
  80943. * - VertexBuffer.MatricesWeightsExtraKind
  80944. * @param data defines the data source
  80945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80946. * @param stride defines the data stride size (can be null)
  80947. * @returns the current mesh
  80948. */
  80949. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  80950. if (updatable === void 0) { updatable = false; }
  80951. if (!this._geometry) {
  80952. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  80953. vertexData.set(data, kind);
  80954. var scene = this.getScene();
  80955. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  80956. }
  80957. else {
  80958. this._geometry.setVerticesData(kind, data, updatable, stride);
  80959. }
  80960. return this;
  80961. };
  80962. /**
  80963. * Flags an associated vertex buffer as updatable
  80964. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80965. * - VertexBuffer.PositionKind
  80966. * - VertexBuffer.UVKind
  80967. * - VertexBuffer.UV2Kind
  80968. * - VertexBuffer.UV3Kind
  80969. * - VertexBuffer.UV4Kind
  80970. * - VertexBuffer.UV5Kind
  80971. * - VertexBuffer.UV6Kind
  80972. * - VertexBuffer.ColorKind
  80973. * - VertexBuffer.MatricesIndicesKind
  80974. * - VertexBuffer.MatricesIndicesExtraKind
  80975. * - VertexBuffer.MatricesWeightsKind
  80976. * - VertexBuffer.MatricesWeightsExtraKind
  80977. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80978. */
  80979. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  80980. if (updatable === void 0) { updatable = true; }
  80981. var vb = this.getVertexBuffer(kind);
  80982. if (!vb || vb.isUpdatable() === updatable) {
  80983. return;
  80984. }
  80985. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  80986. };
  80987. /**
  80988. * Sets the mesh global Vertex Buffer
  80989. * @param buffer defines the buffer to use
  80990. * @returns the current mesh
  80991. */
  80992. Mesh.prototype.setVerticesBuffer = function (buffer) {
  80993. if (!this._geometry) {
  80994. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  80995. }
  80996. this._geometry.setVerticesBuffer(buffer);
  80997. return this;
  80998. };
  80999. /**
  81000. * Update a specific associated vertex buffer
  81001. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81002. * - VertexBuffer.PositionKind
  81003. * - VertexBuffer.UVKind
  81004. * - VertexBuffer.UV2Kind
  81005. * - VertexBuffer.UV3Kind
  81006. * - VertexBuffer.UV4Kind
  81007. * - VertexBuffer.UV5Kind
  81008. * - VertexBuffer.UV6Kind
  81009. * - VertexBuffer.ColorKind
  81010. * - VertexBuffer.MatricesIndicesKind
  81011. * - VertexBuffer.MatricesIndicesExtraKind
  81012. * - VertexBuffer.MatricesWeightsKind
  81013. * - VertexBuffer.MatricesWeightsExtraKind
  81014. * @param data defines the data source
  81015. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81016. * @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)
  81017. * @returns the current mesh
  81018. */
  81019. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81020. if (!this._geometry) {
  81021. return this;
  81022. }
  81023. if (!makeItUnique) {
  81024. this._geometry.updateVerticesData(kind, data, updateExtends);
  81025. }
  81026. else {
  81027. this.makeGeometryUnique();
  81028. this.updateVerticesData(kind, data, updateExtends, false);
  81029. }
  81030. return this;
  81031. };
  81032. /**
  81033. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81034. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81035. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81036. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81037. * @returns the current mesh
  81038. */
  81039. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  81040. if (computeNormals === void 0) { computeNormals = true; }
  81041. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  81042. if (!positions) {
  81043. return this;
  81044. }
  81045. positionFunction(positions);
  81046. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  81047. if (computeNormals) {
  81048. var indices = this.getIndices();
  81049. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81050. if (!normals) {
  81051. return this;
  81052. }
  81053. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  81054. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  81055. }
  81056. return this;
  81057. };
  81058. /**
  81059. * Creates a un-shared specific occurence of the geometry for the mesh.
  81060. * @returns the current mesh
  81061. */
  81062. Mesh.prototype.makeGeometryUnique = function () {
  81063. if (!this._geometry) {
  81064. return this;
  81065. }
  81066. var oldGeometry = this._geometry;
  81067. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  81068. oldGeometry.releaseForMesh(this, true);
  81069. geometry.applyToMesh(this);
  81070. return this;
  81071. };
  81072. /**
  81073. * Set the index buffer of this mesh
  81074. * @param indices defines the source data
  81075. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81076. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81077. * @returns the current mesh
  81078. */
  81079. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  81080. if (totalVertices === void 0) { totalVertices = null; }
  81081. if (updatable === void 0) { updatable = false; }
  81082. if (!this._geometry) {
  81083. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  81084. vertexData.indices = indices;
  81085. var scene = this.getScene();
  81086. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  81087. }
  81088. else {
  81089. this._geometry.setIndices(indices, totalVertices, updatable);
  81090. }
  81091. return this;
  81092. };
  81093. /**
  81094. * Update the current index buffer
  81095. * @param indices defines the source data
  81096. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81097. * @returns the current mesh
  81098. */
  81099. Mesh.prototype.updateIndices = function (indices, offset) {
  81100. if (!this._geometry) {
  81101. return this;
  81102. }
  81103. this._geometry.updateIndices(indices, offset);
  81104. return this;
  81105. };
  81106. /**
  81107. * Invert the geometry to move from a right handed system to a left handed one.
  81108. * @returns the current mesh
  81109. */
  81110. Mesh.prototype.toLeftHanded = function () {
  81111. if (!this._geometry) {
  81112. return this;
  81113. }
  81114. this._geometry.toLeftHanded();
  81115. return this;
  81116. };
  81117. /** @hidden */
  81118. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  81119. if (!this._geometry) {
  81120. return this;
  81121. }
  81122. var engine = this.getScene().getEngine();
  81123. // Wireframe
  81124. var indexToBind;
  81125. if (this._unIndexed) {
  81126. indexToBind = null;
  81127. }
  81128. else {
  81129. switch (fillMode) {
  81130. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  81131. indexToBind = null;
  81132. break;
  81133. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  81134. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  81135. break;
  81136. default:
  81137. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  81138. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  81139. break;
  81140. }
  81141. }
  81142. // VBOs
  81143. this._geometry._bind(effect, indexToBind);
  81144. return this;
  81145. };
  81146. /** @hidden */
  81147. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  81148. if (alternate === void 0) { alternate = false; }
  81149. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81150. return this;
  81151. }
  81152. if (this._onBeforeDrawObservable) {
  81153. this._onBeforeDrawObservable.notifyObservers(this);
  81154. }
  81155. var scene = this.getScene();
  81156. var engine = scene.getEngine();
  81157. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  81158. // or triangles as points
  81159. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  81160. }
  81161. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  81162. // Triangles as wireframe
  81163. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  81164. }
  81165. else {
  81166. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  81167. }
  81168. if (scene._isAlternateRenderingEnabled && !alternate) {
  81169. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  81170. if (!effect || !scene.activeCamera) {
  81171. return this;
  81172. }
  81173. scene._switchToAlternateCameraConfiguration(true);
  81174. this._effectiveMaterial.bindView(effect);
  81175. this._effectiveMaterial.bindViewProjection(effect);
  81176. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  81177. this._draw(subMesh, fillMode, instancesCount, true);
  81178. engine.setViewport(scene.activeCamera.viewport);
  81179. scene._switchToAlternateCameraConfiguration(false);
  81180. this._effectiveMaterial.bindView(effect);
  81181. this._effectiveMaterial.bindViewProjection(effect);
  81182. }
  81183. return this;
  81184. };
  81185. /**
  81186. * Registers for this mesh a javascript function called just before the rendering process
  81187. * @param func defines the function to call before rendering this mesh
  81188. * @returns the current mesh
  81189. */
  81190. Mesh.prototype.registerBeforeRender = function (func) {
  81191. this.onBeforeRenderObservable.add(func);
  81192. return this;
  81193. };
  81194. /**
  81195. * Disposes a previously registered javascript function called before the rendering
  81196. * @param func defines the function to remove
  81197. * @returns the current mesh
  81198. */
  81199. Mesh.prototype.unregisterBeforeRender = function (func) {
  81200. this.onBeforeRenderObservable.removeCallback(func);
  81201. return this;
  81202. };
  81203. /**
  81204. * Registers for this mesh a javascript function called just after the rendering is complete
  81205. * @param func defines the function to call after rendering this mesh
  81206. * @returns the current mesh
  81207. */
  81208. Mesh.prototype.registerAfterRender = function (func) {
  81209. this.onAfterRenderObservable.add(func);
  81210. return this;
  81211. };
  81212. /**
  81213. * Disposes a previously registered javascript function called after the rendering.
  81214. * @param func defines the function to remove
  81215. * @returns the current mesh
  81216. */
  81217. Mesh.prototype.unregisterAfterRender = function (func) {
  81218. this.onAfterRenderObservable.removeCallback(func);
  81219. return this;
  81220. };
  81221. /** @hidden */
  81222. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  81223. var scene = this.getScene();
  81224. var batchCache = this._instanceDataStorage.batchCache;
  81225. batchCache.mustReturn = false;
  81226. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  81227. batchCache.visibleInstances[subMeshId] = null;
  81228. if (this._instanceDataStorage.visibleInstances) {
  81229. var visibleInstances = this._instanceDataStorage.visibleInstances;
  81230. var currentRenderId = scene.getRenderId();
  81231. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  81232. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  81233. var selfRenderId = this._renderId;
  81234. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  81235. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  81236. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  81237. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  81238. }
  81239. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  81240. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  81241. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  81242. batchCache.mustReturn = true;
  81243. return batchCache;
  81244. }
  81245. if (currentRenderId !== selfRenderId) {
  81246. batchCache.renderSelf[subMeshId] = false;
  81247. }
  81248. }
  81249. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  81250. }
  81251. return batchCache;
  81252. };
  81253. /** @hidden */
  81254. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  81255. var visibleInstances = batch.visibleInstances[subMesh._id];
  81256. if (!visibleInstances) {
  81257. return this;
  81258. }
  81259. var matricesCount = visibleInstances.length + 1;
  81260. var bufferSize = matricesCount * 16 * 4;
  81261. var instanceStorage = this._instanceDataStorage;
  81262. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  81263. var instancesBuffer = instanceStorage.instancesBuffer;
  81264. while (instanceStorage.instancesBufferSize < bufferSize) {
  81265. instanceStorage.instancesBufferSize *= 2;
  81266. }
  81267. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81268. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  81269. }
  81270. var offset = 0;
  81271. var instancesCount = 0;
  81272. var world = this.getWorldMatrix();
  81273. if (batch.renderSelf[subMesh._id]) {
  81274. world.copyToArray(instanceStorage.instancesData, offset);
  81275. offset += 16;
  81276. instancesCount++;
  81277. }
  81278. if (visibleInstances) {
  81279. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  81280. var instance = visibleInstances[instanceIndex];
  81281. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  81282. offset += 16;
  81283. instancesCount++;
  81284. }
  81285. }
  81286. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81287. if (instancesBuffer) {
  81288. instancesBuffer.dispose();
  81289. }
  81290. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  81291. instanceStorage.instancesBuffer = instancesBuffer;
  81292. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  81293. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  81294. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  81295. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  81296. }
  81297. else {
  81298. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  81299. }
  81300. this._bind(subMesh, effect, fillMode);
  81301. this._draw(subMesh, fillMode, instancesCount);
  81302. engine.unbindInstanceAttributes();
  81303. return this;
  81304. };
  81305. /** @hidden */
  81306. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  81307. var scene = this.getScene();
  81308. var engine = scene.getEngine();
  81309. if (hardwareInstancedRendering) {
  81310. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  81311. }
  81312. else {
  81313. if (batch.renderSelf[subMesh._id]) {
  81314. // Draw
  81315. if (onBeforeDraw) {
  81316. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  81317. }
  81318. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  81319. }
  81320. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  81321. if (visibleInstancesForSubMesh) {
  81322. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  81323. var instance = visibleInstancesForSubMesh[instanceIndex];
  81324. // World
  81325. var world = instance.getWorldMatrix();
  81326. if (onBeforeDraw) {
  81327. onBeforeDraw(true, world, effectiveMaterial);
  81328. }
  81329. // Draw
  81330. this._draw(subMesh, fillMode);
  81331. }
  81332. }
  81333. }
  81334. return this;
  81335. };
  81336. /**
  81337. * 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
  81338. * @param subMesh defines the subMesh to render
  81339. * @param enableAlphaMode defines if alpha mode can be changed
  81340. * @returns the current mesh
  81341. */
  81342. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  81343. if (this._checkOcclusionQuery()) {
  81344. return this;
  81345. }
  81346. var scene = this.getScene();
  81347. // Managing instances
  81348. var batch = this._getInstancesRenderList(subMesh._id);
  81349. if (batch.mustReturn) {
  81350. return this;
  81351. }
  81352. // Checking geometry state
  81353. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81354. return this;
  81355. }
  81356. if (this._onBeforeRenderObservable) {
  81357. this._onBeforeRenderObservable.notifyObservers(this);
  81358. }
  81359. var engine = scene.getEngine();
  81360. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  81361. // Material
  81362. var material = subMesh.getMaterial();
  81363. if (!material) {
  81364. return this;
  81365. }
  81366. this._effectiveMaterial = material;
  81367. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81368. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  81369. return this;
  81370. }
  81371. }
  81372. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  81373. return this;
  81374. }
  81375. // Alpha mode
  81376. if (enableAlphaMode) {
  81377. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  81378. }
  81379. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  81380. var step = _a[_i];
  81381. step.action(this, subMesh, batch);
  81382. }
  81383. var effect;
  81384. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81385. effect = subMesh.effect;
  81386. }
  81387. else {
  81388. effect = this._effectiveMaterial.getEffect();
  81389. }
  81390. if (!effect) {
  81391. return this;
  81392. }
  81393. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  81394. var sideOrientation = this.overrideMaterialSideOrientation;
  81395. if (sideOrientation == null) {
  81396. sideOrientation = this._effectiveMaterial.sideOrientation;
  81397. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  81398. 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);
  81399. }
  81400. }
  81401. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  81402. if (this._effectiveMaterial.forceDepthWrite) {
  81403. engine.setDepthWrite(true);
  81404. }
  81405. // Bind
  81406. 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);
  81407. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  81408. this._bind(subMesh, effect, fillMode);
  81409. }
  81410. var world = effectiveMesh.getWorldMatrix();
  81411. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81412. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  81413. }
  81414. else {
  81415. this._effectiveMaterial.bind(world, this);
  81416. }
  81417. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  81418. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  81419. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81420. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  81421. }
  81422. // Draw
  81423. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81424. // Unbind
  81425. this._effectiveMaterial.unbind();
  81426. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  81427. var step = _c[_b];
  81428. step.action(this, subMesh, batch);
  81429. }
  81430. if (this._onAfterRenderObservable) {
  81431. this._onAfterRenderObservable.notifyObservers(this);
  81432. }
  81433. return this;
  81434. };
  81435. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  81436. if (isInstance && effectiveMaterial) {
  81437. effectiveMaterial.bindOnlyWorldMatrix(world);
  81438. }
  81439. };
  81440. /**
  81441. * Renormalize the mesh and patch it up if there are no weights
  81442. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81443. * However in the case of zero weights then we set just a single influence to 1.
  81444. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81445. */
  81446. Mesh.prototype.cleanMatrixWeights = function () {
  81447. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  81448. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  81449. this.normalizeSkinWeightsAndExtra();
  81450. }
  81451. else {
  81452. this.normalizeSkinFourWeights();
  81453. }
  81454. }
  81455. };
  81456. // faster 4 weight version.
  81457. Mesh.prototype.normalizeSkinFourWeights = function () {
  81458. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81459. var numWeights = matricesWeights.length;
  81460. for (var a = 0; a < numWeights; a += 4) {
  81461. // accumulate weights
  81462. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81463. // check for invalid weight and just set it to 1.
  81464. if (t === 0) {
  81465. matricesWeights[a] = 1;
  81466. }
  81467. else {
  81468. // renormalize so everything adds to 1 use reciprical
  81469. var recip = 1 / t;
  81470. matricesWeights[a] *= recip;
  81471. matricesWeights[a + 1] *= recip;
  81472. matricesWeights[a + 2] *= recip;
  81473. matricesWeights[a + 3] *= recip;
  81474. }
  81475. }
  81476. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81477. };
  81478. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  81479. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  81480. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81481. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81482. var numWeights = matricesWeights.length;
  81483. for (var a = 0; a < numWeights; a += 4) {
  81484. // accumulate weights
  81485. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81486. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  81487. // check for invalid weight and just set it to 1.
  81488. if (t === 0) {
  81489. matricesWeights[a] = 1;
  81490. }
  81491. else {
  81492. // renormalize so everything adds to 1 use reciprical
  81493. var recip = 1 / t;
  81494. matricesWeights[a] *= recip;
  81495. matricesWeights[a + 1] *= recip;
  81496. matricesWeights[a + 2] *= recip;
  81497. matricesWeights[a + 3] *= recip;
  81498. // same goes for extras
  81499. matricesWeightsExtra[a] *= recip;
  81500. matricesWeightsExtra[a + 1] *= recip;
  81501. matricesWeightsExtra[a + 2] *= recip;
  81502. matricesWeightsExtra[a + 3] *= recip;
  81503. }
  81504. }
  81505. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81506. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  81507. };
  81508. /**
  81509. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81510. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81511. * the user know there was an issue with importing the mesh
  81512. * @returns a validation object with skinned, valid and report string
  81513. */
  81514. Mesh.prototype.validateSkinning = function () {
  81515. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81516. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81517. if (matricesWeights === null || this.skeleton == null) {
  81518. return { skinned: false, valid: true, report: "not skinned" };
  81519. }
  81520. var numWeights = matricesWeights.length;
  81521. var numberNotSorted = 0;
  81522. var missingWeights = 0;
  81523. var maxUsedWeights = 0;
  81524. var numberNotNormalized = 0;
  81525. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  81526. var usedWeightCounts = new Array();
  81527. for (var a = 0; a <= numInfluences; a++) {
  81528. usedWeightCounts[a] = 0;
  81529. }
  81530. var toleranceEpsilon = 0.001;
  81531. for (var a = 0; a < numWeights; a += 4) {
  81532. var lastWeight = matricesWeights[a];
  81533. var t = lastWeight;
  81534. var usedWeights = t === 0 ? 0 : 1;
  81535. for (var b = 1; b < numInfluences; b++) {
  81536. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  81537. if (d > lastWeight) {
  81538. numberNotSorted++;
  81539. }
  81540. if (d !== 0) {
  81541. usedWeights++;
  81542. }
  81543. t += d;
  81544. lastWeight = d;
  81545. }
  81546. // count the buffer weights usage
  81547. usedWeightCounts[usedWeights]++;
  81548. // max influences
  81549. if (usedWeights > maxUsedWeights) {
  81550. maxUsedWeights = usedWeights;
  81551. }
  81552. // check for invalid weight and just set it to 1.
  81553. if (t === 0) {
  81554. missingWeights++;
  81555. }
  81556. else {
  81557. // renormalize so everything adds to 1 use reciprical
  81558. var recip = 1 / t;
  81559. var tolerance = 0;
  81560. for (b = 0; b < numInfluences; b++) {
  81561. if (b < 4) {
  81562. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  81563. }
  81564. else {
  81565. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  81566. }
  81567. }
  81568. // arbitary epsilon value for dicdating not normalized
  81569. if (tolerance > toleranceEpsilon) {
  81570. numberNotNormalized++;
  81571. }
  81572. }
  81573. }
  81574. // validate bone indices are in range of the skeleton
  81575. var numBones = this.skeleton.bones.length;
  81576. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  81577. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  81578. var numBadBoneIndices = 0;
  81579. for (var a = 0; a < numWeights; a++) {
  81580. for (var b = 0; b < numInfluences; b++) {
  81581. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  81582. if (index >= numBones || index < 0) {
  81583. numBadBoneIndices++;
  81584. }
  81585. }
  81586. }
  81587. // log mesh stats
  81588. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  81589. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  81590. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  81591. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  81592. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  81593. };
  81594. /** @hidden */
  81595. Mesh.prototype._checkDelayState = function () {
  81596. var scene = this.getScene();
  81597. if (this._geometry) {
  81598. this._geometry.load(scene);
  81599. }
  81600. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  81601. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING;
  81602. this._queueLoad(scene);
  81603. }
  81604. return this;
  81605. };
  81606. Mesh.prototype._queueLoad = function (scene) {
  81607. var _this = this;
  81608. scene._addPendingData(this);
  81609. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  81610. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  81611. if (data instanceof ArrayBuffer) {
  81612. _this._delayLoadingFunction(data, _this);
  81613. }
  81614. else {
  81615. _this._delayLoadingFunction(JSON.parse(data), _this);
  81616. }
  81617. _this.instances.forEach(function (instance) {
  81618. instance._syncSubMeshes();
  81619. });
  81620. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADED;
  81621. scene._removePendingData(_this);
  81622. }, function () { }, scene.offlineProvider, getBinaryData);
  81623. return this;
  81624. };
  81625. /**
  81626. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81627. * A mesh is in the frustum if its bounding box intersects the frustum
  81628. * @param frustumPlanes defines the frustum to test
  81629. * @returns true if the mesh is in the frustum planes
  81630. */
  81631. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  81632. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  81633. return false;
  81634. }
  81635. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  81636. return false;
  81637. }
  81638. this._checkDelayState();
  81639. return true;
  81640. };
  81641. /**
  81642. * Sets the mesh material by the material or multiMaterial `id` property
  81643. * @param id is a string identifying the material or the multiMaterial
  81644. * @returns the current mesh
  81645. */
  81646. Mesh.prototype.setMaterialByID = function (id) {
  81647. var materials = this.getScene().materials;
  81648. var index;
  81649. for (index = materials.length - 1; index > -1; index--) {
  81650. if (materials[index].id === id) {
  81651. this.material = materials[index];
  81652. return this;
  81653. }
  81654. }
  81655. // Multi
  81656. var multiMaterials = this.getScene().multiMaterials;
  81657. for (index = multiMaterials.length - 1; index > -1; index--) {
  81658. if (multiMaterials[index].id === id) {
  81659. this.material = multiMaterials[index];
  81660. return this;
  81661. }
  81662. }
  81663. return this;
  81664. };
  81665. /**
  81666. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81667. * @returns an array of IAnimatable
  81668. */
  81669. Mesh.prototype.getAnimatables = function () {
  81670. var results = new Array();
  81671. if (this.material) {
  81672. results.push(this.material);
  81673. }
  81674. if (this.skeleton) {
  81675. results.push(this.skeleton);
  81676. }
  81677. return results;
  81678. };
  81679. /**
  81680. * Modifies the mesh geometry according to the passed transformation matrix.
  81681. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81682. * The mesh normals are modified using the same transformation.
  81683. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81684. * @param transform defines the transform matrix to use
  81685. * @see http://doc.babylonjs.com/resources/baking_transformations
  81686. * @returns the current mesh
  81687. */
  81688. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  81689. // Position
  81690. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  81691. return this;
  81692. }
  81693. var submeshes = this.subMeshes.splice(0);
  81694. this._resetPointsArrayCache();
  81695. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  81696. var temp = new Array();
  81697. var index;
  81698. for (index = 0; index < data.length; index += 3) {
  81699. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  81700. }
  81701. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  81702. // Normals
  81703. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  81704. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81705. temp = [];
  81706. for (index = 0; index < data.length; index += 3) {
  81707. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  81708. }
  81709. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  81710. }
  81711. // flip faces?
  81712. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  81713. this.flipFaces();
  81714. }
  81715. // Restore submeshes
  81716. this.releaseSubMeshes();
  81717. this.subMeshes = submeshes;
  81718. return this;
  81719. };
  81720. /**
  81721. * Modifies the mesh geometry according to its own current World Matrix.
  81722. * The mesh World Matrix is then reset.
  81723. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81724. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81725. * @see http://doc.babylonjs.com/resources/baking_transformations
  81726. * @returns the current mesh
  81727. */
  81728. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  81729. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  81730. this.scaling.copyFromFloats(1, 1, 1);
  81731. this.position.copyFromFloats(0, 0, 0);
  81732. this.rotation.copyFromFloats(0, 0, 0);
  81733. //only if quaternion is already set
  81734. if (this.rotationQuaternion) {
  81735. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  81736. }
  81737. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  81738. return this;
  81739. };
  81740. Object.defineProperty(Mesh.prototype, "_positions", {
  81741. // Cache
  81742. /** @hidden */
  81743. get: function () {
  81744. if (this._geometry) {
  81745. return this._geometry._positions;
  81746. }
  81747. return null;
  81748. },
  81749. enumerable: true,
  81750. configurable: true
  81751. });
  81752. /** @hidden */
  81753. Mesh.prototype._resetPointsArrayCache = function () {
  81754. if (this._geometry) {
  81755. this._geometry._resetPointsArrayCache();
  81756. }
  81757. return this;
  81758. };
  81759. /** @hidden */
  81760. Mesh.prototype._generatePointsArray = function () {
  81761. if (this._geometry) {
  81762. return this._geometry._generatePointsArray();
  81763. }
  81764. return false;
  81765. };
  81766. /**
  81767. * Returns a new Mesh object generated from the current mesh properties.
  81768. * This method must not get confused with createInstance()
  81769. * @param name is a string, the name given to the new mesh
  81770. * @param newParent can be any Node object (default `null`)
  81771. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81772. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81773. * @returns a new mesh
  81774. */
  81775. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  81776. if (name === void 0) { name = ""; }
  81777. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  81778. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  81779. };
  81780. /**
  81781. * Releases resources associated with this mesh.
  81782. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81783. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81784. */
  81785. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  81786. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  81787. this.morphTargetManager = null;
  81788. if (this._geometry) {
  81789. this._geometry.releaseForMesh(this, true);
  81790. }
  81791. if (this._onBeforeDrawObservable) {
  81792. this._onBeforeDrawObservable.clear();
  81793. }
  81794. if (this._onBeforeRenderObservable) {
  81795. this._onBeforeRenderObservable.clear();
  81796. }
  81797. if (this._onAfterRenderObservable) {
  81798. this._onAfterRenderObservable.clear();
  81799. }
  81800. // Sources
  81801. if (this._scene.useClonedMeshhMap) {
  81802. if (this.meshMap) {
  81803. for (var uniqueId in this.meshMap) {
  81804. var mesh = this.meshMap[uniqueId];
  81805. if (mesh) {
  81806. mesh._source = null;
  81807. this.meshMap[uniqueId] = undefined;
  81808. }
  81809. }
  81810. }
  81811. if (this._source && this._source.meshMap) {
  81812. this._source.meshMap[this.uniqueId] = undefined;
  81813. }
  81814. }
  81815. else {
  81816. var meshes = this.getScene().meshes;
  81817. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81818. var abstractMesh = meshes_1[_i];
  81819. var mesh = abstractMesh;
  81820. if (mesh._source && mesh._source === this) {
  81821. mesh._source = null;
  81822. }
  81823. }
  81824. }
  81825. this._source = null;
  81826. // Instances
  81827. if (this._instanceDataStorage.instancesBuffer) {
  81828. this._instanceDataStorage.instancesBuffer.dispose();
  81829. this._instanceDataStorage.instancesBuffer = null;
  81830. }
  81831. while (this.instances.length) {
  81832. this.instances[0].dispose();
  81833. }
  81834. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  81835. };
  81836. /**
  81837. * Modifies the mesh geometry according to a displacement map.
  81838. * 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.
  81839. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81840. * @param url is a string, the URL from the image file is to be downloaded.
  81841. * @param minHeight is the lower limit of the displacement.
  81842. * @param maxHeight is the upper limit of the displacement.
  81843. * @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.
  81844. * @param uvOffset is an optional vector2 used to offset UV.
  81845. * @param uvScale is an optional vector2 used to scale UV.
  81846. * @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.
  81847. * @returns the Mesh.
  81848. */
  81849. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  81850. var _this = this;
  81851. if (forceUpdate === void 0) { forceUpdate = false; }
  81852. var scene = this.getScene();
  81853. var onload = function (img) {
  81854. // Getting height map data
  81855. var canvas = document.createElement("canvas");
  81856. var context = canvas.getContext("2d");
  81857. var heightMapWidth = img.width;
  81858. var heightMapHeight = img.height;
  81859. canvas.width = heightMapWidth;
  81860. canvas.height = heightMapHeight;
  81861. context.drawImage(img, 0, 0);
  81862. // Create VertexData from map data
  81863. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  81864. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  81865. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  81866. //execute success callback, if set
  81867. if (onSuccess) {
  81868. onSuccess(_this);
  81869. }
  81870. };
  81871. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  81872. return this;
  81873. };
  81874. /**
  81875. * Modifies the mesh geometry according to a displacementMap buffer.
  81876. * 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.
  81877. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81878. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81879. * @param heightMapWidth is the width of the buffer image.
  81880. * @param heightMapHeight is the height of the buffer image.
  81881. * @param minHeight is the lower limit of the displacement.
  81882. * @param maxHeight is the upper limit of the displacement.
  81883. * @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.
  81884. * @param uvOffset is an optional vector2 used to offset UV.
  81885. * @param uvScale is an optional vector2 used to scale UV.
  81886. * @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.
  81887. * @returns the Mesh.
  81888. */
  81889. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  81890. if (forceUpdate === void 0) { forceUpdate = false; }
  81891. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  81892. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  81893. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  81894. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  81895. return this;
  81896. }
  81897. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  81898. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81899. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  81900. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  81901. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  81902. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  81903. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  81904. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  81905. for (var index = 0; index < positions.length; index += 3) {
  81906. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  81907. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  81908. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  81909. // Compute height
  81910. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  81911. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  81912. var pos = (u + v * heightMapWidth) * 4;
  81913. var r = buffer[pos] / 255.0;
  81914. var g = buffer[pos + 1] / 255.0;
  81915. var b = buffer[pos + 2] / 255.0;
  81916. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  81917. normal.normalize();
  81918. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  81919. position = position.add(normal);
  81920. position.toArray(positions, index);
  81921. }
  81922. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  81923. if (forceUpdate) {
  81924. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  81925. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  81926. }
  81927. else {
  81928. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  81929. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  81930. }
  81931. return this;
  81932. };
  81933. /**
  81934. * Modify the mesh to get a flat shading rendering.
  81935. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81936. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81937. * @returns current mesh
  81938. */
  81939. Mesh.prototype.convertToFlatShadedMesh = function () {
  81940. var kinds = this.getVerticesDataKinds();
  81941. var vbs = {};
  81942. var data = {};
  81943. var newdata = {};
  81944. var updatableNormals = false;
  81945. var kindIndex;
  81946. var kind;
  81947. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  81948. kind = kinds[kindIndex];
  81949. var vertexBuffer = this.getVertexBuffer(kind);
  81950. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  81951. updatableNormals = vertexBuffer.isUpdatable();
  81952. kinds.splice(kindIndex, 1);
  81953. kindIndex--;
  81954. continue;
  81955. }
  81956. vbs[kind] = vertexBuffer;
  81957. data[kind] = vbs[kind].getData();
  81958. newdata[kind] = [];
  81959. }
  81960. // Save previous submeshes
  81961. var previousSubmeshes = this.subMeshes.slice(0);
  81962. var indices = this.getIndices();
  81963. var totalIndices = this.getTotalIndices();
  81964. // Generating unique vertices per face
  81965. var index;
  81966. for (index = 0; index < totalIndices; index++) {
  81967. var vertexIndex = indices[index];
  81968. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  81969. kind = kinds[kindIndex];
  81970. var stride = vbs[kind].getStrideSize();
  81971. for (var offset = 0; offset < stride; offset++) {
  81972. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  81973. }
  81974. }
  81975. }
  81976. // Updating faces & normal
  81977. var normals = [];
  81978. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  81979. for (index = 0; index < totalIndices; index += 3) {
  81980. indices[index] = index;
  81981. indices[index + 1] = index + 1;
  81982. indices[index + 2] = index + 2;
  81983. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  81984. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  81985. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  81986. var p1p2 = p1.subtract(p2);
  81987. var p3p2 = p3.subtract(p2);
  81988. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  81989. // Store same normals for every vertex
  81990. for (var localIndex = 0; localIndex < 3; localIndex++) {
  81991. normals.push(normal.x);
  81992. normals.push(normal.y);
  81993. normals.push(normal.z);
  81994. }
  81995. }
  81996. this.setIndices(indices);
  81997. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  81998. // Updating vertex buffers
  81999. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82000. kind = kinds[kindIndex];
  82001. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82002. }
  82003. // Updating submeshes
  82004. this.releaseSubMeshes();
  82005. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82006. var previousOne = previousSubmeshes[submeshIndex];
  82007. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82008. }
  82009. this.synchronizeInstances();
  82010. return this;
  82011. };
  82012. /**
  82013. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  82014. * In other words, more vertices, no more indices and a single bigger VBO.
  82015. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  82016. * @returns current mesh
  82017. */
  82018. Mesh.prototype.convertToUnIndexedMesh = function () {
  82019. var kinds = this.getVerticesDataKinds();
  82020. var vbs = {};
  82021. var data = {};
  82022. var newdata = {};
  82023. var kindIndex;
  82024. var kind;
  82025. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82026. kind = kinds[kindIndex];
  82027. var vertexBuffer = this.getVertexBuffer(kind);
  82028. vbs[kind] = vertexBuffer;
  82029. data[kind] = vbs[kind].getData();
  82030. newdata[kind] = [];
  82031. }
  82032. // Save previous submeshes
  82033. var previousSubmeshes = this.subMeshes.slice(0);
  82034. var indices = this.getIndices();
  82035. var totalIndices = this.getTotalIndices();
  82036. // Generating unique vertices per face
  82037. var index;
  82038. for (index = 0; index < totalIndices; index++) {
  82039. var vertexIndex = indices[index];
  82040. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82041. kind = kinds[kindIndex];
  82042. var stride = vbs[kind].getStrideSize();
  82043. for (var offset = 0; offset < stride; offset++) {
  82044. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  82045. }
  82046. }
  82047. }
  82048. // Updating indices
  82049. for (index = 0; index < totalIndices; index += 3) {
  82050. indices[index] = index;
  82051. indices[index + 1] = index + 1;
  82052. indices[index + 2] = index + 2;
  82053. }
  82054. this.setIndices(indices);
  82055. // Updating vertex buffers
  82056. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82057. kind = kinds[kindIndex];
  82058. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82059. }
  82060. // Updating submeshes
  82061. this.releaseSubMeshes();
  82062. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82063. var previousOne = previousSubmeshes[submeshIndex];
  82064. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82065. }
  82066. this._unIndexed = true;
  82067. this.synchronizeInstances();
  82068. return this;
  82069. };
  82070. /**
  82071. * Inverses facet orientations.
  82072. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  82073. * @param flipNormals will also inverts the normals
  82074. * @returns current mesh
  82075. */
  82076. Mesh.prototype.flipFaces = function (flipNormals) {
  82077. if (flipNormals === void 0) { flipNormals = false; }
  82078. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  82079. var i;
  82080. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  82081. for (i = 0; i < vertex_data.normals.length; i++) {
  82082. vertex_data.normals[i] *= -1;
  82083. }
  82084. }
  82085. if (vertex_data.indices) {
  82086. var temp;
  82087. for (i = 0; i < vertex_data.indices.length; i += 3) {
  82088. // reassign indices
  82089. temp = vertex_data.indices[i + 1];
  82090. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  82091. vertex_data.indices[i + 2] = temp;
  82092. }
  82093. }
  82094. vertex_data.applyToMesh(this);
  82095. return this;
  82096. };
  82097. /**
  82098. * Creates a new InstancedMesh object from the mesh model.
  82099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82100. * @param name defines the name of the new instance
  82101. * @returns a new InstancedMesh
  82102. */
  82103. Mesh.prototype.createInstance = function (name) {
  82104. return Mesh._instancedMeshFactory(name, this);
  82105. };
  82106. /**
  82107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  82108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  82109. * @returns the current mesh
  82110. */
  82111. Mesh.prototype.synchronizeInstances = function () {
  82112. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  82113. var instance = this.instances[instanceIndex];
  82114. instance._syncSubMeshes();
  82115. }
  82116. return this;
  82117. };
  82118. /**
  82119. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  82120. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  82121. * This should be used together with the simplification to avoid disappearing triangles.
  82122. * @param successCallback an optional success callback to be called after the optimization finished.
  82123. * @returns the current mesh
  82124. */
  82125. Mesh.prototype.optimizeIndices = function (successCallback) {
  82126. var _this = this;
  82127. var indices = this.getIndices();
  82128. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  82129. if (!positions || !indices) {
  82130. return this;
  82131. }
  82132. var vectorPositions = new Array();
  82133. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  82134. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  82135. }
  82136. var dupes = new Array();
  82137. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  82138. var realPos = vectorPositions.length - 1 - iteration;
  82139. var testedPosition = vectorPositions[realPos];
  82140. for (var j = 0; j < realPos; ++j) {
  82141. var againstPosition = vectorPositions[j];
  82142. if (testedPosition.equals(againstPosition)) {
  82143. dupes[realPos] = j;
  82144. break;
  82145. }
  82146. }
  82147. }, function () {
  82148. for (var i = 0; i < indices.length; ++i) {
  82149. indices[i] = dupes[indices[i]] || indices[i];
  82150. }
  82151. //indices are now reordered
  82152. var originalSubMeshes = _this.subMeshes.slice(0);
  82153. _this.setIndices(indices);
  82154. _this.subMeshes = originalSubMeshes;
  82155. if (successCallback) {
  82156. successCallback(_this);
  82157. }
  82158. });
  82159. return this;
  82160. };
  82161. /**
  82162. * Serialize current mesh
  82163. * @param serializationObject defines the object which will receive the serialization data
  82164. */
  82165. Mesh.prototype.serialize = function (serializationObject) {
  82166. serializationObject.name = this.name;
  82167. serializationObject.id = this.id;
  82168. serializationObject.type = this.getClassName();
  82169. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  82170. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  82171. }
  82172. serializationObject.position = this.position.asArray();
  82173. if (this.rotationQuaternion) {
  82174. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  82175. }
  82176. else if (this.rotation) {
  82177. serializationObject.rotation = this.rotation.asArray();
  82178. }
  82179. serializationObject.scaling = this.scaling.asArray();
  82180. if (this._postMultiplyPivotMatrix) {
  82181. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  82182. }
  82183. else {
  82184. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  82185. }
  82186. serializationObject.isEnabled = this.isEnabled(false);
  82187. serializationObject.isVisible = this.isVisible;
  82188. serializationObject.infiniteDistance = this.infiniteDistance;
  82189. serializationObject.pickable = this.isPickable;
  82190. serializationObject.receiveShadows = this.receiveShadows;
  82191. serializationObject.billboardMode = this.billboardMode;
  82192. serializationObject.visibility = this.visibility;
  82193. serializationObject.checkCollisions = this.checkCollisions;
  82194. serializationObject.isBlocker = this.isBlocker;
  82195. // Parent
  82196. if (this.parent) {
  82197. serializationObject.parentId = this.parent.id;
  82198. }
  82199. // Geometry
  82200. serializationObject.isUnIndexed = this.isUnIndexed;
  82201. var geometry = this._geometry;
  82202. if (geometry) {
  82203. var geometryId = geometry.id;
  82204. serializationObject.geometryId = geometryId;
  82205. // SubMeshes
  82206. serializationObject.subMeshes = [];
  82207. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  82208. var subMesh = this.subMeshes[subIndex];
  82209. serializationObject.subMeshes.push({
  82210. materialIndex: subMesh.materialIndex,
  82211. verticesStart: subMesh.verticesStart,
  82212. verticesCount: subMesh.verticesCount,
  82213. indexStart: subMesh.indexStart,
  82214. indexCount: subMesh.indexCount
  82215. });
  82216. }
  82217. }
  82218. // Material
  82219. if (this.material) {
  82220. serializationObject.materialId = this.material.id;
  82221. }
  82222. else {
  82223. this.material = null;
  82224. }
  82225. // Morph targets
  82226. if (this.morphTargetManager) {
  82227. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  82228. }
  82229. // Skeleton
  82230. if (this.skeleton) {
  82231. serializationObject.skeletonId = this.skeleton.id;
  82232. }
  82233. // Physics
  82234. //TODO implement correct serialization for physics impostors.
  82235. var impostor = this.getPhysicsImpostor();
  82236. if (impostor) {
  82237. serializationObject.physicsMass = impostor.getParam("mass");
  82238. serializationObject.physicsFriction = impostor.getParam("friction");
  82239. serializationObject.physicsRestitution = impostor.getParam("mass");
  82240. serializationObject.physicsImpostor = impostor.type;
  82241. }
  82242. // Metadata
  82243. if (this.metadata) {
  82244. serializationObject.metadata = this.metadata;
  82245. }
  82246. // Instances
  82247. serializationObject.instances = [];
  82248. for (var index = 0; index < this.instances.length; index++) {
  82249. var instance = this.instances[index];
  82250. if (instance.doNotSerialize) {
  82251. continue;
  82252. }
  82253. var serializationInstance = {
  82254. name: instance.name,
  82255. id: instance.id,
  82256. position: instance.position.asArray(),
  82257. scaling: instance.scaling.asArray()
  82258. };
  82259. if (instance.parent) {
  82260. serializationInstance.parentId = instance.parent.id;
  82261. }
  82262. if (instance.rotationQuaternion) {
  82263. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  82264. }
  82265. else if (instance.rotation) {
  82266. serializationInstance.rotation = instance.rotation.asArray();
  82267. }
  82268. serializationObject.instances.push(serializationInstance);
  82269. // Animations
  82270. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  82271. serializationInstance.ranges = instance.serializeAnimationRanges();
  82272. }
  82273. //
  82274. // Animations
  82275. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  82276. serializationObject.ranges = this.serializeAnimationRanges();
  82277. // Layer mask
  82278. serializationObject.layerMask = this.layerMask;
  82279. // Alpha
  82280. serializationObject.alphaIndex = this.alphaIndex;
  82281. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  82282. // Overlay
  82283. serializationObject.overlayAlpha = this.overlayAlpha;
  82284. serializationObject.overlayColor = this.overlayColor.asArray();
  82285. serializationObject.renderOverlay = this.renderOverlay;
  82286. // Fog
  82287. serializationObject.applyFog = this.applyFog;
  82288. // Action Manager
  82289. if (this.actionManager) {
  82290. serializationObject.actions = this.actionManager.serialize(this.name);
  82291. }
  82292. };
  82293. /** @hidden */
  82294. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  82295. if (!this.geometry) {
  82296. return;
  82297. }
  82298. this._markSubMeshesAsAttributesDirty();
  82299. var morphTargetManager = this._morphTargetManager;
  82300. if (morphTargetManager && morphTargetManager.vertexCount) {
  82301. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  82302. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  82303. this.morphTargetManager = null;
  82304. return;
  82305. }
  82306. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  82307. var morphTarget = morphTargetManager.getActiveTarget(index);
  82308. var positions = morphTarget.getPositions();
  82309. if (!positions) {
  82310. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Invalid morph target. Target must have positions.");
  82311. return;
  82312. }
  82313. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  82314. var normals = morphTarget.getNormals();
  82315. if (normals) {
  82316. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  82317. }
  82318. var tangents = morphTarget.getTangents();
  82319. if (tangents) {
  82320. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  82321. }
  82322. }
  82323. }
  82324. else {
  82325. var index = 0;
  82326. // Positions
  82327. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  82328. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  82329. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  82330. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  82331. }
  82332. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  82333. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  82334. }
  82335. index++;
  82336. }
  82337. }
  82338. };
  82339. /**
  82340. * Returns a new Mesh object parsed from the source provided.
  82341. * @param parsedMesh is the source
  82342. * @param scene defines the hosting scene
  82343. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  82344. * @returns a new Mesh
  82345. */
  82346. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  82347. var mesh;
  82348. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  82349. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  82350. }
  82351. else {
  82352. mesh = new Mesh(parsedMesh.name, scene);
  82353. }
  82354. mesh.id = parsedMesh.id;
  82355. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82356. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  82357. }
  82358. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  82359. if (parsedMesh.metadata !== undefined) {
  82360. mesh.metadata = parsedMesh.metadata;
  82361. }
  82362. if (parsedMesh.rotationQuaternion) {
  82363. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  82364. }
  82365. else if (parsedMesh.rotation) {
  82366. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  82367. }
  82368. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  82369. if (parsedMesh.localMatrix) {
  82370. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  82371. }
  82372. else if (parsedMesh.pivotMatrix) {
  82373. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  82374. }
  82375. mesh.setEnabled(parsedMesh.isEnabled);
  82376. mesh.isVisible = parsedMesh.isVisible;
  82377. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  82378. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  82379. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  82380. if (parsedMesh.applyFog !== undefined) {
  82381. mesh.applyFog = parsedMesh.applyFog;
  82382. }
  82383. if (parsedMesh.pickable !== undefined) {
  82384. mesh.isPickable = parsedMesh.pickable;
  82385. }
  82386. if (parsedMesh.alphaIndex !== undefined) {
  82387. mesh.alphaIndex = parsedMesh.alphaIndex;
  82388. }
  82389. mesh.receiveShadows = parsedMesh.receiveShadows;
  82390. mesh.billboardMode = parsedMesh.billboardMode;
  82391. if (parsedMesh.visibility !== undefined) {
  82392. mesh.visibility = parsedMesh.visibility;
  82393. }
  82394. mesh.checkCollisions = parsedMesh.checkCollisions;
  82395. if (parsedMesh.isBlocker !== undefined) {
  82396. mesh.isBlocker = parsedMesh.isBlocker;
  82397. }
  82398. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  82399. // freezeWorldMatrix
  82400. if (parsedMesh.freezeWorldMatrix) {
  82401. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  82402. }
  82403. // Parent
  82404. if (parsedMesh.parentId) {
  82405. mesh._waitingParentId = parsedMesh.parentId;
  82406. }
  82407. // Actions
  82408. if (parsedMesh.actions !== undefined) {
  82409. mesh._waitingActions = parsedMesh.actions;
  82410. }
  82411. // Overlay
  82412. if (parsedMesh.overlayAlpha !== undefined) {
  82413. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  82414. }
  82415. if (parsedMesh.overlayColor !== undefined) {
  82416. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  82417. }
  82418. if (parsedMesh.renderOverlay !== undefined) {
  82419. mesh.renderOverlay = parsedMesh.renderOverlay;
  82420. }
  82421. // Geometry
  82422. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  82423. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  82424. if (parsedMesh.delayLoadingFile) {
  82425. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82426. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  82427. 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));
  82428. if (parsedMesh._binaryInfo) {
  82429. mesh._binaryInfo = parsedMesh._binaryInfo;
  82430. }
  82431. mesh._delayInfo = [];
  82432. if (parsedMesh.hasUVs) {
  82433. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  82434. }
  82435. if (parsedMesh.hasUVs2) {
  82436. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  82437. }
  82438. if (parsedMesh.hasUVs3) {
  82439. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  82440. }
  82441. if (parsedMesh.hasUVs4) {
  82442. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  82443. }
  82444. if (parsedMesh.hasUVs5) {
  82445. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  82446. }
  82447. if (parsedMesh.hasUVs6) {
  82448. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  82449. }
  82450. if (parsedMesh.hasColors) {
  82451. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  82452. }
  82453. if (parsedMesh.hasMatricesIndices) {
  82454. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  82455. }
  82456. if (parsedMesh.hasMatricesWeights) {
  82457. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  82458. }
  82459. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  82460. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  82461. mesh._checkDelayState();
  82462. }
  82463. }
  82464. else {
  82465. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  82466. }
  82467. // Material
  82468. if (parsedMesh.materialId) {
  82469. mesh.setMaterialByID(parsedMesh.materialId);
  82470. }
  82471. else {
  82472. mesh.material = null;
  82473. }
  82474. // Morph targets
  82475. if (parsedMesh.morphTargetManagerId > -1) {
  82476. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  82477. }
  82478. // Skeleton
  82479. if (parsedMesh.skeletonId > -1) {
  82480. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  82481. if (parsedMesh.numBoneInfluencers) {
  82482. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  82483. }
  82484. }
  82485. // Animations
  82486. if (parsedMesh.animations) {
  82487. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  82488. var parsedAnimation = parsedMesh.animations[animationIndex];
  82489. mesh.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82490. }
  82491. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  82492. }
  82493. if (parsedMesh.autoAnimate) {
  82494. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  82495. }
  82496. // Layer Mask
  82497. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  82498. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  82499. }
  82500. else {
  82501. mesh.layerMask = 0x0FFFFFFF;
  82502. }
  82503. // Physics
  82504. if (parsedMesh.physicsImpostor) {
  82505. mesh.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](mesh, parsedMesh.physicsImpostor, {
  82506. mass: parsedMesh.physicsMass,
  82507. friction: parsedMesh.physicsFriction,
  82508. restitution: parsedMesh.physicsRestitution
  82509. }, scene);
  82510. }
  82511. // Instances
  82512. if (parsedMesh.instances) {
  82513. for (var index = 0; index < parsedMesh.instances.length; index++) {
  82514. var parsedInstance = parsedMesh.instances[index];
  82515. var instance = mesh.createInstance(parsedInstance.name);
  82516. if (parsedInstance.id) {
  82517. instance.id = parsedInstance.id;
  82518. }
  82519. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82520. if (parsedInstance.tags) {
  82521. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  82522. }
  82523. else {
  82524. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  82525. }
  82526. }
  82527. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  82528. if (parsedInstance.parentId) {
  82529. instance._waitingParentId = parsedInstance.parentId;
  82530. }
  82531. if (parsedInstance.rotationQuaternion) {
  82532. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  82533. }
  82534. else if (parsedInstance.rotation) {
  82535. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  82536. }
  82537. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  82538. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  82539. instance.checkCollisions = parsedInstance.checkCollisions;
  82540. }
  82541. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  82542. instance.isPickable = parsedInstance.pickable;
  82543. }
  82544. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  82545. instance.showBoundingBox = parsedInstance.showBoundingBox;
  82546. }
  82547. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82548. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  82549. }
  82550. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82551. instance.alphaIndex = parsedInstance.alphaIndex;
  82552. }
  82553. // Physics
  82554. if (parsedInstance.physicsImpostor) {
  82555. instance.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](instance, parsedInstance.physicsImpostor, {
  82556. mass: parsedInstance.physicsMass,
  82557. friction: parsedInstance.physicsFriction,
  82558. restitution: parsedInstance.physicsRestitution
  82559. }, scene);
  82560. }
  82561. // Animation
  82562. if (parsedInstance.animations) {
  82563. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  82564. parsedAnimation = parsedInstance.animations[animationIndex];
  82565. instance.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82566. }
  82567. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  82568. if (parsedInstance.autoAnimate) {
  82569. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  82570. }
  82571. }
  82572. }
  82573. }
  82574. return mesh;
  82575. };
  82576. /**
  82577. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  82578. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82579. * @param name defines the name of the mesh to create
  82580. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  82581. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  82582. * @param closePath creates a seam between the first and the last points of each path of the path array
  82583. * @param offset is taken in account only if the `pathArray` is containing a single path
  82584. * @param scene defines the hosting scene
  82585. * @param updatable defines if the mesh must be flagged as updatable
  82586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82587. * @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)
  82588. * @returns a new Mesh
  82589. */
  82590. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  82591. throw "Import MeshBuilder before creating meshes.";
  82592. };
  82593. /**
  82594. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  82595. * @param name defines the name of the mesh to create
  82596. * @param radius sets the radius size (float) of the polygon (default 0.5)
  82597. * @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
  82598. * @param scene defines the hosting scene
  82599. * @param updatable defines if the mesh must be flagged as updatable
  82600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82601. * @returns a new Mesh
  82602. */
  82603. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  82604. if (scene === void 0) { scene = null; }
  82605. throw "Import MeshBuilder before creating meshes.";
  82606. };
  82607. /**
  82608. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  82609. * @param name defines the name of the mesh to create
  82610. * @param size sets the size (float) of each box side (default 1)
  82611. * @param scene defines the hosting scene
  82612. * @param updatable defines if the mesh must be flagged as updatable
  82613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82614. * @returns a new Mesh
  82615. */
  82616. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  82617. if (scene === void 0) { scene = null; }
  82618. throw "Import MeshBuilder before creating meshes.";
  82619. };
  82620. /**
  82621. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  82622. * @param name defines the name of the mesh to create
  82623. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  82624. * @param diameter sets the diameter size (float) of the sphere (default 1)
  82625. * @param scene defines the hosting scene
  82626. * @param updatable defines if the mesh must be flagged as updatable
  82627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82628. * @returns a new Mesh
  82629. */
  82630. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  82631. throw "Import MeshBuilder before creating meshes.";
  82632. };
  82633. /**
  82634. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  82635. * @param name defines the name of the mesh to create
  82636. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  82637. * @param diameterTop set the top cap diameter (floats, default 1)
  82638. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  82639. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  82640. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  82641. * @param scene defines the hosting scene
  82642. * @param updatable defines if the mesh must be flagged as updatable
  82643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82644. * @returns a new Mesh
  82645. */
  82646. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  82647. throw "Import MeshBuilder before creating meshes.";
  82648. };
  82649. // Torus (Code from SharpDX.org)
  82650. /**
  82651. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  82652. * @param name defines the name of the mesh to create
  82653. * @param diameter sets the diameter size (float) of the torus (default 1)
  82654. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  82655. * @param tessellation sets the number of torus sides (postive integer, default 16)
  82656. * @param scene defines the hosting scene
  82657. * @param updatable defines if the mesh must be flagged as updatable
  82658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82659. * @returns a new Mesh
  82660. */
  82661. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  82662. throw "Import MeshBuilder before creating meshes.";
  82663. };
  82664. /**
  82665. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  82666. * @param name defines the name of the mesh to create
  82667. * @param radius sets the global radius size (float) of the torus knot (default 2)
  82668. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  82669. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  82670. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  82671. * @param p the number of windings on X axis (positive integers, default 2)
  82672. * @param q the number of windings on Y axis (positive integers, default 3)
  82673. * @param scene defines the hosting scene
  82674. * @param updatable defines if the mesh must be flagged as updatable
  82675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82676. * @returns a new Mesh
  82677. */
  82678. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  82679. throw "Import MeshBuilder before creating meshes.";
  82680. };
  82681. /**
  82682. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  82683. * @param name defines the name of the mesh to create
  82684. * @param points is an array successive Vector3
  82685. * @param scene defines the hosting scene
  82686. * @param updatable defines if the mesh must be flagged as updatable
  82687. * @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).
  82688. * @returns a new Mesh
  82689. */
  82690. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  82691. if (scene === void 0) { scene = null; }
  82692. if (updatable === void 0) { updatable = false; }
  82693. if (instance === void 0) { instance = null; }
  82694. throw "Import MeshBuilder before creating meshes.";
  82695. };
  82696. /**
  82697. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  82698. * @param name defines the name of the mesh to create
  82699. * @param points is an array successive Vector3
  82700. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  82701. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  82702. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  82703. * @param scene defines the hosting scene
  82704. * @param updatable defines if the mesh must be flagged as updatable
  82705. * @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)
  82706. * @returns a new Mesh
  82707. */
  82708. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  82709. if (scene === void 0) { scene = null; }
  82710. throw "Import MeshBuilder before creating meshes.";
  82711. };
  82712. /**
  82713. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  82714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  82715. * 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.
  82716. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  82718. * Remember you can only change the shape positions, not their number when updating a polygon.
  82719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  82720. * @param name defines the name of the mesh to create
  82721. * @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
  82722. * @param scene defines the hosting scene
  82723. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  82724. * @param updatable defines if the mesh must be flagged as updatable
  82725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82726. * @returns a new Mesh
  82727. */
  82728. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  82729. throw "Import MeshBuilder before creating meshes.";
  82730. };
  82731. /**
  82732. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  82733. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  82734. * @param name defines the name of the mesh to create
  82735. * @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
  82736. * @param depth defines the height of extrusion
  82737. * @param scene defines the hosting scene
  82738. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  82739. * @param updatable defines if the mesh must be flagged as updatable
  82740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82741. * @returns a new Mesh
  82742. */
  82743. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  82744. throw "Import MeshBuilder before creating meshes.";
  82745. };
  82746. /**
  82747. * Creates an extruded shape mesh.
  82748. * 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
  82749. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82750. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82751. * @param name defines the name of the mesh to create
  82752. * @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
  82753. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  82754. * @param scale is the value to scale the shape
  82755. * @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
  82756. * @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
  82757. * @param scene defines the hosting scene
  82758. * @param updatable defines if the mesh must be flagged as updatable
  82759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82760. * @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)
  82761. * @returns a new Mesh
  82762. */
  82763. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  82764. if (scene === void 0) { scene = null; }
  82765. throw "Import MeshBuilder before creating meshes.";
  82766. };
  82767. /**
  82768. * Creates an custom extruded shape mesh.
  82769. * The custom extrusion is a parametric shape.
  82770. * It has no predefined shape. Its final shape will depend on the input parameters.
  82771. * Please consider using the same method from the MeshBuilder class instead
  82772. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82773. * @param name defines the name of the mesh to create
  82774. * @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
  82775. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  82776. * @param scaleFunction is a custom Javascript function called on each path point
  82777. * @param rotationFunction is a custom Javascript function called on each path point
  82778. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  82779. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  82780. * @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
  82781. * @param scene defines the hosting scene
  82782. * @param updatable defines if the mesh must be flagged as updatable
  82783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82784. * @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)
  82785. * @returns a new Mesh
  82786. */
  82787. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  82788. throw "Import MeshBuilder before creating meshes.";
  82789. };
  82790. /**
  82791. * Creates lathe mesh.
  82792. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  82793. * Please consider using the same method from the MeshBuilder class instead
  82794. * @param name defines the name of the mesh to create
  82795. * @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
  82796. * @param radius is the radius value of the lathe
  82797. * @param tessellation is the side number of the lathe.
  82798. * @param scene defines the hosting scene
  82799. * @param updatable defines if the mesh must be flagged as updatable
  82800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82801. * @returns a new Mesh
  82802. */
  82803. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  82804. throw "Import MeshBuilder before creating meshes.";
  82805. };
  82806. /**
  82807. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  82808. * @param name defines the name of the mesh to create
  82809. * @param size sets the size (float) of both sides of the plane at once (default 1)
  82810. * @param scene defines the hosting scene
  82811. * @param updatable defines if the mesh must be flagged as updatable
  82812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82813. * @returns a new Mesh
  82814. */
  82815. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  82816. throw "Import MeshBuilder before creating meshes.";
  82817. };
  82818. /**
  82819. * Creates a ground mesh.
  82820. * Please consider using the same method from the MeshBuilder class instead
  82821. * @param name defines the name of the mesh to create
  82822. * @param width set the width of the ground
  82823. * @param height set the height of the ground
  82824. * @param subdivisions sets the number of subdivisions per side
  82825. * @param scene defines the hosting scene
  82826. * @param updatable defines if the mesh must be flagged as updatable
  82827. * @returns a new Mesh
  82828. */
  82829. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  82830. throw "Import MeshBuilder before creating meshes.";
  82831. };
  82832. /**
  82833. * Creates a tiled ground mesh.
  82834. * Please consider using the same method from the MeshBuilder class instead
  82835. * @param name defines the name of the mesh to create
  82836. * @param xmin set the ground minimum X coordinate
  82837. * @param zmin set the ground minimum Y coordinate
  82838. * @param xmax set the ground maximum X coordinate
  82839. * @param zmax set the ground maximum Z coordinate
  82840. * @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
  82841. * @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
  82842. * @param scene defines the hosting scene
  82843. * @param updatable defines if the mesh must be flagged as updatable
  82844. * @returns a new Mesh
  82845. */
  82846. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  82847. throw "Import MeshBuilder before creating meshes.";
  82848. };
  82849. /**
  82850. * Creates a ground mesh from a height map.
  82851. * Please consider using the same method from the MeshBuilder class instead
  82852. * @see http://doc.babylonjs.com/babylon101/height_map
  82853. * @param name defines the name of the mesh to create
  82854. * @param url sets the URL of the height map image resource
  82855. * @param width set the ground width size
  82856. * @param height set the ground height size
  82857. * @param subdivisions sets the number of subdivision per side
  82858. * @param minHeight is the minimum altitude on the ground
  82859. * @param maxHeight is the maximum altitude on the ground
  82860. * @param scene defines the hosting scene
  82861. * @param updatable defines if the mesh must be flagged as updatable
  82862. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  82863. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  82864. * @returns a new Mesh
  82865. */
  82866. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  82867. throw "Import MeshBuilder before creating meshes.";
  82868. };
  82869. /**
  82870. * Creates a tube mesh.
  82871. * The tube is a parametric shape.
  82872. * It has no predefined shape. Its final shape will depend on the input parameters.
  82873. * Please consider using the same method from the MeshBuilder class instead
  82874. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82875. * @param name defines the name of the mesh to create
  82876. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  82877. * @param radius sets the tube radius size
  82878. * @param tessellation is the number of sides on the tubular surface
  82879. * @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
  82880. * @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
  82881. * @param scene defines the hosting scene
  82882. * @param updatable defines if the mesh must be flagged as updatable
  82883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82884. * @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)
  82885. * @returns a new Mesh
  82886. */
  82887. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  82888. throw "Import MeshBuilder before creating meshes.";
  82889. };
  82890. /**
  82891. * Creates a polyhedron mesh.
  82892. * Please consider using the same method from the MeshBuilder class instead.
  82893. * * 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
  82894. * * The parameter `size` (positive float, default 1) sets the polygon size
  82895. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  82896. * * 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`
  82897. * * 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
  82898. * * 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)`)
  82899. * * 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
  82900. * * 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
  82901. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82902. * * 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
  82903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82904. * @param name defines the name of the mesh to create
  82905. * @param options defines the options used to create the mesh
  82906. * @param scene defines the hosting scene
  82907. * @returns a new Mesh
  82908. */
  82909. Mesh.CreatePolyhedron = function (name, options, scene) {
  82910. throw "Import MeshBuilder before creating meshes.";
  82911. };
  82912. /**
  82913. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  82914. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  82915. * * 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`)
  82916. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  82917. * * 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
  82918. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82919. * * 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
  82920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82921. * @param name defines the name of the mesh
  82922. * @param options defines the options used to create the mesh
  82923. * @param scene defines the hosting scene
  82924. * @returns a new Mesh
  82925. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  82926. */
  82927. Mesh.CreateIcoSphere = function (name, options, scene) {
  82928. throw "Import MeshBuilder before creating meshes.";
  82929. };
  82930. /**
  82931. * Creates a decal mesh.
  82932. * Please consider using the same method from the MeshBuilder class instead.
  82933. * A decal is a mesh usually applied as a model onto the surface of another mesh
  82934. * @param name defines the name of the mesh
  82935. * @param sourceMesh defines the mesh receiving the decal
  82936. * @param position sets the position of the decal in world coordinates
  82937. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  82938. * @param size sets the decal scaling
  82939. * @param angle sets the angle to rotate the decal
  82940. * @returns a new Mesh
  82941. */
  82942. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  82943. throw "Import MeshBuilder before creating meshes.";
  82944. };
  82945. // Skeletons
  82946. /**
  82947. * Prepare internal position array for software CPU skinning
  82948. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  82949. */
  82950. Mesh.prototype.setPositionsForCPUSkinning = function () {
  82951. if (!this._sourcePositions) {
  82952. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  82953. if (!source) {
  82954. return this._sourcePositions;
  82955. }
  82956. this._sourcePositions = new Float32Array(source);
  82957. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  82958. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  82959. }
  82960. }
  82961. return this._sourcePositions;
  82962. };
  82963. /**
  82964. * Prepare internal normal array for software CPU skinning
  82965. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  82966. */
  82967. Mesh.prototype.setNormalsForCPUSkinning = function () {
  82968. if (!this._sourceNormals) {
  82969. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  82970. if (!source) {
  82971. return this._sourceNormals;
  82972. }
  82973. this._sourceNormals = new Float32Array(source);
  82974. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  82975. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  82976. }
  82977. }
  82978. return this._sourceNormals;
  82979. };
  82980. /**
  82981. * Updates the vertex buffer by applying transformation from the bones
  82982. * @param skeleton defines the skeleton to apply to current mesh
  82983. * @returns the current mesh
  82984. */
  82985. Mesh.prototype.applySkeleton = function (skeleton) {
  82986. if (!this.geometry) {
  82987. return this;
  82988. }
  82989. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  82990. return this;
  82991. }
  82992. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  82993. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  82994. return this;
  82995. }
  82996. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  82997. return this;
  82998. }
  82999. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  83000. return this;
  83001. }
  83002. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  83003. return this;
  83004. }
  83005. if (!this._sourcePositions) {
  83006. var submeshes = this.subMeshes.slice();
  83007. this.setPositionsForCPUSkinning();
  83008. this.subMeshes = submeshes;
  83009. }
  83010. if (!this._sourceNormals) {
  83011. this.setNormalsForCPUSkinning();
  83012. }
  83013. // positionsData checks for not being Float32Array will only pass at most once
  83014. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83015. if (!positionsData) {
  83016. return this;
  83017. }
  83018. if (!(positionsData instanceof Float32Array)) {
  83019. positionsData = new Float32Array(positionsData);
  83020. }
  83021. // normalsData checks for not being Float32Array will only pass at most once
  83022. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  83023. if (!normalsData) {
  83024. return this;
  83025. }
  83026. if (!(normalsData instanceof Float32Array)) {
  83027. normalsData = new Float32Array(normalsData);
  83028. }
  83029. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  83030. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  83031. if (!matricesWeightsData || !matricesIndicesData) {
  83032. return this;
  83033. }
  83034. var needExtras = this.numBoneInfluencers > 4;
  83035. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  83036. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  83037. var skeletonMatrices = skeleton.getTransformMatrices(this);
  83038. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  83039. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83040. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83041. var matWeightIdx = 0;
  83042. var inf;
  83043. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  83044. var weight;
  83045. for (inf = 0; inf < 4; inf++) {
  83046. weight = matricesWeightsData[matWeightIdx + inf];
  83047. if (weight > 0) {
  83048. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83049. finalMatrix.addToSelf(tempMatrix);
  83050. }
  83051. }
  83052. if (needExtras) {
  83053. for (inf = 0; inf < 4; inf++) {
  83054. weight = matricesWeightsExtraData[matWeightIdx + inf];
  83055. if (weight > 0) {
  83056. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83057. finalMatrix.addToSelf(tempMatrix);
  83058. }
  83059. }
  83060. }
  83061. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  83062. tempVector3.toArray(positionsData, index);
  83063. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  83064. tempVector3.toArray(normalsData, index);
  83065. finalMatrix.reset();
  83066. }
  83067. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  83068. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  83069. return this;
  83070. };
  83071. // Tools
  83072. /**
  83073. * 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
  83074. * @param meshes defines the list of meshes to scan
  83075. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  83076. */
  83077. Mesh.MinMax = function (meshes) {
  83078. var minVector = null;
  83079. var maxVector = null;
  83080. meshes.forEach(function (mesh) {
  83081. var boundingInfo = mesh.getBoundingInfo();
  83082. var boundingBox = boundingInfo.boundingBox;
  83083. if (!minVector || !maxVector) {
  83084. minVector = boundingBox.minimumWorld;
  83085. maxVector = boundingBox.maximumWorld;
  83086. }
  83087. else {
  83088. minVector.minimizeInPlace(boundingBox.minimumWorld);
  83089. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  83090. }
  83091. });
  83092. if (!minVector || !maxVector) {
  83093. return {
  83094. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  83095. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  83096. };
  83097. }
  83098. return {
  83099. min: minVector,
  83100. max: maxVector
  83101. };
  83102. };
  83103. /**
  83104. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  83105. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  83106. * @returns a vector3
  83107. */
  83108. Mesh.Center = function (meshesOrMinMaxVector) {
  83109. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  83110. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  83111. };
  83112. /**
  83113. * Merge the array of meshes into a single mesh for performance reasons.
  83114. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  83115. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  83116. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  83117. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  83118. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  83119. * @returns a new mesh
  83120. */
  83121. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes) {
  83122. if (disposeSource === void 0) { disposeSource = true; }
  83123. var index;
  83124. if (!allow32BitsIndices) {
  83125. var totalVertices = 0;
  83126. // Counting vertices
  83127. for (index = 0; index < meshes.length; index++) {
  83128. if (meshes[index]) {
  83129. totalVertices += meshes[index].getTotalVertices();
  83130. if (totalVertices > 65536) {
  83131. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  83132. return null;
  83133. }
  83134. }
  83135. }
  83136. }
  83137. // Merge
  83138. var vertexData = null;
  83139. var otherVertexData;
  83140. var indiceArray = new Array();
  83141. var source = null;
  83142. for (index = 0; index < meshes.length; index++) {
  83143. if (meshes[index]) {
  83144. var wm = meshes[index].computeWorldMatrix(true);
  83145. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(meshes[index], true, true);
  83146. otherVertexData.transform(wm);
  83147. if (vertexData) {
  83148. vertexData.merge(otherVertexData, allow32BitsIndices);
  83149. }
  83150. else {
  83151. vertexData = otherVertexData;
  83152. source = meshes[index];
  83153. }
  83154. if (subdivideWithSubMeshes) {
  83155. indiceArray.push(meshes[index].getTotalIndices());
  83156. }
  83157. }
  83158. }
  83159. source = source;
  83160. if (!meshSubclass) {
  83161. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  83162. }
  83163. vertexData.applyToMesh(meshSubclass);
  83164. // Setting properties
  83165. meshSubclass.material = source.material;
  83166. meshSubclass.checkCollisions = source.checkCollisions;
  83167. // Cleaning
  83168. if (disposeSource) {
  83169. for (index = 0; index < meshes.length; index++) {
  83170. if (meshes[index]) {
  83171. meshes[index].dispose();
  83172. }
  83173. }
  83174. }
  83175. // Subdivide
  83176. if (subdivideWithSubMeshes) {
  83177. //-- removal of global submesh
  83178. meshSubclass.releaseSubMeshes();
  83179. index = 0;
  83180. var offset = 0;
  83181. //-- apply subdivision according to index table
  83182. while (index < indiceArray.length) {
  83183. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  83184. offset += indiceArray[index];
  83185. index++;
  83186. }
  83187. }
  83188. return meshSubclass;
  83189. };
  83190. /** @hidden */
  83191. Mesh.prototype.addInstance = function (instance) {
  83192. instance._indexInSourceMeshInstanceArray = this.instances.length;
  83193. this.instances.push(instance);
  83194. };
  83195. /** @hidden */
  83196. Mesh.prototype.removeInstance = function (instance) {
  83197. // Remove from mesh
  83198. var index = instance._indexInSourceMeshInstanceArray;
  83199. if (index != -1) {
  83200. if (index !== this.instances.length - 1) {
  83201. var last = this.instances[this.instances.length - 1];
  83202. this.instances[index] = last;
  83203. last._indexInSourceMeshInstanceArray = index;
  83204. }
  83205. instance._indexInSourceMeshInstanceArray = -1;
  83206. this.instances.pop();
  83207. }
  83208. };
  83209. // Consts
  83210. /**
  83211. * Mesh side orientation : usually the external or front surface
  83212. */
  83213. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  83214. /**
  83215. * Mesh side orientation : usually the internal or back surface
  83216. */
  83217. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  83218. /**
  83219. * Mesh side orientation : both internal and external or front and back surfaces
  83220. */
  83221. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  83222. /**
  83223. * Mesh side orientation : by default, `FRONTSIDE`
  83224. */
  83225. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  83226. /**
  83227. * Mesh cap setting : no cap
  83228. */
  83229. Mesh.NO_CAP = 0;
  83230. /**
  83231. * Mesh cap setting : one cap at the beginning of the mesh
  83232. */
  83233. Mesh.CAP_START = 1;
  83234. /**
  83235. * Mesh cap setting : one cap at the end of the mesh
  83236. */
  83237. Mesh.CAP_END = 2;
  83238. /**
  83239. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83240. */
  83241. Mesh.CAP_ALL = 3;
  83242. // Instances
  83243. /** @hidden */
  83244. Mesh._instancedMeshFactory = function (name, mesh) {
  83245. throw "Import InstancedMesh before creating instances.";
  83246. };
  83247. // Statics
  83248. /** @hidden */
  83249. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  83250. throw "Import GroundMesh before trying to parse it.";
  83251. };
  83252. return Mesh;
  83253. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  83254. //import { MeshBuilder } from "./meshBuilder";
  83255. /***/ }),
  83256. /***/ "./Meshes/mesh.vertexData.ts":
  83257. /*!***********************************!*\
  83258. !*** ./Meshes/mesh.vertexData.ts ***!
  83259. \***********************************/
  83260. /*! exports provided: VertexData */
  83261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83262. "use strict";
  83263. __webpack_require__.r(__webpack_exports__);
  83264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  83265. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83266. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83267. /**
  83268. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83269. */
  83270. var VertexData = /** @class */ (function () {
  83271. function VertexData() {
  83272. }
  83273. /**
  83274. * Uses the passed data array to set the set the values for the specified kind of data
  83275. * @param data a linear array of floating numbers
  83276. * @param kind the type of data that is being set, eg positions, colors etc
  83277. */
  83278. VertexData.prototype.set = function (data, kind) {
  83279. switch (kind) {
  83280. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  83281. this.positions = data;
  83282. break;
  83283. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  83284. this.normals = data;
  83285. break;
  83286. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  83287. this.tangents = data;
  83288. break;
  83289. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  83290. this.uvs = data;
  83291. break;
  83292. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  83293. this.uvs2 = data;
  83294. break;
  83295. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  83296. this.uvs3 = data;
  83297. break;
  83298. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  83299. this.uvs4 = data;
  83300. break;
  83301. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  83302. this.uvs5 = data;
  83303. break;
  83304. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  83305. this.uvs6 = data;
  83306. break;
  83307. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  83308. this.colors = data;
  83309. break;
  83310. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  83311. this.matricesIndices = data;
  83312. break;
  83313. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  83314. this.matricesWeights = data;
  83315. break;
  83316. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  83317. this.matricesIndicesExtra = data;
  83318. break;
  83319. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  83320. this.matricesWeightsExtra = data;
  83321. break;
  83322. }
  83323. };
  83324. /**
  83325. * Associates the vertexData to the passed Mesh.
  83326. * Sets it as updatable or not (default `false`)
  83327. * @param mesh the mesh the vertexData is applied to
  83328. * @param updatable when used and having the value true allows new data to update the vertexData
  83329. * @returns the VertexData
  83330. */
  83331. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  83332. this._applyTo(mesh, updatable);
  83333. return this;
  83334. };
  83335. /**
  83336. * Associates the vertexData to the passed Geometry.
  83337. * Sets it as updatable or not (default `false`)
  83338. * @param geometry the geometry the vertexData is applied to
  83339. * @param updatable when used and having the value true allows new data to update the vertexData
  83340. * @returns VertexData
  83341. */
  83342. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  83343. this._applyTo(geometry, updatable);
  83344. return this;
  83345. };
  83346. /**
  83347. * Updates the associated mesh
  83348. * @param mesh the mesh to be updated
  83349. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83350. * @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
  83351. * @returns VertexData
  83352. */
  83353. VertexData.prototype.updateMesh = function (mesh) {
  83354. this._update(mesh);
  83355. return this;
  83356. };
  83357. /**
  83358. * Updates the associated geometry
  83359. * @param geometry the geometry to be updated
  83360. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83361. * @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
  83362. * @returns VertexData.
  83363. */
  83364. VertexData.prototype.updateGeometry = function (geometry) {
  83365. this._update(geometry);
  83366. return this;
  83367. };
  83368. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  83369. if (updatable === void 0) { updatable = false; }
  83370. if (this.positions) {
  83371. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  83372. }
  83373. if (this.normals) {
  83374. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  83375. }
  83376. if (this.tangents) {
  83377. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  83378. }
  83379. if (this.uvs) {
  83380. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  83381. }
  83382. if (this.uvs2) {
  83383. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  83384. }
  83385. if (this.uvs3) {
  83386. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  83387. }
  83388. if (this.uvs4) {
  83389. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  83390. }
  83391. if (this.uvs5) {
  83392. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  83393. }
  83394. if (this.uvs6) {
  83395. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  83396. }
  83397. if (this.colors) {
  83398. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  83399. }
  83400. if (this.matricesIndices) {
  83401. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  83402. }
  83403. if (this.matricesWeights) {
  83404. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  83405. }
  83406. if (this.matricesIndicesExtra) {
  83407. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  83408. }
  83409. if (this.matricesWeightsExtra) {
  83410. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  83411. }
  83412. if (this.indices) {
  83413. meshOrGeometry.setIndices(this.indices, null, updatable);
  83414. }
  83415. else {
  83416. meshOrGeometry.setIndices([], null);
  83417. }
  83418. return this;
  83419. };
  83420. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  83421. if (this.positions) {
  83422. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  83423. }
  83424. if (this.normals) {
  83425. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  83426. }
  83427. if (this.tangents) {
  83428. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  83429. }
  83430. if (this.uvs) {
  83431. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  83432. }
  83433. if (this.uvs2) {
  83434. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  83435. }
  83436. if (this.uvs3) {
  83437. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  83438. }
  83439. if (this.uvs4) {
  83440. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  83441. }
  83442. if (this.uvs5) {
  83443. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  83444. }
  83445. if (this.uvs6) {
  83446. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  83447. }
  83448. if (this.colors) {
  83449. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  83450. }
  83451. if (this.matricesIndices) {
  83452. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  83453. }
  83454. if (this.matricesWeights) {
  83455. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  83456. }
  83457. if (this.matricesIndicesExtra) {
  83458. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  83459. }
  83460. if (this.matricesWeightsExtra) {
  83461. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  83462. }
  83463. if (this.indices) {
  83464. meshOrGeometry.setIndices(this.indices, null);
  83465. }
  83466. return this;
  83467. };
  83468. /**
  83469. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83470. * @param matrix the transforming matrix
  83471. * @returns the VertexData
  83472. */
  83473. VertexData.prototype.transform = function (matrix) {
  83474. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  83475. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83476. var index;
  83477. if (this.positions) {
  83478. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83479. for (index = 0; index < this.positions.length; index += 3) {
  83480. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  83481. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  83482. this.positions[index] = transformed.x;
  83483. this.positions[index + 1] = transformed.y;
  83484. this.positions[index + 2] = transformed.z;
  83485. }
  83486. }
  83487. if (this.normals) {
  83488. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83489. for (index = 0; index < this.normals.length; index += 3) {
  83490. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  83491. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  83492. this.normals[index] = transformed.x;
  83493. this.normals[index + 1] = transformed.y;
  83494. this.normals[index + 2] = transformed.z;
  83495. }
  83496. }
  83497. if (this.tangents) {
  83498. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83499. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83500. for (index = 0; index < this.tangents.length; index += 4) {
  83501. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  83502. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  83503. this.tangents[index] = tangentTransformed.x;
  83504. this.tangents[index + 1] = tangentTransformed.y;
  83505. this.tangents[index + 2] = tangentTransformed.z;
  83506. this.tangents[index + 3] = tangentTransformed.w;
  83507. }
  83508. }
  83509. if (flip && this.indices) {
  83510. for (index = 0; index < this.indices.length; index += 3) {
  83511. var tmp = this.indices[index + 1];
  83512. this.indices[index + 1] = this.indices[index + 2];
  83513. this.indices[index + 2] = tmp;
  83514. }
  83515. }
  83516. return this;
  83517. };
  83518. /**
  83519. * Merges the passed VertexData into the current one
  83520. * @param other the VertexData to be merged into the current one
  83521. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83522. * @returns the modified VertexData
  83523. */
  83524. VertexData.prototype.merge = function (other, use32BitsIndices) {
  83525. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  83526. this._validate();
  83527. other._validate();
  83528. if (!this.normals !== !other.normals ||
  83529. !this.tangents !== !other.tangents ||
  83530. !this.uvs !== !other.uvs ||
  83531. !this.uvs2 !== !other.uvs2 ||
  83532. !this.uvs3 !== !other.uvs3 ||
  83533. !this.uvs4 !== !other.uvs4 ||
  83534. !this.uvs5 !== !other.uvs5 ||
  83535. !this.uvs6 !== !other.uvs6 ||
  83536. !this.colors !== !other.colors ||
  83537. !this.matricesIndices !== !other.matricesIndices ||
  83538. !this.matricesWeights !== !other.matricesWeights ||
  83539. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  83540. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  83541. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  83542. }
  83543. if (other.indices) {
  83544. if (!this.indices) {
  83545. this.indices = [];
  83546. }
  83547. var offset = this.positions ? this.positions.length / 3 : 0;
  83548. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  83549. if (isSrcTypedArray) {
  83550. var len = this.indices.length + other.indices.length;
  83551. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  83552. temp.set(this.indices);
  83553. var decal = this.indices.length;
  83554. for (var index = 0; index < other.indices.length; index++) {
  83555. temp[decal + index] = other.indices[index] + offset;
  83556. }
  83557. this.indices = temp;
  83558. }
  83559. else {
  83560. for (var index = 0; index < other.indices.length; index++) {
  83561. this.indices.push(other.indices[index] + offset);
  83562. }
  83563. }
  83564. }
  83565. this.positions = this._mergeElement(this.positions, other.positions);
  83566. this.normals = this._mergeElement(this.normals, other.normals);
  83567. this.tangents = this._mergeElement(this.tangents, other.tangents);
  83568. this.uvs = this._mergeElement(this.uvs, other.uvs);
  83569. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  83570. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  83571. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  83572. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  83573. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  83574. this.colors = this._mergeElement(this.colors, other.colors);
  83575. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  83576. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  83577. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  83578. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  83579. return this;
  83580. };
  83581. VertexData.prototype._mergeElement = function (source, other) {
  83582. if (!source) {
  83583. return other;
  83584. }
  83585. if (!other) {
  83586. return source;
  83587. }
  83588. var len = other.length + source.length;
  83589. var isSrcTypedArray = source instanceof Float32Array;
  83590. var isOthTypedArray = other instanceof Float32Array;
  83591. // use non-loop method when the source is Float32Array
  83592. if (isSrcTypedArray) {
  83593. var ret32 = new Float32Array(len);
  83594. ret32.set(source);
  83595. ret32.set(other, source.length);
  83596. return ret32;
  83597. // source is number[], when other is also use concat
  83598. }
  83599. else if (!isOthTypedArray) {
  83600. return source.concat(other);
  83601. // source is a number[], but other is a Float32Array, loop required
  83602. }
  83603. else {
  83604. var ret = source.slice(0); // copy source to a separate array
  83605. for (var i = 0, len = other.length; i < len; i++) {
  83606. ret.push(other[i]);
  83607. }
  83608. return ret;
  83609. }
  83610. };
  83611. VertexData.prototype._validate = function () {
  83612. if (!this.positions) {
  83613. throw new Error("Positions are required");
  83614. }
  83615. var getElementCount = function (kind, values) {
  83616. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  83617. if ((values.length % stride) !== 0) {
  83618. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  83619. }
  83620. return values.length / stride;
  83621. };
  83622. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  83623. var validateElementCount = function (kind, values) {
  83624. var elementCount = getElementCount(kind, values);
  83625. if (elementCount !== positionsElementCount) {
  83626. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  83627. }
  83628. };
  83629. if (this.normals) {
  83630. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  83631. }
  83632. if (this.tangents) {
  83633. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  83634. }
  83635. if (this.uvs) {
  83636. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  83637. }
  83638. if (this.uvs2) {
  83639. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  83640. }
  83641. if (this.uvs3) {
  83642. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  83643. }
  83644. if (this.uvs4) {
  83645. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  83646. }
  83647. if (this.uvs5) {
  83648. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  83649. }
  83650. if (this.uvs6) {
  83651. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  83652. }
  83653. if (this.colors) {
  83654. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  83655. }
  83656. if (this.matricesIndices) {
  83657. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  83658. }
  83659. if (this.matricesWeights) {
  83660. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  83661. }
  83662. if (this.matricesIndicesExtra) {
  83663. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  83664. }
  83665. if (this.matricesWeightsExtra) {
  83666. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  83667. }
  83668. };
  83669. /**
  83670. * Serializes the VertexData
  83671. * @returns a serialized object
  83672. */
  83673. VertexData.prototype.serialize = function () {
  83674. var serializationObject = this.serialize();
  83675. if (this.positions) {
  83676. serializationObject.positions = this.positions;
  83677. }
  83678. if (this.normals) {
  83679. serializationObject.normals = this.normals;
  83680. }
  83681. if (this.tangents) {
  83682. serializationObject.tangents = this.tangents;
  83683. }
  83684. if (this.uvs) {
  83685. serializationObject.uvs = this.uvs;
  83686. }
  83687. if (this.uvs2) {
  83688. serializationObject.uvs2 = this.uvs2;
  83689. }
  83690. if (this.uvs3) {
  83691. serializationObject.uvs3 = this.uvs3;
  83692. }
  83693. if (this.uvs4) {
  83694. serializationObject.uvs4 = this.uvs4;
  83695. }
  83696. if (this.uvs5) {
  83697. serializationObject.uvs5 = this.uvs5;
  83698. }
  83699. if (this.uvs6) {
  83700. serializationObject.uvs6 = this.uvs6;
  83701. }
  83702. if (this.colors) {
  83703. serializationObject.colors = this.colors;
  83704. }
  83705. if (this.matricesIndices) {
  83706. serializationObject.matricesIndices = this.matricesIndices;
  83707. serializationObject.matricesIndices._isExpanded = true;
  83708. }
  83709. if (this.matricesWeights) {
  83710. serializationObject.matricesWeights = this.matricesWeights;
  83711. }
  83712. if (this.matricesIndicesExtra) {
  83713. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  83714. serializationObject.matricesIndicesExtra._isExpanded = true;
  83715. }
  83716. if (this.matricesWeightsExtra) {
  83717. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  83718. }
  83719. serializationObject.indices = this.indices;
  83720. return serializationObject;
  83721. };
  83722. // Statics
  83723. /**
  83724. * Extracts the vertexData from a mesh
  83725. * @param mesh the mesh from which to extract the VertexData
  83726. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83727. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83728. * @returns the object VertexData associated to the passed mesh
  83729. */
  83730. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  83731. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  83732. };
  83733. /**
  83734. * Extracts the vertexData from the geometry
  83735. * @param geometry the geometry from which to extract the VertexData
  83736. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83737. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83738. * @returns the object VertexData associated to the passed mesh
  83739. */
  83740. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  83741. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  83742. };
  83743. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  83744. var result = new VertexData();
  83745. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  83746. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  83747. }
  83748. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  83749. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  83750. }
  83751. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  83752. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  83753. }
  83754. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  83755. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  83756. }
  83757. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  83758. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  83759. }
  83760. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  83761. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  83762. }
  83763. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  83764. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  83765. }
  83766. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  83767. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  83768. }
  83769. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  83770. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  83771. }
  83772. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  83773. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  83774. }
  83775. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  83776. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  83777. }
  83778. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  83779. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  83780. }
  83781. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  83782. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  83783. }
  83784. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  83785. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  83786. }
  83787. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  83788. return result;
  83789. };
  83790. /**
  83791. * Creates the VertexData for a Ribbon
  83792. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83793. * * pathArray array of paths, each of which an array of successive Vector3
  83794. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83795. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83796. * * 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
  83797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83798. * * 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)
  83799. * * 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)
  83800. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83801. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83802. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83803. * @returns the VertexData of the ribbon
  83804. */
  83805. VertexData.CreateRibbon = function (options) {
  83806. var pathArray = options.pathArray;
  83807. var closeArray = options.closeArray || false;
  83808. var closePath = options.closePath || false;
  83809. var invertUV = options.invertUV || false;
  83810. var defaultOffset = Math.floor(pathArray[0].length / 2);
  83811. var offset = options.offset || defaultOffset;
  83812. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  83813. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  83814. var customUV = options.uvs;
  83815. var customColors = options.colors;
  83816. var positions = [];
  83817. var indices = [];
  83818. var normals = [];
  83819. var uvs = [];
  83820. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  83821. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  83822. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  83823. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  83824. var minlg; // minimal length among all paths from pathArray
  83825. var lg = []; // array of path lengths : nb of vertex per path
  83826. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  83827. var p; // path iterator
  83828. var i; // point iterator
  83829. var j; // point iterator
  83830. // if single path in pathArray
  83831. if (pathArray.length < 2) {
  83832. var ar1 = [];
  83833. var ar2 = [];
  83834. for (i = 0; i < pathArray[0].length - offset; i++) {
  83835. ar1.push(pathArray[0][i]);
  83836. ar2.push(pathArray[0][i + offset]);
  83837. }
  83838. pathArray = [ar1, ar2];
  83839. }
  83840. // positions and horizontal distances (u)
  83841. var idc = 0;
  83842. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  83843. var path;
  83844. var l;
  83845. minlg = pathArray[0].length;
  83846. var vectlg;
  83847. var dist;
  83848. for (p = 0; p < pathArray.length; p++) {
  83849. uTotalDistance[p] = 0;
  83850. us[p] = [0];
  83851. path = pathArray[p];
  83852. l = path.length;
  83853. minlg = (minlg < l) ? minlg : l;
  83854. j = 0;
  83855. while (j < l) {
  83856. positions.push(path[j].x, path[j].y, path[j].z);
  83857. if (j > 0) {
  83858. vectlg = path[j].subtract(path[j - 1]).length();
  83859. dist = vectlg + uTotalDistance[p];
  83860. us[p].push(dist);
  83861. uTotalDistance[p] = dist;
  83862. }
  83863. j++;
  83864. }
  83865. if (closePath) { // an extra hidden vertex is added in the "positions" array
  83866. j--;
  83867. positions.push(path[0].x, path[0].y, path[0].z);
  83868. vectlg = path[j].subtract(path[0]).length();
  83869. dist = vectlg + uTotalDistance[p];
  83870. us[p].push(dist);
  83871. uTotalDistance[p] = dist;
  83872. }
  83873. lg[p] = l + closePathCorr;
  83874. idx[p] = idc;
  83875. idc += (l + closePathCorr);
  83876. }
  83877. // vertical distances (v)
  83878. var path1;
  83879. var path2;
  83880. var vertex1 = null;
  83881. var vertex2 = null;
  83882. for (i = 0; i < minlg + closePathCorr; i++) {
  83883. vTotalDistance[i] = 0;
  83884. vs[i] = [0];
  83885. for (p = 0; p < pathArray.length - 1; p++) {
  83886. path1 = pathArray[p];
  83887. path2 = pathArray[p + 1];
  83888. if (i === minlg) { // closePath
  83889. vertex1 = path1[0];
  83890. vertex2 = path2[0];
  83891. }
  83892. else {
  83893. vertex1 = path1[i];
  83894. vertex2 = path2[i];
  83895. }
  83896. vectlg = vertex2.subtract(vertex1).length();
  83897. dist = vectlg + vTotalDistance[i];
  83898. vs[i].push(dist);
  83899. vTotalDistance[i] = dist;
  83900. }
  83901. if (closeArray && vertex2 && vertex1) {
  83902. path1 = pathArray[p];
  83903. path2 = pathArray[0];
  83904. if (i === minlg) { // closePath
  83905. vertex2 = path2[0];
  83906. }
  83907. vectlg = vertex2.subtract(vertex1).length();
  83908. dist = vectlg + vTotalDistance[i];
  83909. vTotalDistance[i] = dist;
  83910. }
  83911. }
  83912. // uvs
  83913. var u;
  83914. var v;
  83915. if (customUV) {
  83916. for (p = 0; p < customUV.length; p++) {
  83917. uvs.push(customUV[p].x, customUV[p].y);
  83918. }
  83919. }
  83920. else {
  83921. for (p = 0; p < pathArray.length; p++) {
  83922. for (i = 0; i < minlg + closePathCorr; i++) {
  83923. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  83924. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  83925. if (invertUV) {
  83926. uvs.push(v, u);
  83927. }
  83928. else {
  83929. uvs.push(u, v);
  83930. }
  83931. }
  83932. }
  83933. }
  83934. // indices
  83935. p = 0; // path index
  83936. var pi = 0; // positions array index
  83937. var l1 = lg[p] - 1; // path1 length
  83938. var l2 = lg[p + 1] - 1; // path2 length
  83939. var min = (l1 < l2) ? l1 : l2; // current path stop index
  83940. var shft = idx[1] - idx[0]; // shift
  83941. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  83942. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  83943. // 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
  83944. indices.push(pi, pi + shft, pi + 1);
  83945. indices.push(pi + shft + 1, pi + 1, pi + shft);
  83946. pi += 1;
  83947. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  83948. p++;
  83949. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  83950. shft = idx[0] - idx[p];
  83951. l1 = lg[p] - 1;
  83952. l2 = lg[0] - 1;
  83953. }
  83954. else {
  83955. shft = idx[p + 1] - idx[p];
  83956. l1 = lg[p] - 1;
  83957. l2 = lg[p + 1] - 1;
  83958. }
  83959. pi = idx[p];
  83960. min = (l1 < l2) ? l1 + pi : l2 + pi;
  83961. }
  83962. }
  83963. // normals
  83964. VertexData.ComputeNormals(positions, indices, normals);
  83965. if (closePath) { // update both the first and last vertex normals to their average value
  83966. var indexFirst = 0;
  83967. var indexLast = 0;
  83968. for (p = 0; p < pathArray.length; p++) {
  83969. indexFirst = idx[p] * 3;
  83970. if (p + 1 < pathArray.length) {
  83971. indexLast = (idx[p + 1] - 1) * 3;
  83972. }
  83973. else {
  83974. indexLast = normals.length - 3;
  83975. }
  83976. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  83977. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  83978. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  83979. normals[indexLast] = normals[indexFirst];
  83980. normals[indexLast + 1] = normals[indexFirst + 1];
  83981. normals[indexLast + 2] = normals[indexFirst + 2];
  83982. }
  83983. }
  83984. // sides
  83985. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  83986. // Colors
  83987. var colors = null;
  83988. if (customColors) {
  83989. colors = new Float32Array(customColors.length * 4);
  83990. for (var c = 0; c < customColors.length; c++) {
  83991. colors[c * 4] = customColors[c].r;
  83992. colors[c * 4 + 1] = customColors[c].g;
  83993. colors[c * 4 + 2] = customColors[c].b;
  83994. colors[c * 4 + 3] = customColors[c].a;
  83995. }
  83996. }
  83997. // Result
  83998. var vertexData = new VertexData();
  83999. var positions32 = new Float32Array(positions);
  84000. var normals32 = new Float32Array(normals);
  84001. var uvs32 = new Float32Array(uvs);
  84002. vertexData.indices = indices;
  84003. vertexData.positions = positions32;
  84004. vertexData.normals = normals32;
  84005. vertexData.uvs = uvs32;
  84006. if (colors) {
  84007. vertexData.set(colors, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  84008. }
  84009. if (closePath) {
  84010. vertexData._idx = idx;
  84011. }
  84012. return vertexData;
  84013. };
  84014. /**
  84015. * Creates the VertexData for a box
  84016. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84017. * * size sets the width, height and depth of the box to the value of size, optional default 1
  84018. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  84019. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  84020. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  84021. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84022. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84024. * * 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)
  84025. * * 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)
  84026. * @returns the VertexData of the box
  84027. */
  84028. VertexData.CreateBox = function (options) {
  84029. var normalsSource = [
  84030. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  84031. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  84032. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  84033. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  84034. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  84035. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  84036. ];
  84037. var indices = [];
  84038. var positions = [];
  84039. var normals = [];
  84040. var uvs = [];
  84041. var width = options.width || options.size || 1;
  84042. var height = options.height || options.size || 1;
  84043. var depth = options.depth || options.size || 1;
  84044. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84045. var faceUV = options.faceUV || new Array(6);
  84046. var faceColors = options.faceColors;
  84047. var colors = [];
  84048. // default face colors and UV if undefined
  84049. for (var f = 0; f < 6; f++) {
  84050. if (faceUV[f] === undefined) {
  84051. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84052. }
  84053. if (faceColors && faceColors[f] === undefined) {
  84054. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84055. }
  84056. }
  84057. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  84058. // Create each face in turn.
  84059. for (var index = 0; index < normalsSource.length; index++) {
  84060. var normal = normalsSource[index];
  84061. // Get two vectors perpendicular to the face normal and to each other.
  84062. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  84063. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  84064. // Six indices (two triangles) per face.
  84065. var verticesLength = positions.length / 3;
  84066. indices.push(verticesLength);
  84067. indices.push(verticesLength + 1);
  84068. indices.push(verticesLength + 2);
  84069. indices.push(verticesLength);
  84070. indices.push(verticesLength + 2);
  84071. indices.push(verticesLength + 3);
  84072. // Four vertices per face.
  84073. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  84074. positions.push(vertex.x, vertex.y, vertex.z);
  84075. normals.push(normal.x, normal.y, normal.z);
  84076. uvs.push(faceUV[index].z, faceUV[index].w);
  84077. if (faceColors) {
  84078. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84079. }
  84080. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  84081. positions.push(vertex.x, vertex.y, vertex.z);
  84082. normals.push(normal.x, normal.y, normal.z);
  84083. uvs.push(faceUV[index].x, faceUV[index].w);
  84084. if (faceColors) {
  84085. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84086. }
  84087. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  84088. positions.push(vertex.x, vertex.y, vertex.z);
  84089. normals.push(normal.x, normal.y, normal.z);
  84090. uvs.push(faceUV[index].x, faceUV[index].y);
  84091. if (faceColors) {
  84092. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84093. }
  84094. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  84095. positions.push(vertex.x, vertex.y, vertex.z);
  84096. normals.push(normal.x, normal.y, normal.z);
  84097. uvs.push(faceUV[index].z, faceUV[index].y);
  84098. if (faceColors) {
  84099. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84100. }
  84101. }
  84102. // sides
  84103. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84104. // Result
  84105. var vertexData = new VertexData();
  84106. vertexData.indices = indices;
  84107. vertexData.positions = positions;
  84108. vertexData.normals = normals;
  84109. vertexData.uvs = uvs;
  84110. if (faceColors) {
  84111. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  84112. vertexData.colors = totalColors;
  84113. }
  84114. return vertexData;
  84115. };
  84116. /**
  84117. * Creates the VertexData for an ellipsoid, defaults to a sphere
  84118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84119. * * segments sets the number of horizontal strips optional, default 32
  84120. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  84121. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  84122. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  84123. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  84124. * * 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
  84125. * * 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
  84126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84127. * * 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)
  84128. * * 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)
  84129. * @returns the VertexData of the ellipsoid
  84130. */
  84131. VertexData.CreateSphere = function (options) {
  84132. var segments = options.segments || 32;
  84133. var diameterX = options.diameterX || options.diameter || 1;
  84134. var diameterY = options.diameterY || options.diameter || 1;
  84135. var diameterZ = options.diameterZ || options.diameter || 1;
  84136. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84137. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  84138. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84139. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  84140. var totalZRotationSteps = 2 + segments;
  84141. var totalYRotationSteps = 2 * totalZRotationSteps;
  84142. var indices = [];
  84143. var positions = [];
  84144. var normals = [];
  84145. var uvs = [];
  84146. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  84147. var normalizedZ = zRotationStep / totalZRotationSteps;
  84148. var angleZ = normalizedZ * Math.PI * slice;
  84149. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  84150. var normalizedY = yRotationStep / totalYRotationSteps;
  84151. var angleY = normalizedY * Math.PI * 2 * arc;
  84152. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  84153. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  84154. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  84155. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  84156. var vertex = complete.multiply(radius);
  84157. var normal = complete.divide(radius).normalize();
  84158. positions.push(vertex.x, vertex.y, vertex.z);
  84159. normals.push(normal.x, normal.y, normal.z);
  84160. uvs.push(normalizedY, normalizedZ);
  84161. }
  84162. if (zRotationStep > 0) {
  84163. var verticesCount = positions.length / 3;
  84164. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  84165. indices.push((firstIndex));
  84166. indices.push((firstIndex + 1));
  84167. indices.push(firstIndex + totalYRotationSteps + 1);
  84168. indices.push((firstIndex + totalYRotationSteps + 1));
  84169. indices.push((firstIndex + 1));
  84170. indices.push((firstIndex + totalYRotationSteps + 2));
  84171. }
  84172. }
  84173. }
  84174. // Sides
  84175. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84176. // Result
  84177. var vertexData = new VertexData();
  84178. vertexData.indices = indices;
  84179. vertexData.positions = positions;
  84180. vertexData.normals = normals;
  84181. vertexData.uvs = uvs;
  84182. return vertexData;
  84183. };
  84184. /**
  84185. * Creates the VertexData for a cylinder, cone or prism
  84186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84187. * * height sets the height (y direction) of the cylinder, optional, default 2
  84188. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  84189. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  84190. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  84191. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84192. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  84193. * * 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
  84194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84195. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84196. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  84197. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  84198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84199. * * 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)
  84200. * * 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)
  84201. * @returns the VertexData of the cylinder, cone or prism
  84202. */
  84203. VertexData.CreateCylinder = function (options) {
  84204. var height = options.height || 2;
  84205. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  84206. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  84207. var tessellation = options.tessellation || 24;
  84208. var subdivisions = options.subdivisions || 1;
  84209. var hasRings = options.hasRings ? true : false;
  84210. var enclose = options.enclose ? true : false;
  84211. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84212. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84213. var faceUV = options.faceUV || new Array(3);
  84214. var faceColors = options.faceColors;
  84215. // default face colors and UV if undefined
  84216. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  84217. var ringNb = (hasRings) ? subdivisions : 1;
  84218. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  84219. var f;
  84220. for (f = 0; f < surfaceNb; f++) {
  84221. if (faceColors && faceColors[f] === undefined) {
  84222. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84223. }
  84224. }
  84225. for (f = 0; f < surfaceNb; f++) {
  84226. if (faceUV && faceUV[f] === undefined) {
  84227. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84228. }
  84229. }
  84230. var indices = new Array();
  84231. var positions = new Array();
  84232. var normals = new Array();
  84233. var uvs = new Array();
  84234. var colors = new Array();
  84235. var angle_step = Math.PI * 2 * arc / tessellation;
  84236. var angle;
  84237. var h;
  84238. var radius;
  84239. var tan = (diameterBottom - diameterTop) / 2 / height;
  84240. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84241. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84242. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84243. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84244. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84245. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  84246. // positions, normals, uvs
  84247. var i;
  84248. var j;
  84249. var r;
  84250. var ringIdx = 1;
  84251. var s = 1; // surface index
  84252. var cs = 0;
  84253. var v = 0;
  84254. for (i = 0; i <= subdivisions; i++) {
  84255. h = i / subdivisions;
  84256. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  84257. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  84258. for (r = 0; r < ringIdx; r++) {
  84259. if (hasRings) {
  84260. s += r;
  84261. }
  84262. if (enclose) {
  84263. s += 2 * r;
  84264. }
  84265. for (j = 0; j <= tessellation; j++) {
  84266. angle = j * angle_step;
  84267. // position
  84268. ringVertex.x = Math.cos(-angle) * radius;
  84269. ringVertex.y = -height / 2 + h * height;
  84270. ringVertex.z = Math.sin(-angle) * radius;
  84271. // normal
  84272. if (diameterTop === 0 && i === subdivisions) {
  84273. // if no top cap, reuse former normals
  84274. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  84275. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  84276. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  84277. }
  84278. else {
  84279. ringNormal.x = ringVertex.x;
  84280. ringNormal.z = ringVertex.z;
  84281. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  84282. ringNormal.normalize();
  84283. }
  84284. // keep first ring vertex values for enclose
  84285. if (j === 0) {
  84286. ringFirstVertex.copyFrom(ringVertex);
  84287. ringFirstNormal.copyFrom(ringNormal);
  84288. }
  84289. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84290. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  84291. if (hasRings) {
  84292. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  84293. }
  84294. else {
  84295. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  84296. }
  84297. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  84298. if (faceColors) {
  84299. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  84300. }
  84301. }
  84302. // if enclose, add four vertices and their dedicated normals
  84303. if (arc !== 1 && enclose) {
  84304. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84305. positions.push(0, ringVertex.y, 0);
  84306. positions.push(0, ringVertex.y, 0);
  84307. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  84308. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  84309. quadNormal.normalize();
  84310. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84311. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  84312. quadNormal.normalize();
  84313. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84314. if (hasRings) {
  84315. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  84316. }
  84317. else {
  84318. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  84319. }
  84320. uvs.push(faceUV[s + 1].x, v);
  84321. uvs.push(faceUV[s + 1].z, v);
  84322. if (hasRings) {
  84323. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  84324. }
  84325. else {
  84326. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  84327. }
  84328. uvs.push(faceUV[s + 2].x, v);
  84329. uvs.push(faceUV[s + 2].z, v);
  84330. if (faceColors) {
  84331. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84332. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84333. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84334. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84335. }
  84336. }
  84337. if (cs !== s) {
  84338. cs = s;
  84339. }
  84340. }
  84341. }
  84342. // indices
  84343. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  84344. var s;
  84345. i = 0;
  84346. for (s = 0; s < subdivisions; s++) {
  84347. var i0 = 0;
  84348. var i1 = 0;
  84349. var i2 = 0;
  84350. var i3 = 0;
  84351. for (j = 0; j < tessellation; j++) {
  84352. i0 = i * (e + 1) + j;
  84353. i1 = (i + 1) * (e + 1) + j;
  84354. i2 = i * (e + 1) + (j + 1);
  84355. i3 = (i + 1) * (e + 1) + (j + 1);
  84356. indices.push(i0, i1, i2);
  84357. indices.push(i3, i2, i1);
  84358. }
  84359. if (arc !== 1 && enclose) { // if enclose, add two quads
  84360. indices.push(i0 + 2, i1 + 2, i2 + 2);
  84361. indices.push(i3 + 2, i2 + 2, i1 + 2);
  84362. indices.push(i0 + 4, i1 + 4, i2 + 4);
  84363. indices.push(i3 + 4, i2 + 4, i1 + 4);
  84364. }
  84365. i = (hasRings) ? (i + 2) : (i + 1);
  84366. }
  84367. // Caps
  84368. var createCylinderCap = function (isTop) {
  84369. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  84370. if (radius === 0) {
  84371. return;
  84372. }
  84373. // Cap positions, normals & uvs
  84374. var angle;
  84375. var circleVector;
  84376. var i;
  84377. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  84378. var c = null;
  84379. if (faceColors) {
  84380. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  84381. }
  84382. // cap center
  84383. var vbase = positions.length / 3;
  84384. var offset = isTop ? height / 2 : -height / 2;
  84385. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  84386. positions.push(center.x, center.y, center.z);
  84387. normals.push(0, isTop ? 1 : -1, 0);
  84388. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  84389. if (c) {
  84390. colors.push(c.r, c.g, c.b, c.a);
  84391. }
  84392. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  84393. for (i = 0; i <= tessellation; i++) {
  84394. angle = Math.PI * 2 * i * arc / tessellation;
  84395. var cos = Math.cos(-angle);
  84396. var sin = Math.sin(-angle);
  84397. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  84398. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  84399. positions.push(circleVector.x, circleVector.y, circleVector.z);
  84400. normals.push(0, isTop ? 1 : -1, 0);
  84401. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  84402. if (c) {
  84403. colors.push(c.r, c.g, c.b, c.a);
  84404. }
  84405. }
  84406. // Cap indices
  84407. for (i = 0; i < tessellation; i++) {
  84408. if (!isTop) {
  84409. indices.push(vbase);
  84410. indices.push(vbase + (i + 1));
  84411. indices.push(vbase + (i + 2));
  84412. }
  84413. else {
  84414. indices.push(vbase);
  84415. indices.push(vbase + (i + 2));
  84416. indices.push(vbase + (i + 1));
  84417. }
  84418. }
  84419. };
  84420. // add caps to geometry
  84421. createCylinderCap(false);
  84422. createCylinderCap(true);
  84423. // Sides
  84424. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84425. var vertexData = new VertexData();
  84426. vertexData.indices = indices;
  84427. vertexData.positions = positions;
  84428. vertexData.normals = normals;
  84429. vertexData.uvs = uvs;
  84430. if (faceColors) {
  84431. vertexData.colors = colors;
  84432. }
  84433. return vertexData;
  84434. };
  84435. /**
  84436. * Creates the VertexData for a torus
  84437. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84438. * * diameter the diameter of the torus, optional default 1
  84439. * * thickness the diameter of the tube forming the torus, optional default 0.5
  84440. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84442. * * 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)
  84443. * * 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)
  84444. * @returns the VertexData of the torus
  84445. */
  84446. VertexData.CreateTorus = function (options) {
  84447. var indices = [];
  84448. var positions = [];
  84449. var normals = [];
  84450. var uvs = [];
  84451. var diameter = options.diameter || 1;
  84452. var thickness = options.thickness || 0.5;
  84453. var tessellation = options.tessellation || 16;
  84454. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84455. var stride = tessellation + 1;
  84456. for (var i = 0; i <= tessellation; i++) {
  84457. var u = i / tessellation;
  84458. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  84459. 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));
  84460. for (var j = 0; j <= tessellation; j++) {
  84461. var v = 1 - j / tessellation;
  84462. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  84463. var dx = Math.cos(innerAngle);
  84464. var dy = Math.sin(innerAngle);
  84465. // Create a vertex.
  84466. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  84467. var position = normal.scale(thickness / 2);
  84468. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  84469. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  84470. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  84471. positions.push(position.x, position.y, position.z);
  84472. normals.push(normal.x, normal.y, normal.z);
  84473. uvs.push(textureCoordinate.x, textureCoordinate.y);
  84474. // And create indices for two triangles.
  84475. var nextI = (i + 1) % stride;
  84476. var nextJ = (j + 1) % stride;
  84477. indices.push(i * stride + j);
  84478. indices.push(i * stride + nextJ);
  84479. indices.push(nextI * stride + j);
  84480. indices.push(i * stride + nextJ);
  84481. indices.push(nextI * stride + nextJ);
  84482. indices.push(nextI * stride + j);
  84483. }
  84484. }
  84485. // Sides
  84486. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84487. // Result
  84488. var vertexData = new VertexData();
  84489. vertexData.indices = indices;
  84490. vertexData.positions = positions;
  84491. vertexData.normals = normals;
  84492. vertexData.uvs = uvs;
  84493. return vertexData;
  84494. };
  84495. /**
  84496. * Creates the VertexData of the LineSystem
  84497. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  84498. * - lines an array of lines, each line being an array of successive Vector3
  84499. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  84500. * @returns the VertexData of the LineSystem
  84501. */
  84502. VertexData.CreateLineSystem = function (options) {
  84503. var indices = [];
  84504. var positions = [];
  84505. var lines = options.lines;
  84506. var colors = options.colors;
  84507. var vertexColors = [];
  84508. var idx = 0;
  84509. for (var l = 0; l < lines.length; l++) {
  84510. var points = lines[l];
  84511. for (var index = 0; index < points.length; index++) {
  84512. positions.push(points[index].x, points[index].y, points[index].z);
  84513. if (colors) {
  84514. var color = colors[l];
  84515. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  84516. }
  84517. if (index > 0) {
  84518. indices.push(idx - 1);
  84519. indices.push(idx);
  84520. }
  84521. idx++;
  84522. }
  84523. }
  84524. var vertexData = new VertexData();
  84525. vertexData.indices = indices;
  84526. vertexData.positions = positions;
  84527. if (colors) {
  84528. vertexData.colors = vertexColors;
  84529. }
  84530. return vertexData;
  84531. };
  84532. /**
  84533. * Create the VertexData for a DashedLines
  84534. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  84535. * - points an array successive Vector3
  84536. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  84537. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  84538. * - dashNb the intended total number of dashes, optional, default 200
  84539. * @returns the VertexData for the DashedLines
  84540. */
  84541. VertexData.CreateDashedLines = function (options) {
  84542. var dashSize = options.dashSize || 3;
  84543. var gapSize = options.gapSize || 1;
  84544. var dashNb = options.dashNb || 200;
  84545. var points = options.points;
  84546. var positions = new Array();
  84547. var indices = new Array();
  84548. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84549. var lg = 0;
  84550. var nb = 0;
  84551. var shft = 0;
  84552. var dashshft = 0;
  84553. var curshft = 0;
  84554. var idx = 0;
  84555. var i = 0;
  84556. for (i = 0; i < points.length - 1; i++) {
  84557. points[i + 1].subtractToRef(points[i], curvect);
  84558. lg += curvect.length();
  84559. }
  84560. shft = lg / dashNb;
  84561. dashshft = dashSize * shft / (dashSize + gapSize);
  84562. for (i = 0; i < points.length - 1; i++) {
  84563. points[i + 1].subtractToRef(points[i], curvect);
  84564. nb = Math.floor(curvect.length() / shft);
  84565. curvect.normalize();
  84566. for (var j = 0; j < nb; j++) {
  84567. curshft = shft * j;
  84568. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  84569. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  84570. indices.push(idx, idx + 1);
  84571. idx += 2;
  84572. }
  84573. }
  84574. // Result
  84575. var vertexData = new VertexData();
  84576. vertexData.positions = positions;
  84577. vertexData.indices = indices;
  84578. return vertexData;
  84579. };
  84580. /**
  84581. * Creates the VertexData for a Ground
  84582. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84583. * - width the width (x direction) of the ground, optional, default 1
  84584. * - height the height (z direction) of the ground, optional, default 1
  84585. * - subdivisions the number of subdivisions per side, optional, default 1
  84586. * @returns the VertexData of the Ground
  84587. */
  84588. VertexData.CreateGround = function (options) {
  84589. var indices = [];
  84590. var positions = [];
  84591. var normals = [];
  84592. var uvs = [];
  84593. var row, col;
  84594. var width = options.width || 1;
  84595. var height = options.height || 1;
  84596. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  84597. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  84598. for (row = 0; row <= subdivisionsY; row++) {
  84599. for (col = 0; col <= subdivisionsX; col++) {
  84600. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  84601. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  84602. positions.push(position.x, position.y, position.z);
  84603. normals.push(normal.x, normal.y, normal.z);
  84604. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  84605. }
  84606. }
  84607. for (row = 0; row < subdivisionsY; row++) {
  84608. for (col = 0; col < subdivisionsX; col++) {
  84609. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84610. indices.push(col + 1 + row * (subdivisionsX + 1));
  84611. indices.push(col + row * (subdivisionsX + 1));
  84612. indices.push(col + (row + 1) * (subdivisionsX + 1));
  84613. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84614. indices.push(col + row * (subdivisionsX + 1));
  84615. }
  84616. }
  84617. // Result
  84618. var vertexData = new VertexData();
  84619. vertexData.indices = indices;
  84620. vertexData.positions = positions;
  84621. vertexData.normals = normals;
  84622. vertexData.uvs = uvs;
  84623. return vertexData;
  84624. };
  84625. /**
  84626. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  84627. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84628. * * xmin the ground minimum X coordinate, optional, default -1
  84629. * * zmin the ground minimum Z coordinate, optional, default -1
  84630. * * xmax the ground maximum X coordinate, optional, default 1
  84631. * * zmax the ground maximum Z coordinate, optional, default 1
  84632. * * 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}
  84633. * * 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}
  84634. * @returns the VertexData of the TiledGround
  84635. */
  84636. VertexData.CreateTiledGround = function (options) {
  84637. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  84638. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  84639. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  84640. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  84641. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  84642. var precision = options.precision || { w: 1, h: 1 };
  84643. var indices = new Array();
  84644. var positions = new Array();
  84645. var normals = new Array();
  84646. var uvs = new Array();
  84647. var row, col, tileRow, tileCol;
  84648. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  84649. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  84650. precision.w = (precision.w < 1) ? 1 : precision.w;
  84651. precision.h = (precision.h < 1) ? 1 : precision.h;
  84652. var tileSize = {
  84653. 'w': (xmax - xmin) / subdivisions.w,
  84654. 'h': (zmax - zmin) / subdivisions.h
  84655. };
  84656. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  84657. // Indices
  84658. var base = positions.length / 3;
  84659. var rowLength = precision.w + 1;
  84660. for (row = 0; row < precision.h; row++) {
  84661. for (col = 0; col < precision.w; col++) {
  84662. var square = [
  84663. base + col + row * rowLength,
  84664. base + (col + 1) + row * rowLength,
  84665. base + (col + 1) + (row + 1) * rowLength,
  84666. base + col + (row + 1) * rowLength
  84667. ];
  84668. indices.push(square[1]);
  84669. indices.push(square[2]);
  84670. indices.push(square[3]);
  84671. indices.push(square[0]);
  84672. indices.push(square[1]);
  84673. indices.push(square[3]);
  84674. }
  84675. }
  84676. // Position, normals and uvs
  84677. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84678. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  84679. for (row = 0; row <= precision.h; row++) {
  84680. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  84681. for (col = 0; col <= precision.w; col++) {
  84682. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  84683. position.y = 0;
  84684. positions.push(position.x, position.y, position.z);
  84685. normals.push(normal.x, normal.y, normal.z);
  84686. uvs.push(col / precision.w, row / precision.h);
  84687. }
  84688. }
  84689. }
  84690. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  84691. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  84692. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  84693. }
  84694. }
  84695. // Result
  84696. var vertexData = new VertexData();
  84697. vertexData.indices = indices;
  84698. vertexData.positions = positions;
  84699. vertexData.normals = normals;
  84700. vertexData.uvs = uvs;
  84701. return vertexData;
  84702. };
  84703. /**
  84704. * Creates the VertexData of the Ground designed from a heightmap
  84705. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  84706. * * width the width (x direction) of the ground
  84707. * * height the height (z direction) of the ground
  84708. * * subdivisions the number of subdivisions per side
  84709. * * minHeight the minimum altitude on the ground, optional, default 0
  84710. * * maxHeight the maximum altitude on the ground, optional default 1
  84711. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  84712. * * buffer the array holding the image color data
  84713. * * bufferWidth the width of image
  84714. * * bufferHeight the height of image
  84715. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  84716. * @returns the VertexData of the Ground designed from a heightmap
  84717. */
  84718. VertexData.CreateGroundFromHeightMap = function (options) {
  84719. var indices = [];
  84720. var positions = [];
  84721. var normals = [];
  84722. var uvs = [];
  84723. var row, col;
  84724. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  84725. var alphaFilter = options.alphaFilter || 0.0;
  84726. // Vertices
  84727. for (row = 0; row <= options.subdivisions; row++) {
  84728. for (col = 0; col <= options.subdivisions; col++) {
  84729. 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));
  84730. // Compute height
  84731. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  84732. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  84733. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  84734. var r = options.buffer[pos] / 255.0;
  84735. var g = options.buffer[pos + 1] / 255.0;
  84736. var b = options.buffer[pos + 2] / 255.0;
  84737. var a = options.buffer[pos + 3] / 255.0;
  84738. var gradient = r * filter.r + g * filter.g + b * filter.b;
  84739. // If our alpha channel is not within our filter then we will assign a 'special' height
  84740. // Then when building the indices, we will ignore any vertex that is using the special height
  84741. if (a >= alphaFilter) {
  84742. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  84743. }
  84744. else {
  84745. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  84746. }
  84747. // Add vertex
  84748. positions.push(position.x, position.y, position.z);
  84749. normals.push(0, 0, 0);
  84750. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  84751. }
  84752. }
  84753. // Indices
  84754. for (row = 0; row < options.subdivisions; row++) {
  84755. for (col = 0; col < options.subdivisions; col++) {
  84756. // Calculate Indices
  84757. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  84758. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  84759. var idx3 = (col + row * (options.subdivisions + 1));
  84760. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  84761. // Check that all indices are visible (based on our special height)
  84762. // Only display the vertex if all Indices are visible
  84763. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  84764. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  84765. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  84766. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  84767. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  84768. indices.push(idx1);
  84769. indices.push(idx2);
  84770. indices.push(idx3);
  84771. }
  84772. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  84773. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  84774. indices.push(idx4);
  84775. indices.push(idx1);
  84776. indices.push(idx3);
  84777. }
  84778. }
  84779. }
  84780. // Normals
  84781. VertexData.ComputeNormals(positions, indices, normals);
  84782. // Result
  84783. var vertexData = new VertexData();
  84784. vertexData.indices = indices;
  84785. vertexData.positions = positions;
  84786. vertexData.normals = normals;
  84787. vertexData.uvs = uvs;
  84788. return vertexData;
  84789. };
  84790. /**
  84791. * Creates the VertexData for a Plane
  84792. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  84793. * * size sets the width and height of the plane to the value of size, optional default 1
  84794. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  84795. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  84796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84797. * * 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)
  84798. * * 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)
  84799. * @returns the VertexData of the box
  84800. */
  84801. VertexData.CreatePlane = function (options) {
  84802. var indices = [];
  84803. var positions = [];
  84804. var normals = [];
  84805. var uvs = [];
  84806. var width = options.width || options.size || 1;
  84807. var height = options.height || options.size || 1;
  84808. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84809. // Vertices
  84810. var halfWidth = width / 2.0;
  84811. var halfHeight = height / 2.0;
  84812. positions.push(-halfWidth, -halfHeight, 0);
  84813. normals.push(0, 0, -1.0);
  84814. uvs.push(0.0, 0.0);
  84815. positions.push(halfWidth, -halfHeight, 0);
  84816. normals.push(0, 0, -1.0);
  84817. uvs.push(1.0, 0.0);
  84818. positions.push(halfWidth, halfHeight, 0);
  84819. normals.push(0, 0, -1.0);
  84820. uvs.push(1.0, 1.0);
  84821. positions.push(-halfWidth, halfHeight, 0);
  84822. normals.push(0, 0, -1.0);
  84823. uvs.push(0.0, 1.0);
  84824. // Indices
  84825. indices.push(0);
  84826. indices.push(1);
  84827. indices.push(2);
  84828. indices.push(0);
  84829. indices.push(2);
  84830. indices.push(3);
  84831. // Sides
  84832. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84833. // Result
  84834. var vertexData = new VertexData();
  84835. vertexData.indices = indices;
  84836. vertexData.positions = positions;
  84837. vertexData.normals = normals;
  84838. vertexData.uvs = uvs;
  84839. return vertexData;
  84840. };
  84841. /**
  84842. * Creates the VertexData of the Disc or regular Polygon
  84843. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  84844. * * radius the radius of the disc, optional default 0.5
  84845. * * tessellation the number of polygon sides, optional, default 64
  84846. * * 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
  84847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84848. * * 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)
  84849. * * 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)
  84850. * @returns the VertexData of the box
  84851. */
  84852. VertexData.CreateDisc = function (options) {
  84853. var positions = new Array();
  84854. var indices = new Array();
  84855. var normals = new Array();
  84856. var uvs = new Array();
  84857. var radius = options.radius || 0.5;
  84858. var tessellation = options.tessellation || 64;
  84859. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84860. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84861. // positions and uvs
  84862. positions.push(0, 0, 0); // disc center first
  84863. uvs.push(0.5, 0.5);
  84864. var theta = Math.PI * 2 * arc;
  84865. var step = theta / tessellation;
  84866. for (var a = 0; a < theta; a += step) {
  84867. var x = Math.cos(a);
  84868. var y = Math.sin(a);
  84869. var u = (x + 1) / 2;
  84870. var v = (1 - y) / 2;
  84871. positions.push(radius * x, radius * y, 0);
  84872. uvs.push(u, v);
  84873. }
  84874. if (arc === 1) {
  84875. positions.push(positions[3], positions[4], positions[5]); // close the circle
  84876. uvs.push(uvs[2], uvs[3]);
  84877. }
  84878. //indices
  84879. var vertexNb = positions.length / 3;
  84880. for (var i = 1; i < vertexNb - 1; i++) {
  84881. indices.push(i + 1, 0, i);
  84882. }
  84883. // result
  84884. VertexData.ComputeNormals(positions, indices, normals);
  84885. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84886. var vertexData = new VertexData();
  84887. vertexData.indices = indices;
  84888. vertexData.positions = positions;
  84889. vertexData.normals = normals;
  84890. vertexData.uvs = uvs;
  84891. return vertexData;
  84892. };
  84893. /**
  84894. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  84895. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  84896. * @param polygon a mesh built from polygonTriangulation.build()
  84897. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84898. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84899. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84900. * @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)
  84901. * @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)
  84902. * @returns the VertexData of the Polygon
  84903. */
  84904. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  84905. var faceUV = fUV || new Array(3);
  84906. var faceColors = fColors;
  84907. var colors = [];
  84908. // default face colors and UV if undefined
  84909. for (var f = 0; f < 3; f++) {
  84910. if (faceUV[f] === undefined) {
  84911. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84912. }
  84913. if (faceColors && faceColors[f] === undefined) {
  84914. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84915. }
  84916. }
  84917. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  84918. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  84919. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  84920. var indices = polygon.getIndices();
  84921. // set face colours and textures
  84922. var idx = 0;
  84923. var face = 0;
  84924. for (var index = 0; index < normals.length; index += 3) {
  84925. //Edge Face no. 1
  84926. if (Math.abs(normals[index + 1]) < 0.001) {
  84927. face = 1;
  84928. }
  84929. //Top Face no. 0
  84930. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  84931. face = 0;
  84932. }
  84933. //Bottom Face no. 2
  84934. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  84935. face = 2;
  84936. }
  84937. idx = index / 3;
  84938. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  84939. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  84940. if (faceColors) {
  84941. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  84942. }
  84943. }
  84944. // sides
  84945. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  84946. // Result
  84947. var vertexData = new VertexData();
  84948. vertexData.indices = indices;
  84949. vertexData.positions = positions;
  84950. vertexData.normals = normals;
  84951. vertexData.uvs = uvs;
  84952. if (faceColors) {
  84953. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  84954. vertexData.colors = totalColors;
  84955. }
  84956. return vertexData;
  84957. };
  84958. /**
  84959. * Creates the VertexData of the IcoSphere
  84960. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  84961. * * radius the radius of the IcoSphere, optional default 1
  84962. * * radiusX allows stretching in the x direction, optional, default radius
  84963. * * radiusY allows stretching in the y direction, optional, default radius
  84964. * * radiusZ allows stretching in the z direction, optional, default radius
  84965. * * flat when true creates a flat shaded mesh, optional, default true
  84966. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  84967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84968. * * 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)
  84969. * * 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)
  84970. * @returns the VertexData of the IcoSphere
  84971. */
  84972. VertexData.CreateIcoSphere = function (options) {
  84973. var sideOrientation = options.sideOrientation || VertexData.DEFAULTSIDE;
  84974. var radius = options.radius || 1;
  84975. var flat = (options.flat === undefined) ? true : options.flat;
  84976. var subdivisions = options.subdivisions || 4;
  84977. var radiusX = options.radiusX || radius;
  84978. var radiusY = options.radiusY || radius;
  84979. var radiusZ = options.radiusZ || radius;
  84980. var t = (1 + Math.sqrt(5)) / 2;
  84981. // 12 vertex x,y,z
  84982. var ico_vertices = [
  84983. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  84984. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  84985. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  84986. ];
  84987. // index of 3 vertex makes a face of icopshere
  84988. var ico_indices = [
  84989. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  84990. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  84991. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  84992. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  84993. ];
  84994. // vertex for uv have aliased position, not for UV
  84995. var vertices_unalias_id = [
  84996. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  84997. // vertex alias
  84998. 0,
  84999. 2,
  85000. 3,
  85001. 3,
  85002. 3,
  85003. 4,
  85004. 7,
  85005. 8,
  85006. 9,
  85007. 9,
  85008. 10,
  85009. 11 // 23: B + 12
  85010. ];
  85011. // uv as integer step (not pixels !)
  85012. var ico_vertexuv = [
  85013. 5, 1, 3, 1, 6, 4, 0, 0,
  85014. 5, 3, 4, 2, 2, 2, 4, 0,
  85015. 2, 0, 1, 1, 6, 0, 6, 2,
  85016. // vertex alias (for same vertex on different faces)
  85017. 0, 4,
  85018. 3, 3,
  85019. 4, 4,
  85020. 3, 1,
  85021. 4, 2,
  85022. 4, 4,
  85023. 0, 2,
  85024. 1, 1,
  85025. 2, 2,
  85026. 3, 3,
  85027. 1, 3,
  85028. 2, 4 // 23: B + 12
  85029. ];
  85030. // Vertices[0, 1, ...9, A, B] : position on UV plane
  85031. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  85032. // First island of uv mapping
  85033. // v = 4h 3+ 2
  85034. // v = 3h 9+ 4
  85035. // v = 2h 9+ 5 B
  85036. // v = 1h 9 1 0
  85037. // v = 0h 3 8 7 A
  85038. // u = 0 1 2 3 4 5 6 *a
  85039. // Second island of uv mapping
  85040. // v = 4h 0+ B+ 4+
  85041. // v = 3h A+ 2+
  85042. // v = 2h 7+ 6 3+
  85043. // v = 1h 8+ 3+
  85044. // v = 0h
  85045. // u = 0 1 2 3 4 5 6 *a
  85046. // Face layout on texture UV mapping
  85047. // ============
  85048. // \ 4 /\ 16 / ======
  85049. // \ / \ / /\ 11 /
  85050. // \/ 7 \/ / \ /
  85051. // ======= / 10 \/
  85052. // /\ 17 /\ =======
  85053. // / \ / \ \ 15 /\
  85054. // / 8 \/ 12 \ \ / \
  85055. // ============ \/ 6 \
  85056. // \ 18 /\ ============
  85057. // \ / \ \ 5 /\ 0 /
  85058. // \/ 13 \ \ / \ /
  85059. // ======= \/ 1 \/
  85060. // =============
  85061. // /\ 19 /\ 2 /\
  85062. // / \ / \ / \
  85063. // / 14 \/ 9 \/ 3 \
  85064. // ===================
  85065. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  85066. var ustep = 138 / 1024;
  85067. var vstep = 239 / 1024;
  85068. var uoffset = 60 / 1024;
  85069. var voffset = 26 / 1024;
  85070. // Second island should have margin, not to touch the first island
  85071. // avoid any borderline artefact in pixel rounding
  85072. var island_u_offset = -40 / 1024;
  85073. var island_v_offset = +20 / 1024;
  85074. // face is either island 0 or 1 :
  85075. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  85076. var island = [
  85077. 0, 0, 0, 0, 1,
  85078. 0, 0, 1, 1, 0,
  85079. 0, 0, 1, 1, 0,
  85080. 0, 1, 1, 1, 0 // 15 - 19
  85081. ];
  85082. var indices = new Array();
  85083. var positions = new Array();
  85084. var normals = new Array();
  85085. var uvs = new Array();
  85086. var current_indice = 0;
  85087. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  85088. var face_vertex_pos = new Array(3);
  85089. var face_vertex_uv = new Array(3);
  85090. var v012;
  85091. for (v012 = 0; v012 < 3; v012++) {
  85092. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85093. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  85094. }
  85095. // create all with normals
  85096. for (var face = 0; face < 20; face++) {
  85097. // 3 vertex per face
  85098. for (v012 = 0; v012 < 3; v012++) {
  85099. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  85100. var v_id = ico_indices[3 * face + v012];
  85101. // vertex have 3D position (x,y,z)
  85102. 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]);
  85103. // Normalize to get normal, then scale to radius
  85104. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  85105. // uv Coordinates from vertex ID
  85106. 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);
  85107. }
  85108. // Subdivide the face (interpolate pos, norm, uv)
  85109. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  85110. // - norm is linear interpolation of vertex corner normal
  85111. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  85112. // - uv is linear interpolation
  85113. //
  85114. // Topology is as below for sub-divide by 2
  85115. // vertex shown as v0,v1,v2
  85116. // interp index is i1 to progress in range [v0,v1[
  85117. // interp index is i2 to progress in range [v0,v2[
  85118. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  85119. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85120. //
  85121. //
  85122. // i2 v2
  85123. // ^ ^
  85124. // / / \
  85125. // / / \
  85126. // / / \
  85127. // / / (0,1) \
  85128. // / #---------\
  85129. // / / \ (0,0)'/ \
  85130. // / / \ / \
  85131. // / / \ / \
  85132. // / / (0,0) \ / (1,0) \
  85133. // / #---------#---------\
  85134. // v0 v1
  85135. //
  85136. // --------------------> i1
  85137. //
  85138. // interp of (i1,i2):
  85139. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  85140. // along i1 : lerp(x0,x1, i1/(S-i2))
  85141. //
  85142. // centroid of triangle is needed to get help normal computation
  85143. // (c1,c2) are used for centroid location
  85144. var interp_vertex = function (i1, i2, c1, c2) {
  85145. // vertex is interpolated from
  85146. // - face_vertex_pos[0..2]
  85147. // - face_vertex_uv[0..2]
  85148. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  85149. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  85150. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  85151. pos_interp.normalize();
  85152. var vertex_normal;
  85153. if (flat) {
  85154. // in flat mode, recalculate normal as face centroid normal
  85155. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  85156. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  85157. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  85158. }
  85159. else {
  85160. // in smooth mode, recalculate normal from each single vertex position
  85161. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  85162. }
  85163. // Vertex normal need correction due to X,Y,Z radius scaling
  85164. vertex_normal.x /= radiusX;
  85165. vertex_normal.y /= radiusY;
  85166. vertex_normal.z /= radiusZ;
  85167. vertex_normal.normalize();
  85168. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  85169. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  85170. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  85171. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  85172. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  85173. uvs.push(uv_interp.x, uv_interp.y);
  85174. // push each vertex has member of a face
  85175. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  85176. indices.push(current_indice);
  85177. current_indice++;
  85178. };
  85179. for (var i2 = 0; i2 < subdivisions; i2++) {
  85180. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  85181. // face : (i1,i2) for /\ :
  85182. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  85183. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85184. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85185. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85186. if (i1 + i2 + 1 < subdivisions) {
  85187. // face : (i1,i2)' for \/ :
  85188. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85189. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85190. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85191. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85192. }
  85193. }
  85194. }
  85195. }
  85196. // Sides
  85197. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85198. // Result
  85199. var vertexData = new VertexData();
  85200. vertexData.indices = indices;
  85201. vertexData.positions = positions;
  85202. vertexData.normals = normals;
  85203. vertexData.uvs = uvs;
  85204. return vertexData;
  85205. };
  85206. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  85207. /**
  85208. * Creates the VertexData for a Polyhedron
  85209. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85210. * * type provided types are:
  85211. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85212. * * 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)
  85213. * * size the size of the IcoSphere, optional default 1
  85214. * * sizeX allows stretching in the x direction, optional, default size
  85215. * * sizeY allows stretching in the y direction, optional, default size
  85216. * * sizeZ allows stretching in the z direction, optional, default size
  85217. * * 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
  85218. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85219. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85220. * * flat when true creates a flat shaded mesh, optional, default true
  85221. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85223. * * 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)
  85224. * * 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)
  85225. * @returns the VertexData of the Polyhedron
  85226. */
  85227. VertexData.CreatePolyhedron = function (options) {
  85228. // provided polyhedron types :
  85229. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85230. // 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)
  85231. var polyhedra = [];
  85232. 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]] };
  85233. 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]] };
  85234. polyhedra[2] = {
  85235. 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]],
  85236. 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]]
  85237. };
  85238. polyhedra[3] = {
  85239. 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]],
  85240. 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]]
  85241. };
  85242. polyhedra[4] = {
  85243. 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]],
  85244. 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]]
  85245. };
  85246. 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]] };
  85247. 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]] };
  85248. 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]] };
  85249. 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]] };
  85250. 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]] };
  85251. 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]] };
  85252. 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]] };
  85253. 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]] };
  85254. 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]] };
  85255. polyhedra[14] = {
  85256. 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]],
  85257. 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]]
  85258. };
  85259. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  85260. var size = options.size;
  85261. var sizeX = options.sizeX || size || 1;
  85262. var sizeY = options.sizeY || size || 1;
  85263. var sizeZ = options.sizeZ || size || 1;
  85264. var data = options.custom || polyhedra[type];
  85265. var nbfaces = data.face.length;
  85266. var faceUV = options.faceUV || new Array(nbfaces);
  85267. var faceColors = options.faceColors;
  85268. var flat = (options.flat === undefined) ? true : options.flat;
  85269. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85270. var positions = new Array();
  85271. var indices = new Array();
  85272. var normals = new Array();
  85273. var uvs = new Array();
  85274. var colors = new Array();
  85275. var index = 0;
  85276. var faceIdx = 0; // face cursor in the array "indexes"
  85277. var indexes = new Array();
  85278. var i = 0;
  85279. var f = 0;
  85280. var u, v, ang, x, y, tmp;
  85281. // default face colors and UV if undefined
  85282. if (flat) {
  85283. for (f = 0; f < nbfaces; f++) {
  85284. if (faceColors && faceColors[f] === undefined) {
  85285. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  85286. }
  85287. if (faceUV && faceUV[f] === undefined) {
  85288. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  85289. }
  85290. }
  85291. }
  85292. if (!flat) {
  85293. for (i = 0; i < data.vertex.length; i++) {
  85294. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  85295. uvs.push(0, 0);
  85296. }
  85297. for (f = 0; f < nbfaces; f++) {
  85298. for (i = 0; i < data.face[f].length - 2; i++) {
  85299. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  85300. }
  85301. }
  85302. }
  85303. else {
  85304. for (f = 0; f < nbfaces; f++) {
  85305. var fl = data.face[f].length; // number of vertices of the current face
  85306. ang = 2 * Math.PI / fl;
  85307. x = 0.5 * Math.tan(ang / 2);
  85308. y = 0.5;
  85309. // positions, uvs, colors
  85310. for (i = 0; i < fl; i++) {
  85311. // positions
  85312. 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);
  85313. indexes.push(index);
  85314. index++;
  85315. // uvs
  85316. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  85317. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  85318. uvs.push(u, v);
  85319. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  85320. y = x * Math.sin(ang) + y * Math.cos(ang);
  85321. x = tmp;
  85322. // colors
  85323. if (faceColors) {
  85324. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  85325. }
  85326. }
  85327. // indices from indexes
  85328. for (i = 0; i < fl - 2; i++) {
  85329. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  85330. }
  85331. faceIdx += fl;
  85332. }
  85333. }
  85334. VertexData.ComputeNormals(positions, indices, normals);
  85335. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85336. var vertexData = new VertexData();
  85337. vertexData.positions = positions;
  85338. vertexData.indices = indices;
  85339. vertexData.normals = normals;
  85340. vertexData.uvs = uvs;
  85341. if (faceColors && flat) {
  85342. vertexData.colors = colors;
  85343. }
  85344. return vertexData;
  85345. };
  85346. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  85347. /**
  85348. * Creates the VertexData for a TorusKnot
  85349. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85350. * * radius the radius of the torus knot, optional, default 2
  85351. * * tube the thickness of the tube, optional, default 0.5
  85352. * * radialSegments the number of sides on each tube segments, optional, default 32
  85353. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85354. * * p the number of windings around the z axis, optional, default 2
  85355. * * q the number of windings around the x axis, optional, default 3
  85356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85357. * * 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)
  85358. * * 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)
  85359. * @returns the VertexData of the Torus Knot
  85360. */
  85361. VertexData.CreateTorusKnot = function (options) {
  85362. var indices = new Array();
  85363. var positions = new Array();
  85364. var normals = new Array();
  85365. var uvs = new Array();
  85366. var radius = options.radius || 2;
  85367. var tube = options.tube || 0.5;
  85368. var radialSegments = options.radialSegments || 32;
  85369. var tubularSegments = options.tubularSegments || 32;
  85370. var p = options.p || 2;
  85371. var q = options.q || 3;
  85372. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85373. // Helper
  85374. var getPos = function (angle) {
  85375. var cu = Math.cos(angle);
  85376. var su = Math.sin(angle);
  85377. var quOverP = q / p * angle;
  85378. var cs = Math.cos(quOverP);
  85379. var tx = radius * (2 + cs) * 0.5 * cu;
  85380. var ty = radius * (2 + cs) * su * 0.5;
  85381. var tz = radius * Math.sin(quOverP) * 0.5;
  85382. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  85383. };
  85384. // Vertices
  85385. var i;
  85386. var j;
  85387. for (i = 0; i <= radialSegments; i++) {
  85388. var modI = i % radialSegments;
  85389. var u = modI / radialSegments * 2 * p * Math.PI;
  85390. var p1 = getPos(u);
  85391. var p2 = getPos(u + 0.01);
  85392. var tang = p2.subtract(p1);
  85393. var n = p2.add(p1);
  85394. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  85395. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  85396. bitan.normalize();
  85397. n.normalize();
  85398. for (j = 0; j < tubularSegments; j++) {
  85399. var modJ = j % tubularSegments;
  85400. var v = modJ / tubularSegments * 2 * Math.PI;
  85401. var cx = -tube * Math.cos(v);
  85402. var cy = tube * Math.sin(v);
  85403. positions.push(p1.x + cx * n.x + cy * bitan.x);
  85404. positions.push(p1.y + cx * n.y + cy * bitan.y);
  85405. positions.push(p1.z + cx * n.z + cy * bitan.z);
  85406. uvs.push(i / radialSegments);
  85407. uvs.push(j / tubularSegments);
  85408. }
  85409. }
  85410. for (i = 0; i < radialSegments; i++) {
  85411. for (j = 0; j < tubularSegments; j++) {
  85412. var jNext = (j + 1) % tubularSegments;
  85413. var a = i * tubularSegments + j;
  85414. var b = (i + 1) * tubularSegments + j;
  85415. var c = (i + 1) * tubularSegments + jNext;
  85416. var d = i * tubularSegments + jNext;
  85417. indices.push(d);
  85418. indices.push(b);
  85419. indices.push(a);
  85420. indices.push(d);
  85421. indices.push(c);
  85422. indices.push(b);
  85423. }
  85424. }
  85425. // Normals
  85426. VertexData.ComputeNormals(positions, indices, normals);
  85427. // Sides
  85428. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85429. // Result
  85430. var vertexData = new VertexData();
  85431. vertexData.indices = indices;
  85432. vertexData.positions = positions;
  85433. vertexData.normals = normals;
  85434. vertexData.uvs = uvs;
  85435. return vertexData;
  85436. };
  85437. // Tools
  85438. /**
  85439. * Compute normals for given positions and indices
  85440. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85441. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85442. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85443. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85444. * * facetNormals : optional array of facet normals (vector3)
  85445. * * facetPositions : optional array of facet positions (vector3)
  85446. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85447. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85448. * * bInfo : optional bounding info, required for facetPartitioning computation
  85449. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85450. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85451. * * useRightHandedSystem: optional boolean to for right handed system computation
  85452. * * depthSort : optional boolean to enable the facet depth sort computation
  85453. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85454. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85455. */
  85456. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  85457. // temporary scalar variables
  85458. var index = 0; // facet index
  85459. var p1p2x = 0.0; // p1p2 vector x coordinate
  85460. var p1p2y = 0.0; // p1p2 vector y coordinate
  85461. var p1p2z = 0.0; // p1p2 vector z coordinate
  85462. var p3p2x = 0.0; // p3p2 vector x coordinate
  85463. var p3p2y = 0.0; // p3p2 vector y coordinate
  85464. var p3p2z = 0.0; // p3p2 vector z coordinate
  85465. var faceNormalx = 0.0; // facet normal x coordinate
  85466. var faceNormaly = 0.0; // facet normal y coordinate
  85467. var faceNormalz = 0.0; // facet normal z coordinate
  85468. var length = 0.0; // facet normal length before normalization
  85469. var v1x = 0; // vector1 x index in the positions array
  85470. var v1y = 0; // vector1 y index in the positions array
  85471. var v1z = 0; // vector1 z index in the positions array
  85472. var v2x = 0; // vector2 x index in the positions array
  85473. var v2y = 0; // vector2 y index in the positions array
  85474. var v2z = 0; // vector2 z index in the positions array
  85475. var v3x = 0; // vector3 x index in the positions array
  85476. var v3y = 0; // vector3 y index in the positions array
  85477. var v3z = 0; // vector3 z index in the positions array
  85478. var computeFacetNormals = false;
  85479. var computeFacetPositions = false;
  85480. var computeFacetPartitioning = false;
  85481. var computeDepthSort = false;
  85482. var faceNormalSign = 1;
  85483. var ratio = 0;
  85484. var distanceTo = null;
  85485. if (options) {
  85486. computeFacetNormals = (options.facetNormals) ? true : false;
  85487. computeFacetPositions = (options.facetPositions) ? true : false;
  85488. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  85489. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  85490. ratio = options.ratio || 0;
  85491. computeDepthSort = (options.depthSort) ? true : false;
  85492. distanceTo = (options.distanceTo);
  85493. if (computeDepthSort) {
  85494. if (distanceTo === undefined) {
  85495. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85496. }
  85497. var depthSortedFacets = options.depthSortedFacets;
  85498. }
  85499. }
  85500. // facetPartitioning reinit if needed
  85501. var xSubRatio = 0;
  85502. var ySubRatio = 0;
  85503. var zSubRatio = 0;
  85504. var subSq = 0;
  85505. if (computeFacetPartitioning && options && options.bbSize) {
  85506. var ox = 0; // X partitioning index for facet position
  85507. var oy = 0; // Y partinioning index for facet position
  85508. var oz = 0; // Z partinioning index for facet position
  85509. var b1x = 0; // X partitioning index for facet v1 vertex
  85510. var b1y = 0; // Y partitioning index for facet v1 vertex
  85511. var b1z = 0; // z partitioning index for facet v1 vertex
  85512. var b2x = 0; // X partitioning index for facet v2 vertex
  85513. var b2y = 0; // Y partitioning index for facet v2 vertex
  85514. var b2z = 0; // Z partitioning index for facet v2 vertex
  85515. var b3x = 0; // X partitioning index for facet v3 vertex
  85516. var b3y = 0; // Y partitioning index for facet v3 vertex
  85517. var b3z = 0; // Z partitioning index for facet v3 vertex
  85518. var block_idx_o = 0; // facet barycenter block index
  85519. var block_idx_v1 = 0; // v1 vertex block index
  85520. var block_idx_v2 = 0; // v2 vertex block index
  85521. var block_idx_v3 = 0; // v3 vertex block index
  85522. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  85523. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  85524. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  85525. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  85526. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  85527. subSq = options.subDiv.max * options.subDiv.max;
  85528. options.facetPartitioning.length = 0;
  85529. }
  85530. // reset the normals
  85531. for (index = 0; index < positions.length; index++) {
  85532. normals[index] = 0.0;
  85533. }
  85534. // Loop : 1 indice triplet = 1 facet
  85535. var nbFaces = (indices.length / 3) | 0;
  85536. for (index = 0; index < nbFaces; index++) {
  85537. // get the indexes of the coordinates of each vertex of the facet
  85538. v1x = indices[index * 3] * 3;
  85539. v1y = v1x + 1;
  85540. v1z = v1x + 2;
  85541. v2x = indices[index * 3 + 1] * 3;
  85542. v2y = v2x + 1;
  85543. v2z = v2x + 2;
  85544. v3x = indices[index * 3 + 2] * 3;
  85545. v3y = v3x + 1;
  85546. v3z = v3x + 2;
  85547. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  85548. p1p2y = positions[v1y] - positions[v2y];
  85549. p1p2z = positions[v1z] - positions[v2z];
  85550. p3p2x = positions[v3x] - positions[v2x];
  85551. p3p2y = positions[v3y] - positions[v2y];
  85552. p3p2z = positions[v3z] - positions[v2z];
  85553. // compute the face normal with the cross product
  85554. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  85555. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  85556. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  85557. // normalize this normal and store it in the array facetData
  85558. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85559. length = (length === 0) ? 1.0 : length;
  85560. faceNormalx /= length;
  85561. faceNormaly /= length;
  85562. faceNormalz /= length;
  85563. if (computeFacetNormals && options) {
  85564. options.facetNormals[index].x = faceNormalx;
  85565. options.facetNormals[index].y = faceNormaly;
  85566. options.facetNormals[index].z = faceNormalz;
  85567. }
  85568. if (computeFacetPositions && options) {
  85569. // compute and the facet barycenter coordinates in the array facetPositions
  85570. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  85571. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  85572. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  85573. }
  85574. if (computeFacetPartitioning && options) {
  85575. // store the facet indexes in arrays in the main facetPartitioning array :
  85576. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  85577. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  85578. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  85579. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  85580. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85581. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85582. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85583. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85584. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85585. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85586. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85587. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85588. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85589. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  85590. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  85591. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  85592. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  85593. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  85594. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  85595. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  85596. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  85597. // push each facet index in each block containing the vertex
  85598. options.facetPartitioning[block_idx_v1].push(index);
  85599. if (block_idx_v2 != block_idx_v1) {
  85600. options.facetPartitioning[block_idx_v2].push(index);
  85601. }
  85602. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  85603. options.facetPartitioning[block_idx_v3].push(index);
  85604. }
  85605. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  85606. options.facetPartitioning[block_idx_o].push(index);
  85607. }
  85608. }
  85609. if (computeDepthSort && options && options.facetPositions) {
  85610. var dsf = depthSortedFacets[index];
  85611. dsf.ind = index * 3;
  85612. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  85613. }
  85614. // compute the normals anyway
  85615. normals[v1x] += faceNormalx; // accumulate all the normals per face
  85616. normals[v1y] += faceNormaly;
  85617. normals[v1z] += faceNormalz;
  85618. normals[v2x] += faceNormalx;
  85619. normals[v2y] += faceNormaly;
  85620. normals[v2z] += faceNormalz;
  85621. normals[v3x] += faceNormalx;
  85622. normals[v3y] += faceNormaly;
  85623. normals[v3z] += faceNormalz;
  85624. }
  85625. // last normalization of each normal
  85626. for (index = 0; index < normals.length / 3; index++) {
  85627. faceNormalx = normals[index * 3];
  85628. faceNormaly = normals[index * 3 + 1];
  85629. faceNormalz = normals[index * 3 + 2];
  85630. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85631. length = (length === 0) ? 1.0 : length;
  85632. faceNormalx /= length;
  85633. faceNormaly /= length;
  85634. faceNormalz /= length;
  85635. normals[index * 3] = faceNormalx;
  85636. normals[index * 3 + 1] = faceNormaly;
  85637. normals[index * 3 + 2] = faceNormalz;
  85638. }
  85639. };
  85640. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  85641. var li = indices.length;
  85642. var ln = normals.length;
  85643. var i;
  85644. var n;
  85645. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  85646. switch (sideOrientation) {
  85647. case VertexData.FRONTSIDE:
  85648. // nothing changed
  85649. break;
  85650. case VertexData.BACKSIDE:
  85651. var tmp;
  85652. // indices
  85653. for (i = 0; i < li; i += 3) {
  85654. tmp = indices[i];
  85655. indices[i] = indices[i + 2];
  85656. indices[i + 2] = tmp;
  85657. }
  85658. // normals
  85659. for (n = 0; n < ln; n++) {
  85660. normals[n] = -normals[n];
  85661. }
  85662. break;
  85663. case VertexData.DOUBLESIDE:
  85664. // positions
  85665. var lp = positions.length;
  85666. var l = lp / 3;
  85667. for (var p = 0; p < lp; p++) {
  85668. positions[lp + p] = positions[p];
  85669. }
  85670. // indices
  85671. for (i = 0; i < li; i += 3) {
  85672. indices[i + li] = indices[i + 2] + l;
  85673. indices[i + 1 + li] = indices[i + 1] + l;
  85674. indices[i + 2 + li] = indices[i] + l;
  85675. }
  85676. // normals
  85677. for (n = 0; n < ln; n++) {
  85678. normals[ln + n] = -normals[n];
  85679. }
  85680. // uvs
  85681. var lu = uvs.length;
  85682. var u = 0;
  85683. for (u = 0; u < lu; u++) {
  85684. uvs[u + lu] = uvs[u];
  85685. }
  85686. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  85687. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  85688. u = 0;
  85689. for (i = 0; i < lu / 2; i++) {
  85690. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  85691. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  85692. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  85693. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  85694. u += 2;
  85695. }
  85696. break;
  85697. }
  85698. };
  85699. /**
  85700. * Applies VertexData created from the imported parameters to the geometry
  85701. * @param parsedVertexData the parsed data from an imported file
  85702. * @param geometry the geometry to apply the VertexData to
  85703. */
  85704. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  85705. var vertexData = new VertexData();
  85706. // positions
  85707. var positions = parsedVertexData.positions;
  85708. if (positions) {
  85709. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  85710. }
  85711. // normals
  85712. var normals = parsedVertexData.normals;
  85713. if (normals) {
  85714. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  85715. }
  85716. // tangents
  85717. var tangents = parsedVertexData.tangents;
  85718. if (tangents) {
  85719. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  85720. }
  85721. // uvs
  85722. var uvs = parsedVertexData.uvs;
  85723. if (uvs) {
  85724. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  85725. }
  85726. // uv2s
  85727. var uv2s = parsedVertexData.uv2s;
  85728. if (uv2s) {
  85729. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  85730. }
  85731. // uv3s
  85732. var uv3s = parsedVertexData.uv3s;
  85733. if (uv3s) {
  85734. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  85735. }
  85736. // uv4s
  85737. var uv4s = parsedVertexData.uv4s;
  85738. if (uv4s) {
  85739. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  85740. }
  85741. // uv5s
  85742. var uv5s = parsedVertexData.uv5s;
  85743. if (uv5s) {
  85744. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  85745. }
  85746. // uv6s
  85747. var uv6s = parsedVertexData.uv6s;
  85748. if (uv6s) {
  85749. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  85750. }
  85751. // colors
  85752. var colors = parsedVertexData.colors;
  85753. if (colors) {
  85754. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  85755. }
  85756. // matricesIndices
  85757. var matricesIndices = parsedVertexData.matricesIndices;
  85758. if (matricesIndices) {
  85759. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  85760. }
  85761. // matricesWeights
  85762. var matricesWeights = parsedVertexData.matricesWeights;
  85763. if (matricesWeights) {
  85764. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  85765. }
  85766. // indices
  85767. var indices = parsedVertexData.indices;
  85768. if (indices) {
  85769. vertexData.indices = indices;
  85770. }
  85771. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  85772. };
  85773. /**
  85774. * Mesh side orientation : usually the external or front surface
  85775. */
  85776. VertexData.FRONTSIDE = 0;
  85777. /**
  85778. * Mesh side orientation : usually the internal or back surface
  85779. */
  85780. VertexData.BACKSIDE = 1;
  85781. /**
  85782. * Mesh side orientation : both internal and external or front and back surfaces
  85783. */
  85784. VertexData.DOUBLESIDE = 2;
  85785. /**
  85786. * Mesh side orientation : by default, `FRONTSIDE`
  85787. */
  85788. VertexData.DEFAULTSIDE = 0;
  85789. return VertexData;
  85790. }());
  85791. /***/ }),
  85792. /***/ "./Meshes/meshBuilder.ts":
  85793. /*!*******************************!*\
  85794. !*** ./Meshes/meshBuilder.ts ***!
  85795. \*******************************/
  85796. /*! exports provided: MeshBuilder */
  85797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85798. "use strict";
  85799. __webpack_require__.r(__webpack_exports__);
  85800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  85801. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85802. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  85803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85804. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  85805. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85806. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  85807. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85808. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  85809. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  85810. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85811. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  85812. if (closeArray === void 0) { closeArray = false; }
  85813. if (updatable === void 0) { updatable = false; }
  85814. return MeshBuilder.CreateRibbon(name, {
  85815. pathArray: pathArray,
  85816. closeArray: closeArray,
  85817. closePath: closePath,
  85818. offset: offset,
  85819. updatable: updatable,
  85820. sideOrientation: sideOrientation,
  85821. instance: instance
  85822. }, scene);
  85823. };
  85824. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  85825. if (scene === void 0) { scene = null; }
  85826. var options = {
  85827. radius: radius,
  85828. tessellation: tessellation,
  85829. sideOrientation: sideOrientation,
  85830. updatable: updatable
  85831. };
  85832. return MeshBuilder.CreateDisc(name, options, scene);
  85833. };
  85834. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  85835. if (scene === void 0) { scene = null; }
  85836. var options = {
  85837. size: size,
  85838. sideOrientation: sideOrientation,
  85839. updatable: updatable
  85840. };
  85841. return MeshBuilder.CreateBox(name, options, scene);
  85842. };
  85843. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  85844. var options = {
  85845. segments: segments,
  85846. diameterX: diameter,
  85847. diameterY: diameter,
  85848. diameterZ: diameter,
  85849. sideOrientation: sideOrientation,
  85850. updatable: updatable
  85851. };
  85852. return MeshBuilder.CreateSphere(name, options, scene);
  85853. };
  85854. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  85855. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"])) {
  85856. if (scene !== undefined) {
  85857. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DEFAULTSIDE;
  85858. updatable = scene;
  85859. }
  85860. scene = subdivisions;
  85861. subdivisions = 1;
  85862. }
  85863. var options = {
  85864. height: height,
  85865. diameterTop: diameterTop,
  85866. diameterBottom: diameterBottom,
  85867. tessellation: tessellation,
  85868. subdivisions: subdivisions,
  85869. sideOrientation: sideOrientation,
  85870. updatable: updatable
  85871. };
  85872. return MeshBuilder.CreateCylinder(name, options, scene);
  85873. };
  85874. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  85875. var options = {
  85876. diameter: diameter,
  85877. thickness: thickness,
  85878. tessellation: tessellation,
  85879. sideOrientation: sideOrientation,
  85880. updatable: updatable
  85881. };
  85882. return MeshBuilder.CreateTorus(name, options, scene);
  85883. };
  85884. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  85885. var options = {
  85886. radius: radius,
  85887. tube: tube,
  85888. radialSegments: radialSegments,
  85889. tubularSegments: tubularSegments,
  85890. p: p,
  85891. q: q,
  85892. sideOrientation: sideOrientation,
  85893. updatable: updatable
  85894. };
  85895. return MeshBuilder.CreateTorusKnot(name, options, scene);
  85896. };
  85897. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  85898. if (scene === void 0) { scene = null; }
  85899. if (updatable === void 0) { updatable = false; }
  85900. if (instance === void 0) { instance = null; }
  85901. var options = {
  85902. points: points,
  85903. updatable: updatable,
  85904. instance: instance
  85905. };
  85906. return MeshBuilder.CreateLines(name, options, scene);
  85907. };
  85908. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  85909. if (scene === void 0) { scene = null; }
  85910. var options = {
  85911. points: points,
  85912. dashSize: dashSize,
  85913. gapSize: gapSize,
  85914. dashNb: dashNb,
  85915. updatable: updatable,
  85916. instance: instance
  85917. };
  85918. return MeshBuilder.CreateDashedLines(name, options, scene);
  85919. };
  85920. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  85921. var options = {
  85922. shape: shape,
  85923. holes: holes,
  85924. updatable: updatable,
  85925. sideOrientation: sideOrientation
  85926. };
  85927. return MeshBuilder.CreatePolygon(name, options, scene);
  85928. };
  85929. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  85930. var options = {
  85931. shape: shape,
  85932. holes: holes,
  85933. depth: depth,
  85934. updatable: updatable,
  85935. sideOrientation: sideOrientation
  85936. };
  85937. return MeshBuilder.ExtrudePolygon(name, options, scene);
  85938. };
  85939. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  85940. if (scene === void 0) { scene = null; }
  85941. var options = {
  85942. shape: shape,
  85943. path: path,
  85944. scale: scale,
  85945. rotation: rotation,
  85946. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  85947. sideOrientation: sideOrientation,
  85948. instance: instance,
  85949. updatable: updatable
  85950. };
  85951. return MeshBuilder.ExtrudeShape(name, options, scene);
  85952. };
  85953. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  85954. var options = {
  85955. shape: shape,
  85956. path: path,
  85957. scaleFunction: scaleFunction,
  85958. rotationFunction: rotationFunction,
  85959. ribbonCloseArray: ribbonCloseArray,
  85960. ribbonClosePath: ribbonClosePath,
  85961. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  85962. sideOrientation: sideOrientation,
  85963. instance: instance,
  85964. updatable: updatable
  85965. };
  85966. return MeshBuilder.ExtrudeShapeCustom(name, options, scene);
  85967. };
  85968. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  85969. var options = {
  85970. shape: shape,
  85971. radius: radius,
  85972. tessellation: tessellation,
  85973. sideOrientation: sideOrientation,
  85974. updatable: updatable
  85975. };
  85976. return MeshBuilder.CreateLathe(name, options, scene);
  85977. };
  85978. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  85979. var options = {
  85980. size: size,
  85981. width: size,
  85982. height: size,
  85983. sideOrientation: sideOrientation,
  85984. updatable: updatable
  85985. };
  85986. return MeshBuilder.CreatePlane(name, options, scene);
  85987. };
  85988. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  85989. var options = {
  85990. width: width,
  85991. height: height,
  85992. subdivisions: subdivisions,
  85993. updatable: updatable
  85994. };
  85995. return MeshBuilder.CreateGround(name, options, scene);
  85996. };
  85997. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  85998. var options = {
  85999. xmin: xmin,
  86000. zmin: zmin,
  86001. xmax: xmax,
  86002. zmax: zmax,
  86003. subdivisions: subdivisions,
  86004. precision: precision,
  86005. updatable: updatable
  86006. };
  86007. return MeshBuilder.CreateTiledGround(name, options, scene);
  86008. };
  86009. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86010. var options = {
  86011. width: width,
  86012. height: height,
  86013. subdivisions: subdivisions,
  86014. minHeight: minHeight,
  86015. maxHeight: maxHeight,
  86016. updatable: updatable,
  86017. onReady: onReady,
  86018. alphaFilter: alphaFilter
  86019. };
  86020. return MeshBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  86021. };
  86022. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86023. var options = {
  86024. path: path,
  86025. radius: radius,
  86026. tessellation: tessellation,
  86027. radiusFunction: radiusFunction,
  86028. arc: 1,
  86029. cap: cap,
  86030. updatable: updatable,
  86031. sideOrientation: sideOrientation,
  86032. instance: instance
  86033. };
  86034. return MeshBuilder.CreateTube(name, options, scene);
  86035. };
  86036. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  86037. return MeshBuilder.CreatePolyhedron(name, options, scene);
  86038. };
  86039. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  86040. return MeshBuilder.CreateIcoSphere(name, options, scene);
  86041. };
  86042. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86043. var options = {
  86044. position: position,
  86045. normal: normal,
  86046. size: size,
  86047. angle: angle
  86048. };
  86049. return MeshBuilder.CreateDecal(name, sourceMesh, options);
  86050. };
  86051. /**
  86052. * Class containing static functions to help procedurally build meshes
  86053. */
  86054. var MeshBuilder = /** @class */ (function () {
  86055. function MeshBuilder() {
  86056. }
  86057. MeshBuilder._UpdateSideOrientation = function (orientation) {
  86058. if (orientation == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) {
  86059. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE;
  86060. }
  86061. if (orientation === undefined || orientation === null) {
  86062. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].FRONTSIDE;
  86063. }
  86064. return orientation;
  86065. };
  86066. /**
  86067. * Creates a box mesh
  86068. * * The parameter `size` sets the size (float) of each box side (default 1)
  86069. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  86070. * * 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)
  86071. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  86072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86073. * * 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
  86074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86075. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  86076. * @param name defines the name of the mesh
  86077. * @param options defines the options used to create the mesh
  86078. * @param scene defines the hosting scene
  86079. * @returns the box mesh
  86080. */
  86081. MeshBuilder.CreateBox = function (name, options, scene) {
  86082. if (scene === void 0) { scene = null; }
  86083. var box = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86084. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86085. box._originalBuilderSideOrientation = options.sideOrientation;
  86086. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateBox(options);
  86087. vertexData.applyToMesh(box, options.updatable);
  86088. return box;
  86089. };
  86090. /**
  86091. * Creates a sphere mesh
  86092. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  86093. * * 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`)
  86094. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  86095. * * 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
  86096. * * 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)
  86097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86098. * * 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
  86099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86100. * @param name defines the name of the mesh
  86101. * @param options defines the options used to create the mesh
  86102. * @param scene defines the hosting scene
  86103. * @returns the sphere mesh
  86104. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  86105. */
  86106. MeshBuilder.CreateSphere = function (name, options, scene) {
  86107. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86108. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86109. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86110. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateSphere(options);
  86111. vertexData.applyToMesh(sphere, options.updatable);
  86112. return sphere;
  86113. };
  86114. /**
  86115. * Creates a plane polygonal mesh. By default, this is a disc
  86116. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86117. * * 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
  86118. * * 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
  86119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86120. * * 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
  86121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86122. * @param name defines the name of the mesh
  86123. * @param options defines the options used to create the mesh
  86124. * @param scene defines the hosting scene
  86125. * @returns the plane polygonal mesh
  86126. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86127. */
  86128. MeshBuilder.CreateDisc = function (name, options, scene) {
  86129. if (scene === void 0) { scene = null; }
  86130. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86131. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86132. disc._originalBuilderSideOrientation = options.sideOrientation;
  86133. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDisc(options);
  86134. vertexData.applyToMesh(disc, options.updatable);
  86135. return disc;
  86136. };
  86137. /**
  86138. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86139. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86140. * * 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`)
  86141. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86142. * * 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
  86143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86144. * * 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
  86145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86146. * @param name defines the name of the mesh
  86147. * @param options defines the options used to create the mesh
  86148. * @param scene defines the hosting scene
  86149. * @returns the icosahedron mesh
  86150. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86151. */
  86152. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  86153. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86154. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86155. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86156. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateIcoSphere(options);
  86157. vertexData.applyToMesh(sphere, options.updatable);
  86158. return sphere;
  86159. };
  86160. /**
  86161. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  86162. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  86163. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  86164. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  86165. * * 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
  86166. * * 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
  86167. * * 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
  86168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86169. * * 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
  86170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86171. * * 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
  86172. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  86173. * * 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
  86174. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  86175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86176. * @param name defines the name of the mesh
  86177. * @param options defines the options used to create the mesh
  86178. * @param scene defines the hosting scene
  86179. * @returns the ribbon mesh
  86180. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  86181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86182. */
  86183. MeshBuilder.CreateRibbon = function (name, options, scene) {
  86184. if (scene === void 0) { scene = null; }
  86185. var pathArray = options.pathArray;
  86186. var closeArray = options.closeArray;
  86187. var closePath = options.closePath;
  86188. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86189. var instance = options.instance;
  86190. var updatable = options.updatable;
  86191. if (instance) { // existing ribbon instance update
  86192. // positionFunction : ribbon case
  86193. // only pathArray and sideOrientation parameters are taken into account for positions update
  86194. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  86195. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  86196. var positionFunction = function (positions) {
  86197. var minlg = pathArray[0].length;
  86198. var mesh = instance;
  86199. var i = 0;
  86200. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) ? 2 : 1;
  86201. for (var si = 1; si <= ns; ++si) {
  86202. for (var p = 0; p < pathArray.length; ++p) {
  86203. var path = pathArray[p];
  86204. var l = path.length;
  86205. minlg = (minlg < l) ? minlg : l;
  86206. for (var j = 0; j < minlg; ++j) {
  86207. var pathPoint = path[j];
  86208. positions[i] = pathPoint.x;
  86209. positions[i + 1] = pathPoint.y;
  86210. positions[i + 2] = pathPoint.z;
  86211. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86212. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86213. i += 3;
  86214. }
  86215. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  86216. var pathPoint = path[0];
  86217. positions[i] = pathPoint.x;
  86218. positions[i + 1] = pathPoint.y;
  86219. positions[i + 2] = pathPoint.z;
  86220. i += 3;
  86221. }
  86222. }
  86223. }
  86224. };
  86225. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86226. positionFunction(positions);
  86227. if (instance._boundingInfo) {
  86228. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  86229. }
  86230. else {
  86231. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  86232. }
  86233. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86234. if (options.colors) {
  86235. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86236. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  86237. var color = options.colors[c];
  86238. colors[colorIndex] = color.r;
  86239. colors[colorIndex + 1] = color.g;
  86240. colors[colorIndex + 2] = color.b;
  86241. colors[colorIndex + 3] = color.a;
  86242. }
  86243. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, colors, false, false);
  86244. }
  86245. if (options.uvs) {
  86246. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  86247. for (var i = 0; i < options.uvs.length; i++) {
  86248. uvs[i * 2] = options.uvs[i].x;
  86249. uvs[i * 2 + 1] = options.uvs[i].y;
  86250. }
  86251. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind, uvs, false, false);
  86252. }
  86253. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  86254. var indices = instance.getIndices();
  86255. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  86256. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  86257. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, params);
  86258. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  86259. var indexFirst = 0;
  86260. var indexLast = 0;
  86261. for (var p = 0; p < pathArray.length; p++) {
  86262. indexFirst = instance._creationDataStorage.idx[p] * 3;
  86263. if (p + 1 < pathArray.length) {
  86264. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  86265. }
  86266. else {
  86267. indexLast = normals.length - 3;
  86268. }
  86269. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  86270. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  86271. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  86272. normals[indexLast] = normals[indexFirst];
  86273. normals[indexLast + 1] = normals[indexFirst + 1];
  86274. normals[indexLast + 2] = normals[indexFirst + 2];
  86275. }
  86276. }
  86277. if (!(instance.areNormalsFrozen)) {
  86278. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind, normals, false, false);
  86279. }
  86280. }
  86281. return instance;
  86282. }
  86283. else { // new ribbon creation
  86284. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86285. ribbon._originalBuilderSideOrientation = sideOrientation;
  86286. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86287. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateRibbon(options);
  86288. if (closePath) {
  86289. ribbon._creationDataStorage.idx = vertexData._idx;
  86290. }
  86291. ribbon._creationDataStorage.closePath = closePath;
  86292. ribbon._creationDataStorage.closeArray = closeArray;
  86293. vertexData.applyToMesh(ribbon, updatable);
  86294. return ribbon;
  86295. }
  86296. };
  86297. /**
  86298. * Creates a cylinder or a cone mesh
  86299. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  86300. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  86301. * * 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.
  86302. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  86303. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  86304. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  86305. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  86306. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  86307. * * 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).
  86308. * * 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
  86309. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  86310. * * 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
  86311. * * 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.
  86312. * * If `enclose` is false, a ring surface is one element.
  86313. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  86314. * * 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
  86315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86316. * * 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
  86317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86318. * @param name defines the name of the mesh
  86319. * @param options defines the options used to create the mesh
  86320. * @param scene defines the hosting scene
  86321. * @returns the cylinder mesh
  86322. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  86323. */
  86324. MeshBuilder.CreateCylinder = function (name, options, scene) {
  86325. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86326. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86327. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  86328. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateCylinder(options);
  86329. vertexData.applyToMesh(cylinder, options.updatable);
  86330. return cylinder;
  86331. };
  86332. /**
  86333. * Creates a torus mesh
  86334. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  86335. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  86336. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  86337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86338. * * 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
  86339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86340. * @param name defines the name of the mesh
  86341. * @param options defines the options used to create the mesh
  86342. * @param scene defines the hosting scene
  86343. * @returns the torus mesh
  86344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  86345. */
  86346. MeshBuilder.CreateTorus = function (name, options, scene) {
  86347. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86348. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86349. torus._originalBuilderSideOrientation = options.sideOrientation;
  86350. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorus(options);
  86351. vertexData.applyToMesh(torus, options.updatable);
  86352. return torus;
  86353. };
  86354. /**
  86355. * Creates a torus knot mesh
  86356. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  86357. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  86358. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  86359. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  86360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86361. * * 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
  86362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86363. * @param name defines the name of the mesh
  86364. * @param options defines the options used to create the mesh
  86365. * @param scene defines the hosting scene
  86366. * @returns the torus knot mesh
  86367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  86368. */
  86369. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  86370. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86371. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86372. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  86373. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorusKnot(options);
  86374. vertexData.applyToMesh(torusKnot, options.updatable);
  86375. return torusKnot;
  86376. };
  86377. /**
  86378. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  86379. * * 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
  86380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  86381. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  86382. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  86383. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  86384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  86385. * * 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
  86386. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  86387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  86389. * @param name defines the name of the new line system
  86390. * @param options defines the options used to create the line system
  86391. * @param scene defines the hosting scene
  86392. * @returns a new line system mesh
  86393. */
  86394. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  86395. var instance = options.instance;
  86396. var lines = options.lines;
  86397. var colors = options.colors;
  86398. if (instance) { // lines update
  86399. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86400. var vertexColor;
  86401. var lineColors;
  86402. if (colors) {
  86403. vertexColor = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86404. }
  86405. var i = 0;
  86406. var c = 0;
  86407. for (var l = 0; l < lines.length; l++) {
  86408. var points = lines[l];
  86409. for (var p = 0; p < points.length; p++) {
  86410. positions[i] = points[p].x;
  86411. positions[i + 1] = points[p].y;
  86412. positions[i + 2] = points[p].z;
  86413. if (colors && vertexColor) {
  86414. lineColors = colors[l];
  86415. vertexColor[c] = lineColors[p].r;
  86416. vertexColor[c + 1] = lineColors[p].g;
  86417. vertexColor[c + 2] = lineColors[p].b;
  86418. vertexColor[c + 3] = lineColors[p].a;
  86419. c += 4;
  86420. }
  86421. i += 3;
  86422. }
  86423. }
  86424. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86425. if (colors && vertexColor) {
  86426. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  86427. }
  86428. return instance;
  86429. }
  86430. // line system creation
  86431. var useVertexColor = (colors) ? true : false;
  86432. var lineSystem = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  86433. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateLineSystem(options);
  86434. vertexData.applyToMesh(lineSystem, options.updatable);
  86435. return lineSystem;
  86436. };
  86437. /**
  86438. * Creates a line mesh
  86439. * 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
  86440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86441. * * The parameter `points` is an array successive Vector3
  86442. * * 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
  86443. * * The optional parameter `colors` is an array of successive Color4, one per line point
  86444. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  86445. * * When updating an instance, remember that only point positions can change, not the number of points
  86446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  86448. * @param name defines the name of the new line system
  86449. * @param options defines the options used to create the line system
  86450. * @param scene defines the hosting scene
  86451. * @returns a new line mesh
  86452. */
  86453. MeshBuilder.CreateLines = function (name, options, scene) {
  86454. if (scene === void 0) { scene = null; }
  86455. var colors = (options.colors) ? [options.colors] : null;
  86456. var lines = MeshBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  86457. return lines;
  86458. };
  86459. /**
  86460. * Creates a dashed line mesh
  86461. * * 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
  86462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86463. * * The parameter `points` is an array successive Vector3
  86464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  86465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  86466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86467. * * 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
  86468. * * When updating an instance, remember that only point positions can change, not the number of points
  86469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86470. * @param name defines the name of the mesh
  86471. * @param options defines the options used to create the mesh
  86472. * @param scene defines the hosting scene
  86473. * @returns the dashed line mesh
  86474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  86475. */
  86476. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  86477. if (scene === void 0) { scene = null; }
  86478. var points = options.points;
  86479. var instance = options.instance;
  86480. var gapSize = options.gapSize || 1;
  86481. var dashSize = options.dashSize || 3;
  86482. if (instance) { // dashed lines update
  86483. var positionFunction = function (positions) {
  86484. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  86485. var nbSeg = positions.length / 6;
  86486. var lg = 0;
  86487. var nb = 0;
  86488. var shft = 0;
  86489. var dashshft = 0;
  86490. var curshft = 0;
  86491. var p = 0;
  86492. var i = 0;
  86493. var j = 0;
  86494. for (i = 0; i < points.length - 1; i++) {
  86495. points[i + 1].subtractToRef(points[i], curvect);
  86496. lg += curvect.length();
  86497. }
  86498. shft = lg / nbSeg;
  86499. var dashSize = instance._creationDataStorage.dashSize;
  86500. var gapSize = instance._creationDataStorage.gapSize;
  86501. dashshft = dashSize * shft / (dashSize + gapSize);
  86502. for (i = 0; i < points.length - 1; i++) {
  86503. points[i + 1].subtractToRef(points[i], curvect);
  86504. nb = Math.floor(curvect.length() / shft);
  86505. curvect.normalize();
  86506. j = 0;
  86507. while (j < nb && p < positions.length) {
  86508. curshft = shft * j;
  86509. positions[p] = points[i].x + curshft * curvect.x;
  86510. positions[p + 1] = points[i].y + curshft * curvect.y;
  86511. positions[p + 2] = points[i].z + curshft * curvect.z;
  86512. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  86513. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  86514. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  86515. p += 6;
  86516. j++;
  86517. }
  86518. }
  86519. while (p < positions.length) {
  86520. positions[p] = points[i].x;
  86521. positions[p + 1] = points[i].y;
  86522. positions[p + 2] = points[i].z;
  86523. p += 3;
  86524. }
  86525. };
  86526. instance.updateMeshPositions(positionFunction, false);
  86527. return instance;
  86528. }
  86529. // dashed lines creation
  86530. var dashedLines = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene);
  86531. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDashedLines(options);
  86532. vertexData.applyToMesh(dashedLines, options.updatable);
  86533. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86534. dashedLines._creationDataStorage.dashSize = dashSize;
  86535. dashedLines._creationDataStorage.gapSize = gapSize;
  86536. return dashedLines;
  86537. };
  86538. /**
  86539. * 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.
  86540. * * 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.
  86541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86542. * * 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.
  86543. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  86544. * * 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
  86545. * * 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
  86546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  86547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86548. * * 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
  86549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  86550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86551. * @param name defines the name of the mesh
  86552. * @param options defines the options used to create the mesh
  86553. * @param scene defines the hosting scene
  86554. * @returns the extruded shape mesh
  86555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86557. */
  86558. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  86559. if (scene === void 0) { scene = null; }
  86560. var path = options.path;
  86561. var shape = options.shape;
  86562. var scale = options.scale || 1;
  86563. var rotation = options.rotation || 0;
  86564. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86565. var updatable = options.updatable;
  86566. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86567. var instance = options.instance || null;
  86568. var invertUV = options.invertUV || false;
  86569. return MeshBuilder._ExtrudeShapeGeneric(name, shape, path, scale, rotation, null, null, false, false, cap, false, scene, updatable ? true : false, sideOrientation, instance, invertUV, options.frontUVs || null, options.backUVs || null);
  86570. };
  86571. /**
  86572. * Creates an custom extruded shape mesh.
  86573. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  86574. * * 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.
  86575. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86576. * * 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
  86577. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  86578. * * 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
  86579. * * It must returns a float value that will be the scale value applied to the shape on each path point
  86580. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86581. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  86582. * * 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
  86583. * * 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
  86584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  86585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86586. * * 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
  86587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86589. * @param name defines the name of the mesh
  86590. * @param options defines the options used to create the mesh
  86591. * @param scene defines the hosting scene
  86592. * @returns the custom extruded shape mesh
  86593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  86594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86596. */
  86597. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  86598. var path = options.path;
  86599. var shape = options.shape;
  86600. var scaleFunction = options.scaleFunction || (function () { return 1; });
  86601. var rotationFunction = options.rotationFunction || (function () { return 0; });
  86602. var ribbonCloseArray = options.ribbonCloseArray || false;
  86603. var ribbonClosePath = options.ribbonClosePath || false;
  86604. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86605. var updatable = options.updatable;
  86606. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86607. var instance = options.instance;
  86608. var invertUV = options.invertUV || false;
  86609. return MeshBuilder._ExtrudeShapeGeneric(name, shape, path, null, null, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, true, scene, updatable ? true : false, sideOrientation, instance || null, invertUV, options.frontUVs || null, options.backUVs || null);
  86610. };
  86611. /**
  86612. * Creates lathe mesh.
  86613. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  86614. * * 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
  86615. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  86616. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  86617. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  86618. * * 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
  86619. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  86620. * * 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
  86621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86622. * * 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
  86623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86625. * @param name defines the name of the mesh
  86626. * @param options defines the options used to create the mesh
  86627. * @param scene defines the hosting scene
  86628. * @returns the lathe mesh
  86629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  86630. */
  86631. MeshBuilder.CreateLathe = function (name, options, scene) {
  86632. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  86633. var closed = (options.closed === undefined) ? true : options.closed;
  86634. var shape = options.shape;
  86635. var radius = options.radius || 1;
  86636. var tessellation = options.tessellation || 64;
  86637. var clip = options.clip || 0;
  86638. var updatable = options.updatable;
  86639. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86640. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86641. var pi2 = Math.PI * 2;
  86642. var paths = new Array();
  86643. var invertUV = options.invertUV || false;
  86644. var i = 0;
  86645. var p = 0;
  86646. var step = pi2 / tessellation * arc;
  86647. var rotated;
  86648. var path = new Array();
  86649. for (i = 0; i <= tessellation - clip; i++) {
  86650. var path = [];
  86651. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86652. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[0].y, 0));
  86653. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  86654. }
  86655. for (p = 0; p < shape.length; p++) {
  86656. rotated = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  86657. path.push(rotated);
  86658. }
  86659. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86660. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](Math.cos(i * step) * shape[shape.length - 1].x * radius, shape[shape.length - 1].y, Math.sin(i * step) * shape[shape.length - 1].x * radius));
  86661. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[shape.length - 1].y, 0));
  86662. }
  86663. paths.push(path);
  86664. }
  86665. // lathe ribbon
  86666. var lathe = MeshBuilder.CreateRibbon(name, { pathArray: paths, closeArray: closed, sideOrientation: sideOrientation, updatable: updatable, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  86667. return lathe;
  86668. };
  86669. /**
  86670. * Creates a plane mesh
  86671. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  86672. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  86673. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  86674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86675. * * 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
  86676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86677. * @param name defines the name of the mesh
  86678. * @param options defines the options used to create the mesh
  86679. * @param scene defines the hosting scene
  86680. * @returns the plane mesh
  86681. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  86682. */
  86683. MeshBuilder.CreatePlane = function (name, options, scene) {
  86684. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86685. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86686. plane._originalBuilderSideOrientation = options.sideOrientation;
  86687. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePlane(options);
  86688. vertexData.applyToMesh(plane, options.updatable);
  86689. if (options.sourcePlane) {
  86690. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  86691. plane.setDirection(options.sourcePlane.normal.scale(-1));
  86692. }
  86693. return plane;
  86694. };
  86695. /**
  86696. * Creates a ground mesh
  86697. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  86698. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  86699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86700. * @param name defines the name of the mesh
  86701. * @param options defines the options used to create the mesh
  86702. * @param scene defines the hosting scene
  86703. * @returns the ground mesh
  86704. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  86705. */
  86706. MeshBuilder.CreateGround = function (name, options, scene) {
  86707. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  86708. ground._setReady(false);
  86709. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  86710. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  86711. ground._width = options.width || 1;
  86712. ground._height = options.height || 1;
  86713. ground._maxX = ground._width / 2;
  86714. ground._maxZ = ground._height / 2;
  86715. ground._minX = -ground._maxX;
  86716. ground._minZ = -ground._maxZ;
  86717. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGround(options);
  86718. vertexData.applyToMesh(ground, options.updatable);
  86719. ground._setReady(true);
  86720. return ground;
  86721. };
  86722. /**
  86723. * Creates a tiled ground mesh
  86724. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  86725. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  86726. * * 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
  86727. * * 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
  86728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86729. * @param name defines the name of the mesh
  86730. * @param options defines the options used to create the mesh
  86731. * @param scene defines the hosting scene
  86732. * @returns the tiled ground mesh
  86733. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  86734. */
  86735. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  86736. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86737. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTiledGround(options);
  86738. vertexData.applyToMesh(tiledGround, options.updatable);
  86739. return tiledGround;
  86740. };
  86741. /**
  86742. * Creates a ground mesh from a height map
  86743. * * The parameter `url` sets the URL of the height map image resource.
  86744. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  86745. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  86746. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  86747. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  86748. * * 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.
  86749. * * 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).
  86750. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86752. * @param name defines the name of the mesh
  86753. * @param url defines the url to the height map
  86754. * @param options defines the options used to create the mesh
  86755. * @param scene defines the hosting scene
  86756. * @returns the ground mesh
  86757. * @see https://doc.babylonjs.com/babylon101/height_map
  86758. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  86759. */
  86760. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  86761. var width = options.width || 10.0;
  86762. var height = options.height || 10.0;
  86763. var subdivisions = options.subdivisions || 1 | 0;
  86764. var minHeight = options.minHeight || 0.0;
  86765. var maxHeight = options.maxHeight || 1.0;
  86766. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.59, 0.11);
  86767. var alphaFilter = options.alphaFilter || 0.0;
  86768. var updatable = options.updatable;
  86769. var onReady = options.onReady;
  86770. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  86771. ground._subdivisionsX = subdivisions;
  86772. ground._subdivisionsY = subdivisions;
  86773. ground._width = width;
  86774. ground._height = height;
  86775. ground._maxX = ground._width / 2.0;
  86776. ground._maxZ = ground._height / 2.0;
  86777. ground._minX = -ground._maxX;
  86778. ground._minZ = -ground._maxZ;
  86779. ground._setReady(false);
  86780. var onload = function (img) {
  86781. // Getting height map data
  86782. var canvas = document.createElement("canvas");
  86783. var context = canvas.getContext("2d");
  86784. if (!context) {
  86785. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  86786. }
  86787. if (scene.isDisposed) {
  86788. return;
  86789. }
  86790. var bufferWidth = img.width;
  86791. var bufferHeight = img.height;
  86792. canvas.width = bufferWidth;
  86793. canvas.height = bufferHeight;
  86794. context.drawImage(img, 0, 0);
  86795. // Create VertexData from map data
  86796. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  86797. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  86798. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGroundFromHeightMap({
  86799. width: width, height: height,
  86800. subdivisions: subdivisions,
  86801. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  86802. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  86803. alphaFilter: alphaFilter
  86804. });
  86805. vertexData.applyToMesh(ground, updatable);
  86806. //execute ready callback, if set
  86807. if (onReady) {
  86808. onReady(ground);
  86809. }
  86810. ground._setReady(true);
  86811. };
  86812. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  86813. return ground;
  86814. };
  86815. /**
  86816. * Creates a polygon mesh
  86817. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  86818. * * 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
  86819. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86821. * * 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)
  86822. * * Remember you can only change the shape positions, not their number when updating a polygon
  86823. * @param name defines the name of the mesh
  86824. * @param options defines the options used to create the mesh
  86825. * @param scene defines the hosting scene
  86826. * @returns the polygon mesh
  86827. */
  86828. MeshBuilder.CreatePolygon = function (name, options, scene) {
  86829. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86830. var shape = options.shape;
  86831. var holes = options.holes || [];
  86832. var depth = options.depth || 0;
  86833. var contours = [];
  86834. var hole = [];
  86835. for (var i = 0; i < shape.length; i++) {
  86836. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](shape[i].x, shape[i].z);
  86837. }
  86838. var epsilon = 0.00000001;
  86839. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  86840. contours.pop();
  86841. }
  86842. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_8__["PolygonMeshBuilder"](name, contours, scene);
  86843. for (var hNb = 0; hNb < holes.length; hNb++) {
  86844. hole = [];
  86845. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  86846. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  86847. }
  86848. polygonTriangulation.addHole(hole);
  86849. }
  86850. var polygon = polygonTriangulation.build(options.updatable, depth);
  86851. polygon._originalBuilderSideOrientation = options.sideOrientation;
  86852. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  86853. vertexData.applyToMesh(polygon, options.updatable);
  86854. return polygon;
  86855. };
  86856. /**
  86857. * Creates an extruded polygon mesh, with depth in the Y direction.
  86858. * * 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)
  86859. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  86860. * @param name defines the name of the mesh
  86861. * @param options defines the options used to create the mesh
  86862. * @param scene defines the hosting scene
  86863. * @returns the polygon mesh
  86864. */
  86865. MeshBuilder.ExtrudePolygon = function (name, options, scene) {
  86866. return MeshBuilder.CreatePolygon(name, options, scene);
  86867. };
  86868. /**
  86869. * Creates a tube mesh.
  86870. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  86871. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  86872. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  86873. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  86874. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  86875. * * 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)
  86876. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  86877. * * 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
  86878. * * 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
  86879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86880. * * 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
  86881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86883. * @param name defines the name of the mesh
  86884. * @param options defines the options used to create the mesh
  86885. * @param scene defines the hosting scene
  86886. * @returns the tube mesh
  86887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86888. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  86889. */
  86890. MeshBuilder.CreateTube = function (name, options, scene) {
  86891. var path = options.path;
  86892. var instance = options.instance;
  86893. var radius = 1.0;
  86894. if (options.radius !== undefined) {
  86895. radius = options.radius;
  86896. }
  86897. else if (instance) {
  86898. radius = instance._creationDataStorage.radius;
  86899. }
  86900. var tessellation = options.tessellation || 64 | 0;
  86901. var radiusFunction = options.radiusFunction || null;
  86902. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86903. var invertUV = options.invertUV || false;
  86904. var updatable = options.updatable;
  86905. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86906. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  86907. // tube geometry
  86908. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  86909. var tangents = path3D.getTangents();
  86910. var normals = path3D.getNormals();
  86911. var distances = path3D.getDistances();
  86912. var pi2 = Math.PI * 2;
  86913. var step = pi2 / tessellation * arc;
  86914. var returnRadius = function () { return radius; };
  86915. var radiusFunctionFinal = radiusFunction || returnRadius;
  86916. var circlePath;
  86917. var rad;
  86918. var normal;
  86919. var rotated;
  86920. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  86921. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  86922. for (var i = 0; i < path.length; i++) {
  86923. rad = radiusFunctionFinal(i, distances[i]); // current radius
  86924. circlePath = Array(); // current circle array
  86925. normal = normals[i]; // current normal
  86926. for (var t = 0; t < tessellation; t++) {
  86927. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  86928. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  86929. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  86930. rotated.scaleInPlace(rad).addInPlace(path[i]);
  86931. circlePath[t] = rotated;
  86932. }
  86933. circlePaths[index] = circlePath;
  86934. index++;
  86935. }
  86936. // cap
  86937. var capPath = function (nbPoints, pathIndex) {
  86938. var pointCap = Array();
  86939. for (var i = 0; i < nbPoints; i++) {
  86940. pointCap.push(path[pathIndex]);
  86941. }
  86942. return pointCap;
  86943. };
  86944. switch (cap) {
  86945. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  86946. break;
  86947. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  86948. circlePaths[0] = capPath(tessellation, 0);
  86949. circlePaths[1] = circlePaths[2].slice(0);
  86950. break;
  86951. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  86952. circlePaths[index] = circlePaths[index - 1].slice(0);
  86953. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  86954. break;
  86955. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  86956. circlePaths[0] = capPath(tessellation, 0);
  86957. circlePaths[1] = circlePaths[2].slice(0);
  86958. circlePaths[index] = circlePaths[index - 1].slice(0);
  86959. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  86960. break;
  86961. default:
  86962. break;
  86963. }
  86964. return circlePaths;
  86965. };
  86966. var path3D;
  86967. var pathArray;
  86968. if (instance) { // tube update
  86969. var storage = instance._creationDataStorage;
  86970. var arc = options.arc || storage.arc;
  86971. path3D = storage.path3D.update(path);
  86972. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  86973. instance = MeshBuilder.CreateRibbon("", { pathArray: pathArray, instance: instance });
  86974. // Update mode, no need to recreate the storage.
  86975. storage.path3D = path3D;
  86976. storage.pathArray = pathArray;
  86977. storage.arc = arc;
  86978. storage.radius = radius;
  86979. return instance;
  86980. }
  86981. // tube creation
  86982. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](path);
  86983. var newPathArray = new Array();
  86984. cap = (cap < 0 || cap > 3) ? 0 : cap;
  86985. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  86986. var tube = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closePath: true, closeArray: false, updatable: updatable, sideOrientation: sideOrientation, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  86987. tube._creationDataStorage.pathArray = pathArray;
  86988. tube._creationDataStorage.path3D = path3D;
  86989. tube._creationDataStorage.tessellation = tessellation;
  86990. tube._creationDataStorage.cap = cap;
  86991. tube._creationDataStorage.arc = options.arc;
  86992. tube._creationDataStorage.radius = radius;
  86993. return tube;
  86994. };
  86995. /**
  86996. * Creates a polyhedron mesh
  86997. * * 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
  86998. * * The parameter `size` (positive float, default 1) sets the polygon size
  86999. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87000. * * 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`
  87001. * * 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
  87002. * * 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)`)
  87003. * * 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
  87004. * * 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
  87005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87006. * * 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
  87007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87008. * @param name defines the name of the mesh
  87009. * @param options defines the options used to create the mesh
  87010. * @param scene defines the hosting scene
  87011. * @returns the polyhedron mesh
  87012. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  87013. */
  87014. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  87015. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  87016. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87017. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  87018. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolyhedron(options);
  87019. vertexData.applyToMesh(polyhedron, options.updatable);
  87020. return polyhedron;
  87021. };
  87022. /**
  87023. * Creates a decal mesh.
  87024. * 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
  87025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  87026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  87027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  87028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  87029. * @param name defines the name of the mesh
  87030. * @param sourceMesh defines the mesh where the decal must be applied
  87031. * @param options defines the options used to create the mesh
  87032. * @param scene defines the hosting scene
  87033. * @returns the decal mesh
  87034. * @see https://doc.babylonjs.com/how_to/decals
  87035. */
  87036. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  87037. var indices = sourceMesh.getIndices();
  87038. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  87039. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  87040. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87041. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  87042. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].One();
  87043. var angle = options.angle || 0;
  87044. // Getting correct rotation
  87045. if (!normal) {
  87046. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1);
  87047. var camera = sourceMesh.getScene().activeCamera;
  87048. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  87049. normal = camera.globalPosition.subtract(cameraWorldTarget);
  87050. }
  87051. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  87052. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  87053. var pitch = Math.atan2(normal.y, len);
  87054. // Matrix
  87055. var decalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Translation(position.x, position.y, position.z));
  87056. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Invert(decalWorldMatrix);
  87057. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  87058. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  87059. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"]();
  87060. vertexData.indices = [];
  87061. vertexData.positions = [];
  87062. vertexData.normals = [];
  87063. vertexData.uvs = [];
  87064. var currentVertexDataIndex = 0;
  87065. var extractDecalVector3 = function (indexId) {
  87066. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["PositionNormalVertex"]();
  87067. if (!indices || !positions || !normals) {
  87068. return result;
  87069. }
  87070. var vertexId = indices[indexId];
  87071. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  87072. // Send vector to decal local world
  87073. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  87074. // Get normal
  87075. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  87076. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(result.normal, transformMatrix);
  87077. return result;
  87078. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  87079. var clip = function (vertices, axis) {
  87080. if (vertices.length === 0) {
  87081. return vertices;
  87082. }
  87083. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(size, axis));
  87084. var clipVertices = function (v0, v1) {
  87085. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  87086. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["PositionNormalVertex"](_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  87087. };
  87088. var result = new Array();
  87089. for (var index = 0; index < vertices.length; index += 3) {
  87090. var v1Out;
  87091. var v2Out;
  87092. var v3Out;
  87093. var total = 0;
  87094. var nV1 = null;
  87095. var nV2 = null;
  87096. var nV3 = null;
  87097. var nV4 = null;
  87098. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  87099. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  87100. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  87101. v1Out = d1 > 0;
  87102. v2Out = d2 > 0;
  87103. v3Out = d3 > 0;
  87104. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  87105. switch (total) {
  87106. case 0:
  87107. result.push(vertices[index]);
  87108. result.push(vertices[index + 1]);
  87109. result.push(vertices[index + 2]);
  87110. break;
  87111. case 1:
  87112. if (v1Out) {
  87113. nV1 = vertices[index + 1];
  87114. nV2 = vertices[index + 2];
  87115. nV3 = clipVertices(vertices[index], nV1);
  87116. nV4 = clipVertices(vertices[index], nV2);
  87117. }
  87118. if (v2Out) {
  87119. nV1 = vertices[index];
  87120. nV2 = vertices[index + 2];
  87121. nV3 = clipVertices(vertices[index + 1], nV1);
  87122. nV4 = clipVertices(vertices[index + 1], nV2);
  87123. result.push(nV3);
  87124. result.push(nV2.clone());
  87125. result.push(nV1.clone());
  87126. result.push(nV2.clone());
  87127. result.push(nV3.clone());
  87128. result.push(nV4);
  87129. break;
  87130. }
  87131. if (v3Out) {
  87132. nV1 = vertices[index];
  87133. nV2 = vertices[index + 1];
  87134. nV3 = clipVertices(vertices[index + 2], nV1);
  87135. nV4 = clipVertices(vertices[index + 2], nV2);
  87136. }
  87137. if (nV1 && nV2 && nV3 && nV4) {
  87138. result.push(nV1.clone());
  87139. result.push(nV2.clone());
  87140. result.push(nV3);
  87141. result.push(nV4);
  87142. result.push(nV3.clone());
  87143. result.push(nV2.clone());
  87144. }
  87145. break;
  87146. case 2:
  87147. if (!v1Out) {
  87148. nV1 = vertices[index].clone();
  87149. nV2 = clipVertices(nV1, vertices[index + 1]);
  87150. nV3 = clipVertices(nV1, vertices[index + 2]);
  87151. result.push(nV1);
  87152. result.push(nV2);
  87153. result.push(nV3);
  87154. }
  87155. if (!v2Out) {
  87156. nV1 = vertices[index + 1].clone();
  87157. nV2 = clipVertices(nV1, vertices[index + 2]);
  87158. nV3 = clipVertices(nV1, vertices[index]);
  87159. result.push(nV1);
  87160. result.push(nV2);
  87161. result.push(nV3);
  87162. }
  87163. if (!v3Out) {
  87164. nV1 = vertices[index + 2].clone();
  87165. nV2 = clipVertices(nV1, vertices[index]);
  87166. nV3 = clipVertices(nV1, vertices[index + 1]);
  87167. result.push(nV1);
  87168. result.push(nV2);
  87169. result.push(nV3);
  87170. }
  87171. break;
  87172. case 3:
  87173. break;
  87174. }
  87175. }
  87176. return result;
  87177. };
  87178. for (var index = 0; index < indices.length; index += 3) {
  87179. var faceVertices = new Array();
  87180. faceVertices.push(extractDecalVector3(index));
  87181. faceVertices.push(extractDecalVector3(index + 1));
  87182. faceVertices.push(extractDecalVector3(index + 2));
  87183. // Clip
  87184. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0));
  87185. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1, 0, 0));
  87186. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0));
  87187. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, -1, 0));
  87188. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1));
  87189. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1));
  87190. if (faceVertices.length === 0) {
  87191. continue;
  87192. }
  87193. // Add UVs and get back to world
  87194. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  87195. var vertex = faceVertices[vIndex];
  87196. //TODO check for Int32Array | Uint32Array | Uint16Array
  87197. vertexData.indices.push(currentVertexDataIndex);
  87198. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  87199. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  87200. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  87201. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  87202. currentVertexDataIndex++;
  87203. }
  87204. }
  87205. // Return mesh
  87206. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, sourceMesh.getScene());
  87207. vertexData.applyToMesh(decal);
  87208. decal.position = position.clone();
  87209. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](pitch, yaw, angle);
  87210. return decal;
  87211. };
  87212. // Privates
  87213. MeshBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  87214. // extrusion geometry
  87215. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  87216. var tangents = path3D.getTangents();
  87217. var normals = path3D.getNormals();
  87218. var binormals = path3D.getBinormals();
  87219. var distances = path3D.getDistances();
  87220. var angle = 0;
  87221. var returnScale = function () { return scale !== null ? scale : 1; };
  87222. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  87223. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  87224. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  87225. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  87226. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  87227. for (var i = 0; i < curve.length; i++) {
  87228. var shapePath = new Array();
  87229. var angleStep = rotate(i, distances[i]);
  87230. var scaleRatio = scl(i, distances[i]);
  87231. for (var p = 0; p < shape.length; p++) {
  87232. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  87233. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  87234. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87235. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  87236. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  87237. shapePath[p] = rotated;
  87238. }
  87239. shapePaths[index] = shapePath;
  87240. angle += angleStep;
  87241. index++;
  87242. }
  87243. // cap
  87244. var capPath = function (shapePath) {
  87245. var pointCap = Array();
  87246. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87247. var i;
  87248. for (i = 0; i < shapePath.length; i++) {
  87249. barycenter.addInPlace(shapePath[i]);
  87250. }
  87251. barycenter.scaleInPlace(1.0 / shapePath.length);
  87252. for (i = 0; i < shapePath.length; i++) {
  87253. pointCap.push(barycenter);
  87254. }
  87255. return pointCap;
  87256. };
  87257. switch (cap) {
  87258. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  87259. break;
  87260. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  87261. shapePaths[0] = capPath(shapePaths[2]);
  87262. shapePaths[1] = shapePaths[2];
  87263. break;
  87264. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  87265. shapePaths[index] = shapePaths[index - 1];
  87266. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87267. break;
  87268. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  87269. shapePaths[0] = capPath(shapePaths[2]);
  87270. shapePaths[1] = shapePaths[2];
  87271. shapePaths[index] = shapePaths[index - 1];
  87272. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87273. break;
  87274. default:
  87275. break;
  87276. }
  87277. return shapePaths;
  87278. };
  87279. var path3D;
  87280. var pathArray;
  87281. if (instance) { // instance update
  87282. var storage = instance._creationDataStorage;
  87283. path3D = storage.path3D.update(curve);
  87284. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  87285. instance = _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  87286. return instance;
  87287. }
  87288. // extruded shape creation
  87289. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](curve);
  87290. var newShapePaths = new Array();
  87291. cap = (cap < 0 || cap > 3) ? 0 : cap;
  87292. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  87293. var extrudedGeneric = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closeArray: rbCA, closePath: rbCP, updatable: updtbl, sideOrientation: side, invertUV: invertUV, frontUVs: frontUVs || undefined, backUVs: backUVs || undefined }, scene);
  87294. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  87295. extrudedGeneric._creationDataStorage.path3D = path3D;
  87296. extrudedGeneric._creationDataStorage.cap = cap;
  87297. return extrudedGeneric;
  87298. };
  87299. return MeshBuilder;
  87300. }());
  87301. /***/ }),
  87302. /***/ "./Meshes/meshSimplification.ts":
  87303. /*!**************************************!*\
  87304. !*** ./Meshes/meshSimplification.ts ***!
  87305. \**************************************/
  87306. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  87307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87308. "use strict";
  87309. __webpack_require__.r(__webpack_exports__);
  87310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  87311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  87312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  87313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87314. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87315. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  87316. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87317. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87318. /**
  87319. * Class used to specify simplification options
  87320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87321. */
  87322. var SimplificationSettings = /** @class */ (function () {
  87323. /**
  87324. * Creates a SimplificationSettings
  87325. * @param quality expected quality
  87326. * @param distance distance when this optimized version should be used
  87327. * @param optimizeMesh already optimized mesh
  87328. */
  87329. function SimplificationSettings(
  87330. /** expected quality */
  87331. quality,
  87332. /** distance when this optimized version should be used */
  87333. distance,
  87334. /** already optimized mesh */
  87335. optimizeMesh) {
  87336. this.quality = quality;
  87337. this.distance = distance;
  87338. this.optimizeMesh = optimizeMesh;
  87339. }
  87340. return SimplificationSettings;
  87341. }());
  87342. /**
  87343. * Queue used to order the simplification tasks
  87344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87345. */
  87346. var SimplificationQueue = /** @class */ (function () {
  87347. /**
  87348. * Creates a new queue
  87349. */
  87350. function SimplificationQueue() {
  87351. this.running = false;
  87352. this._simplificationArray = [];
  87353. }
  87354. /**
  87355. * Adds a new simplification task
  87356. * @param task defines a task to add
  87357. */
  87358. SimplificationQueue.prototype.addTask = function (task) {
  87359. this._simplificationArray.push(task);
  87360. };
  87361. /**
  87362. * Execute next task
  87363. */
  87364. SimplificationQueue.prototype.executeNext = function () {
  87365. var task = this._simplificationArray.pop();
  87366. if (task) {
  87367. this.running = true;
  87368. this.runSimplification(task);
  87369. }
  87370. else {
  87371. this.running = false;
  87372. }
  87373. };
  87374. /**
  87375. * Execute a simplification task
  87376. * @param task defines the task to run
  87377. */
  87378. SimplificationQueue.prototype.runSimplification = function (task) {
  87379. var _this = this;
  87380. if (task.parallelProcessing) {
  87381. //parallel simplifier
  87382. task.settings.forEach(function (setting) {
  87383. var simplifier = _this.getSimplifier(task);
  87384. simplifier.simplify(setting, function (newMesh) {
  87385. task.mesh.addLODLevel(setting.distance, newMesh);
  87386. newMesh.isVisible = true;
  87387. //check if it is the last
  87388. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  87389. //all done, run the success callback.
  87390. task.successCallback();
  87391. }
  87392. _this.executeNext();
  87393. });
  87394. });
  87395. }
  87396. else {
  87397. //single simplifier.
  87398. var simplifier = this.getSimplifier(task);
  87399. var runDecimation = function (setting, callback) {
  87400. simplifier.simplify(setting, function (newMesh) {
  87401. task.mesh.addLODLevel(setting.distance, newMesh);
  87402. newMesh.isVisible = true;
  87403. //run the next quality level
  87404. callback();
  87405. });
  87406. };
  87407. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  87408. runDecimation(task.settings[loop.index], function () {
  87409. loop.executeNext();
  87410. });
  87411. }, function () {
  87412. //execution ended, run the success callback.
  87413. if (task.successCallback) {
  87414. task.successCallback();
  87415. }
  87416. _this.executeNext();
  87417. });
  87418. }
  87419. };
  87420. SimplificationQueue.prototype.getSimplifier = function (task) {
  87421. switch (task.simplificationType) {
  87422. case SimplificationType.QUADRATIC:
  87423. default:
  87424. return new QuadraticErrorSimplification(task.mesh);
  87425. }
  87426. };
  87427. return SimplificationQueue;
  87428. }());
  87429. /**
  87430. * The implemented types of simplification
  87431. * At the moment only Quadratic Error Decimation is implemented
  87432. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87433. */
  87434. var SimplificationType;
  87435. (function (SimplificationType) {
  87436. /** Quadratic error decimation */
  87437. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  87438. })(SimplificationType || (SimplificationType = {}));
  87439. var DecimationTriangle = /** @class */ (function () {
  87440. function DecimationTriangle(vertices) {
  87441. this.vertices = vertices;
  87442. this.error = new Array(4);
  87443. this.deleted = false;
  87444. this.isDirty = false;
  87445. this.deletePending = false;
  87446. this.borderFactor = 0;
  87447. }
  87448. return DecimationTriangle;
  87449. }());
  87450. var DecimationVertex = /** @class */ (function () {
  87451. function DecimationVertex(position, id) {
  87452. this.position = position;
  87453. this.id = id;
  87454. this.isBorder = true;
  87455. this.q = new QuadraticMatrix();
  87456. this.triangleCount = 0;
  87457. this.triangleStart = 0;
  87458. this.originalOffsets = [];
  87459. }
  87460. DecimationVertex.prototype.updatePosition = function (newPosition) {
  87461. this.position.copyFrom(newPosition);
  87462. };
  87463. return DecimationVertex;
  87464. }());
  87465. var QuadraticMatrix = /** @class */ (function () {
  87466. function QuadraticMatrix(data) {
  87467. this.data = new Array(10);
  87468. for (var i = 0; i < 10; ++i) {
  87469. if (data && data[i]) {
  87470. this.data[i] = data[i];
  87471. }
  87472. else {
  87473. this.data[i] = 0;
  87474. }
  87475. }
  87476. }
  87477. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  87478. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  87479. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  87480. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  87481. return det;
  87482. };
  87483. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  87484. for (var i = 0; i < 10; ++i) {
  87485. this.data[i] += matrix.data[i];
  87486. }
  87487. };
  87488. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  87489. for (var i = 0; i < 10; ++i) {
  87490. this.data[i] += data[i];
  87491. }
  87492. };
  87493. QuadraticMatrix.prototype.add = function (matrix) {
  87494. var m = new QuadraticMatrix();
  87495. for (var i = 0; i < 10; ++i) {
  87496. m.data[i] = this.data[i] + matrix.data[i];
  87497. }
  87498. return m;
  87499. };
  87500. QuadraticMatrix.FromData = function (a, b, c, d) {
  87501. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  87502. };
  87503. //returning an array to avoid garbage collection
  87504. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  87505. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  87506. };
  87507. return QuadraticMatrix;
  87508. }());
  87509. var Reference = /** @class */ (function () {
  87510. function Reference(vertexId, triangleId) {
  87511. this.vertexId = vertexId;
  87512. this.triangleId = triangleId;
  87513. }
  87514. return Reference;
  87515. }());
  87516. /**
  87517. * An implementation of the Quadratic Error simplification algorithm.
  87518. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  87519. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  87520. * @author RaananW
  87521. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87522. */
  87523. var QuadraticErrorSimplification = /** @class */ (function () {
  87524. function QuadraticErrorSimplification(_mesh) {
  87525. this._mesh = _mesh;
  87526. this.syncIterations = 5000;
  87527. this.aggressiveness = 7;
  87528. this.decimationIterations = 100;
  87529. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  87530. }
  87531. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  87532. var _this = this;
  87533. this.initDecimatedMesh();
  87534. //iterating through the submeshes array, one after the other.
  87535. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  87536. _this.initWithMesh(loop.index, function () {
  87537. _this.runDecimation(settings, loop.index, function () {
  87538. loop.executeNext();
  87539. });
  87540. }, settings.optimizeMesh);
  87541. }, function () {
  87542. setTimeout(function () {
  87543. successCallback(_this._reconstructedMesh);
  87544. }, 0);
  87545. });
  87546. };
  87547. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  87548. var _this = this;
  87549. var targetCount = ~~(this.triangles.length * settings.quality);
  87550. var deletedTriangles = 0;
  87551. var triangleCount = this.triangles.length;
  87552. var iterationFunction = function (iteration, callback) {
  87553. setTimeout(function () {
  87554. if (iteration % 5 === 0) {
  87555. _this.updateMesh(iteration === 0);
  87556. }
  87557. for (var i = 0; i < _this.triangles.length; ++i) {
  87558. _this.triangles[i].isDirty = false;
  87559. }
  87560. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  87561. var trianglesIterator = function (i) {
  87562. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  87563. var t = _this.triangles[tIdx];
  87564. if (!t) {
  87565. return;
  87566. }
  87567. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  87568. return;
  87569. }
  87570. for (var j = 0; j < 3; ++j) {
  87571. if (t.error[j] < threshold) {
  87572. var deleted0 = [];
  87573. var deleted1 = [];
  87574. var v0 = t.vertices[j];
  87575. var v1 = t.vertices[(j + 1) % 3];
  87576. if (v0.isBorder || v1.isBorder) {
  87577. continue;
  87578. }
  87579. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87580. // var n = Vector3.Zero();
  87581. // var uv = Vector2.Zero();
  87582. // var color = new Color4(0, 0, 0, 1);
  87583. _this.calculateError(v0, v1, p);
  87584. var delTr = new Array();
  87585. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  87586. continue;
  87587. }
  87588. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  87589. continue;
  87590. }
  87591. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  87592. continue;
  87593. }
  87594. var uniqueArray = new Array();
  87595. delTr.forEach(function (deletedT) {
  87596. if (uniqueArray.indexOf(deletedT) === -1) {
  87597. deletedT.deletePending = true;
  87598. uniqueArray.push(deletedT);
  87599. }
  87600. });
  87601. if (uniqueArray.length % 2 !== 0) {
  87602. continue;
  87603. }
  87604. v0.q = v1.q.add(v0.q);
  87605. v0.updatePosition(p);
  87606. var tStart = _this.references.length;
  87607. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  87608. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  87609. var tCount = _this.references.length - tStart;
  87610. if (tCount <= v0.triangleCount) {
  87611. if (tCount) {
  87612. for (var c = 0; c < tCount; c++) {
  87613. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  87614. }
  87615. }
  87616. }
  87617. else {
  87618. v0.triangleStart = tStart;
  87619. }
  87620. v0.triangleCount = tCount;
  87621. break;
  87622. }
  87623. }
  87624. };
  87625. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  87626. }, 0);
  87627. };
  87628. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  87629. if (triangleCount - deletedTriangles <= targetCount) {
  87630. loop.breakLoop();
  87631. }
  87632. else {
  87633. iterationFunction(loop.index, function () {
  87634. loop.executeNext();
  87635. });
  87636. }
  87637. }, function () {
  87638. setTimeout(function () {
  87639. //reconstruct this part of the mesh
  87640. _this.reconstructMesh(submeshIndex);
  87641. successCallback();
  87642. }, 0);
  87643. });
  87644. };
  87645. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  87646. var _this = this;
  87647. this.vertices = [];
  87648. this.triangles = [];
  87649. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  87650. var indices = this._mesh.getIndices();
  87651. var submesh = this._mesh.subMeshes[submeshIndex];
  87652. var findInVertices = function (positionToSearch) {
  87653. if (optimizeMesh) {
  87654. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  87655. if (_this.vertices[ii].position.equals(positionToSearch)) {
  87656. return _this.vertices[ii];
  87657. }
  87658. }
  87659. }
  87660. return null;
  87661. };
  87662. var vertexReferences = [];
  87663. var vertexInit = function (i) {
  87664. if (!positionData) {
  87665. return;
  87666. }
  87667. var offset = i + submesh.verticesStart;
  87668. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  87669. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  87670. vertex.originalOffsets.push(offset);
  87671. if (vertex.id === _this.vertices.length) {
  87672. _this.vertices.push(vertex);
  87673. }
  87674. vertexReferences.push(vertex.id);
  87675. };
  87676. //var totalVertices = mesh.getTotalVertices();
  87677. var totalVertices = submesh.verticesCount;
  87678. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  87679. var indicesInit = function (i) {
  87680. if (!indices) {
  87681. return;
  87682. }
  87683. var offset = (submesh.indexStart / 3) + i;
  87684. var pos = (offset * 3);
  87685. var i0 = indices[pos + 0];
  87686. var i1 = indices[pos + 1];
  87687. var i2 = indices[pos + 2];
  87688. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  87689. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  87690. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  87691. var triangle = new DecimationTriangle([v0, v1, v2]);
  87692. triangle.originalOffset = pos;
  87693. _this.triangles.push(triangle);
  87694. };
  87695. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  87696. _this.init(callback);
  87697. });
  87698. });
  87699. };
  87700. QuadraticErrorSimplification.prototype.init = function (callback) {
  87701. var _this = this;
  87702. var triangleInit1 = function (i) {
  87703. var t = _this.triangles[i];
  87704. 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();
  87705. for (var j = 0; j < 3; j++) {
  87706. 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))));
  87707. }
  87708. };
  87709. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  87710. var triangleInit2 = function (i) {
  87711. var t = _this.triangles[i];
  87712. for (var j = 0; j < 3; ++j) {
  87713. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  87714. }
  87715. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  87716. };
  87717. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  87718. callback();
  87719. });
  87720. });
  87721. };
  87722. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  87723. var newTriangles = [];
  87724. var i;
  87725. for (i = 0; i < this.vertices.length; ++i) {
  87726. this.vertices[i].triangleCount = 0;
  87727. }
  87728. var t;
  87729. var j;
  87730. for (i = 0; i < this.triangles.length; ++i) {
  87731. if (!this.triangles[i].deleted) {
  87732. t = this.triangles[i];
  87733. for (j = 0; j < 3; ++j) {
  87734. t.vertices[j].triangleCount = 1;
  87735. }
  87736. newTriangles.push(t);
  87737. }
  87738. }
  87739. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  87740. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  87741. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  87742. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  87743. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  87744. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  87745. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  87746. var vertexCount = 0;
  87747. for (i = 0; i < this.vertices.length; ++i) {
  87748. var vertex = this.vertices[i];
  87749. vertex.id = vertexCount;
  87750. if (vertex.triangleCount) {
  87751. vertex.originalOffsets.forEach(function (originalOffset) {
  87752. if (!normalData) {
  87753. return;
  87754. }
  87755. newPositionData.push(vertex.position.x);
  87756. newPositionData.push(vertex.position.y);
  87757. newPositionData.push(vertex.position.z);
  87758. newNormalData.push(normalData[originalOffset * 3]);
  87759. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  87760. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  87761. if (uvs && uvs.length) {
  87762. newUVsData.push(uvs[(originalOffset * 2)]);
  87763. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  87764. }
  87765. else if (colorsData && colorsData.length) {
  87766. newColorsData.push(colorsData[(originalOffset * 4)]);
  87767. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  87768. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  87769. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  87770. }
  87771. ++vertexCount;
  87772. });
  87773. }
  87774. }
  87775. var startingIndex = this._reconstructedMesh.getTotalIndices();
  87776. var startingVertex = this._reconstructedMesh.getTotalVertices();
  87777. var submeshesArray = this._reconstructedMesh.subMeshes;
  87778. this._reconstructedMesh.subMeshes = [];
  87779. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  87780. var originalIndices = this._mesh.getIndices();
  87781. for (i = 0; i < newTriangles.length; ++i) {
  87782. t = newTriangles[i]; //now get the new referencing point for each vertex
  87783. [0, 1, 2].forEach(function (idx) {
  87784. var id = originalIndices[t.originalOffset + idx];
  87785. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  87786. if (offset < 0) {
  87787. offset = 0;
  87788. }
  87789. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  87790. });
  87791. }
  87792. //overwriting the old vertex buffers and indices.
  87793. this._reconstructedMesh.setIndices(newIndicesArray);
  87794. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  87795. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  87796. if (newUVsData.length > 0) {
  87797. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  87798. }
  87799. if (newColorsData.length > 0) {
  87800. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  87801. }
  87802. //create submesh
  87803. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  87804. if (submeshIndex > 0) {
  87805. this._reconstructedMesh.subMeshes = [];
  87806. submeshesArray.forEach(function (submesh) {
  87807. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  87808. });
  87809. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  87810. }
  87811. };
  87812. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  87813. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  87814. this._reconstructedMesh.material = this._mesh.material;
  87815. this._reconstructedMesh.parent = this._mesh.parent;
  87816. this._reconstructedMesh.isVisible = false;
  87817. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  87818. };
  87819. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  87820. for (var i = 0; i < vertex1.triangleCount; ++i) {
  87821. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  87822. if (t.deleted) {
  87823. continue;
  87824. }
  87825. var s = this.references[vertex1.triangleStart + i].vertexId;
  87826. var v1 = t.vertices[(s + 1) % 3];
  87827. var v2 = t.vertices[(s + 2) % 3];
  87828. if ((v1 === vertex2 || v2 === vertex2)) {
  87829. deletedArray[i] = true;
  87830. delTr.push(t);
  87831. continue;
  87832. }
  87833. var d1 = v1.position.subtract(point);
  87834. d1 = d1.normalize();
  87835. var d2 = v2.position.subtract(point);
  87836. d2 = d2.normalize();
  87837. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  87838. return true;
  87839. }
  87840. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  87841. deletedArray[i] = false;
  87842. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  87843. return true;
  87844. }
  87845. }
  87846. return false;
  87847. };
  87848. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  87849. var newDeleted = deletedTriangles;
  87850. for (var i = 0; i < vertex.triangleCount; ++i) {
  87851. var ref = this.references[vertex.triangleStart + i];
  87852. var t = this.triangles[ref.triangleId];
  87853. if (t.deleted) {
  87854. continue;
  87855. }
  87856. if (deletedArray[i] && t.deletePending) {
  87857. t.deleted = true;
  87858. newDeleted++;
  87859. continue;
  87860. }
  87861. t.vertices[ref.vertexId] = origVertex;
  87862. t.isDirty = true;
  87863. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  87864. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  87865. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  87866. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  87867. this.references.push(ref);
  87868. }
  87869. return newDeleted;
  87870. };
  87871. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  87872. for (var i = 0; i < this.vertices.length; ++i) {
  87873. var vCount = [];
  87874. var vId = [];
  87875. var v = this.vertices[i];
  87876. var j;
  87877. for (j = 0; j < v.triangleCount; ++j) {
  87878. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  87879. for (var ii = 0; ii < 3; ii++) {
  87880. var ofs = 0;
  87881. var vv = triangle.vertices[ii];
  87882. while (ofs < vCount.length) {
  87883. if (vId[ofs] === vv.id) {
  87884. break;
  87885. }
  87886. ++ofs;
  87887. }
  87888. if (ofs === vCount.length) {
  87889. vCount.push(1);
  87890. vId.push(vv.id);
  87891. }
  87892. else {
  87893. vCount[ofs]++;
  87894. }
  87895. }
  87896. }
  87897. for (j = 0; j < vCount.length; ++j) {
  87898. if (vCount[j] === 1) {
  87899. this.vertices[vId[j]].isBorder = true;
  87900. }
  87901. else {
  87902. this.vertices[vId[j]].isBorder = false;
  87903. }
  87904. }
  87905. }
  87906. };
  87907. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  87908. if (identifyBorders === void 0) { identifyBorders = false; }
  87909. var i;
  87910. if (!identifyBorders) {
  87911. var newTrianglesVector = [];
  87912. for (i = 0; i < this.triangles.length; ++i) {
  87913. if (!this.triangles[i].deleted) {
  87914. newTrianglesVector.push(this.triangles[i]);
  87915. }
  87916. }
  87917. this.triangles = newTrianglesVector;
  87918. }
  87919. for (i = 0; i < this.vertices.length; ++i) {
  87920. this.vertices[i].triangleCount = 0;
  87921. this.vertices[i].triangleStart = 0;
  87922. }
  87923. var t;
  87924. var j;
  87925. var v;
  87926. for (i = 0; i < this.triangles.length; ++i) {
  87927. t = this.triangles[i];
  87928. for (j = 0; j < 3; ++j) {
  87929. v = t.vertices[j];
  87930. v.triangleCount++;
  87931. }
  87932. }
  87933. var tStart = 0;
  87934. for (i = 0; i < this.vertices.length; ++i) {
  87935. this.vertices[i].triangleStart = tStart;
  87936. tStart += this.vertices[i].triangleCount;
  87937. this.vertices[i].triangleCount = 0;
  87938. }
  87939. var newReferences = new Array(this.triangles.length * 3);
  87940. for (i = 0; i < this.triangles.length; ++i) {
  87941. t = this.triangles[i];
  87942. for (j = 0; j < 3; ++j) {
  87943. v = t.vertices[j];
  87944. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  87945. v.triangleCount++;
  87946. }
  87947. }
  87948. this.references = newReferences;
  87949. if (identifyBorders) {
  87950. this.identifyBorder();
  87951. }
  87952. };
  87953. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  87954. var x = point.x;
  87955. var y = point.y;
  87956. var z = point.z;
  87957. 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
  87958. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  87959. };
  87960. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  87961. var q = vertex1.q.add(vertex2.q);
  87962. var border = vertex1.isBorder && vertex2.isBorder;
  87963. var error = 0;
  87964. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  87965. if (qDet !== 0 && !border) {
  87966. if (!pointResult) {
  87967. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87968. }
  87969. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  87970. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  87971. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  87972. error = this.vertexError(q, pointResult);
  87973. }
  87974. else {
  87975. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  87976. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  87977. var error1 = this.vertexError(q, vertex1.position);
  87978. var error2 = this.vertexError(q, vertex2.position);
  87979. var error3 = this.vertexError(q, p3);
  87980. error = Math.min(error1, error2, error3);
  87981. if (error === error1) {
  87982. if (pointResult) {
  87983. pointResult.copyFrom(vertex1.position);
  87984. }
  87985. }
  87986. else if (error === error2) {
  87987. if (pointResult) {
  87988. pointResult.copyFrom(vertex2.position);
  87989. }
  87990. }
  87991. else {
  87992. if (pointResult) {
  87993. pointResult.copyFrom(p3);
  87994. }
  87995. }
  87996. }
  87997. return error;
  87998. };
  87999. return QuadraticErrorSimplification;
  88000. }());
  88001. /***/ }),
  88002. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  88003. /*!****************************************************!*\
  88004. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  88005. \****************************************************/
  88006. /*! exports provided: SimplicationQueueSceneComponent */
  88007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88008. "use strict";
  88009. __webpack_require__.r(__webpack_exports__);
  88010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  88011. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  88012. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  88013. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  88014. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  88015. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  88016. get: function () {
  88017. if (!this._simplificationQueue) {
  88018. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  88019. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  88020. if (!component) {
  88021. component = new SimplicationQueueSceneComponent(this);
  88022. this._addComponent(component);
  88023. }
  88024. }
  88025. return this._simplificationQueue;
  88026. },
  88027. set: function (value) {
  88028. this._simplificationQueue = value;
  88029. },
  88030. enumerable: true,
  88031. configurable: true
  88032. });
  88033. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  88034. if (parallelProcessing === void 0) { parallelProcessing = true; }
  88035. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  88036. this.getScene().simplificationQueue.addTask({
  88037. settings: settings,
  88038. parallelProcessing: parallelProcessing,
  88039. mesh: this,
  88040. simplificationType: simplificationType,
  88041. successCallback: successCallback
  88042. });
  88043. return this;
  88044. };
  88045. /**
  88046. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  88047. * created in a scene
  88048. */
  88049. var SimplicationQueueSceneComponent = /** @class */ (function () {
  88050. /**
  88051. * Creates a new instance of the component for the given scene
  88052. * @param scene Defines the scene to register the component in
  88053. */
  88054. function SimplicationQueueSceneComponent(scene) {
  88055. /**
  88056. * The component name helpfull to identify the component in the list of scene components.
  88057. */
  88058. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  88059. this.scene = scene;
  88060. }
  88061. /**
  88062. * Registers the component in a given scene
  88063. */
  88064. SimplicationQueueSceneComponent.prototype.register = function () {
  88065. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  88066. };
  88067. /**
  88068. * Rebuilds the elements related to this component in case of
  88069. * context lost for instance.
  88070. */
  88071. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  88072. // Nothing to do for this component
  88073. };
  88074. /**
  88075. * Disposes the component and the associated ressources
  88076. */
  88077. SimplicationQueueSceneComponent.prototype.dispose = function () {
  88078. // Nothing to do for this component
  88079. };
  88080. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  88081. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  88082. this.scene._simplificationQueue.executeNext();
  88083. }
  88084. };
  88085. return SimplicationQueueSceneComponent;
  88086. }());
  88087. /***/ }),
  88088. /***/ "./Meshes/polygonMesh.ts":
  88089. /*!*******************************!*\
  88090. !*** ./Meshes/polygonMesh.ts ***!
  88091. \*******************************/
  88092. /*! exports provided: Polygon, PolygonMeshBuilder */
  88093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88094. "use strict";
  88095. __webpack_require__.r(__webpack_exports__);
  88096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  88097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  88098. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88099. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  88100. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88101. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88102. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88103. /**
  88104. * Vector2 wth index property
  88105. */
  88106. var IndexedVector2 = /** @class */ (function (_super) {
  88107. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  88108. function IndexedVector2(original,
  88109. /** Index of the vector2 */
  88110. index) {
  88111. var _this = _super.call(this, original.x, original.y) || this;
  88112. _this.index = index;
  88113. return _this;
  88114. }
  88115. return IndexedVector2;
  88116. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  88117. /**
  88118. * Defines points to create a polygon
  88119. */
  88120. var PolygonPoints = /** @class */ (function () {
  88121. function PolygonPoints() {
  88122. this.elements = new Array();
  88123. }
  88124. PolygonPoints.prototype.add = function (originalPoints) {
  88125. var _this = this;
  88126. var result = new Array();
  88127. originalPoints.forEach(function (point) {
  88128. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  88129. var newPoint = new IndexedVector2(point, _this.elements.length);
  88130. result.push(newPoint);
  88131. _this.elements.push(newPoint);
  88132. }
  88133. });
  88134. return result;
  88135. };
  88136. PolygonPoints.prototype.computeBounds = function () {
  88137. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88138. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88139. this.elements.forEach(function (point) {
  88140. // x
  88141. if (point.x < lmin.x) {
  88142. lmin.x = point.x;
  88143. }
  88144. else if (point.x > lmax.x) {
  88145. lmax.x = point.x;
  88146. }
  88147. // y
  88148. if (point.y < lmin.y) {
  88149. lmin.y = point.y;
  88150. }
  88151. else if (point.y > lmax.y) {
  88152. lmax.y = point.y;
  88153. }
  88154. });
  88155. return {
  88156. min: lmin,
  88157. max: lmax,
  88158. width: lmax.x - lmin.x,
  88159. height: lmax.y - lmin.y
  88160. };
  88161. };
  88162. return PolygonPoints;
  88163. }());
  88164. /**
  88165. * Polygon
  88166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88167. */
  88168. var Polygon = /** @class */ (function () {
  88169. function Polygon() {
  88170. }
  88171. /**
  88172. * Creates a rectangle
  88173. * @param xmin bottom X coord
  88174. * @param ymin bottom Y coord
  88175. * @param xmax top X coord
  88176. * @param ymax top Y coord
  88177. * @returns points that make the resulting rectation
  88178. */
  88179. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  88180. return [
  88181. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  88182. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  88183. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  88184. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  88185. ];
  88186. };
  88187. /**
  88188. * Creates a circle
  88189. * @param radius radius of circle
  88190. * @param cx scale in x
  88191. * @param cy scale in y
  88192. * @param numberOfSides number of sides that make up the circle
  88193. * @returns points that make the resulting circle
  88194. */
  88195. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  88196. if (cx === void 0) { cx = 0; }
  88197. if (cy === void 0) { cy = 0; }
  88198. if (numberOfSides === void 0) { numberOfSides = 32; }
  88199. var result = new Array();
  88200. var angle = 0;
  88201. var increment = (Math.PI * 2) / numberOfSides;
  88202. for (var i = 0; i < numberOfSides; i++) {
  88203. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  88204. angle -= increment;
  88205. }
  88206. return result;
  88207. };
  88208. /**
  88209. * Creates a polygon from input string
  88210. * @param input Input polygon data
  88211. * @returns the parsed points
  88212. */
  88213. Polygon.Parse = function (input) {
  88214. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  88215. var i, result = [];
  88216. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  88217. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  88218. }
  88219. return result;
  88220. };
  88221. /**
  88222. * Starts building a polygon from x and y coordinates
  88223. * @param x x coordinate
  88224. * @param y y coordinate
  88225. * @returns the started path2
  88226. */
  88227. Polygon.StartingAt = function (x, y) {
  88228. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  88229. };
  88230. return Polygon;
  88231. }());
  88232. /**
  88233. * Builds a polygon
  88234. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  88235. */
  88236. var PolygonMeshBuilder = /** @class */ (function () {
  88237. /**
  88238. * Creates a PolygonMeshBuilder
  88239. * @param name name of the builder
  88240. * @param contours Path of the polygon
  88241. * @param scene scene to add to
  88242. */
  88243. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  88244. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88245. this._points = new PolygonPoints();
  88246. this._outlinepoints = new PolygonPoints();
  88247. this._holes = new Array();
  88248. this._epoints = new Array();
  88249. this._eholes = new Array();
  88250. this.bjsEarcut = earcutInjection;
  88251. this._name = name;
  88252. this._scene = scene;
  88253. var points;
  88254. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  88255. points = contours.getPoints();
  88256. }
  88257. else {
  88258. points = contours;
  88259. }
  88260. this._addToepoint(points);
  88261. this._points.add(points);
  88262. this._outlinepoints.add(points);
  88263. if (typeof this.bjsEarcut === 'undefined') {
  88264. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  88265. }
  88266. }
  88267. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  88268. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  88269. var p = points_1[_i];
  88270. this._epoints.push(p.x, p.y);
  88271. }
  88272. };
  88273. /**
  88274. * Adds a whole within the polygon
  88275. * @param hole Array of points defining the hole
  88276. * @returns this
  88277. */
  88278. PolygonMeshBuilder.prototype.addHole = function (hole) {
  88279. this._points.add(hole);
  88280. var holepoints = new PolygonPoints();
  88281. holepoints.add(hole);
  88282. this._holes.push(holepoints);
  88283. this._eholes.push(this._epoints.length / 2);
  88284. this._addToepoint(hole);
  88285. return this;
  88286. };
  88287. /**
  88288. * Creates the polygon
  88289. * @param updatable If the mesh should be updatable
  88290. * @param depth The depth of the mesh created
  88291. * @returns the created mesh
  88292. */
  88293. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  88294. var _this = this;
  88295. if (updatable === void 0) { updatable = false; }
  88296. if (depth === void 0) { depth = 0; }
  88297. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  88298. var normals = new Array();
  88299. var positions = new Array();
  88300. var uvs = new Array();
  88301. var bounds = this._points.computeBounds();
  88302. this._points.elements.forEach(function (p) {
  88303. normals.push(0, 1.0, 0);
  88304. positions.push(p.x, 0, p.y);
  88305. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  88306. });
  88307. var indices = new Array();
  88308. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  88309. for (var i = 0; i < res.length; i++) {
  88310. indices.push(res[i]);
  88311. }
  88312. if (depth > 0) {
  88313. var positionscount = (positions.length / 3); //get the current pointcount
  88314. this._points.elements.forEach(function (p) {
  88315. normals.push(0, -1.0, 0);
  88316. positions.push(p.x, -depth, p.y);
  88317. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  88318. });
  88319. var totalCount = indices.length;
  88320. for (var i = 0; i < totalCount; i += 3) {
  88321. var i0 = indices[i + 0];
  88322. var i1 = indices[i + 1];
  88323. var i2 = indices[i + 2];
  88324. indices.push(i2 + positionscount);
  88325. indices.push(i1 + positionscount);
  88326. indices.push(i0 + positionscount);
  88327. }
  88328. //Add the sides
  88329. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  88330. this._holes.forEach(function (hole) {
  88331. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  88332. });
  88333. }
  88334. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  88335. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  88336. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  88337. result.setIndices(indices);
  88338. return result;
  88339. };
  88340. /**
  88341. * Adds a side to the polygon
  88342. * @param positions points that make the polygon
  88343. * @param normals normals of the polygon
  88344. * @param uvs uvs of the polygon
  88345. * @param indices indices of the polygon
  88346. * @param bounds bounds of the polygon
  88347. * @param points points of the polygon
  88348. * @param depth depth of the polygon
  88349. * @param flip flip of the polygon
  88350. */
  88351. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  88352. var StartIndex = positions.length / 3;
  88353. var ulength = 0;
  88354. for (var i = 0; i < points.elements.length; i++) {
  88355. var p = points.elements[i];
  88356. var p1;
  88357. if ((i + 1) > points.elements.length - 1) {
  88358. p1 = points.elements[0];
  88359. }
  88360. else {
  88361. p1 = points.elements[i + 1];
  88362. }
  88363. positions.push(p.x, 0, p.y);
  88364. positions.push(p.x, -depth, p.y);
  88365. positions.push(p1.x, 0, p1.y);
  88366. positions.push(p1.x, -depth, p1.y);
  88367. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  88368. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  88369. var v3 = v2.subtract(v1);
  88370. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  88371. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  88372. vn = vn.normalize();
  88373. uvs.push(ulength / bounds.width, 0);
  88374. uvs.push(ulength / bounds.width, 1);
  88375. ulength += v3.length();
  88376. uvs.push((ulength / bounds.width), 0);
  88377. uvs.push((ulength / bounds.width), 1);
  88378. if (!flip) {
  88379. normals.push(-vn.x, -vn.y, -vn.z);
  88380. normals.push(-vn.x, -vn.y, -vn.z);
  88381. normals.push(-vn.x, -vn.y, -vn.z);
  88382. normals.push(-vn.x, -vn.y, -vn.z);
  88383. indices.push(StartIndex);
  88384. indices.push(StartIndex + 1);
  88385. indices.push(StartIndex + 2);
  88386. indices.push(StartIndex + 1);
  88387. indices.push(StartIndex + 3);
  88388. indices.push(StartIndex + 2);
  88389. }
  88390. else {
  88391. normals.push(vn.x, vn.y, vn.z);
  88392. normals.push(vn.x, vn.y, vn.z);
  88393. normals.push(vn.x, vn.y, vn.z);
  88394. normals.push(vn.x, vn.y, vn.z);
  88395. indices.push(StartIndex);
  88396. indices.push(StartIndex + 2);
  88397. indices.push(StartIndex + 1);
  88398. indices.push(StartIndex + 1);
  88399. indices.push(StartIndex + 2);
  88400. indices.push(StartIndex + 3);
  88401. }
  88402. StartIndex += 4;
  88403. }
  88404. };
  88405. return PolygonMeshBuilder;
  88406. }());
  88407. /***/ }),
  88408. /***/ "./Meshes/subMesh.ts":
  88409. /*!***************************!*\
  88410. !*** ./Meshes/subMesh.ts ***!
  88411. \***************************/
  88412. /*! exports provided: BaseSubMesh, SubMesh */
  88413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88414. "use strict";
  88415. __webpack_require__.r(__webpack_exports__);
  88416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  88417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  88418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88419. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88420. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  88421. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  88422. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  88423. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  88424. /**
  88425. * Base class for submeshes
  88426. */
  88427. var BaseSubMesh = /** @class */ (function () {
  88428. function BaseSubMesh() {
  88429. }
  88430. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  88431. /**
  88432. * Gets associated effect
  88433. */
  88434. get: function () {
  88435. return this._materialEffect;
  88436. },
  88437. enumerable: true,
  88438. configurable: true
  88439. });
  88440. /**
  88441. * Sets associated effect (effect used to render this submesh)
  88442. * @param effect defines the effect to associate with
  88443. * @param defines defines the set of defines used to compile this effect
  88444. */
  88445. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  88446. if (defines === void 0) { defines = null; }
  88447. if (this._materialEffect === effect) {
  88448. if (!effect) {
  88449. this._materialDefines = null;
  88450. }
  88451. return;
  88452. }
  88453. this._materialDefines = defines;
  88454. this._materialEffect = effect;
  88455. };
  88456. return BaseSubMesh;
  88457. }());
  88458. /**
  88459. * Defines a subdivision inside a mesh
  88460. */
  88461. var SubMesh = /** @class */ (function (_super) {
  88462. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  88463. /**
  88464. * Creates a new submesh
  88465. * @param materialIndex defines the material index to use
  88466. * @param verticesStart defines vertex index start
  88467. * @param verticesCount defines vertices count
  88468. * @param indexStart defines index start
  88469. * @param indexCount defines indices count
  88470. * @param mesh defines the parent mesh
  88471. * @param renderingMesh defines an optional rendering mesh
  88472. * @param createBoundingBox defines if bounding box should be created for this submesh
  88473. */
  88474. function SubMesh(
  88475. /** the material index to use */
  88476. materialIndex,
  88477. /** vertex index start */
  88478. verticesStart,
  88479. /** vertices count */
  88480. verticesCount,
  88481. /** index start */
  88482. indexStart,
  88483. /** indices count */
  88484. indexCount, mesh, renderingMesh, createBoundingBox) {
  88485. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88486. var _this = _super.call(this) || this;
  88487. _this.materialIndex = materialIndex;
  88488. _this.verticesStart = verticesStart;
  88489. _this.verticesCount = verticesCount;
  88490. _this.indexStart = indexStart;
  88491. _this.indexCount = indexCount;
  88492. /** @hidden */
  88493. _this._renderId = 0;
  88494. _this._mesh = mesh;
  88495. _this._renderingMesh = renderingMesh || mesh;
  88496. mesh.subMeshes.push(_this);
  88497. _this._trianglePlanes = [];
  88498. _this._id = mesh.subMeshes.length - 1;
  88499. if (createBoundingBox) {
  88500. _this.refreshBoundingInfo();
  88501. mesh.computeWorldMatrix(true);
  88502. }
  88503. return _this;
  88504. }
  88505. /**
  88506. * Add a new submesh to a mesh
  88507. * @param materialIndex defines the material index to use
  88508. * @param verticesStart defines vertex index start
  88509. * @param verticesCount defines vertices count
  88510. * @param indexStart defines index start
  88511. * @param indexCount defines indices count
  88512. * @param mesh defines the parent mesh
  88513. * @param renderingMesh defines an optional rendering mesh
  88514. * @param createBoundingBox defines if bounding box should be created for this submesh
  88515. * @returns the new submesh
  88516. */
  88517. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  88518. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88519. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  88520. };
  88521. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  88522. /**
  88523. * Returns true if this submesh covers the entire parent mesh
  88524. * @ignorenaming
  88525. */
  88526. get: function () {
  88527. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  88528. },
  88529. enumerable: true,
  88530. configurable: true
  88531. });
  88532. /**
  88533. * Returns the submesh BoudingInfo object
  88534. * @returns current bounding info (or mesh's one if the submesh is global)
  88535. */
  88536. SubMesh.prototype.getBoundingInfo = function () {
  88537. if (this.IsGlobal) {
  88538. return this._mesh.getBoundingInfo();
  88539. }
  88540. return this._boundingInfo;
  88541. };
  88542. /**
  88543. * Sets the submesh BoundingInfo
  88544. * @param boundingInfo defines the new bounding info to use
  88545. * @returns the SubMesh
  88546. */
  88547. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  88548. this._boundingInfo = boundingInfo;
  88549. return this;
  88550. };
  88551. /**
  88552. * Returns the mesh of the current submesh
  88553. * @return the parent mesh
  88554. */
  88555. SubMesh.prototype.getMesh = function () {
  88556. return this._mesh;
  88557. };
  88558. /**
  88559. * Returns the rendering mesh of the submesh
  88560. * @returns the rendering mesh (could be different from parent mesh)
  88561. */
  88562. SubMesh.prototype.getRenderingMesh = function () {
  88563. return this._renderingMesh;
  88564. };
  88565. /**
  88566. * Returns the submesh material
  88567. * @returns null or the current material
  88568. */
  88569. SubMesh.prototype.getMaterial = function () {
  88570. var rootMaterial = this._renderingMesh.material;
  88571. if (rootMaterial === null || rootMaterial === undefined) {
  88572. return this._mesh.getScene().defaultMaterial;
  88573. }
  88574. else if (rootMaterial.getSubMaterial) {
  88575. var multiMaterial = rootMaterial;
  88576. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  88577. if (this._currentMaterial !== effectiveMaterial) {
  88578. this._currentMaterial = effectiveMaterial;
  88579. this._materialDefines = null;
  88580. }
  88581. return effectiveMaterial;
  88582. }
  88583. return rootMaterial;
  88584. };
  88585. // Methods
  88586. /**
  88587. * Sets a new updated BoundingInfo object to the submesh
  88588. * @returns the SubMesh
  88589. */
  88590. SubMesh.prototype.refreshBoundingInfo = function () {
  88591. this._lastColliderWorldVertices = null;
  88592. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  88593. return this;
  88594. }
  88595. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  88596. if (!data) {
  88597. this._boundingInfo = this._mesh.getBoundingInfo();
  88598. return this;
  88599. }
  88600. var indices = this._renderingMesh.getIndices();
  88601. var extend;
  88602. //is this the only submesh?
  88603. if (this.indexStart === 0 && this.indexCount === indices.length) {
  88604. var boundingInfo = this._renderingMesh.getBoundingInfo();
  88605. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  88606. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  88607. }
  88608. else {
  88609. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  88610. }
  88611. if (this._boundingInfo) {
  88612. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  88613. }
  88614. else {
  88615. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  88616. }
  88617. return this;
  88618. };
  88619. /** @hidden */
  88620. SubMesh.prototype._checkCollision = function (collider) {
  88621. var boundingInfo = this.getBoundingInfo();
  88622. return boundingInfo._checkCollision(collider);
  88623. };
  88624. /**
  88625. * Updates the submesh BoundingInfo
  88626. * @param world defines the world matrix to use to update the bounding info
  88627. * @returns the submesh
  88628. */
  88629. SubMesh.prototype.updateBoundingInfo = function (world) {
  88630. var boundingInfo = this.getBoundingInfo();
  88631. if (!boundingInfo) {
  88632. this.refreshBoundingInfo();
  88633. boundingInfo = this.getBoundingInfo();
  88634. }
  88635. boundingInfo.update(world);
  88636. return this;
  88637. };
  88638. /**
  88639. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88640. * @param frustumPlanes defines the frustum planes
  88641. * @returns true if the submesh is intersecting with the frustum
  88642. */
  88643. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  88644. var boundingInfo = this.getBoundingInfo();
  88645. if (!boundingInfo) {
  88646. return false;
  88647. }
  88648. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  88649. };
  88650. /**
  88651. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88652. * @param frustumPlanes defines the frustum planes
  88653. * @returns true if the submesh is inside the frustum
  88654. */
  88655. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  88656. var boundingInfo = this.getBoundingInfo();
  88657. if (!boundingInfo) {
  88658. return false;
  88659. }
  88660. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  88661. };
  88662. /**
  88663. * Renders the submesh
  88664. * @param enableAlphaMode defines if alpha needs to be used
  88665. * @returns the submesh
  88666. */
  88667. SubMesh.prototype.render = function (enableAlphaMode) {
  88668. this._renderingMesh.render(this, enableAlphaMode);
  88669. return this;
  88670. };
  88671. /**
  88672. * @hidden
  88673. */
  88674. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  88675. if (!this._linesIndexBuffer) {
  88676. var linesIndices = [];
  88677. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  88678. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  88679. }
  88680. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  88681. this._linesIndexCount = linesIndices.length;
  88682. }
  88683. return this._linesIndexBuffer;
  88684. };
  88685. /**
  88686. * Checks if the submesh intersects with a ray
  88687. * @param ray defines the ray to test
  88688. * @returns true is the passed ray intersects the submesh bounding box
  88689. */
  88690. SubMesh.prototype.canIntersects = function (ray) {
  88691. var boundingInfo = this.getBoundingInfo();
  88692. if (!boundingInfo) {
  88693. return false;
  88694. }
  88695. return ray.intersectsBox(boundingInfo.boundingBox);
  88696. };
  88697. /**
  88698. * Intersects current submesh with a ray
  88699. * @param ray defines the ray to test
  88700. * @param positions defines mesh's positions array
  88701. * @param indices defines mesh's indices array
  88702. * @param fastCheck defines if only bounding info should be used
  88703. * @returns intersection info or null if no intersection
  88704. */
  88705. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  88706. var material = this.getMaterial();
  88707. if (!material) {
  88708. return null;
  88709. }
  88710. switch (material.fillMode) {
  88711. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  88712. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  88713. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  88714. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  88715. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  88716. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  88717. return null;
  88718. }
  88719. // LineMesh first as it's also a Mesh...
  88720. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  88721. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  88722. }
  88723. return this._intersectTriangles(ray, positions, indices, fastCheck);
  88724. };
  88725. /** @hidden */
  88726. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  88727. var intersectInfo = null;
  88728. // Line test
  88729. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  88730. var p0 = positions[indices[index]];
  88731. var p1 = positions[indices[index + 1]];
  88732. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  88733. if (length < 0) {
  88734. continue;
  88735. }
  88736. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  88737. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  88738. intersectInfo.faceId = index / 2;
  88739. if (fastCheck) {
  88740. break;
  88741. }
  88742. }
  88743. }
  88744. return intersectInfo;
  88745. };
  88746. /** @hidden */
  88747. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  88748. var intersectInfo = null;
  88749. // Triangles test
  88750. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  88751. var p0 = positions[indices[index]];
  88752. var p1 = positions[indices[index + 1]];
  88753. var p2 = positions[indices[index + 2]];
  88754. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  88755. if (currentIntersectInfo) {
  88756. if (currentIntersectInfo.distance < 0) {
  88757. continue;
  88758. }
  88759. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  88760. intersectInfo = currentIntersectInfo;
  88761. intersectInfo.faceId = index / 3;
  88762. if (fastCheck) {
  88763. break;
  88764. }
  88765. }
  88766. }
  88767. }
  88768. return intersectInfo;
  88769. };
  88770. /** @hidden */
  88771. SubMesh.prototype._rebuild = function () {
  88772. if (this._linesIndexBuffer) {
  88773. this._linesIndexBuffer = null;
  88774. }
  88775. };
  88776. // Clone
  88777. /**
  88778. * Creates a new submesh from the passed mesh
  88779. * @param newMesh defines the new hosting mesh
  88780. * @param newRenderingMesh defines an optional rendering mesh
  88781. * @returns the new submesh
  88782. */
  88783. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  88784. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  88785. if (!this.IsGlobal) {
  88786. var boundingInfo = this.getBoundingInfo();
  88787. if (!boundingInfo) {
  88788. return result;
  88789. }
  88790. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  88791. }
  88792. return result;
  88793. };
  88794. // Dispose
  88795. /**
  88796. * Release associated resources
  88797. */
  88798. SubMesh.prototype.dispose = function () {
  88799. if (this._linesIndexBuffer) {
  88800. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  88801. this._linesIndexBuffer = null;
  88802. }
  88803. // Remove from mesh
  88804. var index = this._mesh.subMeshes.indexOf(this);
  88805. this._mesh.subMeshes.splice(index, 1);
  88806. };
  88807. /**
  88808. * Gets the class name
  88809. * @returns the string "SubMesh".
  88810. */
  88811. SubMesh.prototype.getClassName = function () {
  88812. return "SubMesh";
  88813. };
  88814. // Statics
  88815. /**
  88816. * Creates a new submesh from indices data
  88817. * @param materialIndex the index of the main mesh material
  88818. * @param startIndex the index where to start the copy in the mesh indices array
  88819. * @param indexCount the number of indices to copy then from the startIndex
  88820. * @param mesh the main mesh to create the submesh from
  88821. * @param renderingMesh the optional rendering mesh
  88822. * @returns a new submesh
  88823. */
  88824. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  88825. var minVertexIndex = Number.MAX_VALUE;
  88826. var maxVertexIndex = -Number.MAX_VALUE;
  88827. var whatWillRender = (renderingMesh || mesh);
  88828. var indices = whatWillRender.getIndices();
  88829. for (var index = startIndex; index < startIndex + indexCount; index++) {
  88830. var vertexIndex = indices[index];
  88831. if (vertexIndex < minVertexIndex) {
  88832. minVertexIndex = vertexIndex;
  88833. }
  88834. if (vertexIndex > maxVertexIndex) {
  88835. maxVertexIndex = vertexIndex;
  88836. }
  88837. }
  88838. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  88839. };
  88840. return SubMesh;
  88841. }(BaseSubMesh));
  88842. /***/ }),
  88843. /***/ "./Meshes/transformNode.ts":
  88844. /*!*********************************!*\
  88845. !*** ./Meshes/transformNode.ts ***!
  88846. \*********************************/
  88847. /*! exports provided: TransformNode */
  88848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88849. "use strict";
  88850. __webpack_require__.r(__webpack_exports__);
  88851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  88852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88853. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  88854. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  88855. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  88856. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88857. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  88858. /**
  88859. * 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.
  88860. * @see https://doc.babylonjs.com/how_to/transformnode
  88861. */
  88862. var TransformNode = /** @class */ (function (_super) {
  88863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  88864. function TransformNode(name, scene, isPure) {
  88865. if (scene === void 0) { scene = null; }
  88866. if (isPure === void 0) { isPure = true; }
  88867. var _this = _super.call(this, name, scene) || this;
  88868. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 1);
  88869. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, -1);
  88870. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0);
  88871. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](1, 0, 0);
  88872. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-1, 0, 0);
  88873. // Properties
  88874. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  88875. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  88876. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  88877. _this._isDirty = false;
  88878. /**
  88879. * Set the billboard mode. Default is 0.
  88880. *
  88881. * | Value | Type | Description |
  88882. * | --- | --- | --- |
  88883. * | 0 | BILLBOARDMODE_NONE | |
  88884. * | 1 | BILLBOARDMODE_X | |
  88885. * | 2 | BILLBOARDMODE_Y | |
  88886. * | 4 | BILLBOARDMODE_Z | |
  88887. * | 7 | BILLBOARDMODE_ALL | |
  88888. *
  88889. */
  88890. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  88891. /**
  88892. * 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
  88893. */
  88894. _this.scalingDeterminant = 1;
  88895. /**
  88896. * Sets the distance of the object to max, often used by skybox
  88897. */
  88898. _this.infiniteDistance = false;
  88899. /**
  88900. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  88901. * By default the system will update normals to compensate
  88902. */
  88903. _this.ignoreNonUniformScaling = false;
  88904. /** @hidden */
  88905. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  88906. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  88907. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  88908. _this._postMultiplyPivotMatrix = false;
  88909. _this._isWorldMatrixFrozen = false;
  88910. /** @hidden */
  88911. _this._indexInSceneTransformNodesArray = -1;
  88912. /**
  88913. * An event triggered after the world matrix is updated
  88914. */
  88915. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  88916. _this._nonUniformScaling = false;
  88917. if (isPure) {
  88918. _this.getScene().addTransformNode(_this);
  88919. }
  88920. return _this;
  88921. }
  88922. /**
  88923. * Gets a string identifying the name of the class
  88924. * @returns "TransformNode" string
  88925. */
  88926. TransformNode.prototype.getClassName = function () {
  88927. return "TransformNode";
  88928. };
  88929. Object.defineProperty(TransformNode.prototype, "position", {
  88930. /**
  88931. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  88932. */
  88933. get: function () {
  88934. return this._position;
  88935. },
  88936. set: function (newPosition) {
  88937. this._position = newPosition;
  88938. this._isDirty = true;
  88939. },
  88940. enumerable: true,
  88941. configurable: true
  88942. });
  88943. Object.defineProperty(TransformNode.prototype, "rotation", {
  88944. /**
  88945. * 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)).
  88946. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  88947. */
  88948. get: function () {
  88949. return this._rotation;
  88950. },
  88951. set: function (newRotation) {
  88952. this._rotation = newRotation;
  88953. this._isDirty = true;
  88954. },
  88955. enumerable: true,
  88956. configurable: true
  88957. });
  88958. Object.defineProperty(TransformNode.prototype, "scaling", {
  88959. /**
  88960. * 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)).
  88961. */
  88962. get: function () {
  88963. return this._scaling;
  88964. },
  88965. set: function (newScaling) {
  88966. this._scaling = newScaling;
  88967. this._isDirty = true;
  88968. },
  88969. enumerable: true,
  88970. configurable: true
  88971. });
  88972. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  88973. /**
  88974. * 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).
  88975. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88976. */
  88977. get: function () {
  88978. return this._rotationQuaternion;
  88979. },
  88980. set: function (quaternion) {
  88981. this._rotationQuaternion = quaternion;
  88982. //reset the rotation vector.
  88983. if (quaternion) {
  88984. this.rotation.setAll(0.0);
  88985. }
  88986. },
  88987. enumerable: true,
  88988. configurable: true
  88989. });
  88990. Object.defineProperty(TransformNode.prototype, "forward", {
  88991. /**
  88992. * The forward direction of that transform in world space.
  88993. */
  88994. get: function () {
  88995. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  88996. },
  88997. enumerable: true,
  88998. configurable: true
  88999. });
  89000. Object.defineProperty(TransformNode.prototype, "up", {
  89001. /**
  89002. * The up direction of that transform in world space.
  89003. */
  89004. get: function () {
  89005. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  89006. },
  89007. enumerable: true,
  89008. configurable: true
  89009. });
  89010. Object.defineProperty(TransformNode.prototype, "right", {
  89011. /**
  89012. * The right direction of that transform in world space.
  89013. */
  89014. get: function () {
  89015. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  89016. },
  89017. enumerable: true,
  89018. configurable: true
  89019. });
  89020. /**
  89021. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89022. * @param matrix the matrix to copy the pose from
  89023. * @returns this TransformNode.
  89024. */
  89025. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  89026. this._poseMatrix.copyFrom(matrix);
  89027. return this;
  89028. };
  89029. /**
  89030. * Returns the mesh Pose matrix.
  89031. * @returns the pose matrix
  89032. */
  89033. TransformNode.prototype.getPoseMatrix = function () {
  89034. return this._poseMatrix;
  89035. };
  89036. /** @hidden */
  89037. TransformNode.prototype._isSynchronized = function () {
  89038. if (this._isDirty) {
  89039. return false;
  89040. }
  89041. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89042. return false;
  89043. }
  89044. if (this._cache.pivotMatrixUpdated) {
  89045. return false;
  89046. }
  89047. if (this.infiniteDistance) {
  89048. return false;
  89049. }
  89050. if (!this._cache.position.equals(this._position)) {
  89051. return false;
  89052. }
  89053. if (this._rotationQuaternion) {
  89054. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  89055. return false;
  89056. }
  89057. }
  89058. if (!this._cache.rotation.equals(this._rotation)) {
  89059. return false;
  89060. }
  89061. if (!this._cache.scaling.equals(this._scaling)) {
  89062. return false;
  89063. }
  89064. return true;
  89065. };
  89066. /** @hidden */
  89067. TransformNode.prototype._initCache = function () {
  89068. _super.prototype._initCache.call(this);
  89069. this._cache.localMatrixUpdated = false;
  89070. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89071. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89072. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89073. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"](0, 0, 0, 0);
  89074. this._cache.billboardMode = -1;
  89075. this._cache.infiniteDistance = false;
  89076. };
  89077. /**
  89078. * Flag the transform node as dirty (Forcing it to update everything)
  89079. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89080. * @returns this transform node
  89081. */
  89082. TransformNode.prototype.markAsDirty = function (property) {
  89083. if (property === "rotation") {
  89084. this.rotationQuaternion = null;
  89085. }
  89086. this._currentRenderId = Number.MAX_VALUE;
  89087. this._isDirty = true;
  89088. return this;
  89089. };
  89090. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  89091. /**
  89092. * Returns the current mesh absolute position.
  89093. * Returns a Vector3.
  89094. */
  89095. get: function () {
  89096. return this._absolutePosition;
  89097. },
  89098. enumerable: true,
  89099. configurable: true
  89100. });
  89101. /**
  89102. * Sets a new matrix to apply before all other transformation
  89103. * @param matrix defines the transform matrix
  89104. * @returns the current TransformNode
  89105. */
  89106. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  89107. return this.setPivotMatrix(matrix, false);
  89108. };
  89109. /**
  89110. * Sets a new pivot matrix to the current node
  89111. * @param matrix defines the new pivot matrix to use
  89112. * @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
  89113. * @returns the current TransformNode
  89114. */
  89115. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  89116. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  89117. this._pivotMatrix.copyFrom(matrix);
  89118. this._cache.pivotMatrixUpdated = true;
  89119. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  89120. if (this._postMultiplyPivotMatrix) {
  89121. if (!this._pivotMatrixInverse) {
  89122. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._pivotMatrix);
  89123. }
  89124. else {
  89125. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  89126. }
  89127. }
  89128. return this;
  89129. };
  89130. /**
  89131. * Returns the mesh pivot matrix.
  89132. * Default : Identity.
  89133. * @returns the matrix
  89134. */
  89135. TransformNode.prototype.getPivotMatrix = function () {
  89136. return this._pivotMatrix;
  89137. };
  89138. /**
  89139. * Prevents the World matrix to be computed any longer.
  89140. * @returns the TransformNode.
  89141. */
  89142. TransformNode.prototype.freezeWorldMatrix = function () {
  89143. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  89144. this.computeWorldMatrix(true);
  89145. this._isWorldMatrixFrozen = true;
  89146. return this;
  89147. };
  89148. /**
  89149. * Allows back the World matrix computation.
  89150. * @returns the TransformNode.
  89151. */
  89152. TransformNode.prototype.unfreezeWorldMatrix = function () {
  89153. this._isWorldMatrixFrozen = false;
  89154. this.computeWorldMatrix(true);
  89155. return this;
  89156. };
  89157. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  89158. /**
  89159. * True if the World matrix has been frozen.
  89160. */
  89161. get: function () {
  89162. return this._isWorldMatrixFrozen;
  89163. },
  89164. enumerable: true,
  89165. configurable: true
  89166. });
  89167. /**
  89168. * Retuns the mesh absolute position in the World.
  89169. * @returns a Vector3.
  89170. */
  89171. TransformNode.prototype.getAbsolutePosition = function () {
  89172. this.computeWorldMatrix();
  89173. return this._absolutePosition;
  89174. };
  89175. /**
  89176. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89177. * @param absolutePosition the absolute position to set
  89178. * @returns the TransformNode.
  89179. */
  89180. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  89181. if (!absolutePosition) {
  89182. return this;
  89183. }
  89184. var absolutePositionX;
  89185. var absolutePositionY;
  89186. var absolutePositionZ;
  89187. if (absolutePosition.x === undefined) {
  89188. if (arguments.length < 3) {
  89189. return this;
  89190. }
  89191. absolutePositionX = arguments[0];
  89192. absolutePositionY = arguments[1];
  89193. absolutePositionZ = arguments[2];
  89194. }
  89195. else {
  89196. absolutePositionX = absolutePosition.x;
  89197. absolutePositionY = absolutePosition.y;
  89198. absolutePositionZ = absolutePosition.z;
  89199. }
  89200. if (this.parent) {
  89201. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89202. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89203. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  89204. }
  89205. else {
  89206. this.position.x = absolutePositionX;
  89207. this.position.y = absolutePositionY;
  89208. this.position.z = absolutePositionZ;
  89209. }
  89210. return this;
  89211. };
  89212. /**
  89213. * Sets the mesh position in its local space.
  89214. * @param vector3 the position to set in localspace
  89215. * @returns the TransformNode.
  89216. */
  89217. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  89218. this.computeWorldMatrix();
  89219. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(vector3, this._localMatrix);
  89220. return this;
  89221. };
  89222. /**
  89223. * Returns the mesh position in the local space from the current World matrix values.
  89224. * @returns a new Vector3.
  89225. */
  89226. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  89227. this.computeWorldMatrix();
  89228. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89229. this._localMatrix.invertToRef(invLocalWorldMatrix);
  89230. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  89231. };
  89232. /**
  89233. * Translates the mesh along the passed Vector3 in its local space.
  89234. * @param vector3 the distance to translate in localspace
  89235. * @returns the TransformNode.
  89236. */
  89237. TransformNode.prototype.locallyTranslate = function (vector3) {
  89238. this.computeWorldMatrix(true);
  89239. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  89240. return this;
  89241. };
  89242. /**
  89243. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89244. * @param targetPoint the position (must be in same space as current mesh) to look at
  89245. * @param yawCor optional yaw (y-axis) correction in radians
  89246. * @param pitchCor optional pitch (x-axis) correction in radians
  89247. * @param rollCor optional roll (z-axis) correction in radians
  89248. * @param space the choosen space of the target
  89249. * @returns the TransformNode.
  89250. */
  89251. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  89252. if (yawCor === void 0) { yawCor = 0; }
  89253. if (pitchCor === void 0) { pitchCor = 0; }
  89254. if (rollCor === void 0) { rollCor = 0; }
  89255. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89256. var dv = TransformNode._lookAtVectorCache;
  89257. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  89258. targetPoint.subtractToRef(pos, dv);
  89259. this.setDirection(dv, yawCor, pitchCor, rollCor);
  89260. // Correct for parent's rotation offset
  89261. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD && this.parent) {
  89262. if (this.rotationQuaternion) {
  89263. // Get local rotation matrix of the looking object
  89264. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89265. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  89266. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89267. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89268. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89269. parentRotationMatrix.invert();
  89270. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89271. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  89272. }
  89273. else {
  89274. // Get local rotation matrix of the looking object
  89275. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89276. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  89277. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89278. quaternionRotation.toRotationMatrix(rotationMatrix);
  89279. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89280. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89281. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89282. parentRotationMatrix.invert();
  89283. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89284. quaternionRotation.fromRotationMatrix(rotationMatrix);
  89285. quaternionRotation.toEulerAnglesToRef(this.rotation);
  89286. }
  89287. }
  89288. return this;
  89289. };
  89290. /**
  89291. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89292. * This Vector3 is expressed in the World space.
  89293. * @param localAxis axis to rotate
  89294. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89295. */
  89296. TransformNode.prototype.getDirection = function (localAxis) {
  89297. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89298. this.getDirectionToRef(localAxis, result);
  89299. return result;
  89300. };
  89301. /**
  89302. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89303. * localAxis is expressed in the mesh local space.
  89304. * result is computed in the Wordl space from the mesh World matrix.
  89305. * @param localAxis axis to rotate
  89306. * @param result the resulting transformnode
  89307. * @returns this TransformNode.
  89308. */
  89309. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  89310. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  89311. return this;
  89312. };
  89313. /**
  89314. * Sets this transform node rotation to the given local axis.
  89315. * @param localAxis the axis in local space
  89316. * @param yawCor optional yaw (y-axis) correction in radians
  89317. * @param pitchCor optional pitch (x-axis) correction in radians
  89318. * @param rollCor optional roll (z-axis) correction in radians
  89319. * @returns this TransformNode
  89320. */
  89321. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  89322. if (yawCor === void 0) { yawCor = 0; }
  89323. if (pitchCor === void 0) { pitchCor = 0; }
  89324. if (rollCor === void 0) { rollCor = 0; }
  89325. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  89326. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  89327. var pitch = -Math.atan2(localAxis.y, len);
  89328. if (this.rotationQuaternion) {
  89329. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  89330. }
  89331. else {
  89332. this.rotation.x = pitch + pitchCor;
  89333. this.rotation.y = yaw + yawCor;
  89334. this.rotation.z = rollCor;
  89335. }
  89336. return this;
  89337. };
  89338. /**
  89339. * Sets a new pivot point to the current node
  89340. * @param point defines the new pivot point to use
  89341. * @param space defines if the point is in world or local space (local by default)
  89342. * @returns the current TransformNode
  89343. */
  89344. TransformNode.prototype.setPivotPoint = function (point, space) {
  89345. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89346. if (this.getScene().getRenderId() == 0) {
  89347. this.computeWorldMatrix(true);
  89348. }
  89349. var wm = this.getWorldMatrix();
  89350. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD) {
  89351. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89352. wm.invertToRef(tmat);
  89353. point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(point, tmat);
  89354. }
  89355. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  89356. };
  89357. /**
  89358. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89359. * @returns the pivot point
  89360. */
  89361. TransformNode.prototype.getPivotPoint = function () {
  89362. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89363. this.getPivotPointToRef(point);
  89364. return point;
  89365. };
  89366. /**
  89367. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89368. * @param result the vector3 to store the result
  89369. * @returns this TransformNode.
  89370. */
  89371. TransformNode.prototype.getPivotPointToRef = function (result) {
  89372. result.x = -this._pivotMatrix.m[12];
  89373. result.y = -this._pivotMatrix.m[13];
  89374. result.z = -this._pivotMatrix.m[14];
  89375. return this;
  89376. };
  89377. /**
  89378. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89379. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89380. */
  89381. TransformNode.prototype.getAbsolutePivotPoint = function () {
  89382. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89383. this.getAbsolutePivotPointToRef(point);
  89384. return point;
  89385. };
  89386. /**
  89387. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89388. * @param result vector3 to store the result
  89389. * @returns this TransformNode.
  89390. */
  89391. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  89392. result.x = this._pivotMatrix.m[12];
  89393. result.y = this._pivotMatrix.m[13];
  89394. result.z = this._pivotMatrix.m[14];
  89395. this.getPivotPointToRef(result);
  89396. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  89397. return this;
  89398. };
  89399. /**
  89400. * Defines the passed node as the parent of the current node.
  89401. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89402. * @param node the node ot set as the parent
  89403. * @returns this TransformNode.
  89404. */
  89405. TransformNode.prototype.setParent = function (node) {
  89406. if (!node && !this.parent) {
  89407. return this;
  89408. }
  89409. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89410. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89411. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89412. if (!node) {
  89413. if (this.parent && this.parent.computeWorldMatrix) {
  89414. this.parent.computeWorldMatrix(true);
  89415. }
  89416. this.computeWorldMatrix(true);
  89417. this.getWorldMatrix().decompose(scale, quatRotation, position);
  89418. }
  89419. else {
  89420. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89421. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89422. this.computeWorldMatrix(true);
  89423. node.computeWorldMatrix(true);
  89424. node.getWorldMatrix().invertToRef(invParentMatrix);
  89425. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  89426. diffMatrix.decompose(scale, quatRotation, position);
  89427. }
  89428. if (this.rotationQuaternion) {
  89429. this.rotationQuaternion.copyFrom(quatRotation);
  89430. }
  89431. else {
  89432. quatRotation.toEulerAnglesToRef(this.rotation);
  89433. }
  89434. this.scaling.copyFrom(scale);
  89435. this.position.copyFrom(position);
  89436. this.parent = node;
  89437. return this;
  89438. };
  89439. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  89440. /**
  89441. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89442. */
  89443. get: function () {
  89444. return this._nonUniformScaling;
  89445. },
  89446. enumerable: true,
  89447. configurable: true
  89448. });
  89449. /** @hidden */
  89450. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  89451. if (this._nonUniformScaling === value) {
  89452. return false;
  89453. }
  89454. this._nonUniformScaling = value;
  89455. return true;
  89456. };
  89457. /**
  89458. * Attach the current TransformNode to another TransformNode associated with a bone
  89459. * @param bone Bone affecting the TransformNode
  89460. * @param affectedTransformNode TransformNode associated with the bone
  89461. * @returns this object
  89462. */
  89463. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  89464. this._transformToBoneReferal = affectedTransformNode;
  89465. this.parent = bone;
  89466. if (bone.getWorldMatrix().determinant() < 0) {
  89467. this.scalingDeterminant *= -1;
  89468. }
  89469. return this;
  89470. };
  89471. /**
  89472. * Detach the transform node if its associated with a bone
  89473. * @returns this object
  89474. */
  89475. TransformNode.prototype.detachFromBone = function () {
  89476. if (!this.parent) {
  89477. return this;
  89478. }
  89479. if (this.parent.getWorldMatrix().determinant() < 0) {
  89480. this.scalingDeterminant *= -1;
  89481. }
  89482. this._transformToBoneReferal = null;
  89483. this.parent = null;
  89484. return this;
  89485. };
  89486. /**
  89487. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89488. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89489. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89490. * The passed axis is also normalized.
  89491. * @param axis the axis to rotate around
  89492. * @param amount the amount to rotate in radians
  89493. * @param space Space to rotate in (Default: local)
  89494. * @returns the TransformNode.
  89495. */
  89496. TransformNode.prototype.rotate = function (axis, amount, space) {
  89497. axis.normalize();
  89498. if (!this.rotationQuaternion) {
  89499. this.rotationQuaternion = this.rotation.toQuaternion();
  89500. this.rotation.setAll(0);
  89501. }
  89502. var rotationQuaternion;
  89503. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89504. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89505. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  89506. }
  89507. else {
  89508. if (this.parent) {
  89509. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89510. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89511. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  89512. }
  89513. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89514. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89515. }
  89516. return this;
  89517. };
  89518. /**
  89519. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89520. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89521. * The passed axis is also normalized. .
  89522. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89523. * @param point the point to rotate around
  89524. * @param axis the axis to rotate around
  89525. * @param amount the amount to rotate in radians
  89526. * @returns the TransformNode
  89527. */
  89528. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  89529. axis.normalize();
  89530. if (!this.rotationQuaternion) {
  89531. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  89532. this.rotation.setAll(0);
  89533. }
  89534. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89535. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89536. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  89537. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89538. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]; // T
  89539. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]; // T'
  89540. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]; // R
  89541. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[3]; // T' x R x T
  89542. point.subtractToRef(this.position, tmpVector);
  89543. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  89544. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  89545. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  89546. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  89547. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  89548. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  89549. this.position.addInPlace(finalTranslation);
  89550. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89551. return this;
  89552. };
  89553. /**
  89554. * Translates the mesh along the axis vector for the passed distance in the given space.
  89555. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89556. * @param axis the axis to translate in
  89557. * @param distance the distance to translate
  89558. * @param space Space to rotate in (Default: local)
  89559. * @returns the TransformNode.
  89560. */
  89561. TransformNode.prototype.translate = function (axis, distance, space) {
  89562. var displacementVector = axis.scale(distance);
  89563. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89564. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  89565. this.setPositionWithLocalVector(tempV3);
  89566. }
  89567. else {
  89568. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  89569. }
  89570. return this;
  89571. };
  89572. /**
  89573. * Adds a rotation step to the mesh current rotation.
  89574. * x, y, z are Euler angles expressed in radians.
  89575. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89576. * This means this rotation is made in the mesh local space only.
  89577. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89578. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89579. * ```javascript
  89580. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89581. * ```
  89582. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89583. * 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.
  89584. * @param x Rotation to add
  89585. * @param y Rotation to add
  89586. * @param z Rotation to add
  89587. * @returns the TransformNode.
  89588. */
  89589. TransformNode.prototype.addRotation = function (x, y, z) {
  89590. var rotationQuaternion;
  89591. if (this.rotationQuaternion) {
  89592. rotationQuaternion = this.rotationQuaternion;
  89593. }
  89594. else {
  89595. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  89596. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  89597. }
  89598. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89599. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  89600. rotationQuaternion.multiplyInPlace(accumulation);
  89601. if (!this.rotationQuaternion) {
  89602. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  89603. }
  89604. return this;
  89605. };
  89606. /**
  89607. * Computes the world matrix of the node
  89608. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89609. * @returns the world matrix
  89610. */
  89611. TransformNode.prototype.computeWorldMatrix = function (force) {
  89612. if (this._isWorldMatrixFrozen) {
  89613. return this._worldMatrix;
  89614. }
  89615. if (!force && this.isSynchronized()) {
  89616. this._currentRenderId = this.getScene().getRenderId();
  89617. return this._worldMatrix;
  89618. }
  89619. this._updateCache();
  89620. this._cache.position.copyFrom(this.position);
  89621. this._cache.scaling.copyFrom(this.scaling);
  89622. this._cache.pivotMatrixUpdated = false;
  89623. this._cache.billboardMode = this.billboardMode;
  89624. this._cache.infiniteDistance = this.infiniteDistance;
  89625. this._currentRenderId = this.getScene().getRenderId();
  89626. this._childRenderId = this.getScene().getRenderId();
  89627. this._isDirty = false;
  89628. // Scaling
  89629. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]);
  89630. // Rotation
  89631. //rotate, if quaternion is set and rotation was used
  89632. if (this.rotationQuaternion) {
  89633. var len = this.rotation.length();
  89634. if (len) {
  89635. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  89636. this.rotation.copyFromFloats(0, 0, 0);
  89637. }
  89638. }
  89639. if (this.rotationQuaternion) {
  89640. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89641. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  89642. }
  89643. else {
  89644. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89645. this._cache.rotation.copyFrom(this.rotation);
  89646. }
  89647. // Translation
  89648. var camera = this.getScene().activeCamera;
  89649. if (this.infiniteDistance && !this.parent && camera) {
  89650. var cameraWorldMatrix = camera.getWorldMatrix();
  89651. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  89652. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  89653. }
  89654. else {
  89655. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  89656. }
  89657. // Composing transformations
  89658. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4]);
  89659. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89660. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  89661. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  89662. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  89663. // Need to decompose each rotation here
  89664. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  89665. if (this.parent && this.parent.getWorldMatrix) {
  89666. if (this._transformToBoneReferal) {
  89667. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89668. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6], currentPosition);
  89669. }
  89670. else {
  89671. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  89672. }
  89673. }
  89674. else {
  89675. currentPosition.copyFrom(this.position);
  89676. }
  89677. currentPosition.subtractInPlace(camera.globalPosition);
  89678. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  89679. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  89680. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  89681. }
  89682. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  89683. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  89684. }
  89685. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  89686. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  89687. }
  89688. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89689. }
  89690. else {
  89691. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  89692. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  89693. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89694. }
  89695. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89696. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89697. }
  89698. // Post multiply inverse of pivotMatrix
  89699. if (this._postMultiplyPivotMatrix) {
  89700. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89701. }
  89702. // Local world
  89703. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2], this._localMatrix);
  89704. // Parent
  89705. if (this.parent && this.parent.getWorldMatrix) {
  89706. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89707. if (this._transformToBoneReferal) {
  89708. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89709. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89710. }
  89711. else {
  89712. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  89713. }
  89714. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89715. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89716. this._worldMatrix.copyFrom(this._localMatrix);
  89717. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89718. }
  89719. else {
  89720. if (this._transformToBoneReferal) {
  89721. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89722. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  89723. }
  89724. else {
  89725. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  89726. }
  89727. }
  89728. this._markSyncedWithParent();
  89729. }
  89730. else {
  89731. this._worldMatrix.copyFrom(this._localMatrix);
  89732. }
  89733. // Normal matrix
  89734. if (!this.ignoreNonUniformScaling) {
  89735. if (this.scaling.isNonUniform) {
  89736. this._updateNonUniformScalingState(true);
  89737. }
  89738. else if (this.parent && this.parent._nonUniformScaling) {
  89739. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  89740. }
  89741. else {
  89742. this._updateNonUniformScalingState(false);
  89743. }
  89744. }
  89745. else {
  89746. this._updateNonUniformScalingState(false);
  89747. }
  89748. this._afterComputeWorldMatrix();
  89749. // Absolute position
  89750. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  89751. // Callbacks
  89752. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  89753. if (!this._poseMatrix) {
  89754. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._worldMatrix);
  89755. }
  89756. // Cache the determinant
  89757. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  89758. return this._worldMatrix;
  89759. };
  89760. TransformNode.prototype._afterComputeWorldMatrix = function () {
  89761. };
  89762. /**
  89763. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  89764. * @param func callback function to add
  89765. *
  89766. * @returns the TransformNode.
  89767. */
  89768. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  89769. this.onAfterWorldMatrixUpdateObservable.add(func);
  89770. return this;
  89771. };
  89772. /**
  89773. * Removes a registered callback function.
  89774. * @param func callback function to remove
  89775. * @returns the TransformNode.
  89776. */
  89777. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  89778. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  89779. return this;
  89780. };
  89781. /**
  89782. * Gets the position of the current mesh in camera space
  89783. * @param camera defines the camera to use
  89784. * @returns a position
  89785. */
  89786. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  89787. if (camera === void 0) { camera = null; }
  89788. if (!camera) {
  89789. camera = this.getScene().activeCamera;
  89790. }
  89791. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  89792. };
  89793. /**
  89794. * Returns the distance from the mesh to the active camera
  89795. * @param camera defines the camera to use
  89796. * @returns the distance
  89797. */
  89798. TransformNode.prototype.getDistanceToCamera = function (camera) {
  89799. if (camera === void 0) { camera = null; }
  89800. if (!camera) {
  89801. camera = this.getScene().activeCamera;
  89802. }
  89803. return this.absolutePosition.subtract(camera.position).length();
  89804. };
  89805. /**
  89806. * Clone the current transform node
  89807. * @param name Name of the new clone
  89808. * @param newParent New parent for the clone
  89809. * @param doNotCloneChildren Do not clone children hierarchy
  89810. * @returns the new transform node
  89811. */
  89812. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  89813. var _this = this;
  89814. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  89815. result.name = name;
  89816. result.id = name;
  89817. if (newParent) {
  89818. result.parent = newParent;
  89819. }
  89820. if (!doNotCloneChildren) {
  89821. // Children
  89822. var directDescendants = this.getDescendants(true);
  89823. for (var index = 0; index < directDescendants.length; index++) {
  89824. var child = directDescendants[index];
  89825. if (child.clone) {
  89826. child.clone(name + "." + child.name, result);
  89827. }
  89828. }
  89829. }
  89830. return result;
  89831. };
  89832. /**
  89833. * Serializes the objects information.
  89834. * @param currentSerializationObject defines the object to serialize in
  89835. * @returns the serialized object
  89836. */
  89837. TransformNode.prototype.serialize = function (currentSerializationObject) {
  89838. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  89839. serializationObject.type = this.getClassName();
  89840. // Parent
  89841. if (this.parent) {
  89842. serializationObject.parentId = this.parent.id;
  89843. }
  89844. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].HasTags(this)) {
  89845. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  89846. }
  89847. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  89848. serializationObject.isEnabled = this.isEnabled();
  89849. // Parent
  89850. if (this.parent) {
  89851. serializationObject.parentId = this.parent.id;
  89852. }
  89853. return serializationObject;
  89854. };
  89855. // Statics
  89856. /**
  89857. * Returns a new TransformNode object parsed from the source provided.
  89858. * @param parsedTransformNode is the source.
  89859. * @param scene the scne the object belongs to
  89860. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  89861. * @returns a new TransformNode object parsed from the source provided.
  89862. */
  89863. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  89864. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  89865. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  89866. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(transformNode, parsedTransformNode.tags);
  89867. }
  89868. if (parsedTransformNode.localMatrix) {
  89869. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  89870. }
  89871. else if (parsedTransformNode.pivotMatrix) {
  89872. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  89873. }
  89874. transformNode.setEnabled(parsedTransformNode.isEnabled);
  89875. // Parent
  89876. if (parsedTransformNode.parentId) {
  89877. transformNode._waitingParentId = parsedTransformNode.parentId;
  89878. }
  89879. return transformNode;
  89880. };
  89881. /**
  89882. * Get all child-transformNodes of this node
  89883. * @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
  89884. * @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
  89885. * @returns an array of TransformNode
  89886. */
  89887. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  89888. var results = [];
  89889. this._getDescendants(results, directDescendantsOnly, function (node) {
  89890. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  89891. });
  89892. return results;
  89893. };
  89894. /**
  89895. * Releases resources associated with this transform node.
  89896. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89897. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89898. */
  89899. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  89900. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  89901. // Animations
  89902. this.getScene().stopAnimation(this);
  89903. // Remove from scene
  89904. this.getScene().removeTransformNode(this);
  89905. this.onAfterWorldMatrixUpdateObservable.clear();
  89906. if (doNotRecurse) {
  89907. var transformNodes = this.getChildTransformNodes(true);
  89908. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  89909. var transformNode = transformNodes_1[_i];
  89910. transformNode.parent = null;
  89911. transformNode.computeWorldMatrix(true);
  89912. }
  89913. }
  89914. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  89915. };
  89916. // Statics
  89917. /**
  89918. * Object will not rotate to face the camera
  89919. */
  89920. TransformNode.BILLBOARDMODE_NONE = 0;
  89921. /**
  89922. * Object will rotate to face the camera but only on the x axis
  89923. */
  89924. TransformNode.BILLBOARDMODE_X = 1;
  89925. /**
  89926. * Object will rotate to face the camera but only on the y axis
  89927. */
  89928. TransformNode.BILLBOARDMODE_Y = 2;
  89929. /**
  89930. * Object will rotate to face the camera but only on the z axis
  89931. */
  89932. TransformNode.BILLBOARDMODE_Z = 4;
  89933. /**
  89934. * Object will rotate to face the camera
  89935. */
  89936. TransformNode.BILLBOARDMODE_ALL = 7;
  89937. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 0);
  89938. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  89939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  89941. ], TransformNode.prototype, "_position", void 0);
  89942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  89944. ], TransformNode.prototype, "_rotation", void 0);
  89945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  89947. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  89948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  89950. ], TransformNode.prototype, "_scaling", void 0);
  89951. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  89953. ], TransformNode.prototype, "billboardMode", void 0);
  89954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  89956. ], TransformNode.prototype, "scalingDeterminant", void 0);
  89957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  89959. ], TransformNode.prototype, "infiniteDistance", void 0);
  89960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  89961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  89962. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  89963. return TransformNode;
  89964. }(_node__WEBPACK_IMPORTED_MODULE_5__["Node"]));
  89965. /***/ }),
  89966. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  89967. /*!***************************************************************!*\
  89968. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  89969. \***************************************************************/
  89970. /*! exports provided: CubeMapToSphericalPolynomialTools */
  89971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89972. "use strict";
  89973. __webpack_require__.r(__webpack_exports__);
  89974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  89975. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  89976. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  89977. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  89978. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  89979. var FileFaceOrientation = /** @class */ (function () {
  89980. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  89981. this.name = name;
  89982. this.worldAxisForNormal = worldAxisForNormal;
  89983. this.worldAxisForFileX = worldAxisForFileX;
  89984. this.worldAxisForFileY = worldAxisForFileY;
  89985. }
  89986. return FileFaceOrientation;
  89987. }());
  89988. /**
  89989. * Helper class dealing with the extraction of spherical polynomial dataArray
  89990. * from a cube map.
  89991. */
  89992. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  89993. function CubeMapToSphericalPolynomialTools() {
  89994. }
  89995. /**
  89996. * Converts a texture to the according Spherical Polynomial data.
  89997. * This extracts the first 3 orders only as they are the only one used in the lighting.
  89998. *
  89999. * @param texture The texture to extract the information from.
  90000. * @return The Spherical Polynomial data.
  90001. */
  90002. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  90003. if (!texture.isCube) {
  90004. // Only supports cube Textures currently.
  90005. return null;
  90006. }
  90007. var size = texture.getSize().width;
  90008. var right = texture.readPixels(0);
  90009. var left = texture.readPixels(1);
  90010. var up;
  90011. var down;
  90012. if (texture.isRenderTarget) {
  90013. up = texture.readPixels(3);
  90014. down = texture.readPixels(2);
  90015. }
  90016. else {
  90017. up = texture.readPixels(2);
  90018. down = texture.readPixels(3);
  90019. }
  90020. var front = texture.readPixels(4);
  90021. var back = texture.readPixels(5);
  90022. var gammaSpace = texture.gammaSpace;
  90023. // Always read as RGBA.
  90024. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  90025. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  90026. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90027. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  90028. }
  90029. var cubeInfo = {
  90030. size: size,
  90031. right: right,
  90032. left: left,
  90033. up: up,
  90034. down: down,
  90035. front: front,
  90036. back: back,
  90037. format: format,
  90038. type: type,
  90039. gammaSpace: gammaSpace,
  90040. };
  90041. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  90042. };
  90043. /**
  90044. * Converts a cubemap to the according Spherical Polynomial data.
  90045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90046. *
  90047. * @param cubeInfo The Cube map to extract the information from.
  90048. * @return The Spherical Polynomial data.
  90049. */
  90050. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  90051. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  90052. var totalSolidAngle = 0.0;
  90053. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  90054. var du = 2.0 / cubeInfo.size;
  90055. var dv = du;
  90056. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  90057. var minUV = du * 0.5 - 1.0;
  90058. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  90059. var fileFace = this.FileFaces[faceIndex];
  90060. var dataArray = cubeInfo[fileFace.name];
  90061. var v = minUV;
  90062. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  90063. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  90064. // Because SP is still linear, so summation is fine in that basis.
  90065. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  90066. for (var y = 0; y < cubeInfo.size; y++) {
  90067. var u = minUV;
  90068. for (var x = 0; x < cubeInfo.size; x++) {
  90069. // World direction (not normalised)
  90070. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  90071. worldDirection.normalize();
  90072. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  90073. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  90074. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  90075. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  90076. // Handle Integer types.
  90077. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90078. r /= 255;
  90079. g /= 255;
  90080. b /= 255;
  90081. }
  90082. // Handle Gamma space textures.
  90083. if (cubeInfo.gammaSpace) {
  90084. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90085. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90086. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90087. }
  90088. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  90089. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  90090. totalSolidAngle += deltaSolidAngle;
  90091. u += du;
  90092. }
  90093. v += dv;
  90094. }
  90095. }
  90096. // Solid angle for entire sphere is 4*pi
  90097. var sphereSolidAngle = 4.0 * Math.PI;
  90098. // Adjust the solid angle to allow for how many faces we processed.
  90099. var facesProcessed = 6.0;
  90100. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  90101. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  90102. // This is needed because the numerical integration over the cube uses a
  90103. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  90104. // and also to compensate for accumulative error due to float precision in the summation.
  90105. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  90106. sphericalHarmonics.scale(correctionFactor);
  90107. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  90108. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  90109. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  90110. };
  90111. CubeMapToSphericalPolynomialTools.FileFaces = [
  90112. 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)),
  90113. 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)),
  90114. 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)),
  90115. 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)),
  90116. 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)),
  90117. 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
  90118. ];
  90119. return CubeMapToSphericalPolynomialTools;
  90120. }());
  90121. /***/ }),
  90122. /***/ "./Misc/HighDynamicRange/hdr.ts":
  90123. /*!**************************************!*\
  90124. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  90125. \**************************************/
  90126. /*! exports provided: HDRTools */
  90127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90128. "use strict";
  90129. __webpack_require__.r(__webpack_exports__);
  90130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  90131. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90132. /**
  90133. * This groups tools to convert HDR texture to native colors array.
  90134. */
  90135. var HDRTools = /** @class */ (function () {
  90136. function HDRTools() {
  90137. }
  90138. HDRTools.Ldexp = function (mantissa, exponent) {
  90139. if (exponent > 1023) {
  90140. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  90141. }
  90142. if (exponent < -1074) {
  90143. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  90144. }
  90145. return mantissa * Math.pow(2, exponent);
  90146. };
  90147. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  90148. if (exponent > 0) { /*nonzero pixel*/
  90149. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  90150. float32array[index + 0] = red * exponent;
  90151. float32array[index + 1] = green * exponent;
  90152. float32array[index + 2] = blue * exponent;
  90153. }
  90154. else {
  90155. float32array[index + 0] = 0;
  90156. float32array[index + 1] = 0;
  90157. float32array[index + 2] = 0;
  90158. }
  90159. };
  90160. HDRTools.readStringLine = function (uint8array, startIndex) {
  90161. var line = "";
  90162. var character = "";
  90163. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  90164. character = String.fromCharCode(uint8array[i]);
  90165. if (character == "\n") {
  90166. break;
  90167. }
  90168. line += character;
  90169. }
  90170. return line;
  90171. };
  90172. /**
  90173. * Reads header information from an RGBE texture stored in a native array.
  90174. * More information on this format are available here:
  90175. * https://en.wikipedia.org/wiki/RGBE_image_format
  90176. *
  90177. * @param uint8array The binary file stored in native array.
  90178. * @return The header information.
  90179. */
  90180. HDRTools.RGBE_ReadHeader = function (uint8array) {
  90181. var height = 0;
  90182. var width = 0;
  90183. var line = this.readStringLine(uint8array, 0);
  90184. if (line[0] != '#' || line[1] != '?') {
  90185. throw "Bad HDR Format.";
  90186. }
  90187. var endOfHeader = false;
  90188. var findFormat = false;
  90189. var lineIndex = 0;
  90190. do {
  90191. lineIndex += (line.length + 1);
  90192. line = this.readStringLine(uint8array, lineIndex);
  90193. if (line == "FORMAT=32-bit_rle_rgbe") {
  90194. findFormat = true;
  90195. }
  90196. else if (line.length == 0) {
  90197. endOfHeader = true;
  90198. }
  90199. } while (!endOfHeader);
  90200. if (!findFormat) {
  90201. throw "HDR Bad header format, unsupported FORMAT";
  90202. }
  90203. lineIndex += (line.length + 1);
  90204. line = this.readStringLine(uint8array, lineIndex);
  90205. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  90206. var match = sizeRegexp.exec(line);
  90207. // TODO. Support +Y and -X if needed.
  90208. if (!match || match.length < 3) {
  90209. throw "HDR Bad header format, no size";
  90210. }
  90211. width = parseInt(match[2]);
  90212. height = parseInt(match[1]);
  90213. if (width < 8 || width > 0x7fff) {
  90214. throw "HDR Bad header format, unsupported size";
  90215. }
  90216. lineIndex += (line.length + 1);
  90217. return {
  90218. height: height,
  90219. width: width,
  90220. dataPosition: lineIndex
  90221. };
  90222. };
  90223. /**
  90224. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  90225. * This RGBE texture needs to store the information as a panorama.
  90226. *
  90227. * More information on this format are available here:
  90228. * https://en.wikipedia.org/wiki/RGBE_image_format
  90229. *
  90230. * @param buffer The binary file stored in an array buffer.
  90231. * @param size The expected size of the extracted cubemap.
  90232. * @return The Cube Map information.
  90233. */
  90234. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  90235. var uint8array = new Uint8Array(buffer);
  90236. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  90237. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90238. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  90239. return cubeMapData;
  90240. };
  90241. /**
  90242. * Returns the pixels data extracted from an RGBE texture.
  90243. * This pixels will be stored left to right up to down in the R G B order in one array.
  90244. *
  90245. * More information on this format are available here:
  90246. * https://en.wikipedia.org/wiki/RGBE_image_format
  90247. *
  90248. * @param uint8array The binary file stored in an array buffer.
  90249. * @param hdrInfo The header information of the file.
  90250. * @return The pixels data in RGB right to left up to down order.
  90251. */
  90252. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  90253. // Keep for multi format supports.
  90254. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90255. };
  90256. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  90257. var num_scanlines = hdrInfo.height;
  90258. var scanline_width = hdrInfo.width;
  90259. var a, b, c, d, count;
  90260. var dataIndex = hdrInfo.dataPosition;
  90261. var index = 0, endIndex = 0, i = 0;
  90262. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  90263. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  90264. // 3 channels of 4 bytes per pixel in float.
  90265. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  90266. var resultArray = new Float32Array(resultBuffer);
  90267. // read in each successive scanline
  90268. while (num_scanlines > 0) {
  90269. a = uint8array[dataIndex++];
  90270. b = uint8array[dataIndex++];
  90271. c = uint8array[dataIndex++];
  90272. d = uint8array[dataIndex++];
  90273. if (a != 2 || b != 2 || (c & 0x80)) {
  90274. // this file is not run length encoded
  90275. throw "HDR Bad header format, not RLE";
  90276. }
  90277. if (((c << 8) | d) != scanline_width) {
  90278. throw "HDR Bad header format, wrong scan line width";
  90279. }
  90280. index = 0;
  90281. // read each of the four channels for the scanline into the buffer
  90282. for (i = 0; i < 4; i++) {
  90283. endIndex = (i + 1) * scanline_width;
  90284. while (index < endIndex) {
  90285. a = uint8array[dataIndex++];
  90286. b = uint8array[dataIndex++];
  90287. if (a > 128) {
  90288. // a run of the same value
  90289. count = a - 128;
  90290. if ((count == 0) || (count > endIndex - index)) {
  90291. throw "HDR Bad Format, bad scanline data (run)";
  90292. }
  90293. while (count-- > 0) {
  90294. scanLineArray[index++] = b;
  90295. }
  90296. }
  90297. else {
  90298. // a non-run
  90299. count = a;
  90300. if ((count == 0) || (count > endIndex - index)) {
  90301. throw "HDR Bad Format, bad scanline data (non-run)";
  90302. }
  90303. scanLineArray[index++] = b;
  90304. if (--count > 0) {
  90305. for (var j = 0; j < count; j++) {
  90306. scanLineArray[index++] = uint8array[dataIndex++];
  90307. }
  90308. }
  90309. }
  90310. }
  90311. }
  90312. // now convert data from buffer into floats
  90313. for (i = 0; i < scanline_width; i++) {
  90314. a = scanLineArray[i];
  90315. b = scanLineArray[i + scanline_width];
  90316. c = scanLineArray[i + 2 * scanline_width];
  90317. d = scanLineArray[i + 3 * scanline_width];
  90318. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  90319. }
  90320. num_scanlines--;
  90321. }
  90322. return resultArray;
  90323. };
  90324. return HDRTools;
  90325. }());
  90326. /***/ }),
  90327. /***/ "./Misc/HighDynamicRange/index.ts":
  90328. /*!****************************************!*\
  90329. !*** ./Misc/HighDynamicRange/index.ts ***!
  90330. \****************************************/
  90331. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  90332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90333. "use strict";
  90334. __webpack_require__.r(__webpack_exports__);
  90335. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  90336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  90337. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  90338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  90339. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  90341. /***/ }),
  90342. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  90343. /*!****************************************************!*\
  90344. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  90345. \****************************************************/
  90346. /*! exports provided: PanoramaToCubeMapTools */
  90347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90348. "use strict";
  90349. __webpack_require__.r(__webpack_exports__);
  90350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  90351. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90352. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90353. /**
  90354. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  90355. */
  90356. var PanoramaToCubeMapTools = /** @class */ (function () {
  90357. function PanoramaToCubeMapTools() {
  90358. }
  90359. /**
  90360. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  90361. *
  90362. * @param float32Array The source data.
  90363. * @param inputWidth The width of the input panorama.
  90364. * @param inputHeight The height of the input panorama.
  90365. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  90366. * @return The cubemap data
  90367. */
  90368. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  90369. if (!float32Array) {
  90370. throw "ConvertPanoramaToCubemap: input cannot be null";
  90371. }
  90372. if (float32Array.length != inputWidth * inputHeight * 3) {
  90373. throw "ConvertPanoramaToCubemap: input size is wrong";
  90374. }
  90375. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  90376. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  90377. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  90378. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  90379. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  90380. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  90381. return {
  90382. front: textureFront,
  90383. back: textureBack,
  90384. left: textureLeft,
  90385. right: textureRight,
  90386. up: textureUp,
  90387. down: textureDown,
  90388. size: size,
  90389. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  90390. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  90391. gammaSpace: false,
  90392. };
  90393. };
  90394. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  90395. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  90396. var textureArray = new Float32Array(buffer);
  90397. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  90398. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  90399. var dy = 1 / texSize;
  90400. var fy = 0;
  90401. for (var y = 0; y < texSize; y++) {
  90402. var xv1 = faceData[0];
  90403. var xv2 = faceData[2];
  90404. for (var x = 0; x < texSize; x++) {
  90405. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  90406. v.normalize();
  90407. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  90408. // 3 channels per pixels
  90409. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  90410. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  90411. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  90412. xv1 = xv1.add(rotDX1);
  90413. xv2 = xv2.add(rotDX2);
  90414. }
  90415. fy += dy;
  90416. }
  90417. return textureArray;
  90418. };
  90419. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  90420. var theta = Math.atan2(vDir.z, vDir.x);
  90421. var phi = Math.acos(vDir.y);
  90422. while (theta < -Math.PI) {
  90423. theta += 2 * Math.PI;
  90424. }
  90425. while (theta > Math.PI) {
  90426. theta -= 2 * Math.PI;
  90427. }
  90428. var dx = theta / Math.PI;
  90429. var dy = phi / Math.PI;
  90430. // recenter.
  90431. dx = dx * 0.5 + 0.5;
  90432. var px = Math.round(dx * inputWidth);
  90433. if (px < 0) {
  90434. px = 0;
  90435. }
  90436. else if (px >= inputWidth) {
  90437. px = inputWidth - 1;
  90438. }
  90439. var py = Math.round(dy * inputHeight);
  90440. if (py < 0) {
  90441. py = 0;
  90442. }
  90443. else if (py >= inputHeight) {
  90444. py = inputHeight - 1;
  90445. }
  90446. var inputY = (inputHeight - py - 1);
  90447. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  90448. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  90449. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  90450. return {
  90451. r: r,
  90452. g: g,
  90453. b: b
  90454. };
  90455. };
  90456. PanoramaToCubeMapTools.FACE_FRONT = [
  90457. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90458. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90459. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90460. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  90461. ];
  90462. PanoramaToCubeMapTools.FACE_BACK = [
  90463. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90464. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90465. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  90466. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  90467. ];
  90468. PanoramaToCubeMapTools.FACE_RIGHT = [
  90469. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90470. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90471. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90472. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90473. ];
  90474. PanoramaToCubeMapTools.FACE_LEFT = [
  90475. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90476. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90477. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90478. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  90479. ];
  90480. PanoramaToCubeMapTools.FACE_DOWN = [
  90481. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90482. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90483. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90484. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90485. ];
  90486. PanoramaToCubeMapTools.FACE_UP = [
  90487. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90488. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90489. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90490. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  90491. ];
  90492. return PanoramaToCubeMapTools;
  90493. }());
  90494. /***/ }),
  90495. /***/ "./Misc/andOrNotEvaluator.ts":
  90496. /*!***********************************!*\
  90497. !*** ./Misc/andOrNotEvaluator.ts ***!
  90498. \***********************************/
  90499. /*! exports provided: AndOrNotEvaluator */
  90500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90501. "use strict";
  90502. __webpack_require__.r(__webpack_exports__);
  90503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  90504. /**
  90505. * Class used to evalaute queries containing `and` and `or` operators
  90506. */
  90507. var AndOrNotEvaluator = /** @class */ (function () {
  90508. function AndOrNotEvaluator() {
  90509. }
  90510. /**
  90511. * Evaluate a query
  90512. * @param query defines the query to evaluate
  90513. * @param evaluateCallback defines the callback used to filter result
  90514. * @returns true if the query matches
  90515. */
  90516. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  90517. if (!query.match(/\([^\(\)]*\)/g)) {
  90518. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  90519. }
  90520. else {
  90521. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  90522. // remove parenthesis
  90523. r = r.slice(1, r.length - 1);
  90524. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  90525. });
  90526. }
  90527. if (query === "true") {
  90528. return true;
  90529. }
  90530. if (query === "false") {
  90531. return false;
  90532. }
  90533. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  90534. };
  90535. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  90536. evaluateCallback = evaluateCallback || (function (r) {
  90537. return r === "true" ? true : false;
  90538. });
  90539. var result;
  90540. var or = parenthesisContent.split("||");
  90541. for (var i in or) {
  90542. if (or.hasOwnProperty(i)) {
  90543. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  90544. var and = ori.split("&&");
  90545. if (and.length > 1) {
  90546. for (var j = 0; j < and.length; ++j) {
  90547. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  90548. if (andj !== "true" && andj !== "false") {
  90549. if (andj[0] === "!") {
  90550. result = !evaluateCallback(andj.substring(1));
  90551. }
  90552. else {
  90553. result = evaluateCallback(andj);
  90554. }
  90555. }
  90556. else {
  90557. result = andj === "true" ? true : false;
  90558. }
  90559. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  90560. ori = "false";
  90561. break;
  90562. }
  90563. }
  90564. }
  90565. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  90566. result = true;
  90567. break;
  90568. }
  90569. // result equals false (or undefined)
  90570. if (ori !== "true" && ori !== "false") {
  90571. if (ori[0] === "!") {
  90572. result = !evaluateCallback(ori.substring(1));
  90573. }
  90574. else {
  90575. result = evaluateCallback(ori);
  90576. }
  90577. }
  90578. else {
  90579. result = ori === "true" ? true : false;
  90580. }
  90581. }
  90582. }
  90583. // the whole parenthesis scope is replaced by 'true' or 'false'
  90584. return result ? "true" : "false";
  90585. };
  90586. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  90587. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  90588. // remove whitespaces
  90589. r = r.replace(/[\s]/g, function () { return ""; });
  90590. return r.length % 2 ? "!" : "";
  90591. });
  90592. booleanString = booleanString.trim();
  90593. if (booleanString === "!true") {
  90594. booleanString = "false";
  90595. }
  90596. else if (booleanString === "!false") {
  90597. booleanString = "true";
  90598. }
  90599. return booleanString;
  90600. };
  90601. return AndOrNotEvaluator;
  90602. }());
  90603. /***/ }),
  90604. /***/ "./Misc/arrayTools.ts":
  90605. /*!****************************!*\
  90606. !*** ./Misc/arrayTools.ts ***!
  90607. \****************************/
  90608. /*! exports provided: ArrayTools */
  90609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90610. "use strict";
  90611. __webpack_require__.r(__webpack_exports__);
  90612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  90613. /**
  90614. * Class containing a set of static utilities functions for arrays.
  90615. */
  90616. var ArrayTools = /** @class */ (function () {
  90617. function ArrayTools() {
  90618. }
  90619. /**
  90620. * Returns an array of the given size filled with element built from the given constructor and the paramters
  90621. * @param size the number of element to construct and put in the array
  90622. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  90623. * @returns a new array filled with new objects
  90624. */
  90625. ArrayTools.BuildArray = function (size, itemBuilder) {
  90626. var a = [];
  90627. for (var i = 0; i < size; ++i) {
  90628. a.push(itemBuilder());
  90629. }
  90630. return a;
  90631. };
  90632. return ArrayTools;
  90633. }());
  90634. /***/ }),
  90635. /***/ "./Misc/assetsManager.ts":
  90636. /*!*******************************!*\
  90637. !*** ./Misc/assetsManager.ts ***!
  90638. \*******************************/
  90639. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  90640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90641. "use strict";
  90642. __webpack_require__.r(__webpack_exports__);
  90643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  90644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  90645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  90646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  90647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  90648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  90649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  90650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  90651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  90652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  90653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  90654. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90655. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  90656. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  90657. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  90658. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  90659. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  90660. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  90661. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  90662. /**
  90663. * Defines the list of states available for a task inside a AssetsManager
  90664. */
  90665. var AssetTaskState;
  90666. (function (AssetTaskState) {
  90667. /**
  90668. * Initialization
  90669. */
  90670. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  90671. /**
  90672. * Running
  90673. */
  90674. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  90675. /**
  90676. * Done
  90677. */
  90678. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  90679. /**
  90680. * Error
  90681. */
  90682. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  90683. })(AssetTaskState || (AssetTaskState = {}));
  90684. /**
  90685. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  90686. */
  90687. var AbstractAssetTask = /** @class */ (function () {
  90688. /**
  90689. * Creates a new AssetsManager
  90690. * @param name defines the name of the task
  90691. */
  90692. function AbstractAssetTask(
  90693. /**
  90694. * Task name
  90695. */ name) {
  90696. this.name = name;
  90697. this._isCompleted = false;
  90698. this._taskState = AssetTaskState.INIT;
  90699. }
  90700. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  90701. /**
  90702. * Get if the task is completed
  90703. */
  90704. get: function () {
  90705. return this._isCompleted;
  90706. },
  90707. enumerable: true,
  90708. configurable: true
  90709. });
  90710. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  90711. /**
  90712. * Gets the current state of the task
  90713. */
  90714. get: function () {
  90715. return this._taskState;
  90716. },
  90717. enumerable: true,
  90718. configurable: true
  90719. });
  90720. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  90721. /**
  90722. * Gets the current error object (if task is in error)
  90723. */
  90724. get: function () {
  90725. return this._errorObject;
  90726. },
  90727. enumerable: true,
  90728. configurable: true
  90729. });
  90730. /**
  90731. * Internal only
  90732. * @hidden
  90733. */
  90734. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  90735. if (this._errorObject) {
  90736. return;
  90737. }
  90738. this._errorObject = {
  90739. message: message,
  90740. exception: exception
  90741. };
  90742. };
  90743. /**
  90744. * Execute the current task
  90745. * @param scene defines the scene where you want your assets to be loaded
  90746. * @param onSuccess is a callback called when the task is successfully executed
  90747. * @param onError is a callback called if an error occurs
  90748. */
  90749. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  90750. var _this = this;
  90751. this._taskState = AssetTaskState.RUNNING;
  90752. this.runTask(scene, function () {
  90753. _this.onDoneCallback(onSuccess, onError);
  90754. }, function (msg, exception) {
  90755. _this.onErrorCallback(onError, msg, exception);
  90756. });
  90757. };
  90758. /**
  90759. * Execute the current task
  90760. * @param scene defines the scene where you want your assets to be loaded
  90761. * @param onSuccess is a callback called when the task is successfully executed
  90762. * @param onError is a callback called if an error occurs
  90763. */
  90764. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90765. throw new Error("runTask is not implemented");
  90766. };
  90767. /**
  90768. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  90769. * This can be used with failed tasks that have the reason for failure fixed.
  90770. */
  90771. AbstractAssetTask.prototype.reset = function () {
  90772. this._taskState = AssetTaskState.INIT;
  90773. };
  90774. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  90775. this._taskState = AssetTaskState.ERROR;
  90776. this._errorObject = {
  90777. message: message,
  90778. exception: exception
  90779. };
  90780. if (this.onError) {
  90781. this.onError(this, message, exception);
  90782. }
  90783. onError();
  90784. };
  90785. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  90786. try {
  90787. this._taskState = AssetTaskState.DONE;
  90788. this._isCompleted = true;
  90789. if (this.onSuccess) {
  90790. this.onSuccess(this);
  90791. }
  90792. onSuccess();
  90793. }
  90794. catch (e) {
  90795. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  90796. }
  90797. };
  90798. return AbstractAssetTask;
  90799. }());
  90800. /**
  90801. * Class used to share progress information about assets loading
  90802. */
  90803. var AssetsProgressEvent = /** @class */ (function () {
  90804. /**
  90805. * Creates a AssetsProgressEvent
  90806. * @param remainingCount defines the number of remaining tasks to process
  90807. * @param totalCount defines the total number of tasks
  90808. * @param task defines the task that was just processed
  90809. */
  90810. function AssetsProgressEvent(remainingCount, totalCount, task) {
  90811. this.remainingCount = remainingCount;
  90812. this.totalCount = totalCount;
  90813. this.task = task;
  90814. }
  90815. return AssetsProgressEvent;
  90816. }());
  90817. /**
  90818. * Define a task used by AssetsManager to load meshes
  90819. */
  90820. var MeshAssetTask = /** @class */ (function (_super) {
  90821. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  90822. /**
  90823. * Creates a new MeshAssetTask
  90824. * @param name defines the name of the task
  90825. * @param meshesNames defines the list of mesh's names you want to load
  90826. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  90827. * @param sceneFilename defines the filename of the scene to load from
  90828. */
  90829. function MeshAssetTask(
  90830. /**
  90831. * Defines the name of the task
  90832. */
  90833. name,
  90834. /**
  90835. * Defines the list of mesh's names you want to load
  90836. */
  90837. meshesNames,
  90838. /**
  90839. * Defines the root url to use as a base to load your meshes and associated resources
  90840. */
  90841. rootUrl,
  90842. /**
  90843. * Defines the filename of the scene to load from
  90844. */
  90845. sceneFilename) {
  90846. var _this = _super.call(this, name) || this;
  90847. _this.name = name;
  90848. _this.meshesNames = meshesNames;
  90849. _this.rootUrl = rootUrl;
  90850. _this.sceneFilename = sceneFilename;
  90851. return _this;
  90852. }
  90853. /**
  90854. * Execute the current task
  90855. * @param scene defines the scene where you want your assets to be loaded
  90856. * @param onSuccess is a callback called when the task is successfully executed
  90857. * @param onError is a callback called if an error occurs
  90858. */
  90859. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90860. var _this = this;
  90861. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  90862. _this.loadedMeshes = meshes;
  90863. _this.loadedParticleSystems = particleSystems;
  90864. _this.loadedSkeletons = skeletons;
  90865. _this.loadedAnimationGroups = animationGroups;
  90866. onSuccess();
  90867. }, null, function (scene, message, exception) {
  90868. onError(message, exception);
  90869. });
  90870. };
  90871. return MeshAssetTask;
  90872. }(AbstractAssetTask));
  90873. /**
  90874. * Define a task used by AssetsManager to load text content
  90875. */
  90876. var TextFileAssetTask = /** @class */ (function (_super) {
  90877. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  90878. /**
  90879. * Creates a new TextFileAssetTask object
  90880. * @param name defines the name of the task
  90881. * @param url defines the location of the file to load
  90882. */
  90883. function TextFileAssetTask(
  90884. /**
  90885. * Defines the name of the task
  90886. */
  90887. name,
  90888. /**
  90889. * Defines the location of the file to load
  90890. */
  90891. url) {
  90892. var _this = _super.call(this, name) || this;
  90893. _this.name = name;
  90894. _this.url = url;
  90895. return _this;
  90896. }
  90897. /**
  90898. * Execute the current task
  90899. * @param scene defines the scene where you want your assets to be loaded
  90900. * @param onSuccess is a callback called when the task is successfully executed
  90901. * @param onError is a callback called if an error occurs
  90902. */
  90903. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90904. var _this = this;
  90905. scene._loadFile(this.url, function (data) {
  90906. _this.text = data;
  90907. onSuccess();
  90908. }, undefined, false, false, function (request, exception) {
  90909. if (request) {
  90910. onError(request.status + " " + request.statusText, exception);
  90911. }
  90912. });
  90913. };
  90914. return TextFileAssetTask;
  90915. }(AbstractAssetTask));
  90916. /**
  90917. * Define a task used by AssetsManager to load binary data
  90918. */
  90919. var BinaryFileAssetTask = /** @class */ (function (_super) {
  90920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  90921. /**
  90922. * Creates a new BinaryFileAssetTask object
  90923. * @param name defines the name of the new task
  90924. * @param url defines the location of the file to load
  90925. */
  90926. function BinaryFileAssetTask(
  90927. /**
  90928. * Defines the name of the task
  90929. */
  90930. name,
  90931. /**
  90932. * Defines the location of the file to load
  90933. */
  90934. url) {
  90935. var _this = _super.call(this, name) || this;
  90936. _this.name = name;
  90937. _this.url = url;
  90938. return _this;
  90939. }
  90940. /**
  90941. * Execute the current task
  90942. * @param scene defines the scene where you want your assets to be loaded
  90943. * @param onSuccess is a callback called when the task is successfully executed
  90944. * @param onError is a callback called if an error occurs
  90945. */
  90946. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90947. var _this = this;
  90948. scene._loadFile(this.url, function (data) {
  90949. _this.data = data;
  90950. onSuccess();
  90951. }, undefined, true, true, function (request, exception) {
  90952. if (request) {
  90953. onError(request.status + " " + request.statusText, exception);
  90954. }
  90955. });
  90956. };
  90957. return BinaryFileAssetTask;
  90958. }(AbstractAssetTask));
  90959. /**
  90960. * Define a task used by AssetsManager to load images
  90961. */
  90962. var ImageAssetTask = /** @class */ (function (_super) {
  90963. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  90964. /**
  90965. * Creates a new ImageAssetTask
  90966. * @param name defines the name of the task
  90967. * @param url defines the location of the image to load
  90968. */
  90969. function ImageAssetTask(
  90970. /**
  90971. * Defines the name of the task
  90972. */
  90973. name,
  90974. /**
  90975. * Defines the location of the image to load
  90976. */
  90977. url) {
  90978. var _this = _super.call(this, name) || this;
  90979. _this.name = name;
  90980. _this.url = url;
  90981. return _this;
  90982. }
  90983. /**
  90984. * Execute the current task
  90985. * @param scene defines the scene where you want your assets to be loaded
  90986. * @param onSuccess is a callback called when the task is successfully executed
  90987. * @param onError is a callback called if an error occurs
  90988. */
  90989. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90990. var _this = this;
  90991. var img = new Image();
  90992. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  90993. img.onload = function () {
  90994. _this.image = img;
  90995. onSuccess();
  90996. };
  90997. img.onerror = function (err) {
  90998. onError("Error loading image", err);
  90999. };
  91000. img.src = this.url;
  91001. };
  91002. return ImageAssetTask;
  91003. }(AbstractAssetTask));
  91004. /**
  91005. * Define a task used by AssetsManager to load 2D textures
  91006. */
  91007. var TextureAssetTask = /** @class */ (function (_super) {
  91008. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  91009. /**
  91010. * Creates a new TextureAssetTask object
  91011. * @param name defines the name of the task
  91012. * @param url defines the location of the file to load
  91013. * @param noMipmap defines if mipmap should not be generated (default is false)
  91014. * @param invertY defines if texture must be inverted on Y axis (default is false)
  91015. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91016. */
  91017. function TextureAssetTask(
  91018. /**
  91019. * Defines the name of the task
  91020. */
  91021. name,
  91022. /**
  91023. * Defines the location of the file to load
  91024. */
  91025. url,
  91026. /**
  91027. * Defines if mipmap should not be generated (default is false)
  91028. */
  91029. noMipmap,
  91030. /**
  91031. * Defines if texture must be inverted on Y axis (default is false)
  91032. */
  91033. invertY,
  91034. /**
  91035. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91036. */
  91037. samplingMode) {
  91038. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91039. var _this = _super.call(this, name) || this;
  91040. _this.name = name;
  91041. _this.url = url;
  91042. _this.noMipmap = noMipmap;
  91043. _this.invertY = invertY;
  91044. _this.samplingMode = samplingMode;
  91045. return _this;
  91046. }
  91047. /**
  91048. * Execute the current task
  91049. * @param scene defines the scene where you want your assets to be loaded
  91050. * @param onSuccess is a callback called when the task is successfully executed
  91051. * @param onError is a callback called if an error occurs
  91052. */
  91053. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91054. var onload = function () {
  91055. onSuccess();
  91056. };
  91057. var onerror = function (message, exception) {
  91058. onError(message, exception);
  91059. };
  91060. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  91061. };
  91062. return TextureAssetTask;
  91063. }(AbstractAssetTask));
  91064. /**
  91065. * Define a task used by AssetsManager to load cube textures
  91066. */
  91067. var CubeTextureAssetTask = /** @class */ (function (_super) {
  91068. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  91069. /**
  91070. * Creates a new CubeTextureAssetTask
  91071. * @param name defines the name of the task
  91072. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91073. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91074. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91075. * @param files defines the explicit list of files (undefined by default)
  91076. */
  91077. function CubeTextureAssetTask(
  91078. /**
  91079. * Defines the name of the task
  91080. */
  91081. name,
  91082. /**
  91083. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91084. */
  91085. url,
  91086. /**
  91087. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91088. */
  91089. extensions,
  91090. /**
  91091. * Defines if mipmaps should not be generated (default is false)
  91092. */
  91093. noMipmap,
  91094. /**
  91095. * Defines the explicit list of files (undefined by default)
  91096. */
  91097. files) {
  91098. var _this = _super.call(this, name) || this;
  91099. _this.name = name;
  91100. _this.url = url;
  91101. _this.extensions = extensions;
  91102. _this.noMipmap = noMipmap;
  91103. _this.files = files;
  91104. return _this;
  91105. }
  91106. /**
  91107. * Execute the current task
  91108. * @param scene defines the scene where you want your assets to be loaded
  91109. * @param onSuccess is a callback called when the task is successfully executed
  91110. * @param onError is a callback called if an error occurs
  91111. */
  91112. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91113. var onload = function () {
  91114. onSuccess();
  91115. };
  91116. var onerror = function (message, exception) {
  91117. onError(message, exception);
  91118. };
  91119. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  91120. };
  91121. return CubeTextureAssetTask;
  91122. }(AbstractAssetTask));
  91123. /**
  91124. * Define a task used by AssetsManager to load HDR cube textures
  91125. */
  91126. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  91127. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  91128. /**
  91129. * Creates a new HDRCubeTextureAssetTask object
  91130. * @param name defines the name of the task
  91131. * @param url defines the location of the file to load
  91132. * @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.
  91133. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91134. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91135. * @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)
  91136. * @param reserved Internal use only
  91137. */
  91138. function HDRCubeTextureAssetTask(
  91139. /**
  91140. * Defines the name of the task
  91141. */
  91142. name,
  91143. /**
  91144. * Defines the location of the file to load
  91145. */
  91146. url,
  91147. /**
  91148. * Defines the desired size (the more it increases the longer the generation will be)
  91149. */
  91150. size,
  91151. /**
  91152. * Defines if mipmaps should not be generated (default is false)
  91153. */
  91154. noMipmap,
  91155. /**
  91156. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91157. */
  91158. generateHarmonics,
  91159. /**
  91160. * 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)
  91161. */
  91162. gammaSpace,
  91163. /**
  91164. * Internal Use Only
  91165. */
  91166. reserved) {
  91167. if (noMipmap === void 0) { noMipmap = false; }
  91168. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91169. if (gammaSpace === void 0) { gammaSpace = false; }
  91170. if (reserved === void 0) { reserved = false; }
  91171. var _this = _super.call(this, name) || this;
  91172. _this.name = name;
  91173. _this.url = url;
  91174. _this.size = size;
  91175. _this.noMipmap = noMipmap;
  91176. _this.generateHarmonics = generateHarmonics;
  91177. _this.gammaSpace = gammaSpace;
  91178. _this.reserved = reserved;
  91179. return _this;
  91180. }
  91181. /**
  91182. * Execute the current task
  91183. * @param scene defines the scene where you want your assets to be loaded
  91184. * @param onSuccess is a callback called when the task is successfully executed
  91185. * @param onError is a callback called if an error occurs
  91186. */
  91187. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91188. var onload = function () {
  91189. onSuccess();
  91190. };
  91191. var onerror = function (message, exception) {
  91192. onError(message, exception);
  91193. };
  91194. 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);
  91195. };
  91196. return HDRCubeTextureAssetTask;
  91197. }(AbstractAssetTask));
  91198. /**
  91199. * This class can be used to easily import assets into a scene
  91200. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  91201. */
  91202. var AssetsManager = /** @class */ (function () {
  91203. /**
  91204. * Creates a new AssetsManager
  91205. * @param scene defines the scene to work on
  91206. */
  91207. function AssetsManager(scene) {
  91208. this._isLoading = false;
  91209. this._tasks = new Array();
  91210. this._waitingTasksCount = 0;
  91211. this._totalTasksCount = 0;
  91212. /**
  91213. * Observable called when all tasks are processed
  91214. */
  91215. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91216. /**
  91217. * Observable called when a task had an error
  91218. */
  91219. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91220. /**
  91221. * Observable called when a task is successful
  91222. */
  91223. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91224. /**
  91225. * Observable called when a task is done (whatever the result is)
  91226. */
  91227. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91228. /**
  91229. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  91230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91231. */
  91232. this.useDefaultLoadingScreen = true;
  91233. this._scene = scene;
  91234. }
  91235. /**
  91236. * Add a MeshAssetTask to the list of active tasks
  91237. * @param taskName defines the name of the new task
  91238. * @param meshesNames defines the name of meshes to load
  91239. * @param rootUrl defines the root url to use to locate files
  91240. * @param sceneFilename defines the filename of the scene file
  91241. * @returns a new MeshAssetTask object
  91242. */
  91243. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  91244. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  91245. this._tasks.push(task);
  91246. return task;
  91247. };
  91248. /**
  91249. * Add a TextFileAssetTask to the list of active tasks
  91250. * @param taskName defines the name of the new task
  91251. * @param url defines the url of the file to load
  91252. * @returns a new TextFileAssetTask object
  91253. */
  91254. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  91255. var task = new TextFileAssetTask(taskName, url);
  91256. this._tasks.push(task);
  91257. return task;
  91258. };
  91259. /**
  91260. * Add a BinaryFileAssetTask to the list of active tasks
  91261. * @param taskName defines the name of the new task
  91262. * @param url defines the url of the file to load
  91263. * @returns a new BinaryFileAssetTask object
  91264. */
  91265. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  91266. var task = new BinaryFileAssetTask(taskName, url);
  91267. this._tasks.push(task);
  91268. return task;
  91269. };
  91270. /**
  91271. * Add a ImageAssetTask to the list of active tasks
  91272. * @param taskName defines the name of the new task
  91273. * @param url defines the url of the file to load
  91274. * @returns a new ImageAssetTask object
  91275. */
  91276. AssetsManager.prototype.addImageTask = function (taskName, url) {
  91277. var task = new ImageAssetTask(taskName, url);
  91278. this._tasks.push(task);
  91279. return task;
  91280. };
  91281. /**
  91282. * Add a TextureAssetTask to the list of active tasks
  91283. * @param taskName defines the name of the new task
  91284. * @param url defines the url of the file to load
  91285. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91286. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  91287. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  91288. * @returns a new TextureAssetTask object
  91289. */
  91290. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  91291. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91292. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  91293. this._tasks.push(task);
  91294. return task;
  91295. };
  91296. /**
  91297. * Add a CubeTextureAssetTask to the list of active tasks
  91298. * @param taskName defines the name of the new task
  91299. * @param url defines the url of the file to load
  91300. * @param extensions defines the extension to use to load the cube map (can be null)
  91301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91302. * @param files defines the list of files to load (can be null)
  91303. * @returns a new CubeTextureAssetTask object
  91304. */
  91305. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  91306. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  91307. this._tasks.push(task);
  91308. return task;
  91309. };
  91310. /**
  91311. *
  91312. * Add a HDRCubeTextureAssetTask to the list of active tasks
  91313. * @param taskName defines the name of the new task
  91314. * @param url defines the url of the file to load
  91315. * @param size defines the size you want for the cubemap (can be null)
  91316. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91317. * @param generateHarmonics defines if you want to automatically generate (true by default)
  91318. * @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)
  91319. * @param reserved Internal use only
  91320. * @returns a new HDRCubeTextureAssetTask object
  91321. */
  91322. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  91323. if (noMipmap === void 0) { noMipmap = false; }
  91324. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91325. if (gammaSpace === void 0) { gammaSpace = false; }
  91326. if (reserved === void 0) { reserved = false; }
  91327. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  91328. this._tasks.push(task);
  91329. return task;
  91330. };
  91331. /**
  91332. * Remove a task from the assets manager.
  91333. * @param task the task to remove
  91334. */
  91335. AssetsManager.prototype.removeTask = function (task) {
  91336. var index = this._tasks.indexOf(task);
  91337. if (index > -1) {
  91338. this._tasks.splice(index, 1);
  91339. }
  91340. };
  91341. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  91342. this._waitingTasksCount--;
  91343. try {
  91344. if (this.onProgress) {
  91345. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  91346. }
  91347. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  91348. }
  91349. catch (e) {
  91350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  91351. console.log(e);
  91352. }
  91353. if (this._waitingTasksCount === 0) {
  91354. try {
  91355. if (this.onFinish) {
  91356. this.onFinish(this._tasks);
  91357. }
  91358. // Let's remove successfull tasks
  91359. var currentTasks = this._tasks.slice();
  91360. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  91361. var task = currentTasks_1[_i];
  91362. if (task.taskState === AssetTaskState.DONE) {
  91363. var index = this._tasks.indexOf(task);
  91364. if (index > -1) {
  91365. this._tasks.splice(index, 1);
  91366. }
  91367. }
  91368. }
  91369. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91370. }
  91371. catch (e) {
  91372. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  91373. console.log(e);
  91374. }
  91375. this._isLoading = false;
  91376. this._scene.getEngine().hideLoadingUI();
  91377. }
  91378. };
  91379. AssetsManager.prototype._runTask = function (task) {
  91380. var _this = this;
  91381. var done = function () {
  91382. try {
  91383. if (_this.onTaskSuccess) {
  91384. _this.onTaskSuccess(task);
  91385. }
  91386. _this.onTaskSuccessObservable.notifyObservers(task);
  91387. _this._decreaseWaitingTasksCount(task);
  91388. }
  91389. catch (e) {
  91390. error("Error executing task success callbacks", e);
  91391. }
  91392. };
  91393. var error = function (message, exception) {
  91394. task._setErrorObject(message, exception);
  91395. if (_this.onTaskError) {
  91396. _this.onTaskError(task);
  91397. }
  91398. _this.onTaskErrorObservable.notifyObservers(task);
  91399. _this._decreaseWaitingTasksCount(task);
  91400. };
  91401. task.run(this._scene, done, error);
  91402. };
  91403. /**
  91404. * Reset the AssetsManager and remove all tasks
  91405. * @return the current instance of the AssetsManager
  91406. */
  91407. AssetsManager.prototype.reset = function () {
  91408. this._isLoading = false;
  91409. this._tasks = new Array();
  91410. return this;
  91411. };
  91412. /**
  91413. * Start the loading process
  91414. * @return the current instance of the AssetsManager
  91415. */
  91416. AssetsManager.prototype.load = function () {
  91417. if (this._isLoading) {
  91418. return this;
  91419. }
  91420. this._isLoading = true;
  91421. this._waitingTasksCount = this._tasks.length;
  91422. this._totalTasksCount = this._tasks.length;
  91423. if (this._waitingTasksCount === 0) {
  91424. this._isLoading = false;
  91425. if (this.onFinish) {
  91426. this.onFinish(this._tasks);
  91427. }
  91428. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91429. return this;
  91430. }
  91431. if (this.useDefaultLoadingScreen) {
  91432. this._scene.getEngine().displayLoadingUI();
  91433. }
  91434. for (var index = 0; index < this._tasks.length; index++) {
  91435. var task = this._tasks[index];
  91436. if (task.taskState === AssetTaskState.INIT) {
  91437. this._runTask(task);
  91438. }
  91439. }
  91440. return this;
  91441. };
  91442. return AssetsManager;
  91443. }());
  91444. /***/ }),
  91445. /***/ "./Misc/dds.ts":
  91446. /*!*********************!*\
  91447. !*** ./Misc/dds.ts ***!
  91448. \*********************/
  91449. /*! exports provided: DDSTools */
  91450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91451. "use strict";
  91452. __webpack_require__.r(__webpack_exports__);
  91453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  91454. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91455. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91456. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  91457. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  91458. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  91459. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91460. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91461. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  91462. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  91463. // All values and structures referenced from:
  91464. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  91465. var DDS_MAGIC = 0x20534444;
  91466. var
  91467. //DDSD_CAPS = 0x1,
  91468. //DDSD_HEIGHT = 0x2,
  91469. //DDSD_WIDTH = 0x4,
  91470. //DDSD_PITCH = 0x8,
  91471. //DDSD_PIXELFORMAT = 0x1000,
  91472. DDSD_MIPMAPCOUNT = 0x20000;
  91473. //DDSD_LINEARSIZE = 0x80000,
  91474. //DDSD_DEPTH = 0x800000;
  91475. // var DDSCAPS_COMPLEX = 0x8,
  91476. // DDSCAPS_MIPMAP = 0x400000,
  91477. // DDSCAPS_TEXTURE = 0x1000;
  91478. var DDSCAPS2_CUBEMAP = 0x200;
  91479. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  91480. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  91481. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  91482. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  91483. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  91484. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  91485. // DDSCAPS2_VOLUME = 0x200000;
  91486. var
  91487. //DDPF_ALPHAPIXELS = 0x1,
  91488. //DDPF_ALPHA = 0x2,
  91489. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  91490. //DDPF_YUV = 0x200,
  91491. DDPF_LUMINANCE = 0x20000;
  91492. function FourCCToInt32(value) {
  91493. return value.charCodeAt(0) +
  91494. (value.charCodeAt(1) << 8) +
  91495. (value.charCodeAt(2) << 16) +
  91496. (value.charCodeAt(3) << 24);
  91497. }
  91498. function Int32ToFourCC(value) {
  91499. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  91500. }
  91501. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  91502. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  91503. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  91504. var FOURCC_DX10 = FourCCToInt32("DX10");
  91505. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  91506. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  91507. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  91508. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  91509. var headerLengthInt = 31; // The header length in 32 bit ints
  91510. // Offsets into the header array
  91511. var off_magic = 0;
  91512. var off_size = 1;
  91513. var off_flags = 2;
  91514. var off_height = 3;
  91515. var off_width = 4;
  91516. var off_mipmapCount = 7;
  91517. var off_pfFlags = 20;
  91518. var off_pfFourCC = 21;
  91519. var off_RGBbpp = 22;
  91520. var off_RMask = 23;
  91521. var off_GMask = 24;
  91522. var off_BMask = 25;
  91523. var off_AMask = 26;
  91524. // var off_caps1 = 27;
  91525. var off_caps2 = 28;
  91526. // var off_caps3 = 29;
  91527. // var off_caps4 = 30;
  91528. var off_dxgiFormat = 32;
  91529. /**
  91530. * Class used to provide DDS decompression tools
  91531. */
  91532. var DDSTools = /** @class */ (function () {
  91533. function DDSTools() {
  91534. }
  91535. /**
  91536. * Gets DDS information from an array buffer
  91537. * @param arrayBuffer defines the array buffer to read data from
  91538. * @returns the DDS information
  91539. */
  91540. DDSTools.GetDDSInfo = function (arrayBuffer) {
  91541. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  91542. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  91543. var mipmapCount = 1;
  91544. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  91545. mipmapCount = Math.max(1, header[off_mipmapCount]);
  91546. }
  91547. var fourCC = header[off_pfFourCC];
  91548. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  91549. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91550. switch (fourCC) {
  91551. case FOURCC_D3DFMT_R16G16B16A16F:
  91552. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91553. break;
  91554. case FOURCC_D3DFMT_R32G32B32A32F:
  91555. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  91556. break;
  91557. case FOURCC_DX10:
  91558. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  91559. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91560. break;
  91561. }
  91562. }
  91563. return {
  91564. width: header[off_width],
  91565. height: header[off_height],
  91566. mipmapCount: mipmapCount,
  91567. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  91568. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  91569. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  91570. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  91571. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  91572. dxgiFormat: dxgiFormat,
  91573. textureType: textureType
  91574. };
  91575. };
  91576. DDSTools._ToHalfFloat = function (value) {
  91577. if (!DDSTools._FloatView) {
  91578. DDSTools._FloatView = new Float32Array(1);
  91579. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  91580. }
  91581. DDSTools._FloatView[0] = value;
  91582. var x = DDSTools._Int32View[0];
  91583. var bits = (x >> 16) & 0x8000; /* Get the sign */
  91584. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  91585. var e = (x >> 23) & 0xff; /* Using int is faster here */
  91586. /* If zero, or denormal, or exponent underflows too much for a denormal
  91587. * half, return signed zero. */
  91588. if (e < 103) {
  91589. return bits;
  91590. }
  91591. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  91592. if (e > 142) {
  91593. bits |= 0x7c00;
  91594. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  91595. * not Inf, so make sure we set one mantissa bit too. */
  91596. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  91597. return bits;
  91598. }
  91599. /* If exponent underflows but not too much, return a denormal */
  91600. if (e < 113) {
  91601. m |= 0x0800;
  91602. /* Extra rounding may overflow and set mantissa to 0 and exponent
  91603. * to 1, which is OK. */
  91604. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  91605. return bits;
  91606. }
  91607. bits |= ((e - 112) << 10) | (m >> 1);
  91608. bits += m & 1;
  91609. return bits;
  91610. };
  91611. DDSTools._FromHalfFloat = function (value) {
  91612. var s = (value & 0x8000) >> 15;
  91613. var e = (value & 0x7C00) >> 10;
  91614. var f = value & 0x03FF;
  91615. if (e === 0) {
  91616. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  91617. }
  91618. else if (e == 0x1F) {
  91619. return f ? NaN : ((s ? -1 : 1) * Infinity);
  91620. }
  91621. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  91622. };
  91623. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91624. var destArray = new Float32Array(dataLength);
  91625. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91626. var index = 0;
  91627. for (var y = 0; y < height; y++) {
  91628. for (var x = 0; x < width; x++) {
  91629. var srcPos = (x + y * width) * 4;
  91630. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  91631. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  91632. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  91633. if (DDSTools.StoreLODInAlphaChannel) {
  91634. destArray[index + 3] = lod;
  91635. }
  91636. else {
  91637. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  91638. }
  91639. index += 4;
  91640. }
  91641. }
  91642. return destArray;
  91643. };
  91644. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91645. if (DDSTools.StoreLODInAlphaChannel) {
  91646. var destArray = new Uint16Array(dataLength);
  91647. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91648. var index = 0;
  91649. for (var y = 0; y < height; y++) {
  91650. for (var x = 0; x < width; x++) {
  91651. var srcPos = (x + y * width) * 4;
  91652. destArray[index] = srcData[srcPos];
  91653. destArray[index + 1] = srcData[srcPos + 1];
  91654. destArray[index + 2] = srcData[srcPos + 2];
  91655. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  91656. index += 4;
  91657. }
  91658. }
  91659. return destArray;
  91660. }
  91661. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  91662. };
  91663. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91664. if (DDSTools.StoreLODInAlphaChannel) {
  91665. var destArray = new Float32Array(dataLength);
  91666. var srcData = new Float32Array(arrayBuffer, dataOffset);
  91667. var index = 0;
  91668. for (var y = 0; y < height; y++) {
  91669. for (var x = 0; x < width; x++) {
  91670. var srcPos = (x + y * width) * 4;
  91671. destArray[index] = srcData[srcPos];
  91672. destArray[index + 1] = srcData[srcPos + 1];
  91673. destArray[index + 2] = srcData[srcPos + 2];
  91674. destArray[index + 3] = lod;
  91675. index += 4;
  91676. }
  91677. }
  91678. return destArray;
  91679. }
  91680. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  91681. };
  91682. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91683. var destArray = new Uint8Array(dataLength);
  91684. var srcData = new Float32Array(arrayBuffer, dataOffset);
  91685. var index = 0;
  91686. for (var y = 0; y < height; y++) {
  91687. for (var x = 0; x < width; x++) {
  91688. var srcPos = (x + y * width) * 4;
  91689. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  91690. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  91691. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  91692. if (DDSTools.StoreLODInAlphaChannel) {
  91693. destArray[index + 3] = lod;
  91694. }
  91695. else {
  91696. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  91697. }
  91698. index += 4;
  91699. }
  91700. }
  91701. return destArray;
  91702. };
  91703. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91704. var destArray = new Uint8Array(dataLength);
  91705. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91706. var index = 0;
  91707. for (var y = 0; y < height; y++) {
  91708. for (var x = 0; x < width; x++) {
  91709. var srcPos = (x + y * width) * 4;
  91710. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  91711. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  91712. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  91713. if (DDSTools.StoreLODInAlphaChannel) {
  91714. destArray[index + 3] = lod;
  91715. }
  91716. else {
  91717. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  91718. }
  91719. index += 4;
  91720. }
  91721. }
  91722. return destArray;
  91723. };
  91724. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  91725. var byteArray = new Uint8Array(dataLength);
  91726. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91727. var index = 0;
  91728. for (var y = 0; y < height; y++) {
  91729. for (var x = 0; x < width; x++) {
  91730. var srcPos = (x + y * width) * 4;
  91731. byteArray[index] = srcData[srcPos + rOffset];
  91732. byteArray[index + 1] = srcData[srcPos + gOffset];
  91733. byteArray[index + 2] = srcData[srcPos + bOffset];
  91734. byteArray[index + 3] = srcData[srcPos + aOffset];
  91735. index += 4;
  91736. }
  91737. }
  91738. return byteArray;
  91739. };
  91740. DDSTools._ExtractLongWordOrder = function (value) {
  91741. if (value === 0 || value === 255 || value === -16777216) {
  91742. return 0;
  91743. }
  91744. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  91745. };
  91746. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  91747. var byteArray = new Uint8Array(dataLength);
  91748. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91749. var index = 0;
  91750. for (var y = 0; y < height; y++) {
  91751. for (var x = 0; x < width; x++) {
  91752. var srcPos = (x + y * width) * 3;
  91753. byteArray[index] = srcData[srcPos + rOffset];
  91754. byteArray[index + 1] = srcData[srcPos + gOffset];
  91755. byteArray[index + 2] = srcData[srcPos + bOffset];
  91756. index += 3;
  91757. }
  91758. }
  91759. return byteArray;
  91760. };
  91761. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  91762. var byteArray = new Uint8Array(dataLength);
  91763. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91764. var index = 0;
  91765. for (var y = 0; y < height; y++) {
  91766. for (var x = 0; x < width; x++) {
  91767. var srcPos = (x + y * width);
  91768. byteArray[index] = srcData[srcPos];
  91769. index++;
  91770. }
  91771. }
  91772. return byteArray;
  91773. };
  91774. /**
  91775. * Uploads DDS Levels to a Babylon Texture
  91776. * @hidden
  91777. */
  91778. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  91779. if (lodIndex === void 0) { lodIndex = -1; }
  91780. var sphericalPolynomialFaces = null;
  91781. if (info.sphericalPolynomial) {
  91782. sphericalPolynomialFaces = new Array();
  91783. }
  91784. var ext = engine.getCaps().s3tc;
  91785. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  91786. var fourCC, width, height, dataLength = 0, dataOffset;
  91787. var byteArray, mipmapCount, mip;
  91788. var internalCompressedFormat = 0;
  91789. var blockBytes = 1;
  91790. if (header[off_magic] !== DDS_MAGIC) {
  91791. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  91792. return;
  91793. }
  91794. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  91795. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  91796. return;
  91797. }
  91798. if (info.isCompressed && !ext) {
  91799. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  91800. return;
  91801. }
  91802. var bpp = header[off_RGBbpp];
  91803. dataOffset = header[off_size] + 4;
  91804. var computeFormats = false;
  91805. if (info.isFourCC) {
  91806. fourCC = header[off_pfFourCC];
  91807. switch (fourCC) {
  91808. case FOURCC_DXT1:
  91809. blockBytes = 8;
  91810. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  91811. break;
  91812. case FOURCC_DXT3:
  91813. blockBytes = 16;
  91814. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  91815. break;
  91816. case FOURCC_DXT5:
  91817. blockBytes = 16;
  91818. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  91819. break;
  91820. case FOURCC_D3DFMT_R16G16B16A16F:
  91821. computeFormats = true;
  91822. break;
  91823. case FOURCC_D3DFMT_R32G32B32A32F:
  91824. computeFormats = true;
  91825. break;
  91826. case FOURCC_DX10:
  91827. // There is an additionnal header so dataOffset need to be changed
  91828. dataOffset += 5 * 4; // 5 uints
  91829. var supported = false;
  91830. switch (info.dxgiFormat) {
  91831. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  91832. computeFormats = true;
  91833. supported = true;
  91834. break;
  91835. case DXGI_FORMAT_B8G8R8X8_UNORM:
  91836. info.isRGB = true;
  91837. info.isFourCC = false;
  91838. bpp = 32;
  91839. supported = true;
  91840. break;
  91841. }
  91842. if (supported) {
  91843. break;
  91844. }
  91845. default:
  91846. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  91847. return;
  91848. }
  91849. }
  91850. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  91851. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  91852. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  91853. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  91854. if (computeFormats) {
  91855. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  91856. }
  91857. mipmapCount = 1;
  91858. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  91859. mipmapCount = Math.max(1, header[off_mipmapCount]);
  91860. }
  91861. for (var face = 0; face < faces; face++) {
  91862. width = header[off_width];
  91863. height = header[off_height];
  91864. for (mip = 0; mip < mipmapCount; ++mip) {
  91865. if (lodIndex === -1 || lodIndex === mip) {
  91866. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  91867. var i = (lodIndex === -1) ? mip : 0;
  91868. if (!info.isCompressed && info.isFourCC) {
  91869. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  91870. dataLength = width * height * 4;
  91871. var floatArray = null;
  91872. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  91873. if (bpp === 128) {
  91874. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  91875. if (sphericalPolynomialFaces && i == 0) {
  91876. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  91877. }
  91878. }
  91879. else if (bpp === 64) {
  91880. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  91881. if (sphericalPolynomialFaces && i == 0) {
  91882. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  91883. }
  91884. }
  91885. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91886. }
  91887. else {
  91888. if (bpp === 128) {
  91889. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  91890. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  91891. if (sphericalPolynomialFaces && i == 0) {
  91892. sphericalPolynomialFaces.push(floatArray);
  91893. }
  91894. }
  91895. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  91896. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  91897. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  91898. if (sphericalPolynomialFaces && i == 0) {
  91899. sphericalPolynomialFaces.push(floatArray);
  91900. }
  91901. }
  91902. else { // 64
  91903. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91904. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  91905. if (sphericalPolynomialFaces && i == 0) {
  91906. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  91907. }
  91908. }
  91909. }
  91910. if (floatArray) {
  91911. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  91912. }
  91913. }
  91914. else if (info.isRGB) {
  91915. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91916. if (bpp === 24) {
  91917. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  91918. dataLength = width * height * 3;
  91919. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  91920. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  91921. }
  91922. else { // 32
  91923. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  91924. dataLength = width * height * 4;
  91925. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  91926. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  91927. }
  91928. }
  91929. else if (info.isLuminance) {
  91930. var unpackAlignment = engine._getUnpackAlignement();
  91931. var unpaddedRowSize = width;
  91932. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  91933. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  91934. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  91935. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  91936. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91937. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  91938. }
  91939. else {
  91940. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  91941. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  91942. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91943. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  91944. }
  91945. }
  91946. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  91947. width *= 0.5;
  91948. height *= 0.5;
  91949. width = Math.max(1.0, width);
  91950. height = Math.max(1.0, height);
  91951. }
  91952. if (currentFace !== undefined) {
  91953. // Loading a single face
  91954. break;
  91955. }
  91956. }
  91957. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  91958. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  91959. size: header[off_width],
  91960. right: sphericalPolynomialFaces[0],
  91961. left: sphericalPolynomialFaces[1],
  91962. up: sphericalPolynomialFaces[2],
  91963. down: sphericalPolynomialFaces[3],
  91964. front: sphericalPolynomialFaces[4],
  91965. back: sphericalPolynomialFaces[5],
  91966. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  91967. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  91968. gammaSpace: false,
  91969. });
  91970. }
  91971. else {
  91972. info.sphericalPolynomial = undefined;
  91973. }
  91974. };
  91975. /**
  91976. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  91977. */
  91978. DDSTools.StoreLODInAlphaChannel = false;
  91979. return DDSTools;
  91980. }());
  91981. /**
  91982. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  91983. * @param rootUrl defines the url where the file to load is located
  91984. * @param scene defines the current scene
  91985. * @param lodScale defines scale to apply to the mip map selection
  91986. * @param lodOffset defines offset to apply to the mip map selection
  91987. * @param onLoad defines an optional callback raised when the texture is loaded
  91988. * @param onError defines an optional callback raised if there is an issue to load the texture
  91989. * @param format defines the format of the data
  91990. * @param forcedExtension defines the extension to use to pick the right loader
  91991. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  91992. * @returns the cube texture as an InternalTexture
  91993. */
  91994. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  91995. var _this = this;
  91996. if (onLoad === void 0) { onLoad = null; }
  91997. if (onError === void 0) { onError = null; }
  91998. if (forcedExtension === void 0) { forcedExtension = null; }
  91999. if (createPolynomials === void 0) { createPolynomials = true; }
  92000. var callback = function (loadData) {
  92001. if (!loadData) {
  92002. if (onLoad) {
  92003. onLoad(null);
  92004. }
  92005. return;
  92006. }
  92007. var texture = loadData.texture;
  92008. if (!createPolynomials) {
  92009. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  92010. }
  92011. else if (loadData.info.sphericalPolynomial) {
  92012. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  92013. }
  92014. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  92015. if (_this.getCaps().textureLOD) {
  92016. // Do not add extra process if texture lod is supported.
  92017. if (onLoad) {
  92018. onLoad(texture);
  92019. }
  92020. return;
  92021. }
  92022. var mipSlices = 3;
  92023. var gl = _this._gl;
  92024. var width = loadData.width;
  92025. if (!width) {
  92026. return;
  92027. }
  92028. var textures = [];
  92029. for (var i = 0; i < mipSlices; i++) {
  92030. //compute LOD from even spacing in smoothness (matching shader calculation)
  92031. var smoothness = i / (mipSlices - 1);
  92032. var roughness = 1 - smoothness;
  92033. var minLODIndex = lodOffset; // roughness = 0
  92034. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  92035. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  92036. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  92037. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  92038. glTextureFromLod.type = texture.type;
  92039. glTextureFromLod.format = texture.format;
  92040. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  92041. glTextureFromLod.height = glTextureFromLod.width;
  92042. glTextureFromLod.isCube = true;
  92043. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  92044. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  92045. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  92046. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  92047. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  92048. if (loadData.isDDS) {
  92049. var info = loadData.info;
  92050. var data = loadData.data;
  92051. _this._unpackFlipY(info.isCompressed);
  92052. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  92053. }
  92054. else {
  92055. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  92056. }
  92057. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  92058. // Wrap in a base texture for easy binding.
  92059. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  92060. lodTexture.isCube = true;
  92061. lodTexture._texture = glTextureFromLod;
  92062. glTextureFromLod.isReady = true;
  92063. textures.push(lodTexture);
  92064. }
  92065. texture._lodTextureHigh = textures[2];
  92066. texture._lodTextureMid = textures[1];
  92067. texture._lodTextureLow = textures[0];
  92068. if (onLoad) {
  92069. onLoad(texture);
  92070. }
  92071. };
  92072. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  92073. };
  92074. /***/ }),
  92075. /***/ "./Misc/decorators.ts":
  92076. /*!****************************!*\
  92077. !*** ./Misc/decorators.ts ***!
  92078. \****************************/
  92079. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  92080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92081. "use strict";
  92082. __webpack_require__.r(__webpack_exports__);
  92083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  92084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  92085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  92086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  92087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  92088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  92089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  92090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  92091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  92092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  92093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  92094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  92095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  92096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  92097. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  92098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92099. var __decoratorInitialStore = {};
  92100. var __mergedStore = {};
  92101. var _copySource = function (creationFunction, source, instanciate) {
  92102. var destination = creationFunction();
  92103. // Tags
  92104. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92105. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92106. }
  92107. var classStore = getMergedStore(destination);
  92108. // Properties
  92109. for (var property in classStore) {
  92110. var propertyDescriptor = classStore[property];
  92111. var sourceProperty = source[property];
  92112. var propertyType = propertyDescriptor.type;
  92113. if (sourceProperty !== undefined && sourceProperty !== null) {
  92114. switch (propertyType) {
  92115. case 0: // Value
  92116. case 6: // Mesh reference
  92117. case 11: // Camera reference
  92118. destination[property] = sourceProperty;
  92119. break;
  92120. case 1: // Texture
  92121. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  92122. break;
  92123. case 2: // Color3
  92124. case 3: // FresnelParameters
  92125. case 4: // Vector2
  92126. case 5: // Vector3
  92127. case 7: // Color Curves
  92128. case 10: // Quaternion
  92129. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  92130. break;
  92131. }
  92132. }
  92133. }
  92134. return destination;
  92135. };
  92136. function getDirectStore(target) {
  92137. var classKey = target.getClassName();
  92138. if (!__decoratorInitialStore[classKey]) {
  92139. __decoratorInitialStore[classKey] = {};
  92140. }
  92141. return __decoratorInitialStore[classKey];
  92142. }
  92143. /**
  92144. * Return the list of properties flagged as serializable
  92145. * @param target: host object
  92146. */
  92147. function getMergedStore(target) {
  92148. var classKey = target.getClassName();
  92149. if (__mergedStore[classKey]) {
  92150. return __mergedStore[classKey];
  92151. }
  92152. __mergedStore[classKey] = {};
  92153. var store = __mergedStore[classKey];
  92154. var currentTarget = target;
  92155. var currentKey = classKey;
  92156. while (currentKey) {
  92157. var initialStore = __decoratorInitialStore[currentKey];
  92158. for (var property in initialStore) {
  92159. store[property] = initialStore[property];
  92160. }
  92161. var parent_1 = void 0;
  92162. var done = false;
  92163. do {
  92164. parent_1 = Object.getPrototypeOf(currentTarget);
  92165. if (!parent_1.getClassName) {
  92166. done = true;
  92167. break;
  92168. }
  92169. if (parent_1.getClassName() !== currentKey) {
  92170. break;
  92171. }
  92172. currentTarget = parent_1;
  92173. } while (parent_1);
  92174. if (done) {
  92175. break;
  92176. }
  92177. currentKey = parent_1.getClassName();
  92178. currentTarget = parent_1;
  92179. }
  92180. return store;
  92181. }
  92182. function generateSerializableMember(type, sourceName) {
  92183. return function (target, propertyKey) {
  92184. var classStore = getDirectStore(target);
  92185. if (!classStore[propertyKey]) {
  92186. classStore[propertyKey] = { type: type, sourceName: sourceName };
  92187. }
  92188. };
  92189. }
  92190. function generateExpandMember(setCallback, targetKey) {
  92191. if (targetKey === void 0) { targetKey = null; }
  92192. return function (target, propertyKey) {
  92193. var key = targetKey || ("_" + propertyKey);
  92194. Object.defineProperty(target, propertyKey, {
  92195. get: function () {
  92196. return this[key];
  92197. },
  92198. set: function (value) {
  92199. if (this[key] === value) {
  92200. return;
  92201. }
  92202. this[key] = value;
  92203. target[setCallback].apply(this);
  92204. },
  92205. enumerable: true,
  92206. configurable: true
  92207. });
  92208. };
  92209. }
  92210. function expandToProperty(callback, targetKey) {
  92211. if (targetKey === void 0) { targetKey = null; }
  92212. return generateExpandMember(callback, targetKey);
  92213. }
  92214. function serialize(sourceName) {
  92215. return generateSerializableMember(0, sourceName); // value member
  92216. }
  92217. function serializeAsTexture(sourceName) {
  92218. return generateSerializableMember(1, sourceName); // texture member
  92219. }
  92220. function serializeAsColor3(sourceName) {
  92221. return generateSerializableMember(2, sourceName); // color3 member
  92222. }
  92223. function serializeAsFresnelParameters(sourceName) {
  92224. return generateSerializableMember(3, sourceName); // fresnel parameters member
  92225. }
  92226. function serializeAsVector2(sourceName) {
  92227. return generateSerializableMember(4, sourceName); // vector2 member
  92228. }
  92229. function serializeAsVector3(sourceName) {
  92230. return generateSerializableMember(5, sourceName); // vector3 member
  92231. }
  92232. function serializeAsMeshReference(sourceName) {
  92233. return generateSerializableMember(6, sourceName); // mesh reference member
  92234. }
  92235. function serializeAsColorCurves(sourceName) {
  92236. return generateSerializableMember(7, sourceName); // color curves
  92237. }
  92238. function serializeAsColor4(sourceName) {
  92239. return generateSerializableMember(8, sourceName); // color 4
  92240. }
  92241. function serializeAsImageProcessingConfiguration(sourceName) {
  92242. return generateSerializableMember(9, sourceName); // image processing
  92243. }
  92244. function serializeAsQuaternion(sourceName) {
  92245. return generateSerializableMember(10, sourceName); // quaternion member
  92246. }
  92247. /**
  92248. * Decorator used to define property that can be serialized as reference to a camera
  92249. * @param sourceName defines the name of the property to decorate
  92250. */
  92251. function serializeAsCameraReference(sourceName) {
  92252. return generateSerializableMember(11, sourceName); // camera reference member
  92253. }
  92254. /**
  92255. * Class used to help serialization objects
  92256. */
  92257. var SerializationHelper = /** @class */ (function () {
  92258. function SerializationHelper() {
  92259. }
  92260. /**
  92261. * Appends the serialized animations from the source animations
  92262. * @param source Source containing the animations
  92263. * @param destination Target to store the animations
  92264. */
  92265. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  92266. if (source.animations) {
  92267. destination.animations = [];
  92268. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  92269. var animation = source.animations[animationIndex];
  92270. destination.animations.push(animation.serialize());
  92271. }
  92272. }
  92273. };
  92274. /**
  92275. * Static function used to serialized a specific entity
  92276. * @param entity defines the entity to serialize
  92277. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92278. * @returns a JSON compatible object representing the serialization of the entity
  92279. */
  92280. SerializationHelper.Serialize = function (entity, serializationObject) {
  92281. if (!serializationObject) {
  92282. serializationObject = {};
  92283. }
  92284. // Tags
  92285. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92286. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  92287. }
  92288. var serializedProperties = getMergedStore(entity);
  92289. // Properties
  92290. for (var property in serializedProperties) {
  92291. var propertyDescriptor = serializedProperties[property];
  92292. var targetPropertyName = propertyDescriptor.sourceName || property;
  92293. var propertyType = propertyDescriptor.type;
  92294. var sourceProperty = entity[property];
  92295. if (sourceProperty !== undefined && sourceProperty !== null) {
  92296. switch (propertyType) {
  92297. case 0: // Value
  92298. serializationObject[targetPropertyName] = sourceProperty;
  92299. break;
  92300. case 1: // Texture
  92301. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92302. break;
  92303. case 2: // Color3
  92304. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92305. break;
  92306. case 3: // FresnelParameters
  92307. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92308. break;
  92309. case 4: // Vector2
  92310. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92311. break;
  92312. case 5: // Vector3
  92313. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92314. break;
  92315. case 6: // Mesh reference
  92316. serializationObject[targetPropertyName] = sourceProperty.id;
  92317. break;
  92318. case 7: // Color Curves
  92319. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92320. break;
  92321. case 8: // Color 4
  92322. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92323. break;
  92324. case 9: // Image Processing
  92325. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92326. break;
  92327. case 10: // Quaternion
  92328. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92329. break;
  92330. case 11: // Camera reference
  92331. serializationObject[targetPropertyName] = sourceProperty.id;
  92332. break;
  92333. }
  92334. }
  92335. }
  92336. return serializationObject;
  92337. };
  92338. /**
  92339. * Creates a new entity from a serialization data object
  92340. * @param creationFunction defines a function used to instanciated the new entity
  92341. * @param source defines the source serialization data
  92342. * @param scene defines the hosting scene
  92343. * @param rootUrl defines the root url for resources
  92344. * @returns a new entity
  92345. */
  92346. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  92347. if (rootUrl === void 0) { rootUrl = null; }
  92348. var destination = creationFunction();
  92349. if (!rootUrl) {
  92350. rootUrl = "";
  92351. }
  92352. // Tags
  92353. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92354. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92355. }
  92356. var classStore = getMergedStore(destination);
  92357. // Properties
  92358. for (var property in classStore) {
  92359. var propertyDescriptor = classStore[property];
  92360. var sourceProperty = source[propertyDescriptor.sourceName || property];
  92361. var propertyType = propertyDescriptor.type;
  92362. if (sourceProperty !== undefined && sourceProperty !== null) {
  92363. var dest = destination;
  92364. switch (propertyType) {
  92365. case 0: // Value
  92366. dest[property] = sourceProperty;
  92367. break;
  92368. case 1: // Texture
  92369. if (scene) {
  92370. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  92371. }
  92372. break;
  92373. case 2: // Color3
  92374. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  92375. break;
  92376. case 3: // FresnelParameters
  92377. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  92378. break;
  92379. case 4: // Vector2
  92380. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  92381. break;
  92382. case 5: // Vector3
  92383. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  92384. break;
  92385. case 6: // Mesh reference
  92386. if (scene) {
  92387. dest[property] = scene.getLastMeshByID(sourceProperty);
  92388. }
  92389. break;
  92390. case 7: // Color Curves
  92391. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  92392. break;
  92393. case 8: // Color 4
  92394. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  92395. break;
  92396. case 9: // Image Processing
  92397. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  92398. break;
  92399. case 10: // Quaternion
  92400. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  92401. break;
  92402. case 11: // Camera reference
  92403. if (scene) {
  92404. dest[property] = scene.getCameraByID(sourceProperty);
  92405. }
  92406. break;
  92407. }
  92408. }
  92409. }
  92410. return destination;
  92411. };
  92412. /**
  92413. * Clones an object
  92414. * @param creationFunction defines the function used to instanciate the new object
  92415. * @param source defines the source object
  92416. * @returns the cloned object
  92417. */
  92418. SerializationHelper.Clone = function (creationFunction, source) {
  92419. return _copySource(creationFunction, source, false);
  92420. };
  92421. /**
  92422. * Instanciates a new object based on a source one (some data will be shared between both object)
  92423. * @param creationFunction defines the function used to instanciate the new object
  92424. * @param source defines the source object
  92425. * @returns the new object
  92426. */
  92427. SerializationHelper.Instanciate = function (creationFunction, source) {
  92428. return _copySource(creationFunction, source, true);
  92429. };
  92430. /** hidden */
  92431. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  92432. throw "ImageProcessingConfiguration needs to be imported before being deserialized.";
  92433. };
  92434. /** hidden */
  92435. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  92436. throw "FresnelParameters needs to be imported before being deserialized.";
  92437. };
  92438. /** hidden */
  92439. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  92440. throw "ColorCurves needs to be imported before being deserialized.";
  92441. };
  92442. /** hidden */
  92443. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  92444. throw "Texture needs to be imported before being deserialized.";
  92445. };
  92446. return SerializationHelper;
  92447. }());
  92448. /***/ }),
  92449. /***/ "./Misc/deepCopier.ts":
  92450. /*!****************************!*\
  92451. !*** ./Misc/deepCopier.ts ***!
  92452. \****************************/
  92453. /*! exports provided: DeepCopier */
  92454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92455. "use strict";
  92456. __webpack_require__.r(__webpack_exports__);
  92457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  92458. var cloneValue = function (source, destinationObject) {
  92459. if (!source) {
  92460. return null;
  92461. }
  92462. if (source.getClassName && source.getClassName() === "Mesh") {
  92463. return null;
  92464. }
  92465. if (source.getClassName && source.getClassName() === "SubMesh") {
  92466. return source.clone(destinationObject);
  92467. }
  92468. else if (source.clone) {
  92469. return source.clone();
  92470. }
  92471. return null;
  92472. };
  92473. /**
  92474. * Class containing a set of static utilities functions for deep copy.
  92475. */
  92476. var DeepCopier = /** @class */ (function () {
  92477. function DeepCopier() {
  92478. }
  92479. /**
  92480. * Tries to copy an object by duplicating every property
  92481. * @param source defines the source object
  92482. * @param destination defines the target object
  92483. * @param doNotCopyList defines a list of properties to avoid
  92484. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  92485. */
  92486. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  92487. for (var prop in source) {
  92488. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  92489. continue;
  92490. }
  92491. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  92492. continue;
  92493. }
  92494. var sourceValue = source[prop];
  92495. var typeOfSourceValue = typeof sourceValue;
  92496. if (typeOfSourceValue === "function") {
  92497. continue;
  92498. }
  92499. try {
  92500. if (typeOfSourceValue === "object") {
  92501. if (sourceValue instanceof Array) {
  92502. destination[prop] = [];
  92503. if (sourceValue.length > 0) {
  92504. if (typeof sourceValue[0] == "object") {
  92505. for (var index = 0; index < sourceValue.length; index++) {
  92506. var clonedValue = cloneValue(sourceValue[index], destination);
  92507. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  92508. destination[prop].push(clonedValue);
  92509. }
  92510. }
  92511. }
  92512. else {
  92513. destination[prop] = sourceValue.slice(0);
  92514. }
  92515. }
  92516. }
  92517. else {
  92518. destination[prop] = cloneValue(sourceValue, destination);
  92519. }
  92520. }
  92521. else {
  92522. destination[prop] = sourceValue;
  92523. }
  92524. }
  92525. catch (e) {
  92526. // Just ignore error (it could be because of a read-only property)
  92527. }
  92528. }
  92529. };
  92530. return DeepCopier;
  92531. }());
  92532. /***/ }),
  92533. /***/ "./Misc/deferred.ts":
  92534. /*!**************************!*\
  92535. !*** ./Misc/deferred.ts ***!
  92536. \**************************/
  92537. /*! exports provided: Deferred */
  92538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92539. "use strict";
  92540. __webpack_require__.r(__webpack_exports__);
  92541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  92542. /**
  92543. * Wrapper class for promise with external resolve and reject.
  92544. */
  92545. var Deferred = /** @class */ (function () {
  92546. /**
  92547. * Constructor for this deferred object.
  92548. */
  92549. function Deferred() {
  92550. var _this = this;
  92551. this.promise = new Promise(function (resolve, reject) {
  92552. _this._resolve = resolve;
  92553. _this._reject = reject;
  92554. });
  92555. }
  92556. Object.defineProperty(Deferred.prototype, "resolve", {
  92557. /**
  92558. * The resolve method of the promise associated with this deferred object.
  92559. */
  92560. get: function () {
  92561. return this._resolve;
  92562. },
  92563. enumerable: true,
  92564. configurable: true
  92565. });
  92566. Object.defineProperty(Deferred.prototype, "reject", {
  92567. /**
  92568. * The reject method of the promise associated with this deferred object.
  92569. */
  92570. get: function () {
  92571. return this._reject;
  92572. },
  92573. enumerable: true,
  92574. configurable: true
  92575. });
  92576. return Deferred;
  92577. }());
  92578. /***/ }),
  92579. /***/ "./Misc/domManagement.ts":
  92580. /*!*******************************!*\
  92581. !*** ./Misc/domManagement.ts ***!
  92582. \*******************************/
  92583. /*! exports provided: DomManagement */
  92584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92585. "use strict";
  92586. __webpack_require__.r(__webpack_exports__);
  92587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  92588. /**
  92589. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  92590. * Babylon.js
  92591. */
  92592. var DomManagement = /** @class */ (function () {
  92593. function DomManagement() {
  92594. }
  92595. /**
  92596. * Checks if the window object exists
  92597. * @returns true if the window object exists
  92598. */
  92599. DomManagement.IsWindowObjectExist = function () {
  92600. return (typeof window) !== "undefined";
  92601. };
  92602. /**
  92603. * Extracts text content from a DOM element hierarchy
  92604. * @param element defines the root element
  92605. * @returns a string
  92606. */
  92607. DomManagement.GetDOMTextContent = function (element) {
  92608. var result = "";
  92609. var child = element.firstChild;
  92610. while (child) {
  92611. if (child.nodeType === 3) {
  92612. result += child.textContent;
  92613. }
  92614. child = (child.nextSibling);
  92615. }
  92616. return result;
  92617. };
  92618. return DomManagement;
  92619. }());
  92620. /***/ }),
  92621. /***/ "./Misc/environmentTextureTools.ts":
  92622. /*!*****************************************!*\
  92623. !*** ./Misc/environmentTextureTools.ts ***!
  92624. \*****************************************/
  92625. /*! exports provided: EnvironmentTextureTools */
  92626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92627. "use strict";
  92628. __webpack_require__.r(__webpack_exports__);
  92629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  92630. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  92631. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92632. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92633. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92634. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92635. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92636. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92637. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  92638. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  92639. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92640. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  92641. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  92642. /**
  92643. * Sets of helpers addressing the serialization and deserialization of environment texture
  92644. * stored in a BabylonJS env file.
  92645. * Those files are usually stored as .env files.
  92646. */
  92647. var EnvironmentTextureTools = /** @class */ (function () {
  92648. function EnvironmentTextureTools() {
  92649. }
  92650. /**
  92651. * Gets the environment info from an env file.
  92652. * @param data The array buffer containing the .env bytes.
  92653. * @returns the environment file info (the json header) if successfully parsed.
  92654. */
  92655. EnvironmentTextureTools.GetEnvInfo = function (data) {
  92656. var dataView = new DataView(data);
  92657. var pos = 0;
  92658. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  92659. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  92660. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  92661. return null;
  92662. }
  92663. }
  92664. // Read json manifest - collect characters up to null terminator
  92665. var manifestString = '';
  92666. var charCode = 0x00;
  92667. while ((charCode = dataView.getUint8(pos++))) {
  92668. manifestString += String.fromCharCode(charCode);
  92669. }
  92670. var manifest = JSON.parse(manifestString);
  92671. if (manifest.specular) {
  92672. // Extend the header with the position of the payload.
  92673. manifest.specular.specularDataPosition = pos;
  92674. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  92675. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  92676. }
  92677. return manifest;
  92678. };
  92679. /**
  92680. * Creates an environment texture from a loaded cube texture.
  92681. * @param texture defines the cube texture to convert in env file
  92682. * @return a promise containing the environment data if succesfull.
  92683. */
  92684. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  92685. var _this = this;
  92686. var internalTexture = texture.getInternalTexture();
  92687. if (!internalTexture) {
  92688. return Promise.reject("The cube texture is invalid.");
  92689. }
  92690. if (!texture._prefiltered) {
  92691. return Promise.reject("The cube texture is invalid (not prefiltered).");
  92692. }
  92693. var engine = internalTexture.getEngine();
  92694. if (engine && engine.premultipliedAlpha) {
  92695. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  92696. }
  92697. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  92698. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  92699. }
  92700. var canvas = engine.getRenderingCanvas();
  92701. if (!canvas) {
  92702. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  92703. }
  92704. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  92705. if (!engine.getCaps().textureFloatRender) {
  92706. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92707. if (!engine.getCaps().textureHalfFloatRender) {
  92708. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  92709. }
  92710. }
  92711. var cubeWidth = internalTexture.width;
  92712. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  92713. var specularTextures = {};
  92714. var promises = [];
  92715. // Read and collect all mipmaps data from the cube.
  92716. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  92717. mipmapsCount = Math.round(mipmapsCount);
  92718. var _loop_1 = function (i) {
  92719. var faceWidth = Math.pow(2, mipmapsCount - i);
  92720. var _loop_2 = function (face) {
  92721. var data = texture.readPixels(face, i);
  92722. // Creates a temp texture with the face data.
  92723. 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);
  92724. // And rgbdEncode them.
  92725. var promise = new Promise(function (resolve, reject) {
  92726. 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);
  92727. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  92728. rgbdPostProcess.onApply = function (effect) {
  92729. effect._bindTexture("textureSampler", tempTexture);
  92730. };
  92731. // As the process needs to happen on the main canvas, keep track of the current size
  92732. var currentW = engine.getRenderWidth();
  92733. var currentH = engine.getRenderHeight();
  92734. // Set the desired size for the texture
  92735. engine.setSize(faceWidth, faceWidth);
  92736. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  92737. // Reading datas from WebGL
  92738. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  92739. var fileReader = new FileReader();
  92740. fileReader.onload = function (event) {
  92741. var arrayBuffer = event.target.result;
  92742. specularTextures[i * 6 + face] = arrayBuffer;
  92743. resolve();
  92744. };
  92745. fileReader.readAsArrayBuffer(blob);
  92746. });
  92747. // Reapply the previous canvas size
  92748. engine.setSize(currentW, currentH);
  92749. });
  92750. });
  92751. promises.push(promise);
  92752. };
  92753. // All faces of the cube.
  92754. for (var face = 0; face < 6; face++) {
  92755. _loop_2(face);
  92756. }
  92757. };
  92758. for (var i = 0; i <= mipmapsCount; i++) {
  92759. _loop_1(i);
  92760. }
  92761. // Once all the textures haves been collected as RGBD stored in PNGs
  92762. return Promise.all(promises).then(function () {
  92763. // We can delete the hosting scene keeping track of all the creation objects
  92764. hostingScene.dispose();
  92765. // Creates the json header for the env texture
  92766. var info = {
  92767. version: 1,
  92768. width: cubeWidth,
  92769. irradiance: _this._CreateEnvTextureIrradiance(texture),
  92770. specular: {
  92771. mipmaps: [],
  92772. lodGenerationScale: texture.lodGenerationScale
  92773. }
  92774. };
  92775. // Sets the specular image data information
  92776. var position = 0;
  92777. for (var i = 0; i <= mipmapsCount; i++) {
  92778. for (var face = 0; face < 6; face++) {
  92779. var byteLength = specularTextures[i * 6 + face].byteLength;
  92780. info.specular.mipmaps.push({
  92781. length: byteLength,
  92782. position: position
  92783. });
  92784. position += byteLength;
  92785. }
  92786. }
  92787. // Encode the JSON as an array buffer
  92788. var infoString = JSON.stringify(info);
  92789. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  92790. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  92791. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  92792. infoView[i] = infoString.charCodeAt(i);
  92793. }
  92794. // Ends up with a null terminator for easier parsing
  92795. infoView[infoString.length] = 0x00;
  92796. // Computes the final required size and creates the storage
  92797. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  92798. var finalBuffer = new ArrayBuffer(totalSize);
  92799. var finalBufferView = new Uint8Array(finalBuffer);
  92800. var dataView = new DataView(finalBuffer);
  92801. // Copy the magic bytes identifying the file in
  92802. var pos = 0;
  92803. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  92804. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  92805. }
  92806. // Add the json info
  92807. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  92808. pos += infoBuffer.byteLength;
  92809. // Finally inserts the texture data
  92810. for (var i = 0; i <= mipmapsCount; i++) {
  92811. for (var face = 0; face < 6; face++) {
  92812. var dataBuffer = specularTextures[i * 6 + face];
  92813. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  92814. pos += dataBuffer.byteLength;
  92815. }
  92816. }
  92817. // Voila
  92818. return finalBuffer;
  92819. });
  92820. };
  92821. /**
  92822. * Creates a JSON representation of the spherical data.
  92823. * @param texture defines the texture containing the polynomials
  92824. * @return the JSON representation of the spherical info
  92825. */
  92826. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  92827. var polynmials = texture.sphericalPolynomial;
  92828. if (polynmials == null) {
  92829. return null;
  92830. }
  92831. return {
  92832. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  92833. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  92834. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  92835. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  92836. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  92837. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  92838. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  92839. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  92840. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  92841. };
  92842. };
  92843. /**
  92844. * Uploads the texture info contained in the env file to the GPU.
  92845. * @param texture defines the internal texture to upload to
  92846. * @param arrayBuffer defines the buffer cotaining the data to load
  92847. * @param info defines the texture info retrieved through the GetEnvInfo method
  92848. * @returns a promise
  92849. */
  92850. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  92851. if (info.version !== 1) {
  92852. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  92853. }
  92854. var specularInfo = info.specular;
  92855. if (!specularInfo) {
  92856. // Nothing else parsed so far
  92857. return Promise.resolve();
  92858. }
  92859. // Double checks the enclosed info
  92860. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  92861. mipmapsCount = Math.round(mipmapsCount) + 1;
  92862. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  92863. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  92864. }
  92865. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  92866. var imageData = new Array(mipmapsCount);
  92867. for (var i = 0; i < mipmapsCount; i++) {
  92868. imageData[i] = new Array(6);
  92869. for (var face = 0; face < 6; face++) {
  92870. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  92871. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  92872. }
  92873. }
  92874. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  92875. };
  92876. /**
  92877. * Uploads the levels of image data to the GPU.
  92878. * @param texture defines the internal texture to upload to
  92879. * @param imageData defines the array buffer views of image data [mipmap][face]
  92880. * @returns a promise
  92881. */
  92882. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  92883. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  92884. throw new Error("Texture size must be a power of two");
  92885. }
  92886. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  92887. // Gets everything ready.
  92888. var engine = texture.getEngine();
  92889. var expandTexture = false;
  92890. var generateNonLODTextures = false;
  92891. var rgbdPostProcess = null;
  92892. var cubeRtt = null;
  92893. var lodTextures = null;
  92894. var caps = engine.getCaps();
  92895. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  92896. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92897. texture.generateMipMaps = true;
  92898. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  92899. // Add extra process if texture lod is not supported
  92900. if (!caps.textureLOD) {
  92901. expandTexture = false;
  92902. generateNonLODTextures = true;
  92903. lodTextures = {};
  92904. }
  92905. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  92906. else if (engine.webGLVersion < 2) {
  92907. expandTexture = false;
  92908. }
  92909. // If half float available we can uncompress the texture
  92910. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  92911. expandTexture = true;
  92912. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92913. }
  92914. // If full float available we can uncompress the texture
  92915. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  92916. expandTexture = true;
  92917. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  92918. }
  92919. // Expand the texture if possible
  92920. if (expandTexture) {
  92921. // Simply run through the decode PP
  92922. 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);
  92923. texture._isRGBD = false;
  92924. texture.invertY = false;
  92925. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  92926. generateDepthBuffer: false,
  92927. generateMipMaps: true,
  92928. generateStencilBuffer: false,
  92929. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  92930. type: texture.type,
  92931. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  92932. });
  92933. }
  92934. else {
  92935. texture._isRGBD = true;
  92936. texture.invertY = true;
  92937. // In case of missing support, applies the same patch than DDS files.
  92938. if (generateNonLODTextures) {
  92939. var mipSlices = 3;
  92940. var scale = texture._lodGenerationScale;
  92941. var offset = texture._lodGenerationOffset;
  92942. for (var i = 0; i < mipSlices; i++) {
  92943. //compute LOD from even spacing in smoothness (matching shader calculation)
  92944. var smoothness = i / (mipSlices - 1);
  92945. var roughness = 1 - smoothness;
  92946. var minLODIndex = offset; // roughness = 0
  92947. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  92948. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  92949. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  92950. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  92951. glTextureFromLod.isCube = true;
  92952. glTextureFromLod.invertY = true;
  92953. glTextureFromLod.generateMipMaps = false;
  92954. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  92955. // Wrap in a base texture for easy binding.
  92956. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  92957. lodTexture.isCube = true;
  92958. lodTexture._texture = glTextureFromLod;
  92959. lodTextures[mipmapIndex] = lodTexture;
  92960. switch (i) {
  92961. case 0:
  92962. texture._lodTextureLow = lodTexture;
  92963. break;
  92964. case 1:
  92965. texture._lodTextureMid = lodTexture;
  92966. break;
  92967. case 2:
  92968. texture._lodTextureHigh = lodTexture;
  92969. break;
  92970. }
  92971. }
  92972. }
  92973. }
  92974. var promises = [];
  92975. var _loop_3 = function (i) {
  92976. var _loop_4 = function (face) {
  92977. // Constructs an image element from image data
  92978. var bytes = imageData[i][face];
  92979. var blob = new Blob([bytes], { type: 'image/png' });
  92980. var url = URL.createObjectURL(blob);
  92981. var image = new Image();
  92982. image.src = url;
  92983. // Enqueue promise to upload to the texture.
  92984. var promise = new Promise(function (resolve, reject) {
  92985. image.onload = function () {
  92986. if (expandTexture) {
  92987. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  92988. reject(message);
  92989. }, image);
  92990. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  92991. // Uncompress the data to a RTT
  92992. rgbdPostProcess.onApply = function (effect) {
  92993. effect._bindTexture("textureSampler", tempTexture_1);
  92994. effect.setFloat2("scale", 1, 1);
  92995. };
  92996. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  92997. // Cleanup
  92998. engine.restoreDefaultFramebuffer();
  92999. tempTexture_1.dispose();
  93000. window.URL.revokeObjectURL(url);
  93001. resolve();
  93002. });
  93003. }
  93004. else {
  93005. engine._uploadImageToTexture(texture, image, face, i);
  93006. // Upload the face to the non lod texture support
  93007. if (generateNonLODTextures) {
  93008. var lodTexture = lodTextures[i];
  93009. if (lodTexture) {
  93010. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  93011. }
  93012. }
  93013. resolve();
  93014. }
  93015. };
  93016. image.onerror = function (error) {
  93017. reject(error);
  93018. };
  93019. });
  93020. promises.push(promise);
  93021. };
  93022. // All faces
  93023. for (var face = 0; face < 6; face++) {
  93024. _loop_4(face);
  93025. }
  93026. };
  93027. // All mipmaps up to provided number of images
  93028. for (var i = 0; i < imageData.length; i++) {
  93029. _loop_3(i);
  93030. }
  93031. // Fill remaining mipmaps with black textures.
  93032. if (imageData.length < mipmapsCount) {
  93033. var data = void 0;
  93034. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  93035. var dataLength = size * size * 4;
  93036. switch (texture.type) {
  93037. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  93038. data = new Uint8Array(dataLength);
  93039. break;
  93040. }
  93041. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  93042. data = new Uint16Array(dataLength);
  93043. break;
  93044. }
  93045. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  93046. data = new Float32Array(dataLength);
  93047. break;
  93048. }
  93049. }
  93050. for (var i = imageData.length; i < mipmapsCount; i++) {
  93051. for (var face = 0; face < 6; face++) {
  93052. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  93053. }
  93054. }
  93055. }
  93056. // Once all done, finishes the cleanup and return
  93057. return Promise.all(promises).then(function () {
  93058. // Release temp RTT.
  93059. if (cubeRtt) {
  93060. engine._releaseFramebufferObjects(cubeRtt);
  93061. cubeRtt._swapAndDie(texture);
  93062. }
  93063. // Release temp Post Process.
  93064. if (rgbdPostProcess) {
  93065. rgbdPostProcess.dispose();
  93066. }
  93067. // Flag internal texture as ready in case they are in use.
  93068. if (generateNonLODTextures) {
  93069. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  93070. texture._lodTextureHigh._texture.isReady = true;
  93071. }
  93072. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  93073. texture._lodTextureMid._texture.isReady = true;
  93074. }
  93075. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  93076. texture._lodTextureLow._texture.isReady = true;
  93077. }
  93078. }
  93079. });
  93080. };
  93081. /**
  93082. * Uploads spherical polynomials information to the texture.
  93083. * @param texture defines the texture we are trying to upload the information to
  93084. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  93085. */
  93086. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  93087. if (info.version !== 1) {
  93088. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  93089. }
  93090. var irradianceInfo = info.irradiance;
  93091. if (!irradianceInfo) {
  93092. return;
  93093. }
  93094. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  93095. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  93096. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  93097. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  93098. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  93099. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  93100. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  93101. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  93102. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  93103. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  93104. texture._sphericalPolynomial = sp;
  93105. };
  93106. /** @hidden */
  93107. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  93108. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  93109. internalTexture._bufferViewArrayArray = data;
  93110. internalTexture._lodGenerationScale = lodScale;
  93111. internalTexture._lodGenerationOffset = lodOffset;
  93112. internalTexture._sphericalPolynomial = sphericalPolynomial;
  93113. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  93114. internalTexture.isReady = true;
  93115. });
  93116. };
  93117. /**
  93118. * Magic number identifying the env file.
  93119. */
  93120. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  93121. return EnvironmentTextureTools;
  93122. }());
  93123. // References the dependencies.
  93124. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  93125. /***/ }),
  93126. /***/ "./Misc/filesInput.ts":
  93127. /*!****************************!*\
  93128. !*** ./Misc/filesInput.ts ***!
  93129. \****************************/
  93130. /*! exports provided: FilesInput */
  93131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93132. "use strict";
  93133. __webpack_require__.r(__webpack_exports__);
  93134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  93135. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  93136. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93137. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93138. /**
  93139. * Class used to help managing file picking and drag'n'drop
  93140. */
  93141. var FilesInput = /** @class */ (function () {
  93142. /**
  93143. * Creates a new FilesInput
  93144. * @param engine defines the rendering engine
  93145. * @param scene defines the hosting scene
  93146. * @param sceneLoadedCallback callback called when scene is loaded
  93147. * @param progressCallback callback called to track progress
  93148. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  93149. * @param textureLoadingCallback callback called when a texture is loading
  93150. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  93151. * @param onReloadCallback callback called when a reload is requested
  93152. * @param errorCallback callback call if an error occurs
  93153. */
  93154. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  93155. /**
  93156. * Callback called when a file is processed
  93157. */
  93158. this.onProcessFileCallback = function () { return true; };
  93159. this._engine = engine;
  93160. this._currentScene = scene;
  93161. this._sceneLoadedCallback = sceneLoadedCallback;
  93162. this._progressCallback = progressCallback;
  93163. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  93164. this._textureLoadingCallback = textureLoadingCallback;
  93165. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  93166. this._onReloadCallback = onReloadCallback;
  93167. this._errorCallback = errorCallback;
  93168. }
  93169. Object.defineProperty(FilesInput, "FilesToLoad", {
  93170. /**
  93171. * List of files ready to be loaded
  93172. */
  93173. get: function () {
  93174. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  93175. },
  93176. enumerable: true,
  93177. configurable: true
  93178. });
  93179. /**
  93180. * Calls this function to listen to drag'n'drop events on a specific DOM element
  93181. * @param elementToMonitor defines the DOM element to track
  93182. */
  93183. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  93184. var _this = this;
  93185. if (elementToMonitor) {
  93186. this._elementToMonitor = elementToMonitor;
  93187. this._dragEnterHandler = function (e) { _this.drag(e); };
  93188. this._dragOverHandler = function (e) { _this.drag(e); };
  93189. this._dropHandler = function (e) { _this.drop(e); };
  93190. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  93191. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  93192. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  93193. }
  93194. };
  93195. /**
  93196. * Release all associated resources
  93197. */
  93198. FilesInput.prototype.dispose = function () {
  93199. if (!this._elementToMonitor) {
  93200. return;
  93201. }
  93202. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  93203. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  93204. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  93205. };
  93206. FilesInput.prototype.renderFunction = function () {
  93207. if (this._additionalRenderLoopLogicCallback) {
  93208. this._additionalRenderLoopLogicCallback();
  93209. }
  93210. if (this._currentScene) {
  93211. if (this._textureLoadingCallback) {
  93212. var remaining = this._currentScene.getWaitingItemsCount();
  93213. if (remaining > 0) {
  93214. this._textureLoadingCallback(remaining);
  93215. }
  93216. }
  93217. this._currentScene.render();
  93218. }
  93219. };
  93220. FilesInput.prototype.drag = function (e) {
  93221. e.stopPropagation();
  93222. e.preventDefault();
  93223. };
  93224. FilesInput.prototype.drop = function (eventDrop) {
  93225. eventDrop.stopPropagation();
  93226. eventDrop.preventDefault();
  93227. this.loadFiles(eventDrop);
  93228. };
  93229. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  93230. var _this = this;
  93231. var reader = folder.createReader();
  93232. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  93233. reader.readEntries(function (entries) {
  93234. remaining.count += entries.length;
  93235. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  93236. var entry = entries_1[_i];
  93237. if (entry.isFile) {
  93238. entry.file(function (file) {
  93239. file.correctName = relativePath + file.name;
  93240. files.push(file);
  93241. if (--remaining.count === 0) {
  93242. callback();
  93243. }
  93244. });
  93245. }
  93246. else if (entry.isDirectory) {
  93247. _this._traverseFolder(entry, files, remaining, callback);
  93248. }
  93249. }
  93250. if (--remaining.count) {
  93251. callback();
  93252. }
  93253. });
  93254. };
  93255. FilesInput.prototype._processFiles = function (files) {
  93256. for (var i = 0; i < files.length; i++) {
  93257. var name = files[i].correctName.toLowerCase();
  93258. var extension = name.split('.').pop();
  93259. if (!this.onProcessFileCallback(files[i], name, extension)) {
  93260. continue;
  93261. }
  93262. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  93263. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  93264. this._sceneFileToLoad = files[i];
  93265. }
  93266. FilesInput.FilesToLoad[name] = files[i];
  93267. }
  93268. };
  93269. /**
  93270. * Load files from a drop event
  93271. * @param event defines the drop event to use as source
  93272. */
  93273. FilesInput.prototype.loadFiles = function (event) {
  93274. var _this = this;
  93275. // Handling data transfer via drag'n'drop
  93276. if (event && event.dataTransfer && event.dataTransfer.files) {
  93277. this._filesToLoad = event.dataTransfer.files;
  93278. }
  93279. // Handling files from input files
  93280. if (event && event.target && event.target.files) {
  93281. this._filesToLoad = event.target.files;
  93282. }
  93283. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  93284. return;
  93285. }
  93286. if (this._startingProcessingFilesCallback) {
  93287. this._startingProcessingFilesCallback(this._filesToLoad);
  93288. }
  93289. if (this._filesToLoad && this._filesToLoad.length > 0) {
  93290. var files_1 = new Array();
  93291. var folders = [];
  93292. var items = event.dataTransfer ? event.dataTransfer.items : null;
  93293. for (var i = 0; i < this._filesToLoad.length; i++) {
  93294. var fileToLoad = this._filesToLoad[i];
  93295. var name_1 = fileToLoad.name.toLowerCase();
  93296. var entry = void 0;
  93297. fileToLoad.correctName = name_1;
  93298. if (items) {
  93299. var item = items[i];
  93300. if (item.getAsEntry) {
  93301. entry = item.getAsEntry();
  93302. }
  93303. else if (item.webkitGetAsEntry) {
  93304. entry = item.webkitGetAsEntry();
  93305. }
  93306. }
  93307. if (!entry) {
  93308. files_1.push(fileToLoad);
  93309. }
  93310. else {
  93311. if (entry.isDirectory) {
  93312. folders.push(entry);
  93313. }
  93314. else {
  93315. files_1.push(fileToLoad);
  93316. }
  93317. }
  93318. }
  93319. if (folders.length === 0) {
  93320. this._processFiles(files_1);
  93321. this._processReload();
  93322. }
  93323. else {
  93324. var remaining = { count: folders.length };
  93325. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  93326. var folder = folders_1[_i];
  93327. this._traverseFolder(folder, files_1, remaining, function () {
  93328. _this._processFiles(files_1);
  93329. if (remaining.count === 0) {
  93330. _this._processReload();
  93331. }
  93332. });
  93333. }
  93334. }
  93335. }
  93336. };
  93337. FilesInput.prototype._processReload = function () {
  93338. if (this._onReloadCallback) {
  93339. this._onReloadCallback(this._sceneFileToLoad);
  93340. }
  93341. else {
  93342. this.reload();
  93343. }
  93344. };
  93345. /**
  93346. * Reload the current scene from the loaded files
  93347. */
  93348. FilesInput.prototype.reload = function () {
  93349. var _this = this;
  93350. // If a scene file has been provided
  93351. if (this._sceneFileToLoad) {
  93352. if (this._currentScene) {
  93353. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  93354. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  93355. }
  93356. this._engine.stopRenderLoop();
  93357. }
  93358. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  93359. if (_this._progressCallback) {
  93360. _this._progressCallback(progress);
  93361. }
  93362. }).then(function (scene) {
  93363. if (_this._currentScene) {
  93364. _this._currentScene.dispose();
  93365. }
  93366. _this._currentScene = scene;
  93367. if (_this._sceneLoadedCallback) {
  93368. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  93369. }
  93370. // Wait for textures and shaders to be ready
  93371. _this._currentScene.executeWhenReady(function () {
  93372. _this._engine.runRenderLoop(function () {
  93373. _this.renderFunction();
  93374. });
  93375. });
  93376. }).catch(function (error) {
  93377. if (_this._errorCallback) {
  93378. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  93379. }
  93380. });
  93381. }
  93382. else {
  93383. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  93384. }
  93385. };
  93386. return FilesInput;
  93387. }());
  93388. /***/ }),
  93389. /***/ "./Misc/filesInputStore.ts":
  93390. /*!*********************************!*\
  93391. !*** ./Misc/filesInputStore.ts ***!
  93392. \*********************************/
  93393. /*! exports provided: FilesInputStore */
  93394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93395. "use strict";
  93396. __webpack_require__.r(__webpack_exports__);
  93397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  93398. /**
  93399. * Class used to help managing file picking and drag'n'drop
  93400. * File Storage
  93401. */
  93402. var FilesInputStore = /** @class */ (function () {
  93403. function FilesInputStore() {
  93404. }
  93405. /**
  93406. * List of files ready to be loaded
  93407. */
  93408. FilesInputStore.FilesToLoad = {};
  93409. return FilesInputStore;
  93410. }());
  93411. /***/ }),
  93412. /***/ "./Misc/index.ts":
  93413. /*!***********************!*\
  93414. !*** ./Misc/index.ts ***!
  93415. \***********************/
  93416. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  93417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93418. "use strict";
  93419. __webpack_require__.r(__webpack_exports__);
  93420. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  93421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  93422. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  93423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  93424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  93425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  93426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  93427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  93428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  93429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  93430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  93431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  93432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  93433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  93434. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  93435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  93436. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  93437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  93438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  93439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  93440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  93441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  93442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  93443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  93444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  93445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  93446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  93447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  93448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  93449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  93450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  93451. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  93452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  93453. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  93454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  93455. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  93456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  93457. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  93458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  93459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  93460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  93461. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  93462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  93463. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  93464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  93465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  93466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  93467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  93468. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  93469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  93470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  93471. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  93472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  93473. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  93474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  93475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  93476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  93477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  93478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  93479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  93480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  93481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  93482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  93483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  93484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  93485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  93486. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  93487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  93488. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  93489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  93490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  93491. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  93492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  93493. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  93494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  93495. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  93496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  93497. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  93498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  93499. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  93501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  93502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  93503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  93504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  93505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  93506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  93507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  93508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  93509. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  93510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  93511. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  93512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  93513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  93514. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  93515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  93516. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  93517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  93518. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  93519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  93520. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  93522. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  93523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  93524. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  93525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  93526. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  93527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  93528. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  93529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  93530. /* empty/unused harmony star reexport */
  93531. /***/ }),
  93532. /***/ "./Misc/khronosTextureContainer.ts":
  93533. /*!*****************************************!*\
  93534. !*** ./Misc/khronosTextureContainer.ts ***!
  93535. \*****************************************/
  93536. /*! exports provided: KhronosTextureContainer */
  93537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93538. "use strict";
  93539. __webpack_require__.r(__webpack_exports__);
  93540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  93541. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93542. /**
  93543. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  93544. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  93545. */
  93546. var KhronosTextureContainer = /** @class */ (function () {
  93547. /**
  93548. * Creates a new KhronosTextureContainer
  93549. * @param arrayBuffer contents of the KTX container file
  93550. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  93551. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  93552. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  93553. */
  93554. function KhronosTextureContainer(
  93555. /** contents of the KTX container file */
  93556. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  93557. this.arrayBuffer = arrayBuffer;
  93558. /**
  93559. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  93560. */
  93561. this.isInvalid = false;
  93562. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  93563. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  93564. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  93565. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  93566. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  93567. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  93568. this.isInvalid = true;
  93569. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  93570. return;
  93571. }
  93572. // load the reset of the header in native 32 bit uint
  93573. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  93574. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  93575. var endianness = headerDataView.getUint32(0, true);
  93576. var littleEndian = endianness === 0x04030201;
  93577. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  93578. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  93579. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  93580. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  93581. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  93582. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  93583. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  93584. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  93585. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  93586. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  93587. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  93588. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  93589. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  93590. if (this.glType !== 0) {
  93591. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  93592. return;
  93593. }
  93594. else {
  93595. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  93596. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  93597. }
  93598. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  93599. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  93600. return;
  93601. }
  93602. if (this.numberOfArrayElements !== 0) {
  93603. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  93604. return;
  93605. }
  93606. if (this.numberOfFaces !== facesExpected) {
  93607. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  93608. return;
  93609. }
  93610. // we now have a completely validated file, so could use existence of loadType as success
  93611. // would need to make this more elaborate & adjust checks above to support more than one load type
  93612. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  93613. }
  93614. /**
  93615. * Uploads KTX content to a Babylon Texture.
  93616. * It is assumed that the texture has already been created & is currently bound
  93617. * @hidden
  93618. */
  93619. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  93620. switch (this.loadType) {
  93621. case KhronosTextureContainer.COMPRESSED_2D:
  93622. this._upload2DCompressedLevels(texture, loadMipmaps);
  93623. break;
  93624. case KhronosTextureContainer.TEX_2D:
  93625. case KhronosTextureContainer.COMPRESSED_3D:
  93626. case KhronosTextureContainer.TEX_3D:
  93627. }
  93628. };
  93629. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  93630. // initialize width & height for level 1
  93631. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  93632. var width = this.pixelWidth;
  93633. var height = this.pixelHeight;
  93634. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  93635. for (var level = 0; level < mipmapCount; level++) {
  93636. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  93637. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  93638. for (var face = 0; face < this.numberOfFaces; face++) {
  93639. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  93640. var engine = texture.getEngine();
  93641. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  93642. dataOffset += imageSize; // add size of the image for the next face/mipmap
  93643. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  93644. }
  93645. width = Math.max(1.0, width * 0.5);
  93646. height = Math.max(1.0, height * 0.5);
  93647. }
  93648. };
  93649. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  93650. // load types
  93651. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  93652. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  93653. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  93654. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  93655. return KhronosTextureContainer;
  93656. }());
  93657. /***/ }),
  93658. /***/ "./Misc/logger.ts":
  93659. /*!************************!*\
  93660. !*** ./Misc/logger.ts ***!
  93661. \************************/
  93662. /*! exports provided: Logger */
  93663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93664. "use strict";
  93665. __webpack_require__.r(__webpack_exports__);
  93666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  93667. /**
  93668. * Logger used througouht the application to allow configuration of
  93669. * the log level required for the messages.
  93670. */
  93671. var Logger = /** @class */ (function () {
  93672. function Logger() {
  93673. }
  93674. Logger._AddLogEntry = function (entry) {
  93675. Logger._LogCache = entry + Logger._LogCache;
  93676. if (Logger.OnNewCacheEntry) {
  93677. Logger.OnNewCacheEntry(entry);
  93678. }
  93679. };
  93680. Logger._FormatMessage = function (message) {
  93681. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  93682. var date = new Date();
  93683. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  93684. };
  93685. Logger._LogDisabled = function (message) {
  93686. // nothing to do
  93687. };
  93688. Logger._LogEnabled = function (message) {
  93689. var formattedMessage = Logger._FormatMessage(message);
  93690. console.log("BJS - " + formattedMessage);
  93691. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  93692. Logger._AddLogEntry(entry);
  93693. };
  93694. Logger._WarnDisabled = function (message) {
  93695. // nothing to do
  93696. };
  93697. Logger._WarnEnabled = function (message) {
  93698. var formattedMessage = Logger._FormatMessage(message);
  93699. console.warn("BJS - " + formattedMessage);
  93700. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  93701. Logger._AddLogEntry(entry);
  93702. };
  93703. Logger._ErrorDisabled = function (message) {
  93704. // nothing to do
  93705. };
  93706. Logger._ErrorEnabled = function (message) {
  93707. Logger.errorsCount++;
  93708. var formattedMessage = Logger._FormatMessage(message);
  93709. console.error("BJS - " + formattedMessage);
  93710. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  93711. Logger._AddLogEntry(entry);
  93712. };
  93713. Object.defineProperty(Logger, "LogCache", {
  93714. /**
  93715. * Gets current log cache (list of logs)
  93716. */
  93717. get: function () {
  93718. return Logger._LogCache;
  93719. },
  93720. enumerable: true,
  93721. configurable: true
  93722. });
  93723. /**
  93724. * Clears the log cache
  93725. */
  93726. Logger.ClearLogCache = function () {
  93727. Logger._LogCache = "";
  93728. Logger.errorsCount = 0;
  93729. };
  93730. Object.defineProperty(Logger, "LogLevels", {
  93731. /**
  93732. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93733. */
  93734. set: function (level) {
  93735. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  93736. Logger.Log = Logger._LogEnabled;
  93737. }
  93738. else {
  93739. Logger.Log = Logger._LogDisabled;
  93740. }
  93741. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  93742. Logger.Warn = Logger._WarnEnabled;
  93743. }
  93744. else {
  93745. Logger.Warn = Logger._WarnDisabled;
  93746. }
  93747. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  93748. Logger.Error = Logger._ErrorEnabled;
  93749. }
  93750. else {
  93751. Logger.Error = Logger._ErrorDisabled;
  93752. }
  93753. },
  93754. enumerable: true,
  93755. configurable: true
  93756. });
  93757. /**
  93758. * No log
  93759. */
  93760. Logger.NoneLogLevel = 0;
  93761. /**
  93762. * Only message logs
  93763. */
  93764. Logger.MessageLogLevel = 1;
  93765. /**
  93766. * Only warning logs
  93767. */
  93768. Logger.WarningLogLevel = 2;
  93769. /**
  93770. * Only error logs
  93771. */
  93772. Logger.ErrorLogLevel = 4;
  93773. /**
  93774. * All logs
  93775. */
  93776. Logger.AllLogLevel = 7;
  93777. Logger._LogCache = "";
  93778. /**
  93779. * Gets a value indicating the number of loading errors
  93780. * @ignorenaming
  93781. */
  93782. Logger.errorsCount = 0;
  93783. /**
  93784. * Log a message to the console
  93785. */
  93786. Logger.Log = Logger._LogEnabled;
  93787. /**
  93788. * Write a warning message to the console
  93789. */
  93790. Logger.Warn = Logger._WarnEnabled;
  93791. /**
  93792. * Write an error message to the console
  93793. */
  93794. Logger.Error = Logger._ErrorEnabled;
  93795. return Logger;
  93796. }());
  93797. /***/ }),
  93798. /***/ "./Misc/observable.ts":
  93799. /*!****************************!*\
  93800. !*** ./Misc/observable.ts ***!
  93801. \****************************/
  93802. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  93803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93804. "use strict";
  93805. __webpack_require__.r(__webpack_exports__);
  93806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  93807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  93808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  93809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  93810. /**
  93811. * A class serves as a medium between the observable and its observers
  93812. */
  93813. var EventState = /** @class */ (function () {
  93814. /**
  93815. * Create a new EventState
  93816. * @param mask defines the mask associated with this state
  93817. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  93818. * @param target defines the original target of the state
  93819. * @param currentTarget defines the current target of the state
  93820. */
  93821. function EventState(mask, skipNextObservers, target, currentTarget) {
  93822. if (skipNextObservers === void 0) { skipNextObservers = false; }
  93823. this.initalize(mask, skipNextObservers, target, currentTarget);
  93824. }
  93825. /**
  93826. * Initialize the current event state
  93827. * @param mask defines the mask associated with this state
  93828. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  93829. * @param target defines the original target of the state
  93830. * @param currentTarget defines the current target of the state
  93831. * @returns the current event state
  93832. */
  93833. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  93834. if (skipNextObservers === void 0) { skipNextObservers = false; }
  93835. this.mask = mask;
  93836. this.skipNextObservers = skipNextObservers;
  93837. this.target = target;
  93838. this.currentTarget = currentTarget;
  93839. return this;
  93840. };
  93841. return EventState;
  93842. }());
  93843. /**
  93844. * Represent an Observer registered to a given Observable object.
  93845. */
  93846. var Observer = /** @class */ (function () {
  93847. /**
  93848. * Creates a new observer
  93849. * @param callback defines the callback to call when the observer is notified
  93850. * @param mask defines the mask of the observer (used to filter notifications)
  93851. * @param scope defines the current scope used to restore the JS context
  93852. */
  93853. function Observer(
  93854. /**
  93855. * Defines the callback to call when the observer is notified
  93856. */
  93857. callback,
  93858. /**
  93859. * Defines the mask of the observer (used to filter notifications)
  93860. */
  93861. mask,
  93862. /**
  93863. * Defines the current scope used to restore the JS context
  93864. */
  93865. scope) {
  93866. if (scope === void 0) { scope = null; }
  93867. this.callback = callback;
  93868. this.mask = mask;
  93869. this.scope = scope;
  93870. /** @hidden */
  93871. this._willBeUnregistered = false;
  93872. /**
  93873. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  93874. */
  93875. this.unregisterOnNextCall = false;
  93876. }
  93877. return Observer;
  93878. }());
  93879. /**
  93880. * Represent a list of observers registered to multiple Observables object.
  93881. */
  93882. var MultiObserver = /** @class */ (function () {
  93883. function MultiObserver() {
  93884. }
  93885. /**
  93886. * Release associated resources
  93887. */
  93888. MultiObserver.prototype.dispose = function () {
  93889. if (this._observers && this._observables) {
  93890. for (var index = 0; index < this._observers.length; index++) {
  93891. this._observables[index].remove(this._observers[index]);
  93892. }
  93893. }
  93894. this._observers = null;
  93895. this._observables = null;
  93896. };
  93897. /**
  93898. * Raise a callback when one of the observable will notify
  93899. * @param observables defines a list of observables to watch
  93900. * @param callback defines the callback to call on notification
  93901. * @param mask defines the mask used to filter notifications
  93902. * @param scope defines the current scope used to restore the JS context
  93903. * @returns the new MultiObserver
  93904. */
  93905. MultiObserver.Watch = function (observables, callback, mask, scope) {
  93906. if (mask === void 0) { mask = -1; }
  93907. if (scope === void 0) { scope = null; }
  93908. var result = new MultiObserver();
  93909. result._observers = new Array();
  93910. result._observables = observables;
  93911. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  93912. var observable = observables_1[_i];
  93913. var observer = observable.add(callback, mask, false, scope);
  93914. if (observer) {
  93915. result._observers.push(observer);
  93916. }
  93917. }
  93918. return result;
  93919. };
  93920. return MultiObserver;
  93921. }());
  93922. /**
  93923. * The Observable class is a simple implementation of the Observable pattern.
  93924. *
  93925. * 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.
  93926. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  93927. * 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).
  93928. * 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.
  93929. */
  93930. var Observable = /** @class */ (function () {
  93931. /**
  93932. * Creates a new observable
  93933. * @param onObserverAdded defines a callback to call when a new observer is added
  93934. */
  93935. function Observable(onObserverAdded) {
  93936. this._observers = new Array();
  93937. this._eventState = new EventState(0);
  93938. if (onObserverAdded) {
  93939. this._onObserverAdded = onObserverAdded;
  93940. }
  93941. }
  93942. /**
  93943. * Create a new Observer with the specified callback
  93944. * @param callback the callback that will be executed for that Observer
  93945. * @param mask the mask used to filter observers
  93946. * @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.
  93947. * @param scope optional scope for the callback to be called from
  93948. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  93949. * @returns the new observer created for the callback
  93950. */
  93951. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  93952. if (mask === void 0) { mask = -1; }
  93953. if (insertFirst === void 0) { insertFirst = false; }
  93954. if (scope === void 0) { scope = null; }
  93955. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  93956. if (!callback) {
  93957. return null;
  93958. }
  93959. var observer = new Observer(callback, mask, scope);
  93960. observer.unregisterOnNextCall = unregisterOnFirstCall;
  93961. if (insertFirst) {
  93962. this._observers.unshift(observer);
  93963. }
  93964. else {
  93965. this._observers.push(observer);
  93966. }
  93967. if (this._onObserverAdded) {
  93968. this._onObserverAdded(observer);
  93969. }
  93970. return observer;
  93971. };
  93972. /**
  93973. * Create a new Observer with the specified callback and unregisters after the next notification
  93974. * @param callback the callback that will be executed for that Observer
  93975. * @returns the new observer created for the callback
  93976. */
  93977. Observable.prototype.addOnce = function (callback) {
  93978. return this.add(callback, undefined, undefined, undefined, true);
  93979. };
  93980. /**
  93981. * Remove an Observer from the Observable object
  93982. * @param observer the instance of the Observer to remove
  93983. * @returns false if it doesn't belong to this Observable
  93984. */
  93985. Observable.prototype.remove = function (observer) {
  93986. if (!observer) {
  93987. return false;
  93988. }
  93989. var index = this._observers.indexOf(observer);
  93990. if (index !== -1) {
  93991. this._deferUnregister(observer);
  93992. return true;
  93993. }
  93994. return false;
  93995. };
  93996. /**
  93997. * Remove a callback from the Observable object
  93998. * @param callback the callback to remove
  93999. * @param scope optional scope. If used only the callbacks with this scope will be removed
  94000. * @returns false if it doesn't belong to this Observable
  94001. */
  94002. Observable.prototype.removeCallback = function (callback, scope) {
  94003. for (var index = 0; index < this._observers.length; index++) {
  94004. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  94005. this._deferUnregister(this._observers[index]);
  94006. return true;
  94007. }
  94008. }
  94009. return false;
  94010. };
  94011. Observable.prototype._deferUnregister = function (observer) {
  94012. var _this = this;
  94013. observer.unregisterOnNextCall = false;
  94014. observer._willBeUnregistered = true;
  94015. setTimeout(function () {
  94016. _this._remove(observer);
  94017. }, 0);
  94018. };
  94019. // This should only be called when not iterating over _observers to avoid callback skipping.
  94020. // Removes an observer from the _observer Array.
  94021. Observable.prototype._remove = function (observer) {
  94022. if (!observer) {
  94023. return false;
  94024. }
  94025. var index = this._observers.indexOf(observer);
  94026. if (index !== -1) {
  94027. this._observers.splice(index, 1);
  94028. return true;
  94029. }
  94030. return false;
  94031. };
  94032. /**
  94033. * Notify all Observers by calling their respective callback with the given data
  94034. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  94035. * @param eventData defines the data to send to all observers
  94036. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  94037. * @param target defines the original target of the state
  94038. * @param currentTarget defines the current target of the state
  94039. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  94040. */
  94041. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  94042. if (mask === void 0) { mask = -1; }
  94043. if (!this._observers.length) {
  94044. return true;
  94045. }
  94046. var state = this._eventState;
  94047. state.mask = mask;
  94048. state.target = target;
  94049. state.currentTarget = currentTarget;
  94050. state.skipNextObservers = false;
  94051. state.lastReturnValue = eventData;
  94052. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94053. var obs = _a[_i];
  94054. if (obs._willBeUnregistered) {
  94055. continue;
  94056. }
  94057. if (obs.mask & mask) {
  94058. if (obs.scope) {
  94059. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  94060. }
  94061. else {
  94062. state.lastReturnValue = obs.callback(eventData, state);
  94063. }
  94064. if (obs.unregisterOnNextCall) {
  94065. this._deferUnregister(obs);
  94066. }
  94067. }
  94068. if (state.skipNextObservers) {
  94069. return false;
  94070. }
  94071. }
  94072. return true;
  94073. };
  94074. /**
  94075. * Calling this will execute each callback, expecting it to be a promise or return a value.
  94076. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  94077. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  94078. * and it is crucial that all callbacks will be executed.
  94079. * The order of the callbacks is kept, callbacks are not executed parallel.
  94080. *
  94081. * @param eventData The data to be sent to each callback
  94082. * @param mask is used to filter observers defaults to -1
  94083. * @param target defines the callback target (see EventState)
  94084. * @param currentTarget defines he current object in the bubbling phase
  94085. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  94086. */
  94087. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  94088. var _this = this;
  94089. if (mask === void 0) { mask = -1; }
  94090. // create an empty promise
  94091. var p = Promise.resolve(eventData);
  94092. // no observers? return this promise.
  94093. if (!this._observers.length) {
  94094. return p;
  94095. }
  94096. var state = this._eventState;
  94097. state.mask = mask;
  94098. state.target = target;
  94099. state.currentTarget = currentTarget;
  94100. state.skipNextObservers = false;
  94101. // execute one callback after another (not using Promise.all, the order is important)
  94102. this._observers.forEach(function (obs) {
  94103. if (state.skipNextObservers) {
  94104. return;
  94105. }
  94106. if (obs._willBeUnregistered) {
  94107. return;
  94108. }
  94109. if (obs.mask & mask) {
  94110. if (obs.scope) {
  94111. p = p.then(function (lastReturnedValue) {
  94112. state.lastReturnValue = lastReturnedValue;
  94113. return obs.callback.apply(obs.scope, [eventData, state]);
  94114. });
  94115. }
  94116. else {
  94117. p = p.then(function (lastReturnedValue) {
  94118. state.lastReturnValue = lastReturnedValue;
  94119. return obs.callback(eventData, state);
  94120. });
  94121. }
  94122. if (obs.unregisterOnNextCall) {
  94123. _this._deferUnregister(obs);
  94124. }
  94125. }
  94126. });
  94127. // return the eventData
  94128. return p.then(function () { return eventData; });
  94129. };
  94130. /**
  94131. * Notify a specific observer
  94132. * @param observer defines the observer to notify
  94133. * @param eventData defines the data to be sent to each callback
  94134. * @param mask is used to filter observers defaults to -1
  94135. */
  94136. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  94137. if (mask === void 0) { mask = -1; }
  94138. var state = this._eventState;
  94139. state.mask = mask;
  94140. state.skipNextObservers = false;
  94141. observer.callback(eventData, state);
  94142. };
  94143. /**
  94144. * Gets a boolean indicating if the observable has at least one observer
  94145. * @returns true is the Observable has at least one Observer registered
  94146. */
  94147. Observable.prototype.hasObservers = function () {
  94148. return this._observers.length > 0;
  94149. };
  94150. /**
  94151. * Clear the list of observers
  94152. */
  94153. Observable.prototype.clear = function () {
  94154. this._observers = new Array();
  94155. this._onObserverAdded = null;
  94156. };
  94157. /**
  94158. * Clone the current observable
  94159. * @returns a new observable
  94160. */
  94161. Observable.prototype.clone = function () {
  94162. var result = new Observable();
  94163. result._observers = this._observers.slice(0);
  94164. return result;
  94165. };
  94166. /**
  94167. * Does this observable handles observer registered with a given mask
  94168. * @param mask defines the mask to be tested
  94169. * @return whether or not one observer registered with the given mask is handeled
  94170. **/
  94171. Observable.prototype.hasSpecificMask = function (mask) {
  94172. if (mask === void 0) { mask = -1; }
  94173. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94174. var obs = _a[_i];
  94175. if (obs.mask & mask || obs.mask === mask) {
  94176. return true;
  94177. }
  94178. }
  94179. return false;
  94180. };
  94181. return Observable;
  94182. }());
  94183. /***/ }),
  94184. /***/ "./Misc/performanceMonitor.ts":
  94185. /*!************************************!*\
  94186. !*** ./Misc/performanceMonitor.ts ***!
  94187. \************************************/
  94188. /*! exports provided: PerformanceMonitor, RollingAverage */
  94189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94190. "use strict";
  94191. __webpack_require__.r(__webpack_exports__);
  94192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  94193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  94194. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94195. /**
  94196. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  94197. */
  94198. var PerformanceMonitor = /** @class */ (function () {
  94199. /**
  94200. * constructor
  94201. * @param frameSampleSize The number of samples required to saturate the sliding window
  94202. */
  94203. function PerformanceMonitor(frameSampleSize) {
  94204. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  94205. this._enabled = true;
  94206. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  94207. }
  94208. /**
  94209. * Samples current frame
  94210. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  94211. */
  94212. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  94213. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  94214. if (!this._enabled) {
  94215. return;
  94216. }
  94217. if (this._lastFrameTimeMs != null) {
  94218. var dt = timeMs - this._lastFrameTimeMs;
  94219. this._rollingFrameTime.add(dt);
  94220. }
  94221. this._lastFrameTimeMs = timeMs;
  94222. };
  94223. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  94224. /**
  94225. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94226. */
  94227. get: function () {
  94228. return this._rollingFrameTime.average;
  94229. },
  94230. enumerable: true,
  94231. configurable: true
  94232. });
  94233. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  94234. /**
  94235. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94236. */
  94237. get: function () {
  94238. return this._rollingFrameTime.variance;
  94239. },
  94240. enumerable: true,
  94241. configurable: true
  94242. });
  94243. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  94244. /**
  94245. * Returns the frame time of the most recent frame
  94246. */
  94247. get: function () {
  94248. return this._rollingFrameTime.history(0);
  94249. },
  94250. enumerable: true,
  94251. configurable: true
  94252. });
  94253. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  94254. /**
  94255. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  94256. */
  94257. get: function () {
  94258. return 1000.0 / this._rollingFrameTime.average;
  94259. },
  94260. enumerable: true,
  94261. configurable: true
  94262. });
  94263. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  94264. /**
  94265. * Returns the average framerate in frames per second using the most recent frame time
  94266. */
  94267. get: function () {
  94268. var history = this._rollingFrameTime.history(0);
  94269. if (history === 0) {
  94270. return 0;
  94271. }
  94272. return 1000.0 / history;
  94273. },
  94274. enumerable: true,
  94275. configurable: true
  94276. });
  94277. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  94278. /**
  94279. * Returns true if enough samples have been taken to completely fill the sliding window
  94280. */
  94281. get: function () {
  94282. return this._rollingFrameTime.isSaturated();
  94283. },
  94284. enumerable: true,
  94285. configurable: true
  94286. });
  94287. /**
  94288. * Enables contributions to the sliding window sample set
  94289. */
  94290. PerformanceMonitor.prototype.enable = function () {
  94291. this._enabled = true;
  94292. };
  94293. /**
  94294. * Disables contributions to the sliding window sample set
  94295. * Samples will not be interpolated over the disabled period
  94296. */
  94297. PerformanceMonitor.prototype.disable = function () {
  94298. this._enabled = false;
  94299. //clear last sample to avoid interpolating over the disabled period when next enabled
  94300. this._lastFrameTimeMs = null;
  94301. };
  94302. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  94303. /**
  94304. * Returns true if sampling is enabled
  94305. */
  94306. get: function () {
  94307. return this._enabled;
  94308. },
  94309. enumerable: true,
  94310. configurable: true
  94311. });
  94312. /**
  94313. * Resets performance monitor
  94314. */
  94315. PerformanceMonitor.prototype.reset = function () {
  94316. //clear last sample to avoid interpolating over the disabled period when next enabled
  94317. this._lastFrameTimeMs = null;
  94318. //wipe record
  94319. this._rollingFrameTime.reset();
  94320. };
  94321. return PerformanceMonitor;
  94322. }());
  94323. /**
  94324. * RollingAverage
  94325. *
  94326. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  94327. */
  94328. var RollingAverage = /** @class */ (function () {
  94329. /**
  94330. * constructor
  94331. * @param length The number of samples required to saturate the sliding window
  94332. */
  94333. function RollingAverage(length) {
  94334. this._samples = new Array(length);
  94335. this.reset();
  94336. }
  94337. /**
  94338. * Adds a sample to the sample set
  94339. * @param v The sample value
  94340. */
  94341. RollingAverage.prototype.add = function (v) {
  94342. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  94343. var delta;
  94344. //we need to check if we've already wrapped round
  94345. if (this.isSaturated()) {
  94346. //remove bottom of stack from mean
  94347. var bottomValue = this._samples[this._pos];
  94348. delta = bottomValue - this.average;
  94349. this.average -= delta / (this._sampleCount - 1);
  94350. this._m2 -= delta * (bottomValue - this.average);
  94351. }
  94352. else {
  94353. this._sampleCount++;
  94354. }
  94355. //add new value to mean
  94356. delta = v - this.average;
  94357. this.average += delta / (this._sampleCount);
  94358. this._m2 += delta * (v - this.average);
  94359. //set the new variance
  94360. this.variance = this._m2 / (this._sampleCount - 1);
  94361. this._samples[this._pos] = v;
  94362. this._pos++;
  94363. this._pos %= this._samples.length; //positive wrap around
  94364. };
  94365. /**
  94366. * Returns previously added values or null if outside of history or outside the sliding window domain
  94367. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  94368. * @return Value previously recorded with add() or null if outside of range
  94369. */
  94370. RollingAverage.prototype.history = function (i) {
  94371. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  94372. return 0;
  94373. }
  94374. var i0 = this._wrapPosition(this._pos - 1.0);
  94375. return this._samples[this._wrapPosition(i0 - i)];
  94376. };
  94377. /**
  94378. * Returns true if enough samples have been taken to completely fill the sliding window
  94379. * @return true if sample-set saturated
  94380. */
  94381. RollingAverage.prototype.isSaturated = function () {
  94382. return this._sampleCount >= this._samples.length;
  94383. };
  94384. /**
  94385. * Resets the rolling average (equivalent to 0 samples taken so far)
  94386. */
  94387. RollingAverage.prototype.reset = function () {
  94388. this.average = 0;
  94389. this.variance = 0;
  94390. this._sampleCount = 0;
  94391. this._pos = 0;
  94392. this._m2 = 0;
  94393. };
  94394. /**
  94395. * Wraps a value around the sample range boundaries
  94396. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  94397. * @return Wrapped position in sample range
  94398. */
  94399. RollingAverage.prototype._wrapPosition = function (i) {
  94400. var max = this._samples.length;
  94401. return ((i % max) + max) % max;
  94402. };
  94403. return RollingAverage;
  94404. }());
  94405. /***/ }),
  94406. /***/ "./Misc/pivotTools.ts":
  94407. /*!****************************!*\
  94408. !*** ./Misc/pivotTools.ts ***!
  94409. \****************************/
  94410. /*! exports provided: PivotTools */
  94411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94412. "use strict";
  94413. __webpack_require__.r(__webpack_exports__);
  94414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  94415. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94416. /**
  94417. * Class containing a set of static utilities functions for managing Pivots
  94418. * @hidden
  94419. */
  94420. var PivotTools = /** @class */ (function () {
  94421. function PivotTools() {
  94422. }
  94423. /** @hidden */
  94424. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  94425. if (mesh && PivotTools._PivotCached === 0) {
  94426. // Save old pivot and set pivot to 0,0,0
  94427. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  94428. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  94429. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  94430. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  94431. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94432. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94433. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94434. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  94435. }
  94436. }
  94437. PivotTools._PivotCached++;
  94438. };
  94439. /** @hidden */
  94440. PivotTools._RestorePivotPoint = function (mesh) {
  94441. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  94442. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  94443. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94444. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94445. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94446. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  94447. }
  94448. this._PivotCached--;
  94449. };
  94450. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  94451. // store/remove pivot point should only be applied during their outermost calls
  94452. PivotTools._PivotCached = 0;
  94453. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94454. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94455. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94456. return PivotTools;
  94457. }());
  94458. /***/ }),
  94459. /***/ "./Misc/precisionDate.ts":
  94460. /*!*******************************!*\
  94461. !*** ./Misc/precisionDate.ts ***!
  94462. \*******************************/
  94463. /*! exports provided: PrecisionDate */
  94464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94465. "use strict";
  94466. __webpack_require__.r(__webpack_exports__);
  94467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  94468. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  94469. /**
  94470. * Class containing a set of static utilities functions for precision date
  94471. */
  94472. var PrecisionDate = /** @class */ (function () {
  94473. function PrecisionDate() {
  94474. }
  94475. Object.defineProperty(PrecisionDate, "Now", {
  94476. /**
  94477. * Gets either window.performance.now() if supported or Date.now() else
  94478. */
  94479. get: function () {
  94480. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  94481. return window.performance.now();
  94482. }
  94483. return Date.now();
  94484. },
  94485. enumerable: true,
  94486. configurable: true
  94487. });
  94488. return PrecisionDate;
  94489. }());
  94490. /***/ }),
  94491. /***/ "./Misc/promise.ts":
  94492. /*!*************************!*\
  94493. !*** ./Misc/promise.ts ***!
  94494. \*************************/
  94495. /*! exports provided: PromisePolyfill */
  94496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94497. "use strict";
  94498. __webpack_require__.r(__webpack_exports__);
  94499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  94500. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94501. var PromiseStates;
  94502. (function (PromiseStates) {
  94503. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  94504. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  94505. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  94506. })(PromiseStates || (PromiseStates = {}));
  94507. var FulFillmentAgregator = /** @class */ (function () {
  94508. function FulFillmentAgregator() {
  94509. this.count = 0;
  94510. this.target = 0;
  94511. this.results = [];
  94512. }
  94513. return FulFillmentAgregator;
  94514. }());
  94515. var InternalPromise = /** @class */ (function () {
  94516. function InternalPromise(resolver) {
  94517. var _this = this;
  94518. this._state = PromiseStates.Pending;
  94519. this._children = new Array();
  94520. this._rejectWasConsumed = false;
  94521. if (!resolver) {
  94522. return;
  94523. }
  94524. try {
  94525. resolver(function (value) {
  94526. _this._resolve(value);
  94527. }, function (reason) {
  94528. _this._reject(reason);
  94529. });
  94530. }
  94531. catch (e) {
  94532. this._reject(e);
  94533. }
  94534. }
  94535. Object.defineProperty(InternalPromise.prototype, "_result", {
  94536. get: function () {
  94537. return this._resultValue;
  94538. },
  94539. set: function (value) {
  94540. this._resultValue = value;
  94541. if (this._parent && this._parent._result === undefined) {
  94542. this._parent._result = value;
  94543. }
  94544. },
  94545. enumerable: true,
  94546. configurable: true
  94547. });
  94548. InternalPromise.prototype.catch = function (onRejected) {
  94549. return this.then(undefined, onRejected);
  94550. };
  94551. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  94552. var _this = this;
  94553. var newPromise = new InternalPromise();
  94554. newPromise._onFulfilled = onFulfilled;
  94555. newPromise._onRejected = onRejected;
  94556. // Composition
  94557. this._children.push(newPromise);
  94558. newPromise._parent = this;
  94559. if (this._state !== PromiseStates.Pending) {
  94560. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  94561. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  94562. var returnedValue = newPromise._resolve(_this._result);
  94563. if (returnedValue !== undefined && returnedValue !== null) {
  94564. if (returnedValue._state !== undefined) {
  94565. var returnedPromise = returnedValue;
  94566. newPromise._children.push(returnedPromise);
  94567. returnedPromise._parent = newPromise;
  94568. newPromise = returnedPromise;
  94569. }
  94570. else {
  94571. newPromise._result = returnedValue;
  94572. }
  94573. }
  94574. }
  94575. else {
  94576. newPromise._reject(_this._reason);
  94577. }
  94578. });
  94579. }
  94580. return newPromise;
  94581. };
  94582. InternalPromise.prototype._moveChildren = function (children) {
  94583. var _this = this;
  94584. var _a;
  94585. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  94586. this._children.forEach(function (child) {
  94587. child._parent = _this;
  94588. });
  94589. if (this._state === PromiseStates.Fulfilled) {
  94590. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  94591. var child = _b[_i];
  94592. child._resolve(this._result);
  94593. }
  94594. }
  94595. else if (this._state === PromiseStates.Rejected) {
  94596. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  94597. var child = _d[_c];
  94598. child._reject(this._reason);
  94599. }
  94600. }
  94601. };
  94602. InternalPromise.prototype._resolve = function (value) {
  94603. try {
  94604. this._state = PromiseStates.Fulfilled;
  94605. var returnedValue = null;
  94606. if (this._onFulfilled) {
  94607. returnedValue = this._onFulfilled(value);
  94608. }
  94609. if (returnedValue !== undefined && returnedValue !== null) {
  94610. if (returnedValue._state !== undefined) {
  94611. // Transmit children
  94612. var returnedPromise = returnedValue;
  94613. returnedPromise._parent = this;
  94614. returnedPromise._moveChildren(this._children);
  94615. value = returnedPromise._result;
  94616. }
  94617. else {
  94618. value = returnedValue;
  94619. }
  94620. }
  94621. this._result = value;
  94622. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94623. var child = _a[_i];
  94624. child._resolve(value);
  94625. }
  94626. this._children.length = 0;
  94627. delete this._onFulfilled;
  94628. delete this._onRejected;
  94629. }
  94630. catch (e) {
  94631. this._reject(e, true);
  94632. }
  94633. };
  94634. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  94635. if (onLocalThrow === void 0) { onLocalThrow = false; }
  94636. this._state = PromiseStates.Rejected;
  94637. this._reason = reason;
  94638. if (this._onRejected && !onLocalThrow) {
  94639. try {
  94640. this._onRejected(reason);
  94641. this._rejectWasConsumed = true;
  94642. }
  94643. catch (e) {
  94644. reason = e;
  94645. }
  94646. }
  94647. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94648. var child = _a[_i];
  94649. if (this._rejectWasConsumed) {
  94650. child._resolve(null);
  94651. }
  94652. else {
  94653. child._reject(reason);
  94654. }
  94655. }
  94656. this._children.length = 0;
  94657. delete this._onFulfilled;
  94658. delete this._onRejected;
  94659. };
  94660. InternalPromise.resolve = function (value) {
  94661. var newPromise = new InternalPromise();
  94662. newPromise._resolve(value);
  94663. return newPromise;
  94664. };
  94665. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  94666. promise.then(function (value) {
  94667. agregator.results[index] = value;
  94668. agregator.count++;
  94669. if (agregator.count === agregator.target) {
  94670. agregator.rootPromise._resolve(agregator.results);
  94671. }
  94672. return null;
  94673. }, function (reason) {
  94674. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  94675. agregator.rootPromise._reject(reason);
  94676. }
  94677. });
  94678. };
  94679. InternalPromise.all = function (promises) {
  94680. var newPromise = new InternalPromise();
  94681. var agregator = new FulFillmentAgregator();
  94682. agregator.target = promises.length;
  94683. agregator.rootPromise = newPromise;
  94684. if (promises.length) {
  94685. for (var index = 0; index < promises.length; index++) {
  94686. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  94687. }
  94688. }
  94689. else {
  94690. newPromise._resolve([]);
  94691. }
  94692. return newPromise;
  94693. };
  94694. InternalPromise.race = function (promises) {
  94695. var newPromise = new InternalPromise();
  94696. if (promises.length) {
  94697. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  94698. var promise = promises_1[_i];
  94699. promise.then(function (value) {
  94700. if (newPromise) {
  94701. newPromise._resolve(value);
  94702. newPromise = null;
  94703. }
  94704. return null;
  94705. }, function (reason) {
  94706. if (newPromise) {
  94707. newPromise._reject(reason);
  94708. newPromise = null;
  94709. }
  94710. });
  94711. }
  94712. }
  94713. return newPromise;
  94714. };
  94715. return InternalPromise;
  94716. }());
  94717. /**
  94718. * Helper class that provides a small promise polyfill
  94719. */
  94720. var PromisePolyfill = /** @class */ (function () {
  94721. function PromisePolyfill() {
  94722. }
  94723. /**
  94724. * Static function used to check if the polyfill is required
  94725. * If this is the case then the function will inject the polyfill to window.Promise
  94726. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  94727. */
  94728. PromisePolyfill.Apply = function (force) {
  94729. if (force === void 0) { force = false; }
  94730. if (force || typeof Promise === 'undefined') {
  94731. var root = window;
  94732. root.Promise = InternalPromise;
  94733. }
  94734. };
  94735. return PromisePolyfill;
  94736. }());
  94737. /***/ }),
  94738. /***/ "./Misc/sceneOptimizer.ts":
  94739. /*!********************************!*\
  94740. !*** ./Misc/sceneOptimizer.ts ***!
  94741. \********************************/
  94742. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  94743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94744. "use strict";
  94745. __webpack_require__.r(__webpack_exports__);
  94746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  94747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  94748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  94749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  94750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  94751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  94752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  94753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  94754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  94755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  94756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  94757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  94758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94759. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  94760. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  94761. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94762. /**
  94763. * Defines the root class used to create scene optimization to use with SceneOptimizer
  94764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94765. */
  94766. var SceneOptimization = /** @class */ (function () {
  94767. /**
  94768. * Creates the SceneOptimization object
  94769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  94770. * @param desc defines the description associated with the optimization
  94771. */
  94772. function SceneOptimization(
  94773. /**
  94774. * Defines the priority of this optimization (0 by default which means first in the list)
  94775. */
  94776. priority) {
  94777. if (priority === void 0) { priority = 0; }
  94778. this.priority = priority;
  94779. }
  94780. /**
  94781. * Gets a string describing the action executed by the current optimization
  94782. * @returns description string
  94783. */
  94784. SceneOptimization.prototype.getDescription = function () {
  94785. return "";
  94786. };
  94787. /**
  94788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94789. * @param scene defines the current scene where to apply this optimization
  94790. * @param optimizer defines the current optimizer
  94791. * @returns true if everything that can be done was applied
  94792. */
  94793. SceneOptimization.prototype.apply = function (scene, optimizer) {
  94794. return true;
  94795. };
  94796. return SceneOptimization;
  94797. }());
  94798. /**
  94799. * Defines an optimization used to reduce the size of render target textures
  94800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94801. */
  94802. var TextureOptimization = /** @class */ (function (_super) {
  94803. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  94804. /**
  94805. * Creates the TextureOptimization object
  94806. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  94807. * @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
  94808. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  94809. */
  94810. function TextureOptimization(
  94811. /**
  94812. * Defines the priority of this optimization (0 by default which means first in the list)
  94813. */
  94814. priority,
  94815. /**
  94816. * 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
  94817. */
  94818. maximumSize,
  94819. /**
  94820. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  94821. */
  94822. step) {
  94823. if (priority === void 0) { priority = 0; }
  94824. if (maximumSize === void 0) { maximumSize = 1024; }
  94825. if (step === void 0) { step = 0.5; }
  94826. var _this = _super.call(this, priority) || this;
  94827. _this.priority = priority;
  94828. _this.maximumSize = maximumSize;
  94829. _this.step = step;
  94830. return _this;
  94831. }
  94832. /**
  94833. * Gets a string describing the action executed by the current optimization
  94834. * @returns description string
  94835. */
  94836. TextureOptimization.prototype.getDescription = function () {
  94837. return "Reducing render target texture size to " + this.maximumSize;
  94838. };
  94839. /**
  94840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94841. * @param scene defines the current scene where to apply this optimization
  94842. * @param optimizer defines the current optimizer
  94843. * @returns true if everything that can be done was applied
  94844. */
  94845. TextureOptimization.prototype.apply = function (scene, optimizer) {
  94846. var allDone = true;
  94847. for (var index = 0; index < scene.textures.length; index++) {
  94848. var texture = scene.textures[index];
  94849. if (!texture.canRescale || texture.getContext) {
  94850. continue;
  94851. }
  94852. var currentSize = texture.getSize();
  94853. var maxDimension = Math.max(currentSize.width, currentSize.height);
  94854. if (maxDimension > this.maximumSize) {
  94855. texture.scale(this.step);
  94856. allDone = false;
  94857. }
  94858. }
  94859. return allDone;
  94860. };
  94861. return TextureOptimization;
  94862. }(SceneOptimization));
  94863. /**
  94864. * Defines an optimization used to increase or decrease the rendering resolution
  94865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94866. */
  94867. var HardwareScalingOptimization = /** @class */ (function (_super) {
  94868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  94869. /**
  94870. * Creates the HardwareScalingOptimization object
  94871. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  94872. * @param maximumScale defines the maximum scale to use (2 by default)
  94873. * @param step defines the step to use between two passes (0.5 by default)
  94874. */
  94875. function HardwareScalingOptimization(
  94876. /**
  94877. * Defines the priority of this optimization (0 by default which means first in the list)
  94878. */
  94879. priority,
  94880. /**
  94881. * Defines the maximum scale to use (2 by default)
  94882. */
  94883. maximumScale,
  94884. /**
  94885. * Defines the step to use between two passes (0.5 by default)
  94886. */
  94887. step) {
  94888. if (priority === void 0) { priority = 0; }
  94889. if (maximumScale === void 0) { maximumScale = 2; }
  94890. if (step === void 0) { step = 0.25; }
  94891. var _this = _super.call(this, priority) || this;
  94892. _this.priority = priority;
  94893. _this.maximumScale = maximumScale;
  94894. _this.step = step;
  94895. _this._currentScale = -1;
  94896. _this._directionOffset = 1;
  94897. return _this;
  94898. }
  94899. /**
  94900. * Gets a string describing the action executed by the current optimization
  94901. * @return description string
  94902. */
  94903. HardwareScalingOptimization.prototype.getDescription = function () {
  94904. return "Setting hardware scaling level to " + this._currentScale;
  94905. };
  94906. /**
  94907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94908. * @param scene defines the current scene where to apply this optimization
  94909. * @param optimizer defines the current optimizer
  94910. * @returns true if everything that can be done was applied
  94911. */
  94912. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  94913. if (this._currentScale === -1) {
  94914. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  94915. if (this._currentScale > this.maximumScale) {
  94916. this._directionOffset = -1;
  94917. }
  94918. }
  94919. this._currentScale += this._directionOffset * this.step;
  94920. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  94921. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  94922. };
  94923. return HardwareScalingOptimization;
  94924. }(SceneOptimization));
  94925. /**
  94926. * Defines an optimization used to remove shadows
  94927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94928. */
  94929. var ShadowsOptimization = /** @class */ (function (_super) {
  94930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  94931. function ShadowsOptimization() {
  94932. return _super !== null && _super.apply(this, arguments) || this;
  94933. }
  94934. /**
  94935. * Gets a string describing the action executed by the current optimization
  94936. * @return description string
  94937. */
  94938. ShadowsOptimization.prototype.getDescription = function () {
  94939. return "Turning shadows on/off";
  94940. };
  94941. /**
  94942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94943. * @param scene defines the current scene where to apply this optimization
  94944. * @param optimizer defines the current optimizer
  94945. * @returns true if everything that can be done was applied
  94946. */
  94947. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  94948. scene.shadowsEnabled = optimizer.isInImprovementMode;
  94949. return true;
  94950. };
  94951. return ShadowsOptimization;
  94952. }(SceneOptimization));
  94953. /**
  94954. * Defines an optimization used to turn post-processes off
  94955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94956. */
  94957. var PostProcessesOptimization = /** @class */ (function (_super) {
  94958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  94959. function PostProcessesOptimization() {
  94960. return _super !== null && _super.apply(this, arguments) || this;
  94961. }
  94962. /**
  94963. * Gets a string describing the action executed by the current optimization
  94964. * @return description string
  94965. */
  94966. PostProcessesOptimization.prototype.getDescription = function () {
  94967. return "Turning post-processes on/off";
  94968. };
  94969. /**
  94970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94971. * @param scene defines the current scene where to apply this optimization
  94972. * @param optimizer defines the current optimizer
  94973. * @returns true if everything that can be done was applied
  94974. */
  94975. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  94976. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  94977. return true;
  94978. };
  94979. return PostProcessesOptimization;
  94980. }(SceneOptimization));
  94981. /**
  94982. * Defines an optimization used to turn lens flares off
  94983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94984. */
  94985. var LensFlaresOptimization = /** @class */ (function (_super) {
  94986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  94987. function LensFlaresOptimization() {
  94988. return _super !== null && _super.apply(this, arguments) || this;
  94989. }
  94990. /**
  94991. * Gets a string describing the action executed by the current optimization
  94992. * @return description string
  94993. */
  94994. LensFlaresOptimization.prototype.getDescription = function () {
  94995. return "Turning lens flares on/off";
  94996. };
  94997. /**
  94998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94999. * @param scene defines the current scene where to apply this optimization
  95000. * @param optimizer defines the current optimizer
  95001. * @returns true if everything that can be done was applied
  95002. */
  95003. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  95004. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  95005. return true;
  95006. };
  95007. return LensFlaresOptimization;
  95008. }(SceneOptimization));
  95009. /**
  95010. * Defines an optimization based on user defined callback.
  95011. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95012. */
  95013. var CustomOptimization = /** @class */ (function (_super) {
  95014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  95015. function CustomOptimization() {
  95016. return _super !== null && _super.apply(this, arguments) || this;
  95017. }
  95018. /**
  95019. * Gets a string describing the action executed by the current optimization
  95020. * @returns description string
  95021. */
  95022. CustomOptimization.prototype.getDescription = function () {
  95023. if (this.onGetDescription) {
  95024. return this.onGetDescription();
  95025. }
  95026. return "Running user defined callback";
  95027. };
  95028. /**
  95029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95030. * @param scene defines the current scene where to apply this optimization
  95031. * @param optimizer defines the current optimizer
  95032. * @returns true if everything that can be done was applied
  95033. */
  95034. CustomOptimization.prototype.apply = function (scene, optimizer) {
  95035. if (this.onApply) {
  95036. return this.onApply(scene, optimizer);
  95037. }
  95038. return true;
  95039. };
  95040. return CustomOptimization;
  95041. }(SceneOptimization));
  95042. /**
  95043. * Defines an optimization used to turn particles off
  95044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95045. */
  95046. var ParticlesOptimization = /** @class */ (function (_super) {
  95047. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  95048. function ParticlesOptimization() {
  95049. return _super !== null && _super.apply(this, arguments) || this;
  95050. }
  95051. /**
  95052. * Gets a string describing the action executed by the current optimization
  95053. * @return description string
  95054. */
  95055. ParticlesOptimization.prototype.getDescription = function () {
  95056. return "Turning particles on/off";
  95057. };
  95058. /**
  95059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95060. * @param scene defines the current scene where to apply this optimization
  95061. * @param optimizer defines the current optimizer
  95062. * @returns true if everything that can be done was applied
  95063. */
  95064. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  95065. scene.particlesEnabled = optimizer.isInImprovementMode;
  95066. return true;
  95067. };
  95068. return ParticlesOptimization;
  95069. }(SceneOptimization));
  95070. /**
  95071. * Defines an optimization used to turn render targets off
  95072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95073. */
  95074. var RenderTargetsOptimization = /** @class */ (function (_super) {
  95075. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  95076. function RenderTargetsOptimization() {
  95077. return _super !== null && _super.apply(this, arguments) || this;
  95078. }
  95079. /**
  95080. * Gets a string describing the action executed by the current optimization
  95081. * @return description string
  95082. */
  95083. RenderTargetsOptimization.prototype.getDescription = function () {
  95084. return "Turning render targets off";
  95085. };
  95086. /**
  95087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95088. * @param scene defines the current scene where to apply this optimization
  95089. * @param optimizer defines the current optimizer
  95090. * @returns true if everything that can be done was applied
  95091. */
  95092. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  95093. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  95094. return true;
  95095. };
  95096. return RenderTargetsOptimization;
  95097. }(SceneOptimization));
  95098. /**
  95099. * Defines an optimization used to merge meshes with compatible materials
  95100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95101. */
  95102. var MergeMeshesOptimization = /** @class */ (function (_super) {
  95103. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  95104. function MergeMeshesOptimization() {
  95105. var _this = _super !== null && _super.apply(this, arguments) || this;
  95106. _this._canBeMerged = function (abstractMesh) {
  95107. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  95108. return false;
  95109. }
  95110. var mesh = abstractMesh;
  95111. if (mesh.isDisposed()) {
  95112. return false;
  95113. }
  95114. if (!mesh.isVisible || !mesh.isEnabled()) {
  95115. return false;
  95116. }
  95117. if (mesh.instances.length > 0) {
  95118. return false;
  95119. }
  95120. if (mesh.skeleton || mesh.hasLODLevels) {
  95121. return false;
  95122. }
  95123. return true;
  95124. };
  95125. return _this;
  95126. }
  95127. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  95128. /**
  95129. * Gets or sets a boolean which defines if optimization octree has to be updated
  95130. */
  95131. get: function () {
  95132. return MergeMeshesOptimization._UpdateSelectionTree;
  95133. },
  95134. /**
  95135. * Gets or sets a boolean which defines if optimization octree has to be updated
  95136. */
  95137. set: function (value) {
  95138. MergeMeshesOptimization._UpdateSelectionTree = value;
  95139. },
  95140. enumerable: true,
  95141. configurable: true
  95142. });
  95143. /**
  95144. * Gets a string describing the action executed by the current optimization
  95145. * @return description string
  95146. */
  95147. MergeMeshesOptimization.prototype.getDescription = function () {
  95148. return "Merging similar meshes together";
  95149. };
  95150. /**
  95151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95152. * @param scene defines the current scene where to apply this optimization
  95153. * @param optimizer defines the current optimizer
  95154. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  95155. * @returns true if everything that can be done was applied
  95156. */
  95157. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  95158. var globalPool = scene.meshes.slice(0);
  95159. var globalLength = globalPool.length;
  95160. for (var index = 0; index < globalLength; index++) {
  95161. var currentPool = new Array();
  95162. var current = globalPool[index];
  95163. // Checks
  95164. if (!this._canBeMerged(current)) {
  95165. continue;
  95166. }
  95167. currentPool.push(current);
  95168. // Find compatible meshes
  95169. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  95170. var otherMesh = globalPool[subIndex];
  95171. if (!this._canBeMerged(otherMesh)) {
  95172. continue;
  95173. }
  95174. if (otherMesh.material !== current.material) {
  95175. continue;
  95176. }
  95177. if (otherMesh.checkCollisions !== current.checkCollisions) {
  95178. continue;
  95179. }
  95180. currentPool.push(otherMesh);
  95181. globalLength--;
  95182. globalPool.splice(subIndex, 1);
  95183. subIndex--;
  95184. }
  95185. if (currentPool.length < 2) {
  95186. continue;
  95187. }
  95188. // Merge meshes
  95189. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  95190. }
  95191. // Call the octree system optimization if it is defined.
  95192. var sceneAsAny = scene;
  95193. if (sceneAsAny.createOrUpdateSelectionOctree) {
  95194. if (updateSelectionTree != undefined) {
  95195. if (updateSelectionTree) {
  95196. sceneAsAny.createOrUpdateSelectionOctree();
  95197. }
  95198. }
  95199. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  95200. sceneAsAny.createOrUpdateSelectionOctree();
  95201. }
  95202. }
  95203. return true;
  95204. };
  95205. MergeMeshesOptimization._UpdateSelectionTree = false;
  95206. return MergeMeshesOptimization;
  95207. }(SceneOptimization));
  95208. /**
  95209. * Defines a list of options used by SceneOptimizer
  95210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95211. */
  95212. var SceneOptimizerOptions = /** @class */ (function () {
  95213. /**
  95214. * Creates a new list of options used by SceneOptimizer
  95215. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  95216. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  95217. */
  95218. function SceneOptimizerOptions(
  95219. /**
  95220. * Defines the target frame rate to reach (60 by default)
  95221. */
  95222. targetFrameRate,
  95223. /**
  95224. * Defines the interval between two checkes (2000ms by default)
  95225. */
  95226. trackerDuration) {
  95227. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  95228. if (trackerDuration === void 0) { trackerDuration = 2000; }
  95229. this.targetFrameRate = targetFrameRate;
  95230. this.trackerDuration = trackerDuration;
  95231. /**
  95232. * Gets the list of optimizations to apply
  95233. */
  95234. this.optimizations = new Array();
  95235. }
  95236. /**
  95237. * Add a new optimization
  95238. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  95239. * @returns the current SceneOptimizerOptions
  95240. */
  95241. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  95242. this.optimizations.push(optimization);
  95243. return this;
  95244. };
  95245. /**
  95246. * Add a new custom optimization
  95247. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  95248. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  95249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95250. * @returns the current SceneOptimizerOptions
  95251. */
  95252. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  95253. if (priority === void 0) { priority = 0; }
  95254. var optimization = new CustomOptimization(priority);
  95255. optimization.onApply = onApply;
  95256. optimization.onGetDescription = onGetDescription;
  95257. this.optimizations.push(optimization);
  95258. return this;
  95259. };
  95260. /**
  95261. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  95262. * @param targetFrameRate defines the target frame rate (60 by default)
  95263. * @returns a SceneOptimizerOptions object
  95264. */
  95265. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  95266. var result = new SceneOptimizerOptions(targetFrameRate);
  95267. var priority = 0;
  95268. result.addOptimization(new MergeMeshesOptimization(priority));
  95269. result.addOptimization(new ShadowsOptimization(priority));
  95270. result.addOptimization(new LensFlaresOptimization(priority));
  95271. // Next priority
  95272. priority++;
  95273. result.addOptimization(new PostProcessesOptimization(priority));
  95274. result.addOptimization(new ParticlesOptimization(priority));
  95275. // Next priority
  95276. priority++;
  95277. result.addOptimization(new TextureOptimization(priority, 1024));
  95278. return result;
  95279. };
  95280. /**
  95281. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  95282. * @param targetFrameRate defines the target frame rate (60 by default)
  95283. * @returns a SceneOptimizerOptions object
  95284. */
  95285. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  95286. var result = new SceneOptimizerOptions(targetFrameRate);
  95287. var priority = 0;
  95288. result.addOptimization(new MergeMeshesOptimization(priority));
  95289. result.addOptimization(new ShadowsOptimization(priority));
  95290. result.addOptimization(new LensFlaresOptimization(priority));
  95291. // Next priority
  95292. priority++;
  95293. result.addOptimization(new PostProcessesOptimization(priority));
  95294. result.addOptimization(new ParticlesOptimization(priority));
  95295. // Next priority
  95296. priority++;
  95297. result.addOptimization(new TextureOptimization(priority, 512));
  95298. // Next priority
  95299. priority++;
  95300. result.addOptimization(new RenderTargetsOptimization(priority));
  95301. // Next priority
  95302. priority++;
  95303. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  95304. return result;
  95305. };
  95306. /**
  95307. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  95308. * @param targetFrameRate defines the target frame rate (60 by default)
  95309. * @returns a SceneOptimizerOptions object
  95310. */
  95311. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  95312. var result = new SceneOptimizerOptions(targetFrameRate);
  95313. var priority = 0;
  95314. result.addOptimization(new MergeMeshesOptimization(priority));
  95315. result.addOptimization(new ShadowsOptimization(priority));
  95316. result.addOptimization(new LensFlaresOptimization(priority));
  95317. // Next priority
  95318. priority++;
  95319. result.addOptimization(new PostProcessesOptimization(priority));
  95320. result.addOptimization(new ParticlesOptimization(priority));
  95321. // Next priority
  95322. priority++;
  95323. result.addOptimization(new TextureOptimization(priority, 256));
  95324. // Next priority
  95325. priority++;
  95326. result.addOptimization(new RenderTargetsOptimization(priority));
  95327. // Next priority
  95328. priority++;
  95329. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  95330. return result;
  95331. };
  95332. return SceneOptimizerOptions;
  95333. }());
  95334. /**
  95335. * Class used to run optimizations in order to reach a target frame rate
  95336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95337. */
  95338. var SceneOptimizer = /** @class */ (function () {
  95339. /**
  95340. * Creates a new SceneOptimizer
  95341. * @param scene defines the scene to work on
  95342. * @param options defines the options to use with the SceneOptimizer
  95343. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  95344. * @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)
  95345. */
  95346. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  95347. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  95348. if (improvementMode === void 0) { improvementMode = false; }
  95349. var _this = this;
  95350. this._isRunning = false;
  95351. this._currentPriorityLevel = 0;
  95352. this._targetFrameRate = 60;
  95353. this._trackerDuration = 2000;
  95354. this._currentFrameRate = 0;
  95355. this._improvementMode = false;
  95356. /**
  95357. * Defines an observable called when the optimizer reaches the target frame rate
  95358. */
  95359. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95360. /**
  95361. * Defines an observable called when the optimizer enables an optimization
  95362. */
  95363. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95364. /**
  95365. * Defines an observable called when the optimizer is not able to reach the target frame rate
  95366. */
  95367. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95368. if (!options) {
  95369. this._options = new SceneOptimizerOptions();
  95370. }
  95371. else {
  95372. this._options = options;
  95373. }
  95374. if (this._options.targetFrameRate) {
  95375. this._targetFrameRate = this._options.targetFrameRate;
  95376. }
  95377. if (this._options.trackerDuration) {
  95378. this._trackerDuration = this._options.trackerDuration;
  95379. }
  95380. if (autoGeneratePriorities) {
  95381. var priority = 0;
  95382. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  95383. var optim = _a[_i];
  95384. optim.priority = priority++;
  95385. }
  95386. }
  95387. this._improvementMode = improvementMode;
  95388. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  95389. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  95390. _this._sceneDisposeObserver = null;
  95391. _this.dispose();
  95392. });
  95393. }
  95394. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  95395. /**
  95396. * Gets a boolean indicating if the optimizer is in improvement mode
  95397. */
  95398. get: function () {
  95399. return this._improvementMode;
  95400. },
  95401. enumerable: true,
  95402. configurable: true
  95403. });
  95404. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  95405. /**
  95406. * Gets the current priority level (0 at start)
  95407. */
  95408. get: function () {
  95409. return this._currentPriorityLevel;
  95410. },
  95411. enumerable: true,
  95412. configurable: true
  95413. });
  95414. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  95415. /**
  95416. * Gets the current frame rate checked by the SceneOptimizer
  95417. */
  95418. get: function () {
  95419. return this._currentFrameRate;
  95420. },
  95421. enumerable: true,
  95422. configurable: true
  95423. });
  95424. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  95425. /**
  95426. * Gets or sets the current target frame rate (60 by default)
  95427. */
  95428. get: function () {
  95429. return this._targetFrameRate;
  95430. },
  95431. /**
  95432. * Gets or sets the current target frame rate (60 by default)
  95433. */
  95434. set: function (value) {
  95435. this._targetFrameRate = value;
  95436. },
  95437. enumerable: true,
  95438. configurable: true
  95439. });
  95440. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  95441. /**
  95442. * Gets or sets the current interval between two checks (every 2000ms by default)
  95443. */
  95444. get: function () {
  95445. return this._trackerDuration;
  95446. },
  95447. /**
  95448. * Gets or sets the current interval between two checks (every 2000ms by default)
  95449. */
  95450. set: function (value) {
  95451. this._trackerDuration = value;
  95452. },
  95453. enumerable: true,
  95454. configurable: true
  95455. });
  95456. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  95457. /**
  95458. * Gets the list of active optimizations
  95459. */
  95460. get: function () {
  95461. return this._options.optimizations;
  95462. },
  95463. enumerable: true,
  95464. configurable: true
  95465. });
  95466. /**
  95467. * Stops the current optimizer
  95468. */
  95469. SceneOptimizer.prototype.stop = function () {
  95470. this._isRunning = false;
  95471. };
  95472. /**
  95473. * Reset the optimizer to initial step (current priority level = 0)
  95474. */
  95475. SceneOptimizer.prototype.reset = function () {
  95476. this._currentPriorityLevel = 0;
  95477. };
  95478. /**
  95479. * Start the optimizer. By default it will try to reach a specific framerate
  95480. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  95481. */
  95482. SceneOptimizer.prototype.start = function () {
  95483. var _this = this;
  95484. if (this._isRunning) {
  95485. return;
  95486. }
  95487. this._isRunning = true;
  95488. // Let's wait for the scene to be ready before running our check
  95489. this._scene.executeWhenReady(function () {
  95490. setTimeout(function () {
  95491. _this._checkCurrentState();
  95492. }, _this._trackerDuration);
  95493. });
  95494. };
  95495. SceneOptimizer.prototype._checkCurrentState = function () {
  95496. var _this = this;
  95497. if (!this._isRunning) {
  95498. return;
  95499. }
  95500. var scene = this._scene;
  95501. var options = this._options;
  95502. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  95503. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  95504. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  95505. this._isRunning = false;
  95506. this.onSuccessObservable.notifyObservers(this);
  95507. return;
  95508. }
  95509. // Apply current level of optimizations
  95510. var allDone = true;
  95511. var noOptimizationApplied = true;
  95512. for (var index = 0; index < options.optimizations.length; index++) {
  95513. var optimization = options.optimizations[index];
  95514. if (optimization.priority === this._currentPriorityLevel) {
  95515. noOptimizationApplied = false;
  95516. allDone = allDone && optimization.apply(scene, this);
  95517. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  95518. }
  95519. }
  95520. // If no optimization was applied, this is a failure :(
  95521. if (noOptimizationApplied) {
  95522. this._isRunning = false;
  95523. this.onFailureObservable.notifyObservers(this);
  95524. return;
  95525. }
  95526. // If all optimizations were done, move to next level
  95527. if (allDone) {
  95528. this._currentPriorityLevel++;
  95529. }
  95530. // Let's the system running for a specific amount of time before checking FPS
  95531. scene.executeWhenReady(function () {
  95532. setTimeout(function () {
  95533. _this._checkCurrentState();
  95534. }, _this._trackerDuration);
  95535. });
  95536. };
  95537. /**
  95538. * Release all resources
  95539. */
  95540. SceneOptimizer.prototype.dispose = function () {
  95541. this.stop();
  95542. this.onSuccessObservable.clear();
  95543. this.onFailureObservable.clear();
  95544. this.onNewOptimizationAppliedObservable.clear();
  95545. if (this._sceneDisposeObserver) {
  95546. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  95547. }
  95548. };
  95549. /**
  95550. * Helper function to create a SceneOptimizer with one single line of code
  95551. * @param scene defines the scene to work on
  95552. * @param options defines the options to use with the SceneOptimizer
  95553. * @param onSuccess defines a callback to call on success
  95554. * @param onFailure defines a callback to call on failure
  95555. * @returns the new SceneOptimizer object
  95556. */
  95557. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  95558. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  95559. if (onSuccess) {
  95560. optimizer.onSuccessObservable.add(function () {
  95561. onSuccess();
  95562. });
  95563. }
  95564. if (onFailure) {
  95565. optimizer.onFailureObservable.add(function () {
  95566. onFailure();
  95567. });
  95568. }
  95569. optimizer.start();
  95570. return optimizer;
  95571. };
  95572. return SceneOptimizer;
  95573. }());
  95574. /***/ }),
  95575. /***/ "./Misc/sceneSerializer.ts":
  95576. /*!*********************************!*\
  95577. !*** ./Misc/sceneSerializer.ts ***!
  95578. \*********************************/
  95579. /*! exports provided: SceneSerializer */
  95580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95581. "use strict";
  95582. __webpack_require__.r(__webpack_exports__);
  95583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  95584. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/geometry */ "./Meshes/geometry.ts");
  95585. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95586. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95587. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95588. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  95589. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  95590. var serializedGeometries = [];
  95591. var serializeGeometry = function (geometry, serializationGeometries) {
  95592. if (serializedGeometries[geometry.id]) {
  95593. return;
  95594. }
  95595. if (geometry.doNotSerialize) {
  95596. return;
  95597. }
  95598. if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]) {
  95599. serializationGeometries.boxes.push(geometry.serialize());
  95600. }
  95601. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]) {
  95602. serializationGeometries.spheres.push(geometry.serialize());
  95603. }
  95604. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]) {
  95605. serializationGeometries.cylinders.push(geometry.serialize());
  95606. }
  95607. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]) {
  95608. serializationGeometries.toruses.push(geometry.serialize());
  95609. }
  95610. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]) {
  95611. serializationGeometries.grounds.push(geometry.serialize());
  95612. }
  95613. else if (geometry instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Plane"]) {
  95614. serializationGeometries.planes.push(geometry.serialize());
  95615. }
  95616. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]) {
  95617. serializationGeometries.torusKnots.push(geometry.serialize());
  95618. }
  95619. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]) {
  95620. throw new Error("Unknown primitive type");
  95621. }
  95622. else {
  95623. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  95624. }
  95625. serializedGeometries[geometry.id] = true;
  95626. };
  95627. var serializeMesh = function (mesh, serializationScene) {
  95628. var serializationObject = {};
  95629. // Geometry
  95630. var geometry = mesh._geometry;
  95631. if (geometry) {
  95632. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  95633. // 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
  95634. serializeGeometry(geometry, serializationScene.geometries);
  95635. }
  95636. }
  95637. // Custom
  95638. if (mesh.serialize) {
  95639. mesh.serialize(serializationObject);
  95640. }
  95641. return serializationObject;
  95642. };
  95643. var finalizeSingleMesh = function (mesh, serializationObject) {
  95644. //only works if the mesh is already loaded
  95645. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  95646. //serialize material
  95647. if (mesh.material) {
  95648. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__["MultiMaterial"]) {
  95649. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  95650. serializationObject.materials = serializationObject.materials || [];
  95651. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95652. serializationObject.multiMaterials.push(mesh.material.serialize());
  95653. var _loop_1 = function (submaterial) {
  95654. if (submaterial) {
  95655. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  95656. serializationObject.materials.push(submaterial.serialize());
  95657. }
  95658. }
  95659. };
  95660. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  95661. var submaterial = _a[_i];
  95662. _loop_1(submaterial);
  95663. }
  95664. }
  95665. }
  95666. else {
  95667. serializationObject.materials = serializationObject.materials || [];
  95668. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95669. serializationObject.materials.push(mesh.material.serialize());
  95670. }
  95671. }
  95672. }
  95673. //serialize geometry
  95674. var geometry = mesh._geometry;
  95675. if (geometry) {
  95676. if (!serializationObject.geometries) {
  95677. serializationObject.geometries = {};
  95678. serializationObject.geometries.boxes = [];
  95679. serializationObject.geometries.spheres = [];
  95680. serializationObject.geometries.cylinders = [];
  95681. serializationObject.geometries.toruses = [];
  95682. serializationObject.geometries.grounds = [];
  95683. serializationObject.geometries.planes = [];
  95684. serializationObject.geometries.torusKnots = [];
  95685. serializationObject.geometries.vertexData = [];
  95686. }
  95687. serializeGeometry(geometry, serializationObject.geometries);
  95688. }
  95689. // Skeletons
  95690. if (mesh.skeleton) {
  95691. serializationObject.skeletons = serializationObject.skeletons || [];
  95692. serializationObject.skeletons.push(mesh.skeleton.serialize());
  95693. }
  95694. //serialize the actual mesh
  95695. serializationObject.meshes = serializationObject.meshes || [];
  95696. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  95697. }
  95698. };
  95699. /**
  95700. * Class used to serialize a scene into a string
  95701. */
  95702. var SceneSerializer = /** @class */ (function () {
  95703. function SceneSerializer() {
  95704. }
  95705. /**
  95706. * Clear cache used by a previous serialization
  95707. */
  95708. SceneSerializer.ClearCache = function () {
  95709. serializedGeometries = [];
  95710. };
  95711. /**
  95712. * Serialize a scene into a JSON compatible object
  95713. * @param scene defines the scene to serialize
  95714. * @returns a JSON compatible object
  95715. */
  95716. SceneSerializer.Serialize = function (scene) {
  95717. var serializationObject = {};
  95718. SceneSerializer.ClearCache();
  95719. // Scene
  95720. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  95721. serializationObject.autoClear = scene.autoClear;
  95722. serializationObject.clearColor = scene.clearColor.asArray();
  95723. serializationObject.ambientColor = scene.ambientColor.asArray();
  95724. serializationObject.gravity = scene.gravity.asArray();
  95725. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  95726. // Fog
  95727. if (scene.fogMode && scene.fogMode !== 0) {
  95728. serializationObject.fogMode = scene.fogMode;
  95729. serializationObject.fogColor = scene.fogColor.asArray();
  95730. serializationObject.fogStart = scene.fogStart;
  95731. serializationObject.fogEnd = scene.fogEnd;
  95732. serializationObject.fogDensity = scene.fogDensity;
  95733. }
  95734. //Physics
  95735. if (scene.isPhysicsEnabled()) {
  95736. var physicEngine = scene.getPhysicsEngine();
  95737. if (physicEngine) {
  95738. serializationObject.physicsEnabled = true;
  95739. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  95740. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  95741. }
  95742. }
  95743. // Metadata
  95744. if (scene.metadata) {
  95745. serializationObject.metadata = scene.metadata;
  95746. }
  95747. // Morph targets
  95748. serializationObject.morphTargetManagers = [];
  95749. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  95750. var abstractMesh = _a[_i];
  95751. var manager = abstractMesh.morphTargetManager;
  95752. if (manager) {
  95753. serializationObject.morphTargetManagers.push(manager.serialize());
  95754. }
  95755. }
  95756. // Lights
  95757. serializationObject.lights = [];
  95758. var index;
  95759. var light;
  95760. for (index = 0; index < scene.lights.length; index++) {
  95761. light = scene.lights[index];
  95762. if (!light.doNotSerialize) {
  95763. serializationObject.lights.push(light.serialize());
  95764. }
  95765. }
  95766. // Cameras
  95767. serializationObject.cameras = [];
  95768. for (index = 0; index < scene.cameras.length; index++) {
  95769. var camera = scene.cameras[index];
  95770. if (!camera.doNotSerialize) {
  95771. serializationObject.cameras.push(camera.serialize());
  95772. }
  95773. }
  95774. if (scene.activeCamera) {
  95775. serializationObject.activeCameraID = scene.activeCamera.id;
  95776. }
  95777. // Animations
  95778. _decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  95779. // Reflection probes
  95780. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  95781. serializationObject.reflectionProbes = [];
  95782. for (index = 0; index < scene.reflectionProbes.length; index++) {
  95783. var reflectionProbe = scene.reflectionProbes[index];
  95784. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  95785. }
  95786. }
  95787. // Materials
  95788. serializationObject.materials = [];
  95789. serializationObject.multiMaterials = [];
  95790. var material;
  95791. for (index = 0; index < scene.materials.length; index++) {
  95792. material = scene.materials[index];
  95793. if (!material.doNotSerialize) {
  95794. serializationObject.materials.push(material.serialize());
  95795. }
  95796. }
  95797. // MultiMaterials
  95798. serializationObject.multiMaterials = [];
  95799. for (index = 0; index < scene.multiMaterials.length; index++) {
  95800. var multiMaterial = scene.multiMaterials[index];
  95801. serializationObject.multiMaterials.push(multiMaterial.serialize());
  95802. }
  95803. // Environment texture
  95804. if (scene.environmentTexture) {
  95805. serializationObject.environmentTexture = scene.environmentTexture.name;
  95806. }
  95807. // Skeletons
  95808. serializationObject.skeletons = [];
  95809. for (index = 0; index < scene.skeletons.length; index++) {
  95810. var skeleton = scene.skeletons[index];
  95811. if (!skeleton.doNotSerialize) {
  95812. serializationObject.skeletons.push(skeleton.serialize());
  95813. }
  95814. }
  95815. // Transform nodes
  95816. serializationObject.transformNodes = [];
  95817. for (index = 0; index < scene.transformNodes.length; index++) {
  95818. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  95819. }
  95820. // Geometries
  95821. serializationObject.geometries = {};
  95822. serializationObject.geometries.boxes = [];
  95823. serializationObject.geometries.spheres = [];
  95824. serializationObject.geometries.cylinders = [];
  95825. serializationObject.geometries.toruses = [];
  95826. serializationObject.geometries.grounds = [];
  95827. serializationObject.geometries.planes = [];
  95828. serializationObject.geometries.torusKnots = [];
  95829. serializationObject.geometries.vertexData = [];
  95830. serializedGeometries = [];
  95831. var geometries = scene.getGeometries();
  95832. for (index = 0; index < geometries.length; index++) {
  95833. var geometry = geometries[index];
  95834. if (geometry.isReady()) {
  95835. serializeGeometry(geometry, serializationObject.geometries);
  95836. }
  95837. }
  95838. // Meshes
  95839. serializationObject.meshes = [];
  95840. for (index = 0; index < scene.meshes.length; index++) {
  95841. var abstractMesh = scene.meshes[index];
  95842. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]) {
  95843. var mesh = abstractMesh;
  95844. if (!mesh.doNotSerialize) {
  95845. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  95846. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  95847. }
  95848. }
  95849. }
  95850. }
  95851. // Particles Systems
  95852. serializationObject.particleSystems = [];
  95853. for (index = 0; index < scene.particleSystems.length; index++) {
  95854. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  95855. }
  95856. // Action Manager
  95857. if (scene.actionManager) {
  95858. serializationObject.actions = scene.actionManager.serialize("scene");
  95859. }
  95860. // Components
  95861. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  95862. var component = _c[_b];
  95863. component.serialize(serializationObject);
  95864. }
  95865. return serializationObject;
  95866. };
  95867. /**
  95868. * Serialize a mesh into a JSON compatible object
  95869. * @param toSerialize defines the mesh to serialize
  95870. * @param withParents defines if parents must be serialized as well
  95871. * @param withChildren defines if children must be serialized as well
  95872. * @returns a JSON compatible object
  95873. */
  95874. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  95875. if (withParents === void 0) { withParents = false; }
  95876. if (withChildren === void 0) { withChildren = false; }
  95877. var serializationObject = {};
  95878. SceneSerializer.ClearCache();
  95879. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  95880. if (withParents || withChildren) {
  95881. //deliberate for loop! not for each, appended should be processed as well.
  95882. for (var i = 0; i < toSerialize.length; ++i) {
  95883. if (withChildren) {
  95884. toSerialize[i].getDescendants().forEach(function (node) {
  95885. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  95886. toSerialize.push(node);
  95887. }
  95888. });
  95889. }
  95890. //make sure the array doesn't contain the object already
  95891. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  95892. toSerialize.push(toSerialize[i].parent);
  95893. }
  95894. }
  95895. }
  95896. toSerialize.forEach(function (mesh) {
  95897. finalizeSingleMesh(mesh, serializationObject);
  95898. });
  95899. return serializationObject;
  95900. };
  95901. return SceneSerializer;
  95902. }());
  95903. /***/ }),
  95904. /***/ "./Misc/screenshotTools.ts":
  95905. /*!*********************************!*\
  95906. !*** ./Misc/screenshotTools.ts ***!
  95907. \*********************************/
  95908. /*! exports provided: ScreenshotTools */
  95909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95910. "use strict";
  95911. __webpack_require__.r(__webpack_exports__);
  95912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  95913. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  95914. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  95915. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  95916. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95917. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  95918. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95919. // Screenshots
  95920. var screenshotCanvas;
  95921. /**
  95922. * Class containing a set of static utilities functions for screenshots
  95923. */
  95924. var ScreenshotTools = /** @class */ (function () {
  95925. function ScreenshotTools() {
  95926. }
  95927. /**
  95928. * Captures a screenshot of the current rendering
  95929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95930. * @param engine defines the rendering engine
  95931. * @param camera defines the source camera
  95932. * @param size This parameter can be set to a single number or to an object with the
  95933. * following (optional) properties: precision, width, height. If a single number is passed,
  95934. * it will be used for both width and height. If an object is passed, the screenshot size
  95935. * will be derived from the parameters. The precision property is a multiplier allowing
  95936. * rendering at a higher or lower resolution
  95937. * @param successCallback defines the callback receives a single parameter which contains the
  95938. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95939. * src parameter of an <img> to display it
  95940. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95941. * Check your browser for supported MIME types
  95942. */
  95943. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  95944. if (mimeType === void 0) { mimeType = "image/png"; }
  95945. var width;
  95946. var height;
  95947. // If a precision value is specified
  95948. if (size.precision) {
  95949. width = Math.round(engine.getRenderWidth() * size.precision);
  95950. height = Math.round(width / engine.getAspectRatio(camera));
  95951. }
  95952. else if (size.width && size.height) {
  95953. width = size.width;
  95954. height = size.height;
  95955. }
  95956. //If passing only width, computing height to keep display canvas ratio.
  95957. else if (size.width && !size.height) {
  95958. width = size.width;
  95959. height = Math.round(width / engine.getAspectRatio(camera));
  95960. }
  95961. //If passing only height, computing width to keep display canvas ratio.
  95962. else if (size.height && !size.width) {
  95963. height = size.height;
  95964. width = Math.round(height * engine.getAspectRatio(camera));
  95965. }
  95966. //Assuming here that "size" parameter is a number
  95967. else if (!isNaN(size)) {
  95968. height = size;
  95969. width = size;
  95970. }
  95971. else {
  95972. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  95973. return;
  95974. }
  95975. if (!screenshotCanvas) {
  95976. screenshotCanvas = document.createElement('canvas');
  95977. }
  95978. screenshotCanvas.width = width;
  95979. screenshotCanvas.height = height;
  95980. var renderContext = screenshotCanvas.getContext("2d");
  95981. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  95982. var newWidth = width;
  95983. var newHeight = newWidth / ratio;
  95984. if (newHeight > height) {
  95985. newHeight = height;
  95986. newWidth = newHeight * ratio;
  95987. }
  95988. var offsetX = Math.max(0, width - newWidth) / 2;
  95989. var offsetY = Math.max(0, height - newHeight) / 2;
  95990. var renderingCanvas = engine.getRenderingCanvas();
  95991. if (renderContext && renderingCanvas) {
  95992. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  95993. }
  95994. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  95995. };
  95996. /**
  95997. * Generates an image screenshot from the specified camera.
  95998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95999. * @param engine The engine to use for rendering
  96000. * @param camera The camera to use for rendering
  96001. * @param size This parameter can be set to a single number or to an object with the
  96002. * following (optional) properties: precision, width, height. If a single number is passed,
  96003. * it will be used for both width and height. If an object is passed, the screenshot size
  96004. * will be derived from the parameters. The precision property is a multiplier allowing
  96005. * rendering at a higher or lower resolution
  96006. * @param successCallback The callback receives a single parameter which contains the
  96007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96008. * src parameter of an <img> to display it
  96009. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96010. * Check your browser for supported MIME types
  96011. * @param samples Texture samples (default: 1)
  96012. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96013. * @param fileName A name for for the downloaded file.
  96014. */
  96015. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  96016. if (mimeType === void 0) { mimeType = "image/png"; }
  96017. if (samples === void 0) { samples = 1; }
  96018. if (antialiasing === void 0) { antialiasing = false; }
  96019. var width;
  96020. var height;
  96021. //If a precision value is specified
  96022. if (size.precision) {
  96023. width = Math.round(engine.getRenderWidth() * size.precision);
  96024. height = Math.round(width / engine.getAspectRatio(camera));
  96025. size = { width: width, height: height };
  96026. }
  96027. else if (size.width && size.height) {
  96028. width = size.width;
  96029. height = size.height;
  96030. }
  96031. //If passing only width, computing height to keep display canvas ratio.
  96032. else if (size.width && !size.height) {
  96033. width = size.width;
  96034. height = Math.round(width / engine.getAspectRatio(camera));
  96035. size = { width: width, height: height };
  96036. }
  96037. //If passing only height, computing width to keep display canvas ratio.
  96038. else if (size.height && !size.width) {
  96039. height = size.height;
  96040. width = Math.round(height * engine.getAspectRatio(camera));
  96041. size = { width: width, height: height };
  96042. }
  96043. //Assuming here that "size" parameter is a number
  96044. else if (!isNaN(size)) {
  96045. height = size;
  96046. width = size;
  96047. }
  96048. else {
  96049. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96050. return;
  96051. }
  96052. var scene = camera.getScene();
  96053. var previousCamera = null;
  96054. if (scene.activeCamera !== camera) {
  96055. previousCamera = scene.activeCamera;
  96056. scene.activeCamera = camera;
  96057. }
  96058. var renderCanvas = engine.getRenderingCanvas();
  96059. if (!renderCanvas) {
  96060. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  96061. return;
  96062. }
  96063. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  96064. engine.setSize(width, height);
  96065. scene.render();
  96066. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  96067. 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);
  96068. texture.renderList = null;
  96069. texture.samples = samples;
  96070. if (antialiasing) {
  96071. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  96072. }
  96073. texture.onAfterRenderObservable.add(function () {
  96074. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  96075. });
  96076. scene.incrementRenderId();
  96077. scene.resetCachedMaterial();
  96078. texture.render(true);
  96079. texture.dispose();
  96080. if (previousCamera) {
  96081. scene.activeCamera = previousCamera;
  96082. }
  96083. engine.setSize(originalSize.width, originalSize.height);
  96084. camera.getProjectionMatrix(true); // Force cache refresh;
  96085. };
  96086. return ScreenshotTools;
  96087. }());
  96088. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  96089. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  96090. /***/ }),
  96091. /***/ "./Misc/smartArray.ts":
  96092. /*!****************************!*\
  96093. !*** ./Misc/smartArray.ts ***!
  96094. \****************************/
  96095. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  96096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96097. "use strict";
  96098. __webpack_require__.r(__webpack_exports__);
  96099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  96100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  96101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96102. /**
  96103. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96104. */
  96105. var SmartArray = /** @class */ (function () {
  96106. /**
  96107. * Instantiates a Smart Array.
  96108. * @param capacity defines the default capacity of the array.
  96109. */
  96110. function SmartArray(capacity) {
  96111. /**
  96112. * The active length of the array.
  96113. */
  96114. this.length = 0;
  96115. this.data = new Array(capacity);
  96116. this._id = SmartArray._GlobalId++;
  96117. }
  96118. /**
  96119. * Pushes a value at the end of the active data.
  96120. * @param value defines the object to push in the array.
  96121. */
  96122. SmartArray.prototype.push = function (value) {
  96123. this.data[this.length++] = value;
  96124. if (this.length > this.data.length) {
  96125. this.data.length *= 2;
  96126. }
  96127. };
  96128. /**
  96129. * Iterates over the active data and apply the lambda to them.
  96130. * @param func defines the action to apply on each value.
  96131. */
  96132. SmartArray.prototype.forEach = function (func) {
  96133. for (var index = 0; index < this.length; index++) {
  96134. func(this.data[index]);
  96135. }
  96136. };
  96137. /**
  96138. * Sorts the full sets of data.
  96139. * @param compareFn defines the comparison function to apply.
  96140. */
  96141. SmartArray.prototype.sort = function (compareFn) {
  96142. this.data.sort(compareFn);
  96143. };
  96144. /**
  96145. * Resets the active data to an empty array.
  96146. */
  96147. SmartArray.prototype.reset = function () {
  96148. this.length = 0;
  96149. };
  96150. /**
  96151. * Releases all the data from the array as well as the array.
  96152. */
  96153. SmartArray.prototype.dispose = function () {
  96154. this.reset();
  96155. if (this.data) {
  96156. this.data.length = 0;
  96157. this.data = [];
  96158. }
  96159. };
  96160. /**
  96161. * Concats the active data with a given array.
  96162. * @param array defines the data to concatenate with.
  96163. */
  96164. SmartArray.prototype.concat = function (array) {
  96165. if (array.length === 0) {
  96166. return;
  96167. }
  96168. if (this.length + array.length > this.data.length) {
  96169. this.data.length = (this.length + array.length) * 2;
  96170. }
  96171. for (var index = 0; index < array.length; index++) {
  96172. this.data[this.length++] = (array.data || array)[index];
  96173. }
  96174. };
  96175. /**
  96176. * Returns the position of a value in the active data.
  96177. * @param value defines the value to find the index for
  96178. * @returns the index if found in the active data otherwise -1
  96179. */
  96180. SmartArray.prototype.indexOf = function (value) {
  96181. var position = this.data.indexOf(value);
  96182. if (position >= this.length) {
  96183. return -1;
  96184. }
  96185. return position;
  96186. };
  96187. /**
  96188. * Returns whether an element is part of the active data.
  96189. * @param value defines the value to look for
  96190. * @returns true if found in the active data otherwise false
  96191. */
  96192. SmartArray.prototype.contains = function (value) {
  96193. return this.indexOf(value) !== -1;
  96194. };
  96195. // Statics
  96196. SmartArray._GlobalId = 0;
  96197. return SmartArray;
  96198. }());
  96199. /**
  96200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96201. * The data in this array can only be present once
  96202. */
  96203. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  96204. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  96205. function SmartArrayNoDuplicate() {
  96206. var _this = _super !== null && _super.apply(this, arguments) || this;
  96207. _this._duplicateId = 0;
  96208. return _this;
  96209. }
  96210. /**
  96211. * Pushes a value at the end of the active data.
  96212. * THIS DOES NOT PREVENT DUPPLICATE DATA
  96213. * @param value defines the object to push in the array.
  96214. */
  96215. SmartArrayNoDuplicate.prototype.push = function (value) {
  96216. _super.prototype.push.call(this, value);
  96217. if (!value.__smartArrayFlags) {
  96218. value.__smartArrayFlags = {};
  96219. }
  96220. value.__smartArrayFlags[this._id] = this._duplicateId;
  96221. };
  96222. /**
  96223. * Pushes a value at the end of the active data.
  96224. * If the data is already present, it won t be added again
  96225. * @param value defines the object to push in the array.
  96226. * @returns true if added false if it was already present
  96227. */
  96228. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  96229. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  96230. return false;
  96231. }
  96232. this.push(value);
  96233. return true;
  96234. };
  96235. /**
  96236. * Resets the active data to an empty array.
  96237. */
  96238. SmartArrayNoDuplicate.prototype.reset = function () {
  96239. _super.prototype.reset.call(this);
  96240. this._duplicateId++;
  96241. };
  96242. /**
  96243. * Concats the active data with a given array.
  96244. * This ensures no dupplicate will be present in the result.
  96245. * @param array defines the data to concatenate with.
  96246. */
  96247. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  96248. if (array.length === 0) {
  96249. return;
  96250. }
  96251. if (this.length + array.length > this.data.length) {
  96252. this.data.length = (this.length + array.length) * 2;
  96253. }
  96254. for (var index = 0; index < array.length; index++) {
  96255. var item = (array.data || array)[index];
  96256. this.pushNoDuplicate(item);
  96257. }
  96258. };
  96259. return SmartArrayNoDuplicate;
  96260. }(SmartArray));
  96261. /***/ }),
  96262. /***/ "./Misc/stringDictionary.ts":
  96263. /*!**********************************!*\
  96264. !*** ./Misc/stringDictionary.ts ***!
  96265. \**********************************/
  96266. /*! exports provided: StringDictionary */
  96267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96268. "use strict";
  96269. __webpack_require__.r(__webpack_exports__);
  96270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  96271. /**
  96272. * This class implement a typical dictionary using a string as key and the generic type T as value.
  96273. * The underlying implementation relies on an associative array to ensure the best performances.
  96274. * The value can be anything including 'null' but except 'undefined'
  96275. */
  96276. var StringDictionary = /** @class */ (function () {
  96277. function StringDictionary() {
  96278. this._count = 0;
  96279. this._data = {};
  96280. }
  96281. /**
  96282. * This will clear this dictionary and copy the content from the 'source' one.
  96283. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  96284. * @param source the dictionary to take the content from and copy to this dictionary
  96285. */
  96286. StringDictionary.prototype.copyFrom = function (source) {
  96287. var _this = this;
  96288. this.clear();
  96289. source.forEach(function (t, v) { return _this.add(t, v); });
  96290. };
  96291. /**
  96292. * Get a value based from its key
  96293. * @param key the given key to get the matching value from
  96294. * @return the value if found, otherwise undefined is returned
  96295. */
  96296. StringDictionary.prototype.get = function (key) {
  96297. var val = this._data[key];
  96298. if (val !== undefined) {
  96299. return val;
  96300. }
  96301. return undefined;
  96302. };
  96303. /**
  96304. * Get a value from its key or add it if it doesn't exist.
  96305. * This method will ensure you that a given key/data will be present in the dictionary.
  96306. * @param key the given key to get the matching value from
  96307. * @param factory the factory that will create the value if the key is not present in the dictionary.
  96308. * The factory will only be invoked if there's no data for the given key.
  96309. * @return the value corresponding to the key.
  96310. */
  96311. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  96312. var val = this.get(key);
  96313. if (val !== undefined) {
  96314. return val;
  96315. }
  96316. val = factory(key);
  96317. if (val) {
  96318. this.add(key, val);
  96319. }
  96320. return val;
  96321. };
  96322. /**
  96323. * Get a value from its key if present in the dictionary otherwise add it
  96324. * @param key the key to get the value from
  96325. * @param val if there's no such key/value pair in the dictionary add it with this value
  96326. * @return the value corresponding to the key
  96327. */
  96328. StringDictionary.prototype.getOrAdd = function (key, val) {
  96329. var curVal = this.get(key);
  96330. if (curVal !== undefined) {
  96331. return curVal;
  96332. }
  96333. this.add(key, val);
  96334. return val;
  96335. };
  96336. /**
  96337. * Check if there's a given key in the dictionary
  96338. * @param key the key to check for
  96339. * @return true if the key is present, false otherwise
  96340. */
  96341. StringDictionary.prototype.contains = function (key) {
  96342. return this._data[key] !== undefined;
  96343. };
  96344. /**
  96345. * Add a new key and its corresponding value
  96346. * @param key the key to add
  96347. * @param value the value corresponding to the key
  96348. * @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
  96349. */
  96350. StringDictionary.prototype.add = function (key, value) {
  96351. if (this._data[key] !== undefined) {
  96352. return false;
  96353. }
  96354. this._data[key] = value;
  96355. ++this._count;
  96356. return true;
  96357. };
  96358. /**
  96359. * Update a specific value associated to a key
  96360. * @param key defines the key to use
  96361. * @param value defines the value to store
  96362. * @returns true if the value was updated (or false if the key was not found)
  96363. */
  96364. StringDictionary.prototype.set = function (key, value) {
  96365. if (this._data[key] === undefined) {
  96366. return false;
  96367. }
  96368. this._data[key] = value;
  96369. return true;
  96370. };
  96371. /**
  96372. * Get the element of the given key and remove it from the dictionary
  96373. * @param key defines the key to search
  96374. * @returns the value associated with the key or null if not found
  96375. */
  96376. StringDictionary.prototype.getAndRemove = function (key) {
  96377. var val = this.get(key);
  96378. if (val !== undefined) {
  96379. delete this._data[key];
  96380. --this._count;
  96381. return val;
  96382. }
  96383. return null;
  96384. };
  96385. /**
  96386. * Remove a key/value from the dictionary.
  96387. * @param key the key to remove
  96388. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  96389. */
  96390. StringDictionary.prototype.remove = function (key) {
  96391. if (this.contains(key)) {
  96392. delete this._data[key];
  96393. --this._count;
  96394. return true;
  96395. }
  96396. return false;
  96397. };
  96398. /**
  96399. * Clear the whole content of the dictionary
  96400. */
  96401. StringDictionary.prototype.clear = function () {
  96402. this._data = {};
  96403. this._count = 0;
  96404. };
  96405. Object.defineProperty(StringDictionary.prototype, "count", {
  96406. /**
  96407. * Gets the current count
  96408. */
  96409. get: function () {
  96410. return this._count;
  96411. },
  96412. enumerable: true,
  96413. configurable: true
  96414. });
  96415. /**
  96416. * Execute a callback on each key/val of the dictionary.
  96417. * Note that you can remove any element in this dictionary in the callback implementation
  96418. * @param callback the callback to execute on a given key/value pair
  96419. */
  96420. StringDictionary.prototype.forEach = function (callback) {
  96421. for (var cur in this._data) {
  96422. var val = this._data[cur];
  96423. callback(cur, val);
  96424. }
  96425. };
  96426. /**
  96427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  96428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  96429. * Note that you can remove any element in this dictionary in the callback implementation
  96430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  96431. * @returns the first item
  96432. */
  96433. StringDictionary.prototype.first = function (callback) {
  96434. for (var cur in this._data) {
  96435. var val = this._data[cur];
  96436. var res = callback(cur, val);
  96437. if (res) {
  96438. return res;
  96439. }
  96440. }
  96441. return null;
  96442. };
  96443. return StringDictionary;
  96444. }());
  96445. /***/ }),
  96446. /***/ "./Misc/tags.ts":
  96447. /*!**********************!*\
  96448. !*** ./Misc/tags.ts ***!
  96449. \**********************/
  96450. /*! exports provided: Tags */
  96451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96452. "use strict";
  96453. __webpack_require__.r(__webpack_exports__);
  96454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  96455. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96456. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  96457. /**
  96458. * Class used to store custom tags
  96459. */
  96460. var Tags = /** @class */ (function () {
  96461. function Tags() {
  96462. }
  96463. /**
  96464. * Adds support for tags on the given object
  96465. * @param obj defines the object to use
  96466. */
  96467. Tags.EnableFor = function (obj) {
  96468. obj._tags = obj._tags || {};
  96469. obj.hasTags = function () {
  96470. return Tags.HasTags(obj);
  96471. };
  96472. obj.addTags = function (tagsString) {
  96473. return Tags.AddTagsTo(obj, tagsString);
  96474. };
  96475. obj.removeTags = function (tagsString) {
  96476. return Tags.RemoveTagsFrom(obj, tagsString);
  96477. };
  96478. obj.matchesTagsQuery = function (tagsQuery) {
  96479. return Tags.MatchesQuery(obj, tagsQuery);
  96480. };
  96481. };
  96482. /**
  96483. * Removes tags support
  96484. * @param obj defines the object to use
  96485. */
  96486. Tags.DisableFor = function (obj) {
  96487. delete obj._tags;
  96488. delete obj.hasTags;
  96489. delete obj.addTags;
  96490. delete obj.removeTags;
  96491. delete obj.matchesTagsQuery;
  96492. };
  96493. /**
  96494. * Gets a boolean indicating if the given object has tags
  96495. * @param obj defines the object to use
  96496. * @returns a boolean
  96497. */
  96498. Tags.HasTags = function (obj) {
  96499. if (!obj._tags) {
  96500. return false;
  96501. }
  96502. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  96503. };
  96504. /**
  96505. * Gets the tags available on a given object
  96506. * @param obj defines the object to use
  96507. * @param asString defines if the tags must be returned as a string instead of an array of strings
  96508. * @returns the tags
  96509. */
  96510. Tags.GetTags = function (obj, asString) {
  96511. if (asString === void 0) { asString = true; }
  96512. if (!obj._tags) {
  96513. return null;
  96514. }
  96515. if (asString) {
  96516. var tagsArray = [];
  96517. for (var tag in obj._tags) {
  96518. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  96519. tagsArray.push(tag);
  96520. }
  96521. }
  96522. return tagsArray.join(" ");
  96523. }
  96524. else {
  96525. return obj._tags;
  96526. }
  96527. };
  96528. /**
  96529. * Adds tags to an object
  96530. * @param obj defines the object to use
  96531. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  96532. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  96533. */
  96534. Tags.AddTagsTo = function (obj, tagsString) {
  96535. if (!tagsString) {
  96536. return;
  96537. }
  96538. if (typeof tagsString !== "string") {
  96539. return;
  96540. }
  96541. var tags = tagsString.split(" ");
  96542. tags.forEach(function (tag, index, array) {
  96543. Tags._AddTagTo(obj, tag);
  96544. });
  96545. };
  96546. /**
  96547. * @hidden
  96548. */
  96549. Tags._AddTagTo = function (obj, tag) {
  96550. tag = tag.trim();
  96551. if (tag === "" || tag === "true" || tag === "false") {
  96552. return;
  96553. }
  96554. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  96555. return;
  96556. }
  96557. Tags.EnableFor(obj);
  96558. obj._tags[tag] = true;
  96559. };
  96560. /**
  96561. * Removes specific tags from a specific object
  96562. * @param obj defines the object to use
  96563. * @param tagsString defines the tags to remove
  96564. */
  96565. Tags.RemoveTagsFrom = function (obj, tagsString) {
  96566. if (!Tags.HasTags(obj)) {
  96567. return;
  96568. }
  96569. var tags = tagsString.split(" ");
  96570. for (var t in tags) {
  96571. Tags._RemoveTagFrom(obj, tags[t]);
  96572. }
  96573. };
  96574. /**
  96575. * @hidden
  96576. */
  96577. Tags._RemoveTagFrom = function (obj, tag) {
  96578. delete obj._tags[tag];
  96579. };
  96580. /**
  96581. * Defines if tags hosted on an object match a given query
  96582. * @param obj defines the object to use
  96583. * @param tagsQuery defines the tag query
  96584. * @returns a boolean
  96585. */
  96586. Tags.MatchesQuery = function (obj, tagsQuery) {
  96587. if (tagsQuery === undefined) {
  96588. return true;
  96589. }
  96590. if (tagsQuery === "") {
  96591. return Tags.HasTags(obj);
  96592. }
  96593. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  96594. };
  96595. return Tags;
  96596. }());
  96597. /***/ }),
  96598. /***/ "./Misc/textureTools.ts":
  96599. /*!******************************!*\
  96600. !*** ./Misc/textureTools.ts ***!
  96601. \******************************/
  96602. /*! exports provided: TextureTools */
  96603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96604. "use strict";
  96605. __webpack_require__.r(__webpack_exports__);
  96606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  96607. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96608. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96609. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  96610. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96611. /**
  96612. * Class used to host texture specific utilities
  96613. */
  96614. var TextureTools = /** @class */ (function () {
  96615. function TextureTools() {
  96616. }
  96617. /**
  96618. * Uses the GPU to create a copy texture rescaled at a given size
  96619. * @param texture Texture to copy from
  96620. * @param width defines the desired width
  96621. * @param height defines the desired height
  96622. * @param useBilinearMode defines if bilinear mode has to be used
  96623. * @return the generated texture
  96624. */
  96625. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  96626. if (useBilinearMode === void 0) { useBilinearMode = true; }
  96627. var scene = texture.getScene();
  96628. var engine = scene.getEngine();
  96629. 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);
  96630. rtt.wrapU = texture.wrapU;
  96631. rtt.wrapV = texture.wrapV;
  96632. rtt.uOffset = texture.uOffset;
  96633. rtt.vOffset = texture.vOffset;
  96634. rtt.uScale = texture.uScale;
  96635. rtt.vScale = texture.vScale;
  96636. rtt.uAng = texture.uAng;
  96637. rtt.vAng = texture.vAng;
  96638. rtt.wAng = texture.wAng;
  96639. rtt.coordinatesIndex = texture.coordinatesIndex;
  96640. rtt.level = texture.level;
  96641. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  96642. rtt._texture.isReady = false;
  96643. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96644. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96645. 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);
  96646. passPostProcess.getEffect().executeWhenCompiled(function () {
  96647. passPostProcess.onApply = function (effect) {
  96648. effect.setTexture("textureSampler", texture);
  96649. };
  96650. var internalTexture = rtt.getInternalTexture();
  96651. if (internalTexture) {
  96652. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  96653. engine.unBindFramebuffer(internalTexture);
  96654. rtt.disposeFramebufferObjects();
  96655. passPostProcess.dispose();
  96656. internalTexture.isReady = true;
  96657. }
  96658. });
  96659. return rtt;
  96660. };
  96661. /**
  96662. * Gets an environment BRDF texture for a given scene
  96663. * @param scene defines the hosting scene
  96664. * @returns the environment BRDF texture
  96665. */
  96666. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  96667. if (!scene._environmentBRDFTexture) {
  96668. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  96669. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96670. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96671. scene._environmentBRDFTexture = texture;
  96672. }
  96673. return scene._environmentBRDFTexture;
  96674. };
  96675. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=";
  96676. return TextureTools;
  96677. }());
  96678. /***/ }),
  96679. /***/ "./Misc/tga.ts":
  96680. /*!*********************!*\
  96681. !*** ./Misc/tga.ts ***!
  96682. \*********************/
  96683. /*! exports provided: TGATools */
  96684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96685. "use strict";
  96686. __webpack_require__.r(__webpack_exports__);
  96687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  96688. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96689. /**
  96690. * Based on jsTGALoader - Javascript loader for TGA file
  96691. * By Vincent Thibault
  96692. * @see http://blog.robrowser.com/javascript-tga-loader.html
  96693. */
  96694. var TGATools = /** @class */ (function () {
  96695. function TGATools() {
  96696. }
  96697. /**
  96698. * Gets the header of a TGA file
  96699. * @param data defines the TGA data
  96700. * @returns the header
  96701. */
  96702. TGATools.GetTGAHeader = function (data) {
  96703. var offset = 0;
  96704. var header = {
  96705. id_length: data[offset++],
  96706. colormap_type: data[offset++],
  96707. image_type: data[offset++],
  96708. colormap_index: data[offset++] | data[offset++] << 8,
  96709. colormap_length: data[offset++] | data[offset++] << 8,
  96710. colormap_size: data[offset++],
  96711. origin: [
  96712. data[offset++] | data[offset++] << 8,
  96713. data[offset++] | data[offset++] << 8
  96714. ],
  96715. width: data[offset++] | data[offset++] << 8,
  96716. height: data[offset++] | data[offset++] << 8,
  96717. pixel_size: data[offset++],
  96718. flags: data[offset++]
  96719. };
  96720. return header;
  96721. };
  96722. /**
  96723. * Uploads TGA content to a Babylon Texture
  96724. * @hidden
  96725. */
  96726. TGATools.UploadContent = function (texture, data) {
  96727. // Not enough data to contain header ?
  96728. if (data.length < 19) {
  96729. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  96730. return;
  96731. }
  96732. // Read Header
  96733. var offset = 18;
  96734. var header = TGATools.GetTGAHeader(data);
  96735. // Assume it's a valid Targa file.
  96736. if (header.id_length + offset > data.length) {
  96737. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  96738. return;
  96739. }
  96740. // Skip not needed data
  96741. offset += header.id_length;
  96742. var use_rle = false;
  96743. var use_pal = false;
  96744. var use_grey = false;
  96745. // Get some informations.
  96746. switch (header.image_type) {
  96747. case TGATools._TYPE_RLE_INDEXED:
  96748. use_rle = true;
  96749. case TGATools._TYPE_INDEXED:
  96750. use_pal = true;
  96751. break;
  96752. case TGATools._TYPE_RLE_RGB:
  96753. use_rle = true;
  96754. case TGATools._TYPE_RGB:
  96755. // use_rgb = true;
  96756. break;
  96757. case TGATools._TYPE_RLE_GREY:
  96758. use_rle = true;
  96759. case TGATools._TYPE_GREY:
  96760. use_grey = true;
  96761. break;
  96762. }
  96763. var pixel_data;
  96764. // var numAlphaBits = header.flags & 0xf;
  96765. var pixel_size = header.pixel_size >> 3;
  96766. var pixel_total = header.width * header.height * pixel_size;
  96767. // Read palettes
  96768. var palettes;
  96769. if (use_pal) {
  96770. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  96771. }
  96772. // Read LRE
  96773. if (use_rle) {
  96774. pixel_data = new Uint8Array(pixel_total);
  96775. var c, count, i;
  96776. var localOffset = 0;
  96777. var pixels = new Uint8Array(pixel_size);
  96778. while (offset < pixel_total && localOffset < pixel_total) {
  96779. c = data[offset++];
  96780. count = (c & 0x7f) + 1;
  96781. // RLE pixels
  96782. if (c & 0x80) {
  96783. // Bind pixel tmp array
  96784. for (i = 0; i < pixel_size; ++i) {
  96785. pixels[i] = data[offset++];
  96786. }
  96787. // Copy pixel array
  96788. for (i = 0; i < count; ++i) {
  96789. pixel_data.set(pixels, localOffset + i * pixel_size);
  96790. }
  96791. localOffset += pixel_size * count;
  96792. }
  96793. // Raw pixels
  96794. else {
  96795. count *= pixel_size;
  96796. for (i = 0; i < count; ++i) {
  96797. pixel_data[localOffset + i] = data[offset++];
  96798. }
  96799. localOffset += count;
  96800. }
  96801. }
  96802. }
  96803. // RAW Pixels
  96804. else {
  96805. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  96806. }
  96807. // Load to texture
  96808. var x_start, y_start, x_step, y_step, y_end, x_end;
  96809. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  96810. default:
  96811. case TGATools._ORIGIN_UL:
  96812. x_start = 0;
  96813. x_step = 1;
  96814. x_end = header.width;
  96815. y_start = 0;
  96816. y_step = 1;
  96817. y_end = header.height;
  96818. break;
  96819. case TGATools._ORIGIN_BL:
  96820. x_start = 0;
  96821. x_step = 1;
  96822. x_end = header.width;
  96823. y_start = header.height - 1;
  96824. y_step = -1;
  96825. y_end = -1;
  96826. break;
  96827. case TGATools._ORIGIN_UR:
  96828. x_start = header.width - 1;
  96829. x_step = -1;
  96830. x_end = -1;
  96831. y_start = 0;
  96832. y_step = 1;
  96833. y_end = header.height;
  96834. break;
  96835. case TGATools._ORIGIN_BR:
  96836. x_start = header.width - 1;
  96837. x_step = -1;
  96838. x_end = -1;
  96839. y_start = header.height - 1;
  96840. y_step = -1;
  96841. y_end = -1;
  96842. break;
  96843. }
  96844. // Load the specify method
  96845. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  96846. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  96847. var engine = texture.getEngine();
  96848. engine._uploadDataToTextureDirectly(texture, imageData);
  96849. };
  96850. /** @hidden */
  96851. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96852. var image = pixel_data, colormap = palettes;
  96853. var width = header.width, height = header.height;
  96854. var color, i = 0, x, y;
  96855. var imageData = new Uint8Array(width * height * 4);
  96856. for (y = y_start; y !== y_end; y += y_step) {
  96857. for (x = x_start; x !== x_end; x += x_step, i++) {
  96858. color = image[i];
  96859. imageData[(x + width * y) * 4 + 3] = 255;
  96860. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  96861. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  96862. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  96863. }
  96864. }
  96865. return imageData;
  96866. };
  96867. /** @hidden */
  96868. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96869. var image = pixel_data;
  96870. var width = header.width, height = header.height;
  96871. var color, i = 0, x, y;
  96872. var imageData = new Uint8Array(width * height * 4);
  96873. for (y = y_start; y !== y_end; y += y_step) {
  96874. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  96875. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  96876. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  96877. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  96878. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  96879. imageData[(x + width * y) * 4 + 0] = r;
  96880. imageData[(x + width * y) * 4 + 1] = g;
  96881. imageData[(x + width * y) * 4 + 2] = b;
  96882. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  96883. }
  96884. }
  96885. return imageData;
  96886. };
  96887. /** @hidden */
  96888. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96889. var image = pixel_data;
  96890. var width = header.width, height = header.height;
  96891. var i = 0, x, y;
  96892. var imageData = new Uint8Array(width * height * 4);
  96893. for (y = y_start; y !== y_end; y += y_step) {
  96894. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  96895. imageData[(x + width * y) * 4 + 3] = 255;
  96896. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  96897. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  96898. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  96899. }
  96900. }
  96901. return imageData;
  96902. };
  96903. /** @hidden */
  96904. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96905. var image = pixel_data;
  96906. var width = header.width, height = header.height;
  96907. var i = 0, x, y;
  96908. var imageData = new Uint8Array(width * height * 4);
  96909. for (y = y_start; y !== y_end; y += y_step) {
  96910. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  96911. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  96912. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  96913. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  96914. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  96915. }
  96916. }
  96917. return imageData;
  96918. };
  96919. /** @hidden */
  96920. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96921. var image = pixel_data;
  96922. var width = header.width, height = header.height;
  96923. var color, i = 0, x, y;
  96924. var imageData = new Uint8Array(width * height * 4);
  96925. for (y = y_start; y !== y_end; y += y_step) {
  96926. for (x = x_start; x !== x_end; x += x_step, i++) {
  96927. color = image[i];
  96928. imageData[(x + width * y) * 4 + 0] = color;
  96929. imageData[(x + width * y) * 4 + 1] = color;
  96930. imageData[(x + width * y) * 4 + 2] = color;
  96931. imageData[(x + width * y) * 4 + 3] = 255;
  96932. }
  96933. }
  96934. return imageData;
  96935. };
  96936. /** @hidden */
  96937. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  96938. var image = pixel_data;
  96939. var width = header.width, height = header.height;
  96940. var i = 0, x, y;
  96941. var imageData = new Uint8Array(width * height * 4);
  96942. for (y = y_start; y !== y_end; y += y_step) {
  96943. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  96944. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  96945. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  96946. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  96947. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  96948. }
  96949. }
  96950. return imageData;
  96951. };
  96952. //private static _TYPE_NO_DATA = 0;
  96953. TGATools._TYPE_INDEXED = 1;
  96954. TGATools._TYPE_RGB = 2;
  96955. TGATools._TYPE_GREY = 3;
  96956. TGATools._TYPE_RLE_INDEXED = 9;
  96957. TGATools._TYPE_RLE_RGB = 10;
  96958. TGATools._TYPE_RLE_GREY = 11;
  96959. TGATools._ORIGIN_MASK = 0x30;
  96960. TGATools._ORIGIN_SHIFT = 0x04;
  96961. TGATools._ORIGIN_BL = 0x00;
  96962. TGATools._ORIGIN_BR = 0x01;
  96963. TGATools._ORIGIN_UL = 0x02;
  96964. TGATools._ORIGIN_UR = 0x03;
  96965. return TGATools;
  96966. }());
  96967. /***/ }),
  96968. /***/ "./Misc/tools.ts":
  96969. /*!***********************!*\
  96970. !*** ./Misc/tools.ts ***!
  96971. \***********************/
  96972. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  96973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96974. "use strict";
  96975. __webpack_require__.r(__webpack_exports__);
  96976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  96977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  96978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  96979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  96980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  96981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  96982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  96983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  96984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  96985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96986. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96987. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  96988. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96989. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  96990. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96991. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  96992. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96993. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  96994. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  96995. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  96996. /** Class used to store color4 gradient */
  96997. var ColorGradient = /** @class */ (function () {
  96998. function ColorGradient() {
  96999. }
  97000. /**
  97001. * Will get a color picked randomly between color1 and color2.
  97002. * If color2 is undefined then color1 will be used
  97003. * @param result defines the target Color4 to store the result in
  97004. */
  97005. ColorGradient.prototype.getColorToRef = function (result) {
  97006. if (!this.color2) {
  97007. result.copyFrom(this.color1);
  97008. return;
  97009. }
  97010. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  97011. };
  97012. return ColorGradient;
  97013. }());
  97014. /** Class used to store color 3 gradient */
  97015. var Color3Gradient = /** @class */ (function () {
  97016. function Color3Gradient() {
  97017. }
  97018. return Color3Gradient;
  97019. }());
  97020. /** Class used to store factor gradient */
  97021. var FactorGradient = /** @class */ (function () {
  97022. function FactorGradient() {
  97023. }
  97024. /**
  97025. * Will get a number picked randomly between factor1 and factor2.
  97026. * If factor2 is undefined then factor1 will be used
  97027. * @returns the picked number
  97028. */
  97029. FactorGradient.prototype.getFactor = function () {
  97030. if (this.factor2 === undefined) {
  97031. return this.factor1;
  97032. }
  97033. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  97034. };
  97035. return FactorGradient;
  97036. }());
  97037. /**
  97038. * @ignore
  97039. * Application error to support additional information when loading a file
  97040. */
  97041. var LoadFileError = /** @class */ (function (_super) {
  97042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  97043. /**
  97044. * Creates a new LoadFileError
  97045. * @param message defines the message of the error
  97046. * @param request defines the optional XHR request
  97047. */
  97048. function LoadFileError(message,
  97049. /** defines the optional XHR request */
  97050. request) {
  97051. var _this = _super.call(this, message) || this;
  97052. _this.request = request;
  97053. _this.name = "LoadFileError";
  97054. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  97055. return _this;
  97056. }
  97057. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  97058. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  97059. // Polyfill for Object.setPrototypeOf if necessary.
  97060. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  97061. return LoadFileError;
  97062. }(Error));
  97063. /**
  97064. * Class used to define a retry strategy when error happens while loading assets
  97065. */
  97066. var RetryStrategy = /** @class */ (function () {
  97067. function RetryStrategy() {
  97068. }
  97069. /**
  97070. * Function used to defines an exponential back off strategy
  97071. * @param maxRetries defines the maximum number of retries (3 by default)
  97072. * @param baseInterval defines the interval between retries
  97073. * @returns the strategy function to use
  97074. */
  97075. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  97076. if (maxRetries === void 0) { maxRetries = 3; }
  97077. if (baseInterval === void 0) { baseInterval = 500; }
  97078. return function (url, request, retryIndex) {
  97079. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  97080. return -1;
  97081. }
  97082. return Math.pow(2, retryIndex) * baseInterval;
  97083. };
  97084. };
  97085. return RetryStrategy;
  97086. }());
  97087. // Screenshots
  97088. var screenshotCanvas;
  97089. /**
  97090. * Class containing a set of static utilities functions
  97091. */
  97092. var Tools = /** @class */ (function () {
  97093. function Tools() {
  97094. }
  97095. /**
  97096. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97097. * @param u defines the coordinate on X axis
  97098. * @param v defines the coordinate on Y axis
  97099. * @param width defines the width of the source data
  97100. * @param height defines the height of the source data
  97101. * @param pixels defines the source byte array
  97102. * @param color defines the output color
  97103. */
  97104. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  97105. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  97106. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  97107. var position = (wrappedU + wrappedV * width) * 4;
  97108. color.r = pixels[position] / 255;
  97109. color.g = pixels[position + 1] / 255;
  97110. color.b = pixels[position + 2] / 255;
  97111. color.a = pixels[position + 3] / 255;
  97112. };
  97113. /**
  97114. * Interpolates between a and b via alpha
  97115. * @param a The lower value (returned when alpha = 0)
  97116. * @param b The upper value (returned when alpha = 1)
  97117. * @param alpha The interpolation-factor
  97118. * @return The mixed value
  97119. */
  97120. Tools.Mix = function (a, b, alpha) {
  97121. return a * (1 - alpha) + b * alpha;
  97122. };
  97123. /**
  97124. * Tries to instantiate a new object from a given class name
  97125. * @param className defines the class name to instantiate
  97126. * @returns the new object or null if the system was not able to do the instantiation
  97127. */
  97128. Tools.Instantiate = function (className) {
  97129. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  97130. return Tools.RegisteredExternalClasses[className];
  97131. }
  97132. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  97133. if (internalClass) {
  97134. return internalClass;
  97135. }
  97136. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  97137. var arr = className.split(".");
  97138. var fn = (window || this);
  97139. for (var i = 0, len = arr.length; i < len; i++) {
  97140. fn = fn[arr[i]];
  97141. }
  97142. if (typeof fn !== "function") {
  97143. return null;
  97144. }
  97145. return fn;
  97146. };
  97147. /**
  97148. * Provides a slice function that will work even on IE
  97149. * @param data defines the array to slice
  97150. * @param start defines the start of the data (optional)
  97151. * @param end defines the end of the data (optional)
  97152. * @returns the new sliced array
  97153. */
  97154. Tools.Slice = function (data, start, end) {
  97155. if (data.slice) {
  97156. return data.slice(start, end);
  97157. }
  97158. return Array.prototype.slice.call(data, start, end);
  97159. };
  97160. /**
  97161. * Polyfill for setImmediate
  97162. * @param action defines the action to execute after the current execution block
  97163. */
  97164. Tools.SetImmediate = function (action) {
  97165. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  97166. window.setImmediate(action);
  97167. }
  97168. else {
  97169. setTimeout(action, 1);
  97170. }
  97171. };
  97172. /**
  97173. * Function indicating if a number is an exponent of 2
  97174. * @param value defines the value to test
  97175. * @returns true if the value is an exponent of 2
  97176. */
  97177. Tools.IsExponentOfTwo = function (value) {
  97178. var count = 1;
  97179. do {
  97180. count *= 2;
  97181. } while (count < value);
  97182. return count === value;
  97183. };
  97184. /**
  97185. * Returns the nearest 32-bit single precision float representation of a Number
  97186. * @param value A Number. If the parameter is of a different type, it will get converted
  97187. * to a number or to NaN if it cannot be converted
  97188. * @returns number
  97189. */
  97190. Tools.FloatRound = function (value) {
  97191. if (Math.fround) {
  97192. return Math.fround(value);
  97193. }
  97194. return (Tools._tmpFloatArray[0] = value);
  97195. };
  97196. /**
  97197. * Find the next highest power of two.
  97198. * @param x Number to start search from.
  97199. * @return Next highest power of two.
  97200. */
  97201. Tools.CeilingPOT = function (x) {
  97202. x--;
  97203. x |= x >> 1;
  97204. x |= x >> 2;
  97205. x |= x >> 4;
  97206. x |= x >> 8;
  97207. x |= x >> 16;
  97208. x++;
  97209. return x;
  97210. };
  97211. /**
  97212. * Find the next lowest power of two.
  97213. * @param x Number to start search from.
  97214. * @return Next lowest power of two.
  97215. */
  97216. Tools.FloorPOT = function (x) {
  97217. x = x | (x >> 1);
  97218. x = x | (x >> 2);
  97219. x = x | (x >> 4);
  97220. x = x | (x >> 8);
  97221. x = x | (x >> 16);
  97222. return x - (x >> 1);
  97223. };
  97224. /**
  97225. * Find the nearest power of two.
  97226. * @param x Number to start search from.
  97227. * @return Next nearest power of two.
  97228. */
  97229. Tools.NearestPOT = function (x) {
  97230. var c = Tools.CeilingPOT(x);
  97231. var f = Tools.FloorPOT(x);
  97232. return (c - x) > (x - f) ? f : c;
  97233. };
  97234. /**
  97235. * Get the closest exponent of two
  97236. * @param value defines the value to approximate
  97237. * @param max defines the maximum value to return
  97238. * @param mode defines how to define the closest value
  97239. * @returns closest exponent of two of the given value
  97240. */
  97241. Tools.GetExponentOfTwo = function (value, max, mode) {
  97242. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  97243. var pot;
  97244. switch (mode) {
  97245. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  97246. pot = Tools.FloorPOT(value);
  97247. break;
  97248. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  97249. pot = Tools.NearestPOT(value);
  97250. break;
  97251. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  97252. default:
  97253. pot = Tools.CeilingPOT(value);
  97254. break;
  97255. }
  97256. return Math.min(pot, max);
  97257. };
  97258. /**
  97259. * Extracts the filename from a path
  97260. * @param path defines the path to use
  97261. * @returns the filename
  97262. */
  97263. Tools.GetFilename = function (path) {
  97264. var index = path.lastIndexOf("/");
  97265. if (index < 0) {
  97266. return path;
  97267. }
  97268. return path.substring(index + 1);
  97269. };
  97270. /**
  97271. * Extracts the "folder" part of a path (everything before the filename).
  97272. * @param uri The URI to extract the info from
  97273. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97274. * @returns The "folder" part of the path
  97275. */
  97276. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  97277. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  97278. var index = uri.lastIndexOf("/");
  97279. if (index < 0) {
  97280. if (returnUnchangedIfNoSlash) {
  97281. return uri;
  97282. }
  97283. return "";
  97284. }
  97285. return uri.substring(0, index + 1);
  97286. };
  97287. /**
  97288. * Convert an angle in radians to degrees
  97289. * @param angle defines the angle to convert
  97290. * @returns the angle in degrees
  97291. */
  97292. Tools.ToDegrees = function (angle) {
  97293. return angle * 180 / Math.PI;
  97294. };
  97295. /**
  97296. * Convert an angle in degrees to radians
  97297. * @param angle defines the angle to convert
  97298. * @returns the angle in radians
  97299. */
  97300. Tools.ToRadians = function (angle) {
  97301. return angle * Math.PI / 180;
  97302. };
  97303. /**
  97304. * Encode a buffer to a base64 string
  97305. * @param buffer defines the buffer to encode
  97306. * @returns the encoded string
  97307. */
  97308. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  97309. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  97310. var output = "";
  97311. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  97312. var i = 0;
  97313. var bytes = new Uint8Array(buffer);
  97314. while (i < bytes.length) {
  97315. chr1 = bytes[i++];
  97316. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  97317. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  97318. enc1 = chr1 >> 2;
  97319. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  97320. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  97321. enc4 = chr3 & 63;
  97322. if (isNaN(chr2)) {
  97323. enc3 = enc4 = 64;
  97324. }
  97325. else if (isNaN(chr3)) {
  97326. enc4 = 64;
  97327. }
  97328. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  97329. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  97330. }
  97331. return "data:image/png;base64," + output;
  97332. };
  97333. /**
  97334. * Extracts minimum and maximum values from a list of indexed positions
  97335. * @param positions defines the positions to use
  97336. * @param indices defines the indices to the positions
  97337. * @param indexStart defines the start index
  97338. * @param indexCount defines the end index
  97339. * @param bias defines bias value to add to the result
  97340. * @return minimum and maximum values
  97341. */
  97342. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  97343. if (bias === void 0) { bias = null; }
  97344. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97345. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97346. for (var index = indexStart; index < indexStart + indexCount; index++) {
  97347. var offset = indices[index] * 3;
  97348. var x = positions[offset];
  97349. var y = positions[offset + 1];
  97350. var z = positions[offset + 2];
  97351. minimum.minimizeInPlaceFromFloats(x, y, z);
  97352. maximum.maximizeInPlaceFromFloats(x, y, z);
  97353. }
  97354. if (bias) {
  97355. minimum.x -= minimum.x * bias.x + bias.y;
  97356. minimum.y -= minimum.y * bias.x + bias.y;
  97357. minimum.z -= minimum.z * bias.x + bias.y;
  97358. maximum.x += maximum.x * bias.x + bias.y;
  97359. maximum.y += maximum.y * bias.x + bias.y;
  97360. maximum.z += maximum.z * bias.x + bias.y;
  97361. }
  97362. return {
  97363. minimum: minimum,
  97364. maximum: maximum
  97365. };
  97366. };
  97367. /**
  97368. * Extracts minimum and maximum values from a list of positions
  97369. * @param positions defines the positions to use
  97370. * @param start defines the start index in the positions array
  97371. * @param count defines the number of positions to handle
  97372. * @param bias defines bias value to add to the result
  97373. * @param stride defines the stride size to use (distance between two positions in the positions array)
  97374. * @return minimum and maximum values
  97375. */
  97376. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  97377. if (bias === void 0) { bias = null; }
  97378. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97379. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97380. if (!stride) {
  97381. stride = 3;
  97382. }
  97383. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  97384. var x = positions[offset];
  97385. var y = positions[offset + 1];
  97386. var z = positions[offset + 2];
  97387. minimum.minimizeInPlaceFromFloats(x, y, z);
  97388. maximum.maximizeInPlaceFromFloats(x, y, z);
  97389. }
  97390. if (bias) {
  97391. minimum.x -= minimum.x * bias.x + bias.y;
  97392. minimum.y -= minimum.y * bias.x + bias.y;
  97393. minimum.z -= minimum.z * bias.x + bias.y;
  97394. maximum.x += maximum.x * bias.x + bias.y;
  97395. maximum.y += maximum.y * bias.x + bias.y;
  97396. maximum.z += maximum.z * bias.x + bias.y;
  97397. }
  97398. return {
  97399. minimum: minimum,
  97400. maximum: maximum
  97401. };
  97402. };
  97403. /**
  97404. * Returns an array if obj is not an array
  97405. * @param obj defines the object to evaluate as an array
  97406. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97407. * @returns either obj directly if obj is an array or a new array containing obj
  97408. */
  97409. Tools.MakeArray = function (obj, allowsNullUndefined) {
  97410. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  97411. return null;
  97412. }
  97413. return Array.isArray(obj) ? obj : [obj];
  97414. };
  97415. /**
  97416. * Gets the pointer prefix to use
  97417. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97418. */
  97419. Tools.GetPointerPrefix = function () {
  97420. var eventPrefix = "pointer";
  97421. // Check if pointer events are supported
  97422. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  97423. eventPrefix = "mouse";
  97424. }
  97425. return eventPrefix;
  97426. };
  97427. /**
  97428. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97429. * @param func - the function to be called
  97430. * @param requester - the object that will request the next frame. Falls back to window.
  97431. * @returns frame number
  97432. */
  97433. Tools.QueueNewFrame = function (func, requester) {
  97434. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  97435. return setTimeout(func, 16);
  97436. }
  97437. if (!requester) {
  97438. requester = window;
  97439. }
  97440. if (requester.requestAnimationFrame) {
  97441. return requester.requestAnimationFrame(func);
  97442. }
  97443. else if (requester.msRequestAnimationFrame) {
  97444. return requester.msRequestAnimationFrame(func);
  97445. }
  97446. else if (requester.webkitRequestAnimationFrame) {
  97447. return requester.webkitRequestAnimationFrame(func);
  97448. }
  97449. else if (requester.mozRequestAnimationFrame) {
  97450. return requester.mozRequestAnimationFrame(func);
  97451. }
  97452. else if (requester.oRequestAnimationFrame) {
  97453. return requester.oRequestAnimationFrame(func);
  97454. }
  97455. else {
  97456. return window.setTimeout(func, 16);
  97457. }
  97458. };
  97459. /**
  97460. * Ask the browser to promote the current element to fullscreen rendering mode
  97461. * @param element defines the DOM element to promote
  97462. */
  97463. Tools.RequestFullscreen = function (element) {
  97464. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  97465. if (!requestFunction) {
  97466. return;
  97467. }
  97468. requestFunction.call(element);
  97469. };
  97470. /**
  97471. * Asks the browser to exit fullscreen mode
  97472. */
  97473. Tools.ExitFullscreen = function () {
  97474. if (document.exitFullscreen) {
  97475. document.exitFullscreen();
  97476. }
  97477. else if (document.mozCancelFullScreen) {
  97478. document.mozCancelFullScreen();
  97479. }
  97480. else if (document.webkitCancelFullScreen) {
  97481. document.webkitCancelFullScreen();
  97482. }
  97483. else if (document.msCancelFullScreen) {
  97484. document.msCancelFullScreen();
  97485. }
  97486. };
  97487. /**
  97488. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97489. * @param url define the url we are trying
  97490. * @param element define the dom element where to configure the cors policy
  97491. */
  97492. Tools.SetCorsBehavior = function (url, element) {
  97493. if (url && url.indexOf("data:") === 0) {
  97494. return;
  97495. }
  97496. if (Tools.CorsBehavior) {
  97497. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  97498. element.crossOrigin = Tools.CorsBehavior;
  97499. }
  97500. else {
  97501. var result = Tools.CorsBehavior(url);
  97502. if (result) {
  97503. element.crossOrigin = result;
  97504. }
  97505. }
  97506. }
  97507. };
  97508. // External files
  97509. /**
  97510. * Removes unwanted characters from an url
  97511. * @param url defines the url to clean
  97512. * @returns the cleaned url
  97513. */
  97514. Tools.CleanUrl = function (url) {
  97515. url = url.replace(/#/mg, "%23");
  97516. return url;
  97517. };
  97518. /**
  97519. * Loads an image as an HTMLImageElement.
  97520. * @param input url string, ArrayBuffer, or Blob to load
  97521. * @param onLoad callback called when the image successfully loads
  97522. * @param onError callback called when the image fails to load
  97523. * @param offlineProvider offline provider for caching
  97524. * @returns the HTMLImageElement of the loaded image
  97525. */
  97526. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  97527. var url;
  97528. var usingObjectURL = false;
  97529. if (input instanceof ArrayBuffer) {
  97530. url = URL.createObjectURL(new Blob([input]));
  97531. usingObjectURL = true;
  97532. }
  97533. else if (input instanceof Blob) {
  97534. url = URL.createObjectURL(input);
  97535. usingObjectURL = true;
  97536. }
  97537. else {
  97538. url = Tools.CleanUrl(input);
  97539. url = Tools.PreprocessUrl(input);
  97540. }
  97541. var img = new Image();
  97542. Tools.SetCorsBehavior(url, img);
  97543. var loadHandler = function () {
  97544. if (usingObjectURL && img.src) {
  97545. URL.revokeObjectURL(img.src);
  97546. }
  97547. img.removeEventListener("load", loadHandler);
  97548. img.removeEventListener("error", errorHandler);
  97549. onLoad(img);
  97550. };
  97551. var errorHandler = function (err) {
  97552. if (usingObjectURL && img.src) {
  97553. URL.revokeObjectURL(img.src);
  97554. }
  97555. img.removeEventListener("load", loadHandler);
  97556. img.removeEventListener("error", errorHandler);
  97557. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  97558. if (onError) {
  97559. onError("Error while trying to load image: " + input, err);
  97560. }
  97561. };
  97562. img.addEventListener("load", loadHandler);
  97563. img.addEventListener("error", errorHandler);
  97564. var noOfflineSupport = function () {
  97565. img.src = url;
  97566. };
  97567. var loadFromOfflineSupport = function () {
  97568. if (offlineProvider) {
  97569. offlineProvider.loadImage(url, img);
  97570. }
  97571. };
  97572. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  97573. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  97574. }
  97575. else {
  97576. if (url.indexOf("file:") !== -1) {
  97577. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  97578. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  97579. try {
  97580. var blobURL;
  97581. try {
  97582. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97583. }
  97584. catch (ex) {
  97585. // Chrome doesn't support oneTimeOnly parameter
  97586. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97587. }
  97588. img.src = blobURL;
  97589. usingObjectURL = true;
  97590. }
  97591. catch (e) {
  97592. img.src = "";
  97593. }
  97594. return img;
  97595. }
  97596. }
  97597. noOfflineSupport();
  97598. }
  97599. return img;
  97600. };
  97601. /**
  97602. * Loads a file
  97603. * @param url url string, ArrayBuffer, or Blob to load
  97604. * @param onSuccess callback called when the file successfully loads
  97605. * @param onProgress callback called while file is loading (if the server supports this mode)
  97606. * @param offlineProvider defines the offline provider for caching
  97607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97608. * @param onError callback called when the file fails to load
  97609. * @returns a file request object
  97610. */
  97611. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  97612. url = Tools.CleanUrl(url);
  97613. url = Tools.PreprocessUrl(url);
  97614. // If file and file input are set
  97615. if (url.indexOf("file:") !== -1) {
  97616. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  97617. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  97618. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  97619. }
  97620. }
  97621. var loadUrl = Tools.BaseUrl + url;
  97622. var aborted = false;
  97623. var fileRequest = {
  97624. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97625. abort: function () { return aborted = true; },
  97626. };
  97627. var requestFile = function () {
  97628. var request = new XMLHttpRequest();
  97629. var retryHandle = null;
  97630. fileRequest.abort = function () {
  97631. aborted = true;
  97632. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  97633. request.abort();
  97634. }
  97635. if (retryHandle !== null) {
  97636. clearTimeout(retryHandle);
  97637. retryHandle = null;
  97638. }
  97639. };
  97640. var retryLoop = function (retryIndex) {
  97641. request.open('GET', loadUrl, true);
  97642. if (useArrayBuffer) {
  97643. request.responseType = "arraybuffer";
  97644. }
  97645. if (onProgress) {
  97646. request.addEventListener("progress", onProgress);
  97647. }
  97648. var onLoadEnd = function () {
  97649. request.removeEventListener("loadend", onLoadEnd);
  97650. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  97651. fileRequest.onCompleteObservable.clear();
  97652. };
  97653. request.addEventListener("loadend", onLoadEnd);
  97654. var onReadyStateChange = function () {
  97655. if (aborted) {
  97656. return;
  97657. }
  97658. // In case of undefined state in some browsers.
  97659. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  97660. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  97661. request.removeEventListener("readystatechange", onReadyStateChange);
  97662. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  97663. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  97664. return;
  97665. }
  97666. var retryStrategy = Tools.DefaultRetryStrategy;
  97667. if (retryStrategy) {
  97668. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  97669. if (waitTime !== -1) {
  97670. // Prevent the request from completing for retry.
  97671. request.removeEventListener("loadend", onLoadEnd);
  97672. request = new XMLHttpRequest();
  97673. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  97674. return;
  97675. }
  97676. }
  97677. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  97678. if (onError) {
  97679. onError(request, e);
  97680. }
  97681. else {
  97682. throw e;
  97683. }
  97684. }
  97685. };
  97686. request.addEventListener("readystatechange", onReadyStateChange);
  97687. if (Tools.UseCustomRequestHeaders) {
  97688. Tools.InjectCustomRequestHeaders(request);
  97689. }
  97690. request.send();
  97691. };
  97692. retryLoop(0);
  97693. };
  97694. // Caching all files
  97695. if (offlineProvider && offlineProvider.enableSceneOffline) {
  97696. var noOfflineSupport_1 = function (request) {
  97697. if (request && request.status > 400) {
  97698. if (onError) {
  97699. onError(request);
  97700. }
  97701. }
  97702. else {
  97703. if (!aborted) {
  97704. requestFile();
  97705. }
  97706. }
  97707. };
  97708. var loadFromOfflineSupport = function () {
  97709. // TODO: database needs to support aborting and should return a IFileRequest
  97710. if (aborted) {
  97711. return;
  97712. }
  97713. if (offlineProvider) {
  97714. offlineProvider.loadFile(url, function (data) {
  97715. if (!aborted) {
  97716. onSuccess(data);
  97717. }
  97718. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  97719. }, onProgress ? function (event) {
  97720. if (!aborted) {
  97721. onProgress(event);
  97722. }
  97723. } : undefined, noOfflineSupport_1, useArrayBuffer);
  97724. }
  97725. };
  97726. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  97727. }
  97728. else {
  97729. requestFile();
  97730. }
  97731. return fileRequest;
  97732. };
  97733. /**
  97734. * Load a script (identified by an url). When the url returns, the
  97735. * content of this file is added into a new script element, attached to the DOM (body element)
  97736. * @param scriptUrl defines the url of the script to laod
  97737. * @param onSuccess defines the callback called when the script is loaded
  97738. * @param onError defines the callback to call if an error occurs
  97739. */
  97740. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  97741. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  97742. return;
  97743. }
  97744. var head = document.getElementsByTagName('head')[0];
  97745. var script = document.createElement('script');
  97746. script.type = 'text/javascript';
  97747. script.src = scriptUrl;
  97748. script.onload = function () {
  97749. if (onSuccess) {
  97750. onSuccess();
  97751. }
  97752. };
  97753. script.onerror = function (e) {
  97754. if (onError) {
  97755. onError("Unable to load script '" + scriptUrl + "'", e);
  97756. }
  97757. };
  97758. head.appendChild(script);
  97759. };
  97760. /**
  97761. * Loads a file from a blob
  97762. * @param fileToLoad defines the blob to use
  97763. * @param callback defines the callback to call when data is loaded
  97764. * @param progressCallback defines the callback to call during loading process
  97765. * @returns a file request object
  97766. */
  97767. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  97768. var reader = new FileReader();
  97769. var request = {
  97770. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97771. abort: function () { return reader.abort(); },
  97772. };
  97773. reader.onloadend = function (e) {
  97774. request.onCompleteObservable.notifyObservers(request);
  97775. };
  97776. reader.onload = function (e) {
  97777. //target doesn't have result from ts 1.3
  97778. callback(e.target['result']);
  97779. };
  97780. reader.onprogress = progressCallback;
  97781. reader.readAsDataURL(fileToLoad);
  97782. return request;
  97783. };
  97784. /**
  97785. * Loads a file
  97786. * @param fileToLoad defines the file to load
  97787. * @param callback defines the callback to call when data is loaded
  97788. * @param progressCallBack defines the callback to call during loading process
  97789. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97790. * @returns a file request object
  97791. */
  97792. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  97793. var reader = new FileReader();
  97794. var request = {
  97795. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97796. abort: function () { return reader.abort(); },
  97797. };
  97798. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  97799. reader.onerror = function (e) {
  97800. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  97801. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  97802. };
  97803. reader.onload = function (e) {
  97804. //target doesn't have result from ts 1.3
  97805. callback(e.target['result']);
  97806. };
  97807. if (progressCallBack) {
  97808. reader.onprogress = progressCallBack;
  97809. }
  97810. if (!useArrayBuffer) {
  97811. // Asynchronous read
  97812. reader.readAsText(fileToLoad);
  97813. }
  97814. else {
  97815. reader.readAsArrayBuffer(fileToLoad);
  97816. }
  97817. return request;
  97818. };
  97819. /**
  97820. * Creates a data url from a given string content
  97821. * @param content defines the content to convert
  97822. * @returns the new data url link
  97823. */
  97824. Tools.FileAsURL = function (content) {
  97825. var fileBlob = new Blob([content]);
  97826. var url = window.URL || window.webkitURL;
  97827. var link = url.createObjectURL(fileBlob);
  97828. return link;
  97829. };
  97830. /**
  97831. * Format the given number to a specific decimal format
  97832. * @param value defines the number to format
  97833. * @param decimals defines the number of decimals to use
  97834. * @returns the formatted string
  97835. */
  97836. Tools.Format = function (value, decimals) {
  97837. if (decimals === void 0) { decimals = 2; }
  97838. return value.toFixed(decimals);
  97839. };
  97840. /**
  97841. * Checks if a given vector is inside a specific range
  97842. * @param v defines the vector to test
  97843. * @param min defines the minimum range
  97844. * @param max defines the maximum range
  97845. */
  97846. Tools.CheckExtends = function (v, min, max) {
  97847. min.minimizeInPlace(v);
  97848. max.maximizeInPlace(v);
  97849. };
  97850. /**
  97851. * Tries to copy an object by duplicating every property
  97852. * @param source defines the source object
  97853. * @param destination defines the target object
  97854. * @param doNotCopyList defines a list of properties to avoid
  97855. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97856. */
  97857. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  97858. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  97859. };
  97860. /**
  97861. * Gets a boolean indicating if the given object has no own property
  97862. * @param obj defines the object to test
  97863. * @returns true if object has no own property
  97864. */
  97865. Tools.IsEmpty = function (obj) {
  97866. for (var i in obj) {
  97867. if (obj.hasOwnProperty(i)) {
  97868. return false;
  97869. }
  97870. }
  97871. return true;
  97872. };
  97873. /**
  97874. * Function used to register events at window level
  97875. * @param events defines the events to register
  97876. */
  97877. Tools.RegisterTopRootEvents = function (events) {
  97878. for (var index = 0; index < events.length; index++) {
  97879. var event = events[index];
  97880. window.addEventListener(event.name, event.handler, false);
  97881. try {
  97882. if (window.parent) {
  97883. window.parent.addEventListener(event.name, event.handler, false);
  97884. }
  97885. }
  97886. catch (e) {
  97887. // Silently fails...
  97888. }
  97889. }
  97890. };
  97891. /**
  97892. * Function used to unregister events from window level
  97893. * @param events defines the events to unregister
  97894. */
  97895. Tools.UnregisterTopRootEvents = function (events) {
  97896. for (var index = 0; index < events.length; index++) {
  97897. var event = events[index];
  97898. window.removeEventListener(event.name, event.handler);
  97899. try {
  97900. if (window.parent) {
  97901. window.parent.removeEventListener(event.name, event.handler);
  97902. }
  97903. }
  97904. catch (e) {
  97905. // Silently fails...
  97906. }
  97907. }
  97908. };
  97909. /**
  97910. * Dumps the current bound framebuffer
  97911. * @param width defines the rendering width
  97912. * @param height defines the rendering height
  97913. * @param engine defines the hosting engine
  97914. * @param successCallback defines the callback triggered once the data are available
  97915. * @param mimeType defines the mime type of the result
  97916. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97917. */
  97918. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  97919. if (mimeType === void 0) { mimeType = "image/png"; }
  97920. // Read the contents of the framebuffer
  97921. var numberOfChannelsByLine = width * 4;
  97922. var halfHeight = height / 2;
  97923. //Reading datas from WebGL
  97924. var data = engine.readPixels(0, 0, width, height);
  97925. //To flip image on Y axis.
  97926. for (var i = 0; i < halfHeight; i++) {
  97927. for (var j = 0; j < numberOfChannelsByLine; j++) {
  97928. var currentCell = j + i * numberOfChannelsByLine;
  97929. var targetLine = height - i - 1;
  97930. var targetCell = j + targetLine * numberOfChannelsByLine;
  97931. var temp = data[currentCell];
  97932. data[currentCell] = data[targetCell];
  97933. data[targetCell] = temp;
  97934. }
  97935. }
  97936. // Create a 2D canvas to store the result
  97937. if (!screenshotCanvas) {
  97938. screenshotCanvas = document.createElement('canvas');
  97939. }
  97940. screenshotCanvas.width = width;
  97941. screenshotCanvas.height = height;
  97942. var context = screenshotCanvas.getContext('2d');
  97943. if (context) {
  97944. // Copy the pixels to a 2D canvas
  97945. var imageData = context.createImageData(width, height);
  97946. var castData = (imageData.data);
  97947. castData.set(data);
  97948. context.putImageData(imageData, 0, 0);
  97949. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  97950. }
  97951. };
  97952. /**
  97953. * Converts the canvas data to blob.
  97954. * This acts as a polyfill for browsers not supporting the to blob function.
  97955. * @param canvas Defines the canvas to extract the data from
  97956. * @param successCallback Defines the callback triggered once the data are available
  97957. * @param mimeType Defines the mime type of the result
  97958. */
  97959. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  97960. if (mimeType === void 0) { mimeType = "image/png"; }
  97961. // We need HTMLCanvasElement.toBlob for HD screenshots
  97962. if (!canvas.toBlob) {
  97963. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  97964. canvas.toBlob = function (callback, type, quality) {
  97965. var _this = this;
  97966. setTimeout(function () {
  97967. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  97968. for (var i = 0; i < len; i++) {
  97969. arr[i] = binStr.charCodeAt(i);
  97970. }
  97971. callback(new Blob([arr]));
  97972. });
  97973. };
  97974. }
  97975. canvas.toBlob(function (blob) {
  97976. successCallback(blob);
  97977. }, mimeType);
  97978. };
  97979. /**
  97980. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97981. * @param successCallback defines the callback triggered once the data are available
  97982. * @param mimeType defines the mime type of the result
  97983. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97984. */
  97985. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  97986. if (mimeType === void 0) { mimeType = "image/png"; }
  97987. if (successCallback) {
  97988. var base64Image = screenshotCanvas.toDataURL(mimeType);
  97989. successCallback(base64Image);
  97990. }
  97991. else {
  97992. this.ToBlob(screenshotCanvas, function (blob) {
  97993. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  97994. if (("download" in document.createElement("a"))) {
  97995. if (!fileName) {
  97996. var date = new Date();
  97997. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  97998. fileName = "screenshot_" + stringDate + ".png";
  97999. }
  98000. Tools.Download(blob, fileName);
  98001. }
  98002. else {
  98003. var url = URL.createObjectURL(blob);
  98004. var newWindow = window.open("");
  98005. if (!newWindow) {
  98006. return;
  98007. }
  98008. var img = newWindow.document.createElement("img");
  98009. img.onload = function () {
  98010. // no longer need to read the blob so it's revoked
  98011. URL.revokeObjectURL(url);
  98012. };
  98013. img.src = url;
  98014. newWindow.document.body.appendChild(img);
  98015. }
  98016. }, mimeType);
  98017. }
  98018. };
  98019. /**
  98020. * Downloads a blob in the browser
  98021. * @param blob defines the blob to download
  98022. * @param fileName defines the name of the downloaded file
  98023. */
  98024. Tools.Download = function (blob, fileName) {
  98025. if (navigator && navigator.msSaveBlob) {
  98026. navigator.msSaveBlob(blob, fileName);
  98027. return;
  98028. }
  98029. var url = window.URL.createObjectURL(blob);
  98030. var a = document.createElement("a");
  98031. document.body.appendChild(a);
  98032. a.style.display = "none";
  98033. a.href = url;
  98034. a.download = fileName;
  98035. a.addEventListener("click", function () {
  98036. if (a.parentElement) {
  98037. a.parentElement.removeChild(a);
  98038. }
  98039. });
  98040. a.click();
  98041. window.URL.revokeObjectURL(url);
  98042. };
  98043. /**
  98044. * Captures a screenshot of the current rendering
  98045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98046. * @param engine defines the rendering engine
  98047. * @param camera defines the source camera
  98048. * @param size This parameter can be set to a single number or to an object with the
  98049. * following (optional) properties: precision, width, height. If a single number is passed,
  98050. * it will be used for both width and height. If an object is passed, the screenshot size
  98051. * will be derived from the parameters. The precision property is a multiplier allowing
  98052. * rendering at a higher or lower resolution
  98053. * @param successCallback defines the callback receives a single parameter which contains the
  98054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98055. * src parameter of an <img> to display it
  98056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98057. * Check your browser for supported MIME types
  98058. */
  98059. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  98060. if (mimeType === void 0) { mimeType = "image/png"; }
  98061. throw "Import ScreenshotTools before creating screenshot.";
  98062. };
  98063. /**
  98064. * Generates an image screenshot from the specified camera.
  98065. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98066. * @param engine The engine to use for rendering
  98067. * @param camera The camera to use for rendering
  98068. * @param size This parameter can be set to a single number or to an object with the
  98069. * following (optional) properties: precision, width, height. If a single number is passed,
  98070. * it will be used for both width and height. If an object is passed, the screenshot size
  98071. * will be derived from the parameters. The precision property is a multiplier allowing
  98072. * rendering at a higher or lower resolution
  98073. * @param successCallback The callback receives a single parameter which contains the
  98074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98075. * src parameter of an <img> to display it
  98076. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98077. * Check your browser for supported MIME types
  98078. * @param samples Texture samples (default: 1)
  98079. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98080. * @param fileName A name for for the downloaded file.
  98081. */
  98082. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  98083. if (mimeType === void 0) { mimeType = "image/png"; }
  98084. if (samples === void 0) { samples = 1; }
  98085. if (antialiasing === void 0) { antialiasing = false; }
  98086. throw "Import ScreenshotTools before creating screenshot.";
  98087. };
  98088. /**
  98089. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98090. * Be aware Math.random() could cause collisions, but:
  98091. * "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"
  98092. * @returns a pseudo random id
  98093. */
  98094. Tools.RandomId = function () {
  98095. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  98096. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  98097. return v.toString(16);
  98098. });
  98099. };
  98100. /**
  98101. * Test if the given uri is a base64 string
  98102. * @param uri The uri to test
  98103. * @return True if the uri is a base64 string or false otherwise
  98104. */
  98105. Tools.IsBase64 = function (uri) {
  98106. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  98107. };
  98108. /**
  98109. * Decode the given base64 uri.
  98110. * @param uri The uri to decode
  98111. * @return The decoded base64 data.
  98112. */
  98113. Tools.DecodeBase64 = function (uri) {
  98114. var decodedString = atob(uri.split(",")[1]);
  98115. var bufferLength = decodedString.length;
  98116. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  98117. for (var i = 0; i < bufferLength; i++) {
  98118. bufferView[i] = decodedString.charCodeAt(i);
  98119. }
  98120. return bufferView.buffer;
  98121. };
  98122. Object.defineProperty(Tools, "errorsCount", {
  98123. /**
  98124. * Gets a value indicating the number of loading errors
  98125. * @ignorenaming
  98126. */
  98127. get: function () {
  98128. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  98129. },
  98130. enumerable: true,
  98131. configurable: true
  98132. });
  98133. /**
  98134. * Log a message to the console
  98135. * @param message defines the message to log
  98136. */
  98137. Tools.Log = function (message) {
  98138. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  98139. };
  98140. /**
  98141. * Write a warning message to the console
  98142. * @param message defines the message to log
  98143. */
  98144. Tools.Warn = function (message) {
  98145. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  98146. };
  98147. /**
  98148. * Write an error message to the console
  98149. * @param message defines the message to log
  98150. */
  98151. Tools.Error = function (message) {
  98152. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  98153. };
  98154. Object.defineProperty(Tools, "LogCache", {
  98155. /**
  98156. * Gets current log cache (list of logs)
  98157. */
  98158. get: function () {
  98159. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  98160. },
  98161. enumerable: true,
  98162. configurable: true
  98163. });
  98164. /**
  98165. * Clears the log cache
  98166. */
  98167. Tools.ClearLogCache = function () {
  98168. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  98169. };
  98170. Object.defineProperty(Tools, "LogLevels", {
  98171. /**
  98172. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98173. */
  98174. set: function (level) {
  98175. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  98176. },
  98177. enumerable: true,
  98178. configurable: true
  98179. });
  98180. /**
  98181. * Checks if the loaded document was accessed via `file:`-Protocol.
  98182. * @returns boolean
  98183. */
  98184. Tools.IsFileURL = function () {
  98185. return location.protocol === "file:";
  98186. };
  98187. Object.defineProperty(Tools, "PerformanceLogLevel", {
  98188. /**
  98189. * Sets the current performance log level
  98190. */
  98191. set: function (level) {
  98192. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  98193. Tools.StartPerformanceCounter = Tools._StartUserMark;
  98194. Tools.EndPerformanceCounter = Tools._EndUserMark;
  98195. return;
  98196. }
  98197. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  98198. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  98199. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  98200. return;
  98201. }
  98202. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98203. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98204. },
  98205. enumerable: true,
  98206. configurable: true
  98207. });
  98208. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  98209. };
  98210. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  98211. };
  98212. Tools._StartUserMark = function (counterName, condition) {
  98213. if (condition === void 0) { condition = true; }
  98214. if (!Tools._performance) {
  98215. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98216. return;
  98217. }
  98218. Tools._performance = window.performance;
  98219. }
  98220. if (!condition || !Tools._performance.mark) {
  98221. return;
  98222. }
  98223. Tools._performance.mark(counterName + "-Begin");
  98224. };
  98225. Tools._EndUserMark = function (counterName, condition) {
  98226. if (condition === void 0) { condition = true; }
  98227. if (!condition || !Tools._performance.mark) {
  98228. return;
  98229. }
  98230. Tools._performance.mark(counterName + "-End");
  98231. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  98232. };
  98233. Tools._StartPerformanceConsole = function (counterName, condition) {
  98234. if (condition === void 0) { condition = true; }
  98235. if (!condition) {
  98236. return;
  98237. }
  98238. Tools._StartUserMark(counterName, condition);
  98239. if (console.time) {
  98240. console.time(counterName);
  98241. }
  98242. };
  98243. Tools._EndPerformanceConsole = function (counterName, condition) {
  98244. if (condition === void 0) { condition = true; }
  98245. if (!condition) {
  98246. return;
  98247. }
  98248. Tools._EndUserMark(counterName, condition);
  98249. if (console.time) {
  98250. console.timeEnd(counterName);
  98251. }
  98252. };
  98253. /**
  98254. * Injects the @see CustomRequestHeaders into the given request
  98255. * @param request the request that should be used for injection
  98256. */
  98257. Tools.InjectCustomRequestHeaders = function (request) {
  98258. for (var key in Tools.CustomRequestHeaders) {
  98259. var val = Tools.CustomRequestHeaders[key];
  98260. if (val) {
  98261. request.setRequestHeader(key, val);
  98262. }
  98263. }
  98264. };
  98265. Object.defineProperty(Tools, "Now", {
  98266. /**
  98267. * Gets either window.performance.now() if supported or Date.now() else
  98268. */
  98269. get: function () {
  98270. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98271. },
  98272. enumerable: true,
  98273. configurable: true
  98274. });
  98275. /**
  98276. * This method will return the name of the class used to create the instance of the given object.
  98277. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98278. * @param object the object to get the class name from
  98279. * @param isType defines if the object is actually a type
  98280. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98281. */
  98282. Tools.GetClassName = function (object, isType) {
  98283. if (isType === void 0) { isType = false; }
  98284. var name = null;
  98285. if (!isType && object.getClassName) {
  98286. name = object.getClassName();
  98287. }
  98288. else {
  98289. if (object instanceof Object) {
  98290. var classObj = isType ? object : Object.getPrototypeOf(object);
  98291. name = classObj.constructor["__bjsclassName__"];
  98292. }
  98293. if (!name) {
  98294. name = typeof object;
  98295. }
  98296. }
  98297. return name;
  98298. };
  98299. /**
  98300. * Gets the first element of an array satisfying a given predicate
  98301. * @param array defines the array to browse
  98302. * @param predicate defines the predicate to use
  98303. * @returns null if not found or the element
  98304. */
  98305. Tools.First = function (array, predicate) {
  98306. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  98307. var el = array_1[_i];
  98308. if (predicate(el)) {
  98309. return el;
  98310. }
  98311. }
  98312. return null;
  98313. };
  98314. /**
  98315. * This method will return the name of the full name of the class, including its owning module (if any).
  98316. * 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).
  98317. * @param object the object to get the class name from
  98318. * @param isType defines if the object is actually a type
  98319. * @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.
  98320. * @ignorenaming
  98321. */
  98322. Tools.getFullClassName = function (object, isType) {
  98323. if (isType === void 0) { isType = false; }
  98324. var className = null;
  98325. var moduleName = null;
  98326. if (!isType && object.getClassName) {
  98327. className = object.getClassName();
  98328. }
  98329. else {
  98330. if (object instanceof Object) {
  98331. var classObj = isType ? object : Object.getPrototypeOf(object);
  98332. className = classObj.constructor["__bjsclassName__"];
  98333. moduleName = classObj.constructor["__bjsmoduleName__"];
  98334. }
  98335. if (!className) {
  98336. className = typeof object;
  98337. }
  98338. }
  98339. if (!className) {
  98340. return null;
  98341. }
  98342. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  98343. };
  98344. /**
  98345. * Returns a promise that resolves after the given amount of time.
  98346. * @param delay Number of milliseconds to delay
  98347. * @returns Promise that resolves after the given amount of time
  98348. */
  98349. Tools.DelayAsync = function (delay) {
  98350. return new Promise(function (resolve) {
  98351. setTimeout(function () {
  98352. resolve();
  98353. }, delay);
  98354. });
  98355. };
  98356. /**
  98357. * Gets the current gradient from an array of IValueGradient
  98358. * @param ratio defines the current ratio to get
  98359. * @param gradients defines the array of IValueGradient
  98360. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  98361. */
  98362. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  98363. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  98364. var currentGradient = gradients[gradientIndex];
  98365. var nextGradient = gradients[gradientIndex + 1];
  98366. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  98367. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  98368. updateFunc(currentGradient, nextGradient, scale);
  98369. return;
  98370. }
  98371. }
  98372. // Use last index if over
  98373. var lastIndex = gradients.length - 1;
  98374. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  98375. };
  98376. /**
  98377. * Gets or sets the base URL to use to load assets
  98378. */
  98379. Tools.BaseUrl = "";
  98380. /**
  98381. * Enable/Disable Custom HTTP Request Headers globally.
  98382. * default = false
  98383. * @see CustomRequestHeaders
  98384. */
  98385. Tools.UseCustomRequestHeaders = false;
  98386. /**
  98387. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98388. * i.e. when loading files, where the server/service expects an Authorization header.
  98389. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  98390. */
  98391. Tools.CustomRequestHeaders = {};
  98392. /**
  98393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98394. */
  98395. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  98396. /**
  98397. * Default behaviour for cors in the application.
  98398. * It can be a string if the expected behavior is identical in the entire app.
  98399. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98400. */
  98401. Tools.CorsBehavior = "anonymous";
  98402. /**
  98403. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98404. * @ignorenaming
  98405. */
  98406. Tools.UseFallbackTexture = true;
  98407. /**
  98408. * Use this object to register external classes like custom textures or material
  98409. * to allow the laoders to instantiate them
  98410. */
  98411. Tools.RegisteredExternalClasses = {};
  98412. /**
  98413. * Texture content used if a texture cannot loaded
  98414. * @ignorenaming
  98415. */
  98416. 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";
  98417. Tools._tmpFloatArray = new Float32Array(1);
  98418. /**
  98419. * Extracts text content from a DOM element hierarchy
  98420. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98421. */
  98422. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  98423. /**
  98424. * Gets or sets a function used to pre-process url before using them to load assets
  98425. */
  98426. Tools.PreprocessUrl = function (url) {
  98427. return url;
  98428. };
  98429. // Logs
  98430. /**
  98431. * No log
  98432. */
  98433. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  98434. /**
  98435. * Only message logs
  98436. */
  98437. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  98438. /**
  98439. * Only warning logs
  98440. */
  98441. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  98442. /**
  98443. * Only error logs
  98444. */
  98445. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  98446. /**
  98447. * All logs
  98448. */
  98449. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  98450. /**
  98451. * Checks if the window object exists
  98452. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98453. */
  98454. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  98455. // Performances
  98456. /**
  98457. * No performance log
  98458. */
  98459. Tools.PerformanceNoneLogLevel = 0;
  98460. /**
  98461. * Use user marks to log performance
  98462. */
  98463. Tools.PerformanceUserMarkLogLevel = 1;
  98464. /**
  98465. * Log performance to the console
  98466. */
  98467. Tools.PerformanceConsoleLogLevel = 2;
  98468. /**
  98469. * Starts a performance counter
  98470. */
  98471. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98472. /**
  98473. * Ends a specific performance coutner
  98474. */
  98475. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98476. return Tools;
  98477. }());
  98478. /**
  98479. * This class is used to track a performance counter which is number based.
  98480. * The user has access to many properties which give statistics of different nature.
  98481. *
  98482. * The implementer can track two kinds of Performance Counter: time and count.
  98483. * 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.
  98484. * 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.
  98485. */
  98486. var PerfCounter = /** @class */ (function () {
  98487. /**
  98488. * Creates a new counter
  98489. */
  98490. function PerfCounter() {
  98491. this._startMonitoringTime = 0;
  98492. this._min = 0;
  98493. this._max = 0;
  98494. this._average = 0;
  98495. this._lastSecAverage = 0;
  98496. this._current = 0;
  98497. this._totalValueCount = 0;
  98498. this._totalAccumulated = 0;
  98499. this._lastSecAccumulated = 0;
  98500. this._lastSecTime = 0;
  98501. this._lastSecValueCount = 0;
  98502. }
  98503. Object.defineProperty(PerfCounter.prototype, "min", {
  98504. /**
  98505. * Returns the smallest value ever
  98506. */
  98507. get: function () {
  98508. return this._min;
  98509. },
  98510. enumerable: true,
  98511. configurable: true
  98512. });
  98513. Object.defineProperty(PerfCounter.prototype, "max", {
  98514. /**
  98515. * Returns the biggest value ever
  98516. */
  98517. get: function () {
  98518. return this._max;
  98519. },
  98520. enumerable: true,
  98521. configurable: true
  98522. });
  98523. Object.defineProperty(PerfCounter.prototype, "average", {
  98524. /**
  98525. * Returns the average value since the performance counter is running
  98526. */
  98527. get: function () {
  98528. return this._average;
  98529. },
  98530. enumerable: true,
  98531. configurable: true
  98532. });
  98533. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  98534. /**
  98535. * Returns the average value of the last second the counter was monitored
  98536. */
  98537. get: function () {
  98538. return this._lastSecAverage;
  98539. },
  98540. enumerable: true,
  98541. configurable: true
  98542. });
  98543. Object.defineProperty(PerfCounter.prototype, "current", {
  98544. /**
  98545. * Returns the current value
  98546. */
  98547. get: function () {
  98548. return this._current;
  98549. },
  98550. enumerable: true,
  98551. configurable: true
  98552. });
  98553. Object.defineProperty(PerfCounter.prototype, "total", {
  98554. /**
  98555. * Gets the accumulated total
  98556. */
  98557. get: function () {
  98558. return this._totalAccumulated;
  98559. },
  98560. enumerable: true,
  98561. configurable: true
  98562. });
  98563. Object.defineProperty(PerfCounter.prototype, "count", {
  98564. /**
  98565. * Gets the total value count
  98566. */
  98567. get: function () {
  98568. return this._totalValueCount;
  98569. },
  98570. enumerable: true,
  98571. configurable: true
  98572. });
  98573. /**
  98574. * Call this method to start monitoring a new frame.
  98575. * 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.
  98576. */
  98577. PerfCounter.prototype.fetchNewFrame = function () {
  98578. this._totalValueCount++;
  98579. this._current = 0;
  98580. this._lastSecValueCount++;
  98581. };
  98582. /**
  98583. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98584. * @param newCount the count value to add to the monitored count
  98585. * @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.
  98586. */
  98587. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  98588. if (!PerfCounter.Enabled) {
  98589. return;
  98590. }
  98591. this._current += newCount;
  98592. if (fetchResult) {
  98593. this._fetchResult();
  98594. }
  98595. };
  98596. /**
  98597. * Start monitoring this performance counter
  98598. */
  98599. PerfCounter.prototype.beginMonitoring = function () {
  98600. if (!PerfCounter.Enabled) {
  98601. return;
  98602. }
  98603. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98604. };
  98605. /**
  98606. * Compute the time lapsed since the previous beginMonitoring() call.
  98607. * @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
  98608. */
  98609. PerfCounter.prototype.endMonitoring = function (newFrame) {
  98610. if (newFrame === void 0) { newFrame = true; }
  98611. if (!PerfCounter.Enabled) {
  98612. return;
  98613. }
  98614. if (newFrame) {
  98615. this.fetchNewFrame();
  98616. }
  98617. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98618. this._current = currentTime - this._startMonitoringTime;
  98619. if (newFrame) {
  98620. this._fetchResult();
  98621. }
  98622. };
  98623. PerfCounter.prototype._fetchResult = function () {
  98624. this._totalAccumulated += this._current;
  98625. this._lastSecAccumulated += this._current;
  98626. // Min/Max update
  98627. this._min = Math.min(this._min, this._current);
  98628. this._max = Math.max(this._max, this._current);
  98629. this._average = this._totalAccumulated / this._totalValueCount;
  98630. // Reset last sec?
  98631. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98632. if ((now - this._lastSecTime) > 1000) {
  98633. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  98634. this._lastSecTime = now;
  98635. this._lastSecAccumulated = 0;
  98636. this._lastSecValueCount = 0;
  98637. }
  98638. };
  98639. /**
  98640. * Gets or sets a global boolean to turn on and off all the counters
  98641. */
  98642. PerfCounter.Enabled = true;
  98643. return PerfCounter;
  98644. }());
  98645. /**
  98646. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98647. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98648. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98649. * @param name The name of the class, case should be preserved
  98650. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98651. */
  98652. function className(name, module) {
  98653. return function (target) {
  98654. target["__bjsclassName__"] = name;
  98655. target["__bjsmoduleName__"] = (module != null) ? module : null;
  98656. };
  98657. }
  98658. /**
  98659. * An implementation of a loop for asynchronous functions.
  98660. */
  98661. var AsyncLoop = /** @class */ (function () {
  98662. /**
  98663. * Constructor.
  98664. * @param iterations the number of iterations.
  98665. * @param func the function to run each iteration
  98666. * @param successCallback the callback that will be called upon succesful execution
  98667. * @param offset starting offset.
  98668. */
  98669. function AsyncLoop(
  98670. /**
  98671. * Defines the number of iterations for the loop
  98672. */
  98673. iterations, func, successCallback, offset) {
  98674. if (offset === void 0) { offset = 0; }
  98675. this.iterations = iterations;
  98676. this.index = offset - 1;
  98677. this._done = false;
  98678. this._fn = func;
  98679. this._successCallback = successCallback;
  98680. }
  98681. /**
  98682. * Execute the next iteration. Must be called after the last iteration was finished.
  98683. */
  98684. AsyncLoop.prototype.executeNext = function () {
  98685. if (!this._done) {
  98686. if (this.index + 1 < this.iterations) {
  98687. ++this.index;
  98688. this._fn(this);
  98689. }
  98690. else {
  98691. this.breakLoop();
  98692. }
  98693. }
  98694. };
  98695. /**
  98696. * Break the loop and run the success callback.
  98697. */
  98698. AsyncLoop.prototype.breakLoop = function () {
  98699. this._done = true;
  98700. this._successCallback();
  98701. };
  98702. /**
  98703. * Create and run an async loop.
  98704. * @param iterations the number of iterations.
  98705. * @param fn the function to run each iteration
  98706. * @param successCallback the callback that will be called upon succesful execution
  98707. * @param offset starting offset.
  98708. * @returns the created async loop object
  98709. */
  98710. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  98711. if (offset === void 0) { offset = 0; }
  98712. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  98713. loop.executeNext();
  98714. return loop;
  98715. };
  98716. /**
  98717. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98718. * @param iterations total number of iterations
  98719. * @param syncedIterations number of synchronous iterations in each async iteration.
  98720. * @param fn the function to call each iteration.
  98721. * @param callback a success call back that will be called when iterating stops.
  98722. * @param breakFunction a break condition (optional)
  98723. * @param timeout timeout settings for the setTimeout function. default - 0.
  98724. * @returns the created async loop object
  98725. */
  98726. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  98727. if (timeout === void 0) { timeout = 0; }
  98728. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  98729. if (breakFunction && breakFunction()) {
  98730. loop.breakLoop();
  98731. }
  98732. else {
  98733. setTimeout(function () {
  98734. for (var i = 0; i < syncedIterations; ++i) {
  98735. var iteration = (loop.index * syncedIterations) + i;
  98736. if (iteration >= iterations) {
  98737. break;
  98738. }
  98739. fn(iteration);
  98740. if (breakFunction && breakFunction()) {
  98741. loop.breakLoop();
  98742. break;
  98743. }
  98744. }
  98745. loop.executeNext();
  98746. }, timeout);
  98747. }
  98748. }, callback);
  98749. };
  98750. return AsyncLoop;
  98751. }());
  98752. /***/ }),
  98753. /***/ "./Misc/typeStore.ts":
  98754. /*!***************************!*\
  98755. !*** ./Misc/typeStore.ts ***!
  98756. \***************************/
  98757. /*! exports provided: _TypeStore */
  98758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98759. "use strict";
  98760. __webpack_require__.r(__webpack_exports__);
  98761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  98762. /** @hidden */
  98763. var _TypeStore = /** @class */ (function () {
  98764. function _TypeStore() {
  98765. }
  98766. /** @hidden */
  98767. _TypeStore.GetClass = function (fqdn) {
  98768. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  98769. return this.RegisteredTypes[fqdn];
  98770. }
  98771. return null;
  98772. };
  98773. /** @hidden */
  98774. _TypeStore.RegisteredTypes = {};
  98775. return _TypeStore;
  98776. }());
  98777. /***/ }),
  98778. /***/ "./Misc/videoRecorder.ts":
  98779. /*!*******************************!*\
  98780. !*** ./Misc/videoRecorder.ts ***!
  98781. \*******************************/
  98782. /*! exports provided: VideoRecorder */
  98783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98784. "use strict";
  98785. __webpack_require__.r(__webpack_exports__);
  98786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  98787. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98788. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98789. /**
  98790. * This can helps recording videos from BabylonJS.
  98791. * This is based on the available WebRTC functionalities of the browser.
  98792. *
  98793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  98794. */
  98795. var VideoRecorder = /** @class */ (function () {
  98796. /**
  98797. * Create a new VideoCapture object which can help converting what you see in Babylon to
  98798. * a video file.
  98799. * @param engine Defines the BabylonJS Engine you wish to record
  98800. * @param options Defines options that can be used to customized the capture
  98801. */
  98802. function VideoRecorder(engine, options) {
  98803. if (options === void 0) { options = null; }
  98804. if (!VideoRecorder.IsSupported(engine)) {
  98805. throw "Your browser does not support recording so far.";
  98806. }
  98807. var canvas = engine.getRenderingCanvas();
  98808. if (!canvas) {
  98809. throw "The babylon engine must have a canvas to be recorded";
  98810. }
  98811. this._canvas = canvas;
  98812. this._canvas.isRecording = false;
  98813. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  98814. var stream = this._canvas.captureStream(this._options.fps);
  98815. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  98816. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  98817. this._mediaRecorder.onerror = this._handleError.bind(this);
  98818. this._mediaRecorder.onstop = this._handleStop.bind(this);
  98819. }
  98820. /**
  98821. * Returns wehther or not the VideoRecorder is available in your browser.
  98822. * @param engine Defines the Babylon Engine to check the support for
  98823. * @returns true if supported otherwise false
  98824. */
  98825. VideoRecorder.IsSupported = function (engine) {
  98826. var canvas = engine.getRenderingCanvas();
  98827. return (!!canvas && typeof canvas.captureStream === "function");
  98828. };
  98829. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  98830. /**
  98831. * True wether a recording is already in progress.
  98832. */
  98833. get: function () {
  98834. return !!this._canvas && this._canvas.isRecording;
  98835. },
  98836. enumerable: true,
  98837. configurable: true
  98838. });
  98839. /**
  98840. * Stops the current recording before the default capture timeout passed in the startRecording
  98841. * functions.
  98842. */
  98843. VideoRecorder.prototype.stopRecording = function () {
  98844. if (!this._canvas || !this._mediaRecorder) {
  98845. return;
  98846. }
  98847. if (!this.isRecording) {
  98848. return;
  98849. }
  98850. this._canvas.isRecording = false;
  98851. this._mediaRecorder.stop();
  98852. };
  98853. /**
  98854. * Starts recording the canvas for a max duration specified in parameters.
  98855. * @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.
  98856. * @param maxDuration Defines the maximum recording time in seconds.
  98857. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  98858. * @return a promise callback at the end of the recording with the video data in Blob.
  98859. */
  98860. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  98861. var _this = this;
  98862. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  98863. if (maxDuration === void 0) { maxDuration = 7; }
  98864. if (!this._canvas || !this._mediaRecorder) {
  98865. throw "Recorder has already been disposed";
  98866. }
  98867. if (this.isRecording) {
  98868. throw "Recording already in progress";
  98869. }
  98870. if (maxDuration > 0) {
  98871. setTimeout(function () {
  98872. _this.stopRecording();
  98873. }, maxDuration * 1000);
  98874. }
  98875. this._fileName = fileName;
  98876. this._recordedChunks = [];
  98877. this._resolve = null;
  98878. this._reject = null;
  98879. this._canvas.isRecording = true;
  98880. this._mediaRecorder.start(this._options.recordChunckSize);
  98881. return new Promise(function (resolve, reject) {
  98882. _this._resolve = resolve;
  98883. _this._reject = reject;
  98884. });
  98885. };
  98886. /**
  98887. * Releases internal resources used during the recording.
  98888. */
  98889. VideoRecorder.prototype.dispose = function () {
  98890. this._canvas = null;
  98891. this._mediaRecorder = null;
  98892. this._recordedChunks = [];
  98893. this._fileName = null;
  98894. this._resolve = null;
  98895. this._reject = null;
  98896. };
  98897. VideoRecorder.prototype._handleDataAvailable = function (event) {
  98898. if (event.data.size > 0) {
  98899. this._recordedChunks.push(event.data);
  98900. }
  98901. };
  98902. VideoRecorder.prototype._handleError = function (event) {
  98903. this.stopRecording();
  98904. if (this._reject) {
  98905. this._reject(event.error);
  98906. }
  98907. else {
  98908. throw new event.error();
  98909. }
  98910. };
  98911. VideoRecorder.prototype._handleStop = function () {
  98912. this.stopRecording();
  98913. var superBuffer = new Blob(this._recordedChunks);
  98914. if (this._resolve) {
  98915. this._resolve(superBuffer);
  98916. }
  98917. window.URL.createObjectURL(superBuffer);
  98918. if (this._fileName) {
  98919. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  98920. }
  98921. };
  98922. VideoRecorder._defaultOptions = {
  98923. mimeType: "video/webm",
  98924. fps: 25,
  98925. recordChunckSize: 3000
  98926. };
  98927. return VideoRecorder;
  98928. }());
  98929. /***/ }),
  98930. /***/ "./Misc/virtualJoystick.ts":
  98931. /*!*********************************!*\
  98932. !*** ./Misc/virtualJoystick.ts ***!
  98933. \*********************************/
  98934. /*! exports provided: JoystickAxis, VirtualJoystick */
  98935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98936. "use strict";
  98937. __webpack_require__.r(__webpack_exports__);
  98938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  98939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  98940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98941. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  98942. // Mainly based on these 2 articles :
  98943. // 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
  98944. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  98945. /**
  98946. * Defines the potential axis of a Joystick
  98947. */
  98948. var JoystickAxis;
  98949. (function (JoystickAxis) {
  98950. /** X axis */
  98951. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  98952. /** Y axis */
  98953. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  98954. /** Z axis */
  98955. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  98956. })(JoystickAxis || (JoystickAxis = {}));
  98957. /**
  98958. * Class used to define virtual joystick (used in touch mode)
  98959. */
  98960. var VirtualJoystick = /** @class */ (function () {
  98961. /**
  98962. * Creates a new virtual joystick
  98963. * @param leftJoystick defines that the joystick is for left hand (false by default)
  98964. */
  98965. function VirtualJoystick(leftJoystick) {
  98966. var _this = this;
  98967. if (leftJoystick) {
  98968. this._leftJoystick = true;
  98969. }
  98970. else {
  98971. this._leftJoystick = false;
  98972. }
  98973. VirtualJoystick._globalJoystickIndex++;
  98974. // By default left & right arrow keys are moving the X
  98975. // and up & down keys are moving the Y
  98976. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  98977. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  98978. this.reverseLeftRight = false;
  98979. this.reverseUpDown = false;
  98980. // collections of pointers
  98981. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  98982. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  98983. this._joystickSensibility = 25;
  98984. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  98985. this._onResize = function (evt) {
  98986. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  98987. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  98988. if (VirtualJoystick.Canvas) {
  98989. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  98990. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  98991. }
  98992. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  98993. };
  98994. // injecting a canvas element on top of the canvas 3D game
  98995. if (!VirtualJoystick.Canvas) {
  98996. window.addEventListener("resize", this._onResize, false);
  98997. VirtualJoystick.Canvas = document.createElement("canvas");
  98998. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  98999. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99000. VirtualJoystick.Canvas.width = window.innerWidth;
  99001. VirtualJoystick.Canvas.height = window.innerHeight;
  99002. VirtualJoystick.Canvas.style.width = "100%";
  99003. VirtualJoystick.Canvas.style.height = "100%";
  99004. VirtualJoystick.Canvas.style.position = "absolute";
  99005. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  99006. VirtualJoystick.Canvas.style.top = "0px";
  99007. VirtualJoystick.Canvas.style.left = "0px";
  99008. VirtualJoystick.Canvas.style.zIndex = "5";
  99009. VirtualJoystick.Canvas.style.msTouchAction = "none";
  99010. // Support for jQuery PEP polyfill
  99011. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  99012. var context = VirtualJoystick.Canvas.getContext('2d');
  99013. if (!context) {
  99014. throw new Error("Unable to create canvas for virtual joystick");
  99015. }
  99016. VirtualJoystick.vjCanvasContext = context;
  99017. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  99018. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99019. document.body.appendChild(VirtualJoystick.Canvas);
  99020. }
  99021. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  99022. this.pressed = false;
  99023. // default joystick color
  99024. this._joystickColor = "cyan";
  99025. this._joystickPointerID = -1;
  99026. // current joystick position
  99027. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99028. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99029. // origin joystick position
  99030. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99031. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99032. this._onPointerDownHandlerRef = function (evt) {
  99033. _this._onPointerDown(evt);
  99034. };
  99035. this._onPointerMoveHandlerRef = function (evt) {
  99036. _this._onPointerMove(evt);
  99037. };
  99038. this._onPointerUpHandlerRef = function (evt) {
  99039. _this._onPointerUp(evt);
  99040. };
  99041. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  99042. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  99043. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  99044. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  99045. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  99046. evt.preventDefault(); // Disables system menu
  99047. }, false);
  99048. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99049. }
  99050. /**
  99051. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99052. * @param newJoystickSensibility defines the new sensibility
  99053. */
  99054. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  99055. this._joystickSensibility = newJoystickSensibility;
  99056. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99057. };
  99058. VirtualJoystick.prototype._onPointerDown = function (e) {
  99059. var positionOnScreenCondition;
  99060. e.preventDefault();
  99061. if (this._leftJoystick === true) {
  99062. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  99063. }
  99064. else {
  99065. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  99066. }
  99067. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  99068. // First contact will be dedicated to the virtual joystick
  99069. this._joystickPointerID = e.pointerId;
  99070. this._joystickPointerStartPos.x = e.clientX;
  99071. this._joystickPointerStartPos.y = e.clientY;
  99072. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  99073. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  99074. this._deltaJoystickVector.x = 0;
  99075. this._deltaJoystickVector.y = 0;
  99076. this.pressed = true;
  99077. this._touches.add(e.pointerId.toString(), e);
  99078. }
  99079. else {
  99080. // You can only trigger the action buttons with a joystick declared
  99081. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  99082. this._action();
  99083. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  99084. }
  99085. }
  99086. };
  99087. VirtualJoystick.prototype._onPointerMove = function (e) {
  99088. // If the current pointer is the one associated to the joystick (first touch contact)
  99089. if (this._joystickPointerID == e.pointerId) {
  99090. this._joystickPointerPos.x = e.clientX;
  99091. this._joystickPointerPos.y = e.clientY;
  99092. this._deltaJoystickVector = this._joystickPointerPos.clone();
  99093. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  99094. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  99095. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  99096. switch (this._axisTargetedByLeftAndRight) {
  99097. case JoystickAxis.X:
  99098. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  99099. break;
  99100. case JoystickAxis.Y:
  99101. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  99102. break;
  99103. case JoystickAxis.Z:
  99104. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  99105. break;
  99106. }
  99107. var directionUpDown = this.reverseUpDown ? 1 : -1;
  99108. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  99109. switch (this._axisTargetedByUpAndDown) {
  99110. case JoystickAxis.X:
  99111. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  99112. break;
  99113. case JoystickAxis.Y:
  99114. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  99115. break;
  99116. case JoystickAxis.Z:
  99117. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  99118. break;
  99119. }
  99120. }
  99121. else {
  99122. var data = this._touches.get(e.pointerId.toString());
  99123. if (data) {
  99124. data.x = e.clientX;
  99125. data.y = e.clientY;
  99126. }
  99127. }
  99128. };
  99129. VirtualJoystick.prototype._onPointerUp = function (e) {
  99130. if (this._joystickPointerID == e.pointerId) {
  99131. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  99132. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  99133. this._joystickPointerID = -1;
  99134. this.pressed = false;
  99135. }
  99136. else {
  99137. var touch = this._touches.get(e.pointerId.toString());
  99138. if (touch) {
  99139. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99140. }
  99141. }
  99142. this._deltaJoystickVector.x = 0;
  99143. this._deltaJoystickVector.y = 0;
  99144. this._touches.remove(e.pointerId.toString());
  99145. };
  99146. /**
  99147. * Change the color of the virtual joystick
  99148. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99149. */
  99150. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  99151. this._joystickColor = newColor;
  99152. };
  99153. /**
  99154. * Defines a callback to call when the joystick is touched
  99155. * @param action defines the callback
  99156. */
  99157. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  99158. this._action = action;
  99159. };
  99160. /**
  99161. * Defines which axis you'd like to control for left & right
  99162. * @param axis defines the axis to use
  99163. */
  99164. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  99165. switch (axis) {
  99166. case JoystickAxis.X:
  99167. case JoystickAxis.Y:
  99168. case JoystickAxis.Z:
  99169. this._axisTargetedByLeftAndRight = axis;
  99170. break;
  99171. default:
  99172. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99173. break;
  99174. }
  99175. };
  99176. /**
  99177. * Defines which axis you'd like to control for up & down
  99178. * @param axis defines the axis to use
  99179. */
  99180. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  99181. switch (axis) {
  99182. case JoystickAxis.X:
  99183. case JoystickAxis.Y:
  99184. case JoystickAxis.Z:
  99185. this._axisTargetedByUpAndDown = axis;
  99186. break;
  99187. default:
  99188. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99189. break;
  99190. }
  99191. };
  99192. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  99193. var _this = this;
  99194. if (this.pressed) {
  99195. this._touches.forEach(function (key, touch) {
  99196. if (touch.pointerId === _this._joystickPointerID) {
  99197. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  99198. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  99199. VirtualJoystick.vjCanvasContext.beginPath();
  99200. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99201. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99202. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  99203. VirtualJoystick.vjCanvasContext.stroke();
  99204. VirtualJoystick.vjCanvasContext.closePath();
  99205. VirtualJoystick.vjCanvasContext.beginPath();
  99206. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99207. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99208. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  99209. VirtualJoystick.vjCanvasContext.stroke();
  99210. VirtualJoystick.vjCanvasContext.closePath();
  99211. VirtualJoystick.vjCanvasContext.beginPath();
  99212. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99213. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  99214. VirtualJoystick.vjCanvasContext.stroke();
  99215. VirtualJoystick.vjCanvasContext.closePath();
  99216. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  99217. }
  99218. else {
  99219. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99220. VirtualJoystick.vjCanvasContext.beginPath();
  99221. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  99222. VirtualJoystick.vjCanvasContext.beginPath();
  99223. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  99224. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99225. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  99226. VirtualJoystick.vjCanvasContext.stroke();
  99227. VirtualJoystick.vjCanvasContext.closePath();
  99228. touch.prevX = touch.x;
  99229. touch.prevY = touch.y;
  99230. }
  99231. });
  99232. }
  99233. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99234. };
  99235. /**
  99236. * Release internal HTML canvas
  99237. */
  99238. VirtualJoystick.prototype.releaseCanvas = function () {
  99239. if (VirtualJoystick.Canvas) {
  99240. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  99241. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  99242. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  99243. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  99244. window.removeEventListener("resize", this._onResize);
  99245. document.body.removeChild(VirtualJoystick.Canvas);
  99246. VirtualJoystick.Canvas = null;
  99247. }
  99248. };
  99249. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  99250. VirtualJoystick._globalJoystickIndex = 0;
  99251. return VirtualJoystick;
  99252. }());
  99253. /***/ }),
  99254. /***/ "./Misc/workerPool.ts":
  99255. /*!****************************!*\
  99256. !*** ./Misc/workerPool.ts ***!
  99257. \****************************/
  99258. /*! exports provided: WorkerPool */
  99259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99260. "use strict";
  99261. __webpack_require__.r(__webpack_exports__);
  99262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  99263. /**
  99264. * Helper class to push actions to a pool of workers.
  99265. */
  99266. var WorkerPool = /** @class */ (function () {
  99267. /**
  99268. * Constructor
  99269. * @param workers Array of workers to use for actions
  99270. */
  99271. function WorkerPool(workers) {
  99272. this._pendingActions = new Array();
  99273. this._workerInfos = workers.map(function (worker) { return ({
  99274. worker: worker,
  99275. active: false
  99276. }); });
  99277. }
  99278. /**
  99279. * Terminates all workers and clears any pending actions.
  99280. */
  99281. WorkerPool.prototype.dispose = function () {
  99282. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99283. var workerInfo = _a[_i];
  99284. workerInfo.worker.terminate();
  99285. }
  99286. delete this._workerInfos;
  99287. delete this._pendingActions;
  99288. };
  99289. /**
  99290. * Pushes an action to the worker pool. If all the workers are active, the action will be
  99291. * pended until a worker has completed its action.
  99292. * @param action The action to perform. Call onComplete when the action is complete.
  99293. */
  99294. WorkerPool.prototype.push = function (action) {
  99295. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99296. var workerInfo = _a[_i];
  99297. if (!workerInfo.active) {
  99298. this._execute(workerInfo, action);
  99299. return;
  99300. }
  99301. }
  99302. this._pendingActions.push(action);
  99303. };
  99304. WorkerPool.prototype._execute = function (workerInfo, action) {
  99305. var _this = this;
  99306. workerInfo.active = true;
  99307. action(workerInfo.worker, function () {
  99308. workerInfo.active = false;
  99309. var nextAction = _this._pendingActions.shift();
  99310. if (nextAction) {
  99311. _this._execute(workerInfo, nextAction);
  99312. }
  99313. });
  99314. };
  99315. return WorkerPool;
  99316. }());
  99317. /***/ }),
  99318. /***/ "./Morph/index.ts":
  99319. /*!************************!*\
  99320. !*** ./Morph/index.ts ***!
  99321. \************************/
  99322. /*! exports provided: MorphTarget, MorphTargetManager */
  99323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99324. "use strict";
  99325. __webpack_require__.r(__webpack_exports__);
  99326. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  99328. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  99329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  99330. /***/ }),
  99331. /***/ "./Morph/morphTarget.ts":
  99332. /*!******************************!*\
  99333. !*** ./Morph/morphTarget.ts ***!
  99334. \******************************/
  99335. /*! exports provided: MorphTarget */
  99336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99337. "use strict";
  99338. __webpack_require__.r(__webpack_exports__);
  99339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  99340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99341. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  99342. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99343. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  99344. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  99345. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  99346. /**
  99347. * Defines a target to use with MorphTargetManager
  99348. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99349. */
  99350. var MorphTarget = /** @class */ (function () {
  99351. /**
  99352. * Creates a new MorphTarget
  99353. * @param name defines the name of the target
  99354. * @param influence defines the influence to use
  99355. */
  99356. function MorphTarget(
  99357. /** defines the name of the target */
  99358. name, influence, scene) {
  99359. if (influence === void 0) { influence = 0; }
  99360. if (scene === void 0) { scene = null; }
  99361. this.name = name;
  99362. /**
  99363. * Gets or sets the list of animations
  99364. */
  99365. this.animations = new Array();
  99366. this._positions = null;
  99367. this._normals = null;
  99368. this._tangents = null;
  99369. /**
  99370. * Observable raised when the influence changes
  99371. */
  99372. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99373. /** @hidden */
  99374. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99375. this._animationPropertiesOverride = null;
  99376. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99377. this.influence = influence;
  99378. }
  99379. Object.defineProperty(MorphTarget.prototype, "influence", {
  99380. /**
  99381. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99382. */
  99383. get: function () {
  99384. return this._influence;
  99385. },
  99386. set: function (influence) {
  99387. if (this._influence === influence) {
  99388. return;
  99389. }
  99390. var previous = this._influence;
  99391. this._influence = influence;
  99392. if (this.onInfluenceChanged.hasObservers) {
  99393. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  99394. }
  99395. },
  99396. enumerable: true,
  99397. configurable: true
  99398. });
  99399. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  99400. /**
  99401. * Gets or sets the animation properties override
  99402. */
  99403. get: function () {
  99404. if (!this._animationPropertiesOverride && this._scene) {
  99405. return this._scene.animationPropertiesOverride;
  99406. }
  99407. return this._animationPropertiesOverride;
  99408. },
  99409. set: function (value) {
  99410. this._animationPropertiesOverride = value;
  99411. },
  99412. enumerable: true,
  99413. configurable: true
  99414. });
  99415. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  99416. /**
  99417. * Gets a boolean defining if the target contains position data
  99418. */
  99419. get: function () {
  99420. return !!this._positions;
  99421. },
  99422. enumerable: true,
  99423. configurable: true
  99424. });
  99425. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  99426. /**
  99427. * Gets a boolean defining if the target contains normal data
  99428. */
  99429. get: function () {
  99430. return !!this._normals;
  99431. },
  99432. enumerable: true,
  99433. configurable: true
  99434. });
  99435. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  99436. /**
  99437. * Gets a boolean defining if the target contains tangent data
  99438. */
  99439. get: function () {
  99440. return !!this._tangents;
  99441. },
  99442. enumerable: true,
  99443. configurable: true
  99444. });
  99445. /**
  99446. * Affects position data to this target
  99447. * @param data defines the position data to use
  99448. */
  99449. MorphTarget.prototype.setPositions = function (data) {
  99450. var hadPositions = this.hasPositions;
  99451. this._positions = data;
  99452. if (hadPositions !== this.hasPositions) {
  99453. this._onDataLayoutChanged.notifyObservers(undefined);
  99454. }
  99455. };
  99456. /**
  99457. * Gets the position data stored in this target
  99458. * @returns a FloatArray containing the position data (or null if not present)
  99459. */
  99460. MorphTarget.prototype.getPositions = function () {
  99461. return this._positions;
  99462. };
  99463. /**
  99464. * Affects normal data to this target
  99465. * @param data defines the normal data to use
  99466. */
  99467. MorphTarget.prototype.setNormals = function (data) {
  99468. var hadNormals = this.hasNormals;
  99469. this._normals = data;
  99470. if (hadNormals !== this.hasNormals) {
  99471. this._onDataLayoutChanged.notifyObservers(undefined);
  99472. }
  99473. };
  99474. /**
  99475. * Gets the normal data stored in this target
  99476. * @returns a FloatArray containing the normal data (or null if not present)
  99477. */
  99478. MorphTarget.prototype.getNormals = function () {
  99479. return this._normals;
  99480. };
  99481. /**
  99482. * Affects tangent data to this target
  99483. * @param data defines the tangent data to use
  99484. */
  99485. MorphTarget.prototype.setTangents = function (data) {
  99486. var hadTangents = this.hasTangents;
  99487. this._tangents = data;
  99488. if (hadTangents !== this.hasTangents) {
  99489. this._onDataLayoutChanged.notifyObservers(undefined);
  99490. }
  99491. };
  99492. /**
  99493. * Gets the tangent data stored in this target
  99494. * @returns a FloatArray containing the tangent data (or null if not present)
  99495. */
  99496. MorphTarget.prototype.getTangents = function () {
  99497. return this._tangents;
  99498. };
  99499. /**
  99500. * Serializes the current target into a Serialization object
  99501. * @returns the serialized object
  99502. */
  99503. MorphTarget.prototype.serialize = function () {
  99504. var serializationObject = {};
  99505. serializationObject.name = this.name;
  99506. serializationObject.influence = this.influence;
  99507. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  99508. if (this.id != null) {
  99509. serializationObject.id = this.id;
  99510. }
  99511. if (this.hasNormals) {
  99512. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  99513. }
  99514. if (this.hasTangents) {
  99515. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  99516. }
  99517. // Animations
  99518. _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  99519. return serializationObject;
  99520. };
  99521. /**
  99522. * Returns the string "MorphTarget"
  99523. * @returns "MorphTarget"
  99524. */
  99525. MorphTarget.prototype.getClassName = function () {
  99526. return "MorphTarget";
  99527. };
  99528. // Statics
  99529. /**
  99530. * Creates a new target from serialized data
  99531. * @param serializationObject defines the serialized data to use
  99532. * @returns a new MorphTarget
  99533. */
  99534. MorphTarget.Parse = function (serializationObject) {
  99535. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  99536. result.setPositions(serializationObject.positions);
  99537. if (serializationObject.id != null) {
  99538. result.id = serializationObject.id;
  99539. }
  99540. if (serializationObject.normals) {
  99541. result.setNormals(serializationObject.normals);
  99542. }
  99543. if (serializationObject.tangents) {
  99544. result.setTangents(serializationObject.tangents);
  99545. }
  99546. // Animations
  99547. if (serializationObject.animations) {
  99548. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  99549. var parsedAnimation = serializationObject.animations[animationIndex];
  99550. result.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedAnimation));
  99551. }
  99552. }
  99553. return result;
  99554. };
  99555. /**
  99556. * Creates a MorphTarget from mesh data
  99557. * @param mesh defines the source mesh
  99558. * @param name defines the name to use for the new target
  99559. * @param influence defines the influence to attach to the target
  99560. * @returns a new MorphTarget
  99561. */
  99562. MorphTarget.FromMesh = function (mesh, name, influence) {
  99563. if (!name) {
  99564. name = mesh.name;
  99565. }
  99566. var result = new MorphTarget(name, influence, mesh.getScene());
  99567. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  99568. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  99569. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  99570. }
  99571. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  99572. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  99573. }
  99574. return result;
  99575. };
  99576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  99577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["serialize"])()
  99578. ], MorphTarget.prototype, "id", void 0);
  99579. return MorphTarget;
  99580. }());
  99581. /***/ }),
  99582. /***/ "./Morph/morphTargetManager.ts":
  99583. /*!*************************************!*\
  99584. !*** ./Morph/morphTargetManager.ts ***!
  99585. \*************************************/
  99586. /*! exports provided: MorphTargetManager */
  99587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99588. "use strict";
  99589. __webpack_require__.r(__webpack_exports__);
  99590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  99591. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  99592. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99593. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99594. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99595. /**
  99596. * This class is used to deform meshes using morphing between different targets
  99597. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99598. */
  99599. var MorphTargetManager = /** @class */ (function () {
  99600. /**
  99601. * Creates a new MorphTargetManager
  99602. * @param scene defines the current scene
  99603. */
  99604. function MorphTargetManager(scene) {
  99605. if (scene === void 0) { scene = null; }
  99606. this._targets = new Array();
  99607. this._targetInfluenceChangedObservers = new Array();
  99608. this._targetDataLayoutChangedObservers = new Array();
  99609. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  99610. this._supportsNormals = false;
  99611. this._supportsTangents = false;
  99612. this._vertexCount = 0;
  99613. this._uniqueId = 0;
  99614. this._tempInfluences = new Array();
  99615. if (!scene) {
  99616. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99617. }
  99618. this._scene = scene;
  99619. if (this._scene) {
  99620. this._scene.morphTargetManagers.push(this);
  99621. this._uniqueId = this._scene.getUniqueId();
  99622. }
  99623. }
  99624. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  99625. /**
  99626. * Gets the unique ID of this manager
  99627. */
  99628. get: function () {
  99629. return this._uniqueId;
  99630. },
  99631. enumerable: true,
  99632. configurable: true
  99633. });
  99634. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  99635. /**
  99636. * Gets the number of vertices handled by this manager
  99637. */
  99638. get: function () {
  99639. return this._vertexCount;
  99640. },
  99641. enumerable: true,
  99642. configurable: true
  99643. });
  99644. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  99645. /**
  99646. * Gets a boolean indicating if this manager supports morphing of normals
  99647. */
  99648. get: function () {
  99649. return this._supportsNormals;
  99650. },
  99651. enumerable: true,
  99652. configurable: true
  99653. });
  99654. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  99655. /**
  99656. * Gets a boolean indicating if this manager supports morphing of tangents
  99657. */
  99658. get: function () {
  99659. return this._supportsTangents;
  99660. },
  99661. enumerable: true,
  99662. configurable: true
  99663. });
  99664. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  99665. /**
  99666. * Gets the number of targets stored in this manager
  99667. */
  99668. get: function () {
  99669. return this._targets.length;
  99670. },
  99671. enumerable: true,
  99672. configurable: true
  99673. });
  99674. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  99675. /**
  99676. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99677. */
  99678. get: function () {
  99679. return this._activeTargets.length;
  99680. },
  99681. enumerable: true,
  99682. configurable: true
  99683. });
  99684. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  99685. /**
  99686. * Gets the list of influences (one per target)
  99687. */
  99688. get: function () {
  99689. return this._influences;
  99690. },
  99691. enumerable: true,
  99692. configurable: true
  99693. });
  99694. /**
  99695. * Gets the active target at specified index. An active target is a target with an influence > 0
  99696. * @param index defines the index to check
  99697. * @returns the requested target
  99698. */
  99699. MorphTargetManager.prototype.getActiveTarget = function (index) {
  99700. return this._activeTargets.data[index];
  99701. };
  99702. /**
  99703. * Gets the target at specified index
  99704. * @param index defines the index to check
  99705. * @returns the requested target
  99706. */
  99707. MorphTargetManager.prototype.getTarget = function (index) {
  99708. return this._targets[index];
  99709. };
  99710. /**
  99711. * Add a new target to this manager
  99712. * @param target defines the target to add
  99713. */
  99714. MorphTargetManager.prototype.addTarget = function (target) {
  99715. var _this = this;
  99716. this._targets.push(target);
  99717. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  99718. _this._syncActiveTargets(needUpdate);
  99719. }));
  99720. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  99721. _this._syncActiveTargets(true);
  99722. }));
  99723. this._syncActiveTargets(true);
  99724. };
  99725. /**
  99726. * Removes a target from the manager
  99727. * @param target defines the target to remove
  99728. */
  99729. MorphTargetManager.prototype.removeTarget = function (target) {
  99730. var index = this._targets.indexOf(target);
  99731. if (index >= 0) {
  99732. this._targets.splice(index, 1);
  99733. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  99734. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  99735. this._syncActiveTargets(true);
  99736. }
  99737. };
  99738. /**
  99739. * Serializes the current manager into a Serialization object
  99740. * @returns the serialized object
  99741. */
  99742. MorphTargetManager.prototype.serialize = function () {
  99743. var serializationObject = {};
  99744. serializationObject.id = this.uniqueId;
  99745. serializationObject.targets = [];
  99746. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  99747. var target = _a[_i];
  99748. serializationObject.targets.push(target.serialize());
  99749. }
  99750. return serializationObject;
  99751. };
  99752. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  99753. var influenceCount = 0;
  99754. this._activeTargets.reset();
  99755. this._supportsNormals = true;
  99756. this._supportsTangents = true;
  99757. this._vertexCount = 0;
  99758. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  99759. var target = _a[_i];
  99760. if (target.influence === 0) {
  99761. continue;
  99762. }
  99763. this._activeTargets.push(target);
  99764. this._tempInfluences[influenceCount++] = target.influence;
  99765. this._supportsNormals = this._supportsNormals && target.hasNormals;
  99766. this._supportsTangents = this._supportsTangents && target.hasTangents;
  99767. var positions = target.getPositions();
  99768. if (positions) {
  99769. var vertexCount = positions.length / 3;
  99770. if (this._vertexCount === 0) {
  99771. this._vertexCount = vertexCount;
  99772. }
  99773. else if (this._vertexCount !== vertexCount) {
  99774. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  99775. return;
  99776. }
  99777. }
  99778. }
  99779. if (!this._influences || this._influences.length !== influenceCount) {
  99780. this._influences = new Float32Array(influenceCount);
  99781. }
  99782. for (var index = 0; index < influenceCount; index++) {
  99783. this._influences[index] = this._tempInfluences[index];
  99784. }
  99785. if (needUpdate) {
  99786. this.synchronize();
  99787. }
  99788. };
  99789. /**
  99790. * Syncrhonize the targets with all the meshes using this morph target manager
  99791. */
  99792. MorphTargetManager.prototype.synchronize = function () {
  99793. if (!this._scene) {
  99794. return;
  99795. }
  99796. // Flag meshes as dirty to resync with the active targets
  99797. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  99798. var mesh = _a[_i];
  99799. if (mesh.morphTargetManager === this) {
  99800. mesh._syncGeometryWithMorphTargetManager();
  99801. }
  99802. }
  99803. };
  99804. // Statics
  99805. /**
  99806. * Creates a new MorphTargetManager from serialized data
  99807. * @param serializationObject defines the serialized data
  99808. * @param scene defines the hosting scene
  99809. * @returns the new MorphTargetManager
  99810. */
  99811. MorphTargetManager.Parse = function (serializationObject, scene) {
  99812. var result = new MorphTargetManager(scene);
  99813. result._uniqueId = serializationObject.id;
  99814. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  99815. var targetData = _a[_i];
  99816. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  99817. }
  99818. return result;
  99819. };
  99820. return MorphTargetManager;
  99821. }());
  99822. /***/ }),
  99823. /***/ "./Offline/database.ts":
  99824. /*!*****************************!*\
  99825. !*** ./Offline/database.ts ***!
  99826. \*****************************/
  99827. /*! exports provided: Database */
  99828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99829. "use strict";
  99830. __webpack_require__.r(__webpack_exports__);
  99831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  99832. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  99833. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99834. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  99835. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  99836. // Sets the default offline provider to Babylon.js
  99837. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  99838. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  99839. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  99840. };
  99841. /**
  99842. * Class used to enable access to IndexedDB
  99843. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99844. */
  99845. var Database = /** @class */ (function () {
  99846. /**
  99847. * Creates a new Database
  99848. * @param urlToScene defines the url to load the scene
  99849. * @param callbackManifestChecked defines the callback to use when manifest is checked
  99850. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  99851. */
  99852. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  99853. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  99854. var _this = this;
  99855. // Handling various flavors of prefixed version of IndexedDB
  99856. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  99857. this._callbackManifestChecked = callbackManifestChecked;
  99858. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  99859. this._db = null;
  99860. this._enableSceneOffline = false;
  99861. this._enableTexturesOffline = false;
  99862. this._manifestVersionFound = 0;
  99863. this._mustUpdateRessources = false;
  99864. this._hasReachedQuota = false;
  99865. if (!Database.IDBStorageEnabled) {
  99866. this._callbackManifestChecked(true);
  99867. }
  99868. else {
  99869. if (disableManifestCheck) {
  99870. this._enableSceneOffline = true;
  99871. this._enableTexturesOffline = true;
  99872. this._manifestVersionFound = 1;
  99873. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  99874. _this._callbackManifestChecked(true);
  99875. });
  99876. }
  99877. else {
  99878. this._checkManifestFile();
  99879. }
  99880. }
  99881. }
  99882. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  99883. /**
  99884. * Gets a boolean indicating if scene must be saved in the database
  99885. */
  99886. get: function () {
  99887. return this._enableSceneOffline;
  99888. },
  99889. enumerable: true,
  99890. configurable: true
  99891. });
  99892. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  99893. /**
  99894. * Gets a boolean indicating if textures must be saved in the database
  99895. */
  99896. get: function () {
  99897. return this._enableTexturesOffline;
  99898. },
  99899. enumerable: true,
  99900. configurable: true
  99901. });
  99902. Database.prototype._checkManifestFile = function () {
  99903. var _this = this;
  99904. var noManifestFile = function () {
  99905. _this._enableSceneOffline = false;
  99906. _this._enableTexturesOffline = false;
  99907. _this._callbackManifestChecked(false);
  99908. };
  99909. var timeStampUsed = false;
  99910. var manifestURL = this._currentSceneUrl + ".manifest";
  99911. var xhr = new XMLHttpRequest();
  99912. if (navigator.onLine) {
  99913. // Adding a timestamp to by-pass browsers' cache
  99914. timeStampUsed = true;
  99915. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  99916. }
  99917. xhr.open("GET", manifestURL, true);
  99918. xhr.addEventListener("load", function () {
  99919. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  99920. try {
  99921. var manifestFile = JSON.parse(xhr.response);
  99922. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  99923. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  99924. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  99925. _this._manifestVersionFound = manifestFile.version;
  99926. }
  99927. if (_this._callbackManifestChecked) {
  99928. _this._callbackManifestChecked(true);
  99929. }
  99930. }
  99931. catch (ex) {
  99932. noManifestFile();
  99933. }
  99934. }
  99935. else {
  99936. noManifestFile();
  99937. }
  99938. }, false);
  99939. xhr.addEventListener("error", function () {
  99940. if (timeStampUsed) {
  99941. timeStampUsed = false;
  99942. // Let's retry without the timeStamp
  99943. // It could fail when coupled with HTML5 Offline API
  99944. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  99945. xhr.open("GET", retryManifestURL, true);
  99946. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  99947. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  99948. }
  99949. xhr.send();
  99950. }
  99951. else {
  99952. noManifestFile();
  99953. }
  99954. }, false);
  99955. try {
  99956. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  99957. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  99958. }
  99959. xhr.send();
  99960. }
  99961. catch (ex) {
  99962. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  99963. this._callbackManifestChecked(false);
  99964. }
  99965. };
  99966. /**
  99967. * Open the database and make it available
  99968. * @param successCallback defines the callback to call on success
  99969. * @param errorCallback defines the callback to call on error
  99970. */
  99971. Database.prototype.open = function (successCallback, errorCallback) {
  99972. var _this = this;
  99973. var handleError = function () {
  99974. _this._isSupported = false;
  99975. if (errorCallback) {
  99976. errorCallback();
  99977. }
  99978. };
  99979. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  99980. // Your browser doesn't support IndexedDB
  99981. this._isSupported = false;
  99982. if (errorCallback) {
  99983. errorCallback();
  99984. }
  99985. }
  99986. else {
  99987. // If the DB hasn't been opened or created yet
  99988. if (!this._db) {
  99989. this._hasReachedQuota = false;
  99990. this._isSupported = true;
  99991. var request = this._idbFactory.open("babylonjs", 1);
  99992. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  99993. request.onerror = function () {
  99994. handleError();
  99995. };
  99996. // executes when a version change transaction cannot complete due to other active transactions
  99997. request.onblocked = function () {
  99998. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  99999. handleError();
  100000. };
  100001. // DB has been opened successfully
  100002. request.onsuccess = function () {
  100003. _this._db = request.result;
  100004. successCallback();
  100005. };
  100006. // Initialization of the DB. Creating Scenes & Textures stores
  100007. request.onupgradeneeded = function (event) {
  100008. _this._db = (event.target).result;
  100009. if (_this._db) {
  100010. try {
  100011. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  100012. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  100013. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  100014. }
  100015. catch (ex) {
  100016. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  100017. handleError();
  100018. }
  100019. }
  100020. };
  100021. }
  100022. // DB has already been created and opened
  100023. else {
  100024. if (successCallback) {
  100025. successCallback();
  100026. }
  100027. }
  100028. }
  100029. };
  100030. /**
  100031. * Loads an image from the database
  100032. * @param url defines the url to load from
  100033. * @param image defines the target DOM image
  100034. */
  100035. Database.prototype.loadImage = function (url, image) {
  100036. var _this = this;
  100037. var completeURL = Database._ReturnFullUrlLocation(url);
  100038. var saveAndLoadImage = function () {
  100039. if (!_this._hasReachedQuota && _this._db !== null) {
  100040. // the texture is not yet in the DB, let's try to save it
  100041. _this._saveImageIntoDBAsync(completeURL, image);
  100042. }
  100043. // If the texture is not in the DB and we've reached the DB quota limit
  100044. // let's load it directly from the web
  100045. else {
  100046. image.src = url;
  100047. }
  100048. };
  100049. if (!this._mustUpdateRessources) {
  100050. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  100051. }
  100052. // First time we're download the images or update requested in the manifest file by a version change
  100053. else {
  100054. saveAndLoadImage();
  100055. }
  100056. };
  100057. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  100058. if (this._isSupported && this._db !== null) {
  100059. var texture;
  100060. var transaction = this._db.transaction(["textures"]);
  100061. transaction.onabort = function () {
  100062. image.src = url;
  100063. };
  100064. transaction.oncomplete = function () {
  100065. var blobTextureURL;
  100066. if (texture) {
  100067. var URL = window.URL || window.webkitURL;
  100068. blobTextureURL = URL.createObjectURL(texture.data);
  100069. image.onerror = function () {
  100070. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  100071. image.src = url;
  100072. };
  100073. image.src = blobTextureURL;
  100074. }
  100075. else {
  100076. notInDBCallback();
  100077. }
  100078. };
  100079. var getRequest = transaction.objectStore("textures").get(url);
  100080. getRequest.onsuccess = function (event) {
  100081. texture = (event.target).result;
  100082. };
  100083. getRequest.onerror = function () {
  100084. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  100085. image.src = url;
  100086. };
  100087. }
  100088. else {
  100089. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100090. image.src = url;
  100091. }
  100092. };
  100093. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  100094. var _this = this;
  100095. if (this._isSupported) {
  100096. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  100097. var generateBlobUrl = function () {
  100098. var blobTextureURL;
  100099. if (blob) {
  100100. var URL = window.URL || window.webkitURL;
  100101. try {
  100102. blobTextureURL = URL.createObjectURL(blob);
  100103. }
  100104. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  100105. catch (ex) {
  100106. blobTextureURL = URL.createObjectURL(blob);
  100107. }
  100108. }
  100109. if (blobTextureURL) {
  100110. image.src = blobTextureURL;
  100111. }
  100112. };
  100113. if (Database.IsUASupportingBlobStorage) { // Create XHR
  100114. var xhr = new XMLHttpRequest(), blob;
  100115. xhr.open("GET", url, true);
  100116. xhr.responseType = "blob";
  100117. xhr.addEventListener("load", function () {
  100118. if (xhr.status === 200 && _this._db) {
  100119. // Blob as response (XHR2)
  100120. blob = xhr.response;
  100121. var transaction = _this._db.transaction(["textures"], "readwrite");
  100122. // the transaction could abort because of a QuotaExceededError error
  100123. transaction.onabort = function (event) {
  100124. try {
  100125. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100126. var srcElement = (event.srcElement || event.target);
  100127. var error = srcElement.error;
  100128. if (error && error.name === "QuotaExceededError") {
  100129. _this._hasReachedQuota = true;
  100130. }
  100131. }
  100132. catch (ex) { }
  100133. generateBlobUrl();
  100134. };
  100135. transaction.oncomplete = function () {
  100136. generateBlobUrl();
  100137. };
  100138. var newTexture = { textureUrl: url, data: blob };
  100139. try {
  100140. // Put the blob into the dabase
  100141. var addRequest = transaction.objectStore("textures").put(newTexture);
  100142. addRequest.onsuccess = function () {
  100143. };
  100144. addRequest.onerror = function () {
  100145. generateBlobUrl();
  100146. };
  100147. }
  100148. catch (ex) {
  100149. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  100150. if (ex.code === 25) {
  100151. Database.IsUASupportingBlobStorage = false;
  100152. _this._enableTexturesOffline = false;
  100153. }
  100154. image.src = url;
  100155. }
  100156. }
  100157. else {
  100158. image.src = url;
  100159. }
  100160. }, false);
  100161. xhr.addEventListener("error", function () {
  100162. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  100163. image.src = url;
  100164. }, false);
  100165. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  100166. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100167. }
  100168. xhr.send();
  100169. }
  100170. else {
  100171. image.src = url;
  100172. }
  100173. }
  100174. else {
  100175. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100176. image.src = url;
  100177. }
  100178. };
  100179. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  100180. var _this = this;
  100181. var updateVersion = function () {
  100182. // the version is not yet in the DB or we need to update it
  100183. _this._saveVersionIntoDBAsync(url, versionLoaded);
  100184. };
  100185. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  100186. };
  100187. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  100188. var _this = this;
  100189. if (this._isSupported && this._db) {
  100190. var version;
  100191. try {
  100192. var transaction = this._db.transaction(["versions"]);
  100193. transaction.oncomplete = function () {
  100194. if (version) {
  100195. // If the version in the JSON file is different from the version in DB
  100196. if (_this._manifestVersionFound !== version.data) {
  100197. _this._mustUpdateRessources = true;
  100198. updateInDBCallback();
  100199. }
  100200. else {
  100201. callback(version.data);
  100202. }
  100203. }
  100204. // version was not found in DB
  100205. else {
  100206. _this._mustUpdateRessources = true;
  100207. updateInDBCallback();
  100208. }
  100209. };
  100210. transaction.onabort = function () {
  100211. callback(-1);
  100212. };
  100213. var getRequest = transaction.objectStore("versions").get(url);
  100214. getRequest.onsuccess = function (event) {
  100215. version = (event.target).result;
  100216. };
  100217. getRequest.onerror = function () {
  100218. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  100219. callback(-1);
  100220. };
  100221. }
  100222. catch (ex) {
  100223. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  100224. callback(-1);
  100225. }
  100226. }
  100227. else {
  100228. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100229. callback(-1);
  100230. }
  100231. };
  100232. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  100233. var _this = this;
  100234. if (this._isSupported && !this._hasReachedQuota && this._db) {
  100235. try {
  100236. // Open a transaction to the database
  100237. var transaction = this._db.transaction(["versions"], "readwrite");
  100238. // the transaction could abort because of a QuotaExceededError error
  100239. transaction.onabort = function (event) {
  100240. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100241. var error = event.srcElement['error'];
  100242. if (error && error.name === "QuotaExceededError") {
  100243. _this._hasReachedQuota = true;
  100244. }
  100245. }
  100246. catch (ex) { }
  100247. callback(-1);
  100248. };
  100249. transaction.oncomplete = function () {
  100250. callback(_this._manifestVersionFound);
  100251. };
  100252. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  100253. // Put the scene into the database
  100254. var addRequest = transaction.objectStore("versions").put(newVersion);
  100255. addRequest.onsuccess = function () {
  100256. };
  100257. addRequest.onerror = function () {
  100258. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  100259. };
  100260. }
  100261. catch (ex) {
  100262. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  100263. callback(-1);
  100264. }
  100265. }
  100266. else {
  100267. callback(-1);
  100268. }
  100269. };
  100270. /**
  100271. * Loads a file from database
  100272. * @param url defines the URL to load from
  100273. * @param sceneLoaded defines a callback to call on success
  100274. * @param progressCallBack defines a callback to call when progress changed
  100275. * @param errorCallback defines a callback to call on error
  100276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  100277. */
  100278. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  100279. var _this = this;
  100280. var completeUrl = Database._ReturnFullUrlLocation(url);
  100281. var saveAndLoadFile = function () {
  100282. // the scene is not yet in the DB, let's try to save it
  100283. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100284. };
  100285. this._checkVersionFromDB(completeUrl, function (version) {
  100286. if (version !== -1) {
  100287. if (!_this._mustUpdateRessources) {
  100288. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  100289. }
  100290. else {
  100291. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100292. }
  100293. }
  100294. else {
  100295. if (errorCallback) {
  100296. errorCallback();
  100297. }
  100298. }
  100299. });
  100300. };
  100301. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  100302. if (this._isSupported && this._db) {
  100303. var targetStore;
  100304. if (url.indexOf(".babylon") !== -1) {
  100305. targetStore = "scenes";
  100306. }
  100307. else {
  100308. targetStore = "textures";
  100309. }
  100310. var file;
  100311. var transaction = this._db.transaction([targetStore]);
  100312. transaction.oncomplete = function () {
  100313. if (file) {
  100314. callback(file.data);
  100315. }
  100316. // file was not found in DB
  100317. else {
  100318. notInDBCallback();
  100319. }
  100320. };
  100321. transaction.onabort = function () {
  100322. notInDBCallback();
  100323. };
  100324. var getRequest = transaction.objectStore(targetStore).get(url);
  100325. getRequest.onsuccess = function (event) {
  100326. file = (event.target).result;
  100327. };
  100328. getRequest.onerror = function () {
  100329. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  100330. notInDBCallback();
  100331. };
  100332. }
  100333. else {
  100334. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100335. callback();
  100336. }
  100337. };
  100338. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  100339. var _this = this;
  100340. if (this._isSupported) {
  100341. var targetStore;
  100342. if (url.indexOf(".babylon") !== -1) {
  100343. targetStore = "scenes";
  100344. }
  100345. else {
  100346. targetStore = "textures";
  100347. }
  100348. // Create XHR
  100349. var xhr = new XMLHttpRequest();
  100350. var fileData;
  100351. xhr.open("GET", url + "?" + Date.now(), true);
  100352. if (useArrayBuffer) {
  100353. xhr.responseType = "arraybuffer";
  100354. }
  100355. if (progressCallback) {
  100356. xhr.onprogress = progressCallback;
  100357. }
  100358. xhr.addEventListener("load", function () {
  100359. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  100360. // Blob as response (XHR2)
  100361. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  100362. if (!_this._hasReachedQuota && _this._db) {
  100363. // Open a transaction to the database
  100364. var transaction = _this._db.transaction([targetStore], "readwrite");
  100365. // the transaction could abort because of a QuotaExceededError error
  100366. transaction.onabort = function (event) {
  100367. try {
  100368. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100369. var error = event.srcElement['error'];
  100370. if (error && error.name === "QuotaExceededError") {
  100371. _this._hasReachedQuota = true;
  100372. }
  100373. }
  100374. catch (ex) { }
  100375. callback(fileData);
  100376. };
  100377. transaction.oncomplete = function () {
  100378. callback(fileData);
  100379. };
  100380. var newFile;
  100381. if (targetStore === "scenes") {
  100382. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  100383. }
  100384. else {
  100385. newFile = { textureUrl: url, data: fileData };
  100386. }
  100387. try {
  100388. // Put the scene into the database
  100389. var addRequest = transaction.objectStore(targetStore).put(newFile);
  100390. addRequest.onsuccess = function () {
  100391. };
  100392. addRequest.onerror = function () {
  100393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  100394. };
  100395. }
  100396. catch (ex) {
  100397. callback(fileData);
  100398. }
  100399. }
  100400. else {
  100401. callback(fileData);
  100402. }
  100403. }
  100404. else {
  100405. if (xhr.status >= 400 && errorCallback) {
  100406. errorCallback(xhr);
  100407. }
  100408. else {
  100409. callback();
  100410. }
  100411. }
  100412. }, false);
  100413. xhr.addEventListener("error", function () {
  100414. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  100415. callback();
  100416. }, false);
  100417. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100418. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100419. }
  100420. xhr.send();
  100421. }
  100422. else {
  100423. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  100424. callback();
  100425. }
  100426. };
  100427. /**
  100428. * Validates if xhr data is correct
  100429. * @param xhr defines the request to validate
  100430. * @param dataType defines the expected data type
  100431. * @returns true if data is correct
  100432. */
  100433. Database._ValidateXHRData = function (xhr, dataType) {
  100434. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  100435. if (dataType === void 0) { dataType = 7; }
  100436. try {
  100437. if (dataType & 1) {
  100438. if (xhr.responseText && xhr.responseText.length > 0) {
  100439. return true;
  100440. }
  100441. else if (dataType === 1) {
  100442. return false;
  100443. }
  100444. }
  100445. if (dataType & 2) {
  100446. // Check header width and height since there is no "TGA" magic number
  100447. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  100448. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  100449. return true;
  100450. }
  100451. else if (dataType === 2) {
  100452. return false;
  100453. }
  100454. }
  100455. if (dataType & 4) {
  100456. // Check for the "DDS" magic number
  100457. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  100458. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  100459. return true;
  100460. }
  100461. else {
  100462. return false;
  100463. }
  100464. }
  100465. }
  100466. catch (e) {
  100467. // Global protection
  100468. }
  100469. return false;
  100470. };
  100471. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  100472. Database.IsUASupportingBlobStorage = true;
  100473. /**
  100474. * Gets a boolean indicating if Database storate is enabled (off by default)
  100475. */
  100476. Database.IDBStorageEnabled = false;
  100477. Database._ParseURL = function (url) {
  100478. var a = document.createElement('a');
  100479. a.href = url;
  100480. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  100481. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  100482. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  100483. return absLocation;
  100484. };
  100485. Database._ReturnFullUrlLocation = function (url) {
  100486. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  100487. return (Database._ParseURL(window.location.href) + url);
  100488. }
  100489. else {
  100490. return url;
  100491. }
  100492. };
  100493. return Database;
  100494. }());
  100495. /***/ }),
  100496. /***/ "./Offline/index.ts":
  100497. /*!**************************!*\
  100498. !*** ./Offline/index.ts ***!
  100499. \**************************/
  100500. /*! exports provided: Database */
  100501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100502. "use strict";
  100503. __webpack_require__.r(__webpack_exports__);
  100504. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  100505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  100506. /***/ }),
  100507. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  100508. /*!******************************************************!*\
  100509. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  100510. \******************************************************/
  100511. /*! exports provided: BoxParticleEmitter */
  100512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100513. "use strict";
  100514. __webpack_require__.r(__webpack_exports__);
  100515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  100516. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100517. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100518. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100519. /**
  100520. * Particle emitter emitting particles from the inside of a box.
  100521. * It emits the particles randomly between 2 given directions.
  100522. */
  100523. var BoxParticleEmitter = /** @class */ (function () {
  100524. /**
  100525. * Creates a new instance BoxParticleEmitter
  100526. */
  100527. function BoxParticleEmitter() {
  100528. /**
  100529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100530. */
  100531. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100532. /**
  100533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100534. */
  100535. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100536. /**
  100537. * 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.
  100538. */
  100539. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  100540. /**
  100541. * 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.
  100542. */
  100543. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  100544. }
  100545. /**
  100546. * Called by the particle System when the direction is computed for the created particle.
  100547. * @param worldMatrix is the world matrix of the particle system
  100548. * @param directionToUpdate is the direction vector to update with the result
  100549. * @param particle is the particle we are computed the direction for
  100550. */
  100551. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100552. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  100553. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  100554. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  100555. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  100556. };
  100557. /**
  100558. * Called by the particle System when the position is computed for the created particle.
  100559. * @param worldMatrix is the world matrix of the particle system
  100560. * @param positionToUpdate is the position vector to update with the result
  100561. * @param particle is the particle we are computed the position for
  100562. */
  100563. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100564. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  100565. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  100566. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  100567. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  100568. };
  100569. /**
  100570. * Clones the current emitter and returns a copy of it
  100571. * @returns the new emitter
  100572. */
  100573. BoxParticleEmitter.prototype.clone = function () {
  100574. var newOne = new BoxParticleEmitter();
  100575. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  100576. return newOne;
  100577. };
  100578. /**
  100579. * Called by the GPUParticleSystem to setup the update shader
  100580. * @param effect defines the update shader
  100581. */
  100582. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  100583. effect.setVector3("direction1", this.direction1);
  100584. effect.setVector3("direction2", this.direction2);
  100585. effect.setVector3("minEmitBox", this.minEmitBox);
  100586. effect.setVector3("maxEmitBox", this.maxEmitBox);
  100587. };
  100588. /**
  100589. * Returns a string to use to update the GPU particles update shader
  100590. * @returns a string containng the defines string
  100591. */
  100592. BoxParticleEmitter.prototype.getEffectDefines = function () {
  100593. return "#define BOXEMITTER";
  100594. };
  100595. /**
  100596. * Returns the string "BoxParticleEmitter"
  100597. * @returns a string containing the class name
  100598. */
  100599. BoxParticleEmitter.prototype.getClassName = function () {
  100600. return "BoxParticleEmitter";
  100601. };
  100602. /**
  100603. * Serializes the particle system to a JSON object.
  100604. * @returns the JSON object
  100605. */
  100606. BoxParticleEmitter.prototype.serialize = function () {
  100607. var serializationObject = {};
  100608. serializationObject.type = this.getClassName();
  100609. serializationObject.direction1 = this.direction1.asArray();
  100610. serializationObject.direction2 = this.direction2.asArray();
  100611. serializationObject.minEmitBox = this.minEmitBox.asArray();
  100612. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  100613. return serializationObject;
  100614. };
  100615. /**
  100616. * Parse properties from a JSON object
  100617. * @param serializationObject defines the JSON object
  100618. */
  100619. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  100620. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  100621. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  100622. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  100623. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  100624. };
  100625. return BoxParticleEmitter;
  100626. }());
  100627. /***/ }),
  100628. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  100629. /*!*******************************************************!*\
  100630. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  100631. \*******************************************************/
  100632. /*! exports provided: ConeParticleEmitter */
  100633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100634. "use strict";
  100635. __webpack_require__.r(__webpack_exports__);
  100636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  100637. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100638. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100639. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100640. /**
  100641. * Particle emitter emitting particles from the inside of a cone.
  100642. * It emits the particles alongside the cone volume from the base to the particle.
  100643. * The emission direction might be randomized.
  100644. */
  100645. var ConeParticleEmitter = /** @class */ (function () {
  100646. /**
  100647. * Creates a new instance ConeParticleEmitter
  100648. * @param radius the radius of the emission cone (1 by default)
  100649. * @param angles the cone base angle (PI by default)
  100650. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  100651. */
  100652. function ConeParticleEmitter(radius, angle,
  100653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100654. directionRandomizer) {
  100655. if (radius === void 0) { radius = 1; }
  100656. if (angle === void 0) { angle = Math.PI; }
  100657. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  100658. this.directionRandomizer = directionRandomizer;
  100659. /**
  100660. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  100661. */
  100662. this.radiusRange = 1;
  100663. /**
  100664. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  100665. */
  100666. this.heightRange = 1;
  100667. /**
  100668. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  100669. */
  100670. this.emitFromSpawnPointOnly = false;
  100671. this.angle = angle;
  100672. this.radius = radius;
  100673. }
  100674. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  100675. /**
  100676. * Gets or sets the radius of the emission cone
  100677. */
  100678. get: function () {
  100679. return this._radius;
  100680. },
  100681. set: function (value) {
  100682. this._radius = value;
  100683. this._buildHeight();
  100684. },
  100685. enumerable: true,
  100686. configurable: true
  100687. });
  100688. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  100689. /**
  100690. * Gets or sets the angle of the emission cone
  100691. */
  100692. get: function () {
  100693. return this._angle;
  100694. },
  100695. set: function (value) {
  100696. this._angle = value;
  100697. this._buildHeight();
  100698. },
  100699. enumerable: true,
  100700. configurable: true
  100701. });
  100702. ConeParticleEmitter.prototype._buildHeight = function () {
  100703. if (this._angle !== 0) {
  100704. this._height = this._radius / Math.tan(this._angle / 2);
  100705. }
  100706. else {
  100707. this._height = 1;
  100708. }
  100709. };
  100710. /**
  100711. * Called by the particle System when the direction is computed for the created particle.
  100712. * @param worldMatrix is the world matrix of the particle system
  100713. * @param directionToUpdate is the direction vector to update with the result
  100714. * @param particle is the particle we are computed the direction for
  100715. */
  100716. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100717. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  100718. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  100719. }
  100720. else {
  100721. // measure the direction Vector from the emitter to the particle.
  100722. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  100723. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100724. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100725. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100726. direction.x += randX;
  100727. direction.y += randY;
  100728. direction.z += randZ;
  100729. direction.normalize();
  100730. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  100731. }
  100732. };
  100733. /**
  100734. * Called by the particle System when the position is computed for the created particle.
  100735. * @param worldMatrix is the world matrix of the particle system
  100736. * @param positionToUpdate is the position vector to update with the result
  100737. * @param particle is the particle we are computed the position for
  100738. */
  100739. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100740. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  100741. var h;
  100742. if (!this.emitFromSpawnPointOnly) {
  100743. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  100744. // Better distribution in a cone at normal angles.
  100745. h = 1 - h * h;
  100746. }
  100747. else {
  100748. h = 0.0001;
  100749. }
  100750. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  100751. radius = radius * h;
  100752. var randX = radius * Math.sin(s);
  100753. var randZ = radius * Math.cos(s);
  100754. var randY = h * this._height;
  100755. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  100756. };
  100757. /**
  100758. * Clones the current emitter and returns a copy of it
  100759. * @returns the new emitter
  100760. */
  100761. ConeParticleEmitter.prototype.clone = function () {
  100762. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  100763. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  100764. return newOne;
  100765. };
  100766. /**
  100767. * Called by the GPUParticleSystem to setup the update shader
  100768. * @param effect defines the update shader
  100769. */
  100770. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  100771. effect.setFloat2("radius", this._radius, this.radiusRange);
  100772. effect.setFloat("coneAngle", this._angle);
  100773. effect.setFloat2("height", this._height, this.heightRange);
  100774. effect.setFloat("directionRandomizer", this.directionRandomizer);
  100775. };
  100776. /**
  100777. * Returns a string to use to update the GPU particles update shader
  100778. * @returns a string containng the defines string
  100779. */
  100780. ConeParticleEmitter.prototype.getEffectDefines = function () {
  100781. var defines = "#define CONEEMITTER";
  100782. if (this.emitFromSpawnPointOnly) {
  100783. defines += "\n#define CONEEMITTERSPAWNPOINT";
  100784. }
  100785. return defines;
  100786. };
  100787. /**
  100788. * Returns the string "ConeParticleEmitter"
  100789. * @returns a string containing the class name
  100790. */
  100791. ConeParticleEmitter.prototype.getClassName = function () {
  100792. return "ConeParticleEmitter";
  100793. };
  100794. /**
  100795. * Serializes the particle system to a JSON object.
  100796. * @returns the JSON object
  100797. */
  100798. ConeParticleEmitter.prototype.serialize = function () {
  100799. var serializationObject = {};
  100800. serializationObject.type = this.getClassName();
  100801. serializationObject.radius = this._radius;
  100802. serializationObject.angle = this._angle;
  100803. serializationObject.directionRandomizer = this.directionRandomizer;
  100804. return serializationObject;
  100805. };
  100806. /**
  100807. * Parse properties from a JSON object
  100808. * @param serializationObject defines the JSON object
  100809. */
  100810. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  100811. this.radius = serializationObject.radius;
  100812. this.angle = serializationObject.angle;
  100813. this.directionRandomizer = serializationObject.directionRandomizer;
  100814. };
  100815. return ConeParticleEmitter;
  100816. }());
  100817. /***/ }),
  100818. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  100819. /*!***********************************************************!*\
  100820. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  100821. \***********************************************************/
  100822. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  100823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100824. "use strict";
  100825. __webpack_require__.r(__webpack_exports__);
  100826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  100827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  100828. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100830. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100831. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100832. /**
  100833. * Particle emitter emitting particles from the inside of a cylinder.
  100834. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  100835. */
  100836. var CylinderParticleEmitter = /** @class */ (function () {
  100837. /**
  100838. * Creates a new instance CylinderParticleEmitter
  100839. * @param radius the radius of the emission cylinder (1 by default)
  100840. * @param height the height of the emission cylinder (1 by default)
  100841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  100843. */
  100844. function CylinderParticleEmitter(
  100845. /**
  100846. * The radius of the emission cylinder.
  100847. */
  100848. radius,
  100849. /**
  100850. * The height of the emission cylinder.
  100851. */
  100852. height,
  100853. /**
  100854. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  100855. */
  100856. radiusRange,
  100857. /**
  100858. * How much to randomize the particle direction [0-1].
  100859. */
  100860. directionRandomizer) {
  100861. if (radius === void 0) { radius = 1; }
  100862. if (height === void 0) { height = 1; }
  100863. if (radiusRange === void 0) { radiusRange = 1; }
  100864. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  100865. this.radius = radius;
  100866. this.height = height;
  100867. this.radiusRange = radiusRange;
  100868. this.directionRandomizer = directionRandomizer;
  100869. }
  100870. /**
  100871. * Called by the particle System when the direction is computed for the created particle.
  100872. * @param worldMatrix is the world matrix of the particle system
  100873. * @param directionToUpdate is the direction vector to update with the result
  100874. * @param particle is the particle we are computed the direction for
  100875. */
  100876. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100877. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  100878. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  100879. var angle = Math.atan2(direction.x, direction.z);
  100880. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  100881. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  100882. direction.x = Math.sin(angle);
  100883. direction.z = Math.cos(angle);
  100884. direction.normalize();
  100885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  100886. };
  100887. /**
  100888. * Called by the particle System when the position is computed for the created particle.
  100889. * @param worldMatrix is the world matrix of the particle system
  100890. * @param positionToUpdate is the position vector to update with the result
  100891. * @param particle is the particle we are computed the position for
  100892. */
  100893. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100894. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  100895. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  100896. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  100897. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  100898. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  100899. var xPos = positionRadius * Math.cos(angle);
  100900. var zPos = positionRadius * Math.sin(angle);
  100901. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  100902. };
  100903. /**
  100904. * Clones the current emitter and returns a copy of it
  100905. * @returns the new emitter
  100906. */
  100907. CylinderParticleEmitter.prototype.clone = function () {
  100908. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  100909. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  100910. return newOne;
  100911. };
  100912. /**
  100913. * Called by the GPUParticleSystem to setup the update shader
  100914. * @param effect defines the update shader
  100915. */
  100916. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  100917. effect.setFloat("radius", this.radius);
  100918. effect.setFloat("height", this.height);
  100919. effect.setFloat("radiusRange", this.radiusRange);
  100920. effect.setFloat("directionRandomizer", this.directionRandomizer);
  100921. };
  100922. /**
  100923. * Returns a string to use to update the GPU particles update shader
  100924. * @returns a string containng the defines string
  100925. */
  100926. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  100927. return "#define CYLINDEREMITTER";
  100928. };
  100929. /**
  100930. * Returns the string "CylinderParticleEmitter"
  100931. * @returns a string containing the class name
  100932. */
  100933. CylinderParticleEmitter.prototype.getClassName = function () {
  100934. return "CylinderParticleEmitter";
  100935. };
  100936. /**
  100937. * Serializes the particle system to a JSON object.
  100938. * @returns the JSON object
  100939. */
  100940. CylinderParticleEmitter.prototype.serialize = function () {
  100941. var serializationObject = {};
  100942. serializationObject.type = this.getClassName();
  100943. serializationObject.radius = this.radius;
  100944. serializationObject.height = this.height;
  100945. serializationObject.radiusRange = this.radiusRange;
  100946. serializationObject.directionRandomizer = this.directionRandomizer;
  100947. return serializationObject;
  100948. };
  100949. /**
  100950. * Parse properties from a JSON object
  100951. * @param serializationObject defines the JSON object
  100952. */
  100953. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  100954. this.radius = serializationObject.radius;
  100955. this.height = serializationObject.height;
  100956. this.radiusRange = serializationObject.radiusRange;
  100957. this.directionRandomizer = serializationObject.directionRandomizer;
  100958. };
  100959. return CylinderParticleEmitter;
  100960. }());
  100961. /**
  100962. * Particle emitter emitting particles from the inside of a cylinder.
  100963. * It emits the particles randomly between two vectors.
  100964. */
  100965. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  100966. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  100967. /**
  100968. * Creates a new instance CylinderDirectedParticleEmitter
  100969. * @param radius the radius of the emission cylinder (1 by default)
  100970. * @param height the height of the emission cylinder (1 by default)
  100971. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100972. * @param direction1 the min limit of the emission direction (up vector by default)
  100973. * @param direction2 the max limit of the emission direction (up vector by default)
  100974. */
  100975. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  100976. /**
  100977. * The min limit of the emission direction.
  100978. */
  100979. direction1,
  100980. /**
  100981. * The max limit of the emission direction.
  100982. */
  100983. direction2) {
  100984. if (radius === void 0) { radius = 1; }
  100985. if (height === void 0) { height = 1; }
  100986. if (radiusRange === void 0) { radiusRange = 1; }
  100987. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  100988. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  100989. var _this = _super.call(this, radius, height, radiusRange) || this;
  100990. _this.direction1 = direction1;
  100991. _this.direction2 = direction2;
  100992. return _this;
  100993. }
  100994. /**
  100995. * Called by the particle System when the direction is computed for the created particle.
  100996. * @param worldMatrix is the world matrix of the particle system
  100997. * @param directionToUpdate is the direction vector to update with the result
  100998. * @param particle is the particle we are computed the direction for
  100999. */
  101000. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101001. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101002. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101003. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101004. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101005. };
  101006. /**
  101007. * Clones the current emitter and returns a copy of it
  101008. * @returns the new emitter
  101009. */
  101010. CylinderDirectedParticleEmitter.prototype.clone = function () {
  101011. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  101012. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101013. return newOne;
  101014. };
  101015. /**
  101016. * Called by the GPUParticleSystem to setup the update shader
  101017. * @param effect defines the update shader
  101018. */
  101019. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101020. effect.setFloat("radius", this.radius);
  101021. effect.setFloat("height", this.height);
  101022. effect.setFloat("radiusRange", this.radiusRange);
  101023. effect.setVector3("direction1", this.direction1);
  101024. effect.setVector3("direction2", this.direction2);
  101025. };
  101026. /**
  101027. * Returns a string to use to update the GPU particles update shader
  101028. * @returns a string containng the defines string
  101029. */
  101030. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101031. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  101032. };
  101033. /**
  101034. * Returns the string "CylinderDirectedParticleEmitter"
  101035. * @returns a string containing the class name
  101036. */
  101037. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  101038. return "CylinderDirectedParticleEmitter";
  101039. };
  101040. /**
  101041. * Serializes the particle system to a JSON object.
  101042. * @returns the JSON object
  101043. */
  101044. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  101045. var serializationObject = _super.prototype.serialize.call(this);
  101046. serializationObject.direction1 = this.direction1.asArray();
  101047. serializationObject.direction2 = this.direction2.asArray();
  101048. return serializationObject;
  101049. };
  101050. /**
  101051. * Parse properties from a JSON object
  101052. * @param serializationObject defines the JSON object
  101053. */
  101054. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101055. _super.prototype.parse.call(this, serializationObject);
  101056. this.direction1.copyFrom(serializationObject.direction1);
  101057. this.direction2.copyFrom(serializationObject.direction2);
  101058. };
  101059. return CylinderDirectedParticleEmitter;
  101060. }(CylinderParticleEmitter));
  101061. /***/ }),
  101062. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  101063. /*!**************************************************************!*\
  101064. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  101065. \**************************************************************/
  101066. /*! exports provided: HemisphericParticleEmitter */
  101067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101068. "use strict";
  101069. __webpack_require__.r(__webpack_exports__);
  101070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  101071. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101072. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101073. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101074. /**
  101075. * Particle emitter emitting particles from the inside of a hemisphere.
  101076. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101077. */
  101078. var HemisphericParticleEmitter = /** @class */ (function () {
  101079. /**
  101080. * Creates a new instance HemisphericParticleEmitter
  101081. * @param radius the radius of the emission hemisphere (1 by default)
  101082. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101083. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101084. */
  101085. function HemisphericParticleEmitter(
  101086. /**
  101087. * The radius of the emission hemisphere.
  101088. */
  101089. radius,
  101090. /**
  101091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101092. */
  101093. radiusRange,
  101094. /**
  101095. * How much to randomize the particle direction [0-1].
  101096. */
  101097. directionRandomizer) {
  101098. if (radius === void 0) { radius = 1; }
  101099. if (radiusRange === void 0) { radiusRange = 1; }
  101100. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101101. this.radius = radius;
  101102. this.radiusRange = radiusRange;
  101103. this.directionRandomizer = directionRandomizer;
  101104. }
  101105. /**
  101106. * Called by the particle System when the direction is computed for the created particle.
  101107. * @param worldMatrix is the world matrix of the particle system
  101108. * @param directionToUpdate is the direction vector to update with the result
  101109. * @param particle is the particle we are computed the direction for
  101110. */
  101111. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101112. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101113. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101114. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101115. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101116. direction.x += randX;
  101117. direction.y += randY;
  101118. direction.z += randZ;
  101119. direction.normalize();
  101120. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101121. };
  101122. /**
  101123. * Called by the particle System when the position is computed for the created particle.
  101124. * @param worldMatrix is the world matrix of the particle system
  101125. * @param positionToUpdate is the position vector to update with the result
  101126. * @param particle is the particle we are computed the position for
  101127. */
  101128. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101129. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101130. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101131. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101132. var theta = Math.acos(2 * v - 1);
  101133. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101134. var randY = randRadius * Math.cos(theta);
  101135. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101136. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  101137. };
  101138. /**
  101139. * Clones the current emitter and returns a copy of it
  101140. * @returns the new emitter
  101141. */
  101142. HemisphericParticleEmitter.prototype.clone = function () {
  101143. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  101144. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101145. return newOne;
  101146. };
  101147. /**
  101148. * Called by the GPUParticleSystem to setup the update shader
  101149. * @param effect defines the update shader
  101150. */
  101151. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  101152. effect.setFloat("radius", this.radius);
  101153. effect.setFloat("radiusRange", this.radiusRange);
  101154. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101155. };
  101156. /**
  101157. * Returns a string to use to update the GPU particles update shader
  101158. * @returns a string containng the defines string
  101159. */
  101160. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  101161. return "#define HEMISPHERICEMITTER";
  101162. };
  101163. /**
  101164. * Returns the string "HemisphericParticleEmitter"
  101165. * @returns a string containing the class name
  101166. */
  101167. HemisphericParticleEmitter.prototype.getClassName = function () {
  101168. return "HemisphericParticleEmitter";
  101169. };
  101170. /**
  101171. * Serializes the particle system to a JSON object.
  101172. * @returns the JSON object
  101173. */
  101174. HemisphericParticleEmitter.prototype.serialize = function () {
  101175. var serializationObject = {};
  101176. serializationObject.type = this.getClassName();
  101177. serializationObject.radius = this.radius;
  101178. serializationObject.radiusRange = this.radiusRange;
  101179. serializationObject.directionRandomizer = this.directionRandomizer;
  101180. return serializationObject;
  101181. };
  101182. /**
  101183. * Parse properties from a JSON object
  101184. * @param serializationObject defines the JSON object
  101185. */
  101186. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  101187. this.radius = serializationObject.radius;
  101188. this.radiusRange = serializationObject.radiusRange;
  101189. this.directionRandomizer = serializationObject.directionRandomizer;
  101190. };
  101191. return HemisphericParticleEmitter;
  101192. }());
  101193. /***/ }),
  101194. /***/ "./Particles/EmitterTypes/index.ts":
  101195. /*!*****************************************!*\
  101196. !*** ./Particles/EmitterTypes/index.ts ***!
  101197. \*****************************************/
  101198. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  101199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101200. "use strict";
  101201. __webpack_require__.r(__webpack_exports__);
  101202. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  101203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  101204. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  101205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  101206. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  101207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  101208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  101209. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  101210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  101211. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  101212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  101213. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  101214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  101215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  101216. /***/ }),
  101217. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  101218. /*!********************************************************!*\
  101219. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  101220. \********************************************************/
  101221. /*! exports provided: PointParticleEmitter */
  101222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101223. "use strict";
  101224. __webpack_require__.r(__webpack_exports__);
  101225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  101226. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101228. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101229. /**
  101230. * Particle emitter emitting particles from a point.
  101231. * It emits the particles randomly between 2 given directions.
  101232. */
  101233. var PointParticleEmitter = /** @class */ (function () {
  101234. /**
  101235. * Creates a new instance PointParticleEmitter
  101236. */
  101237. function PointParticleEmitter() {
  101238. /**
  101239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101240. */
  101241. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101242. /**
  101243. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101244. */
  101245. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101246. }
  101247. /**
  101248. * Called by the particle System when the direction is computed for the created particle.
  101249. * @param worldMatrix is the world matrix of the particle system
  101250. * @param directionToUpdate is the direction vector to update with the result
  101251. * @param particle is the particle we are computed the direction for
  101252. */
  101253. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101254. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101255. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101256. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101257. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101258. };
  101259. /**
  101260. * Called by the particle System when the position is computed for the created particle.
  101261. * @param worldMatrix is the world matrix of the particle system
  101262. * @param positionToUpdate is the position vector to update with the result
  101263. * @param particle is the particle we are computed the position for
  101264. */
  101265. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101266. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  101267. };
  101268. /**
  101269. * Clones the current emitter and returns a copy of it
  101270. * @returns the new emitter
  101271. */
  101272. PointParticleEmitter.prototype.clone = function () {
  101273. var newOne = new PointParticleEmitter();
  101274. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101275. return newOne;
  101276. };
  101277. /**
  101278. * Called by the GPUParticleSystem to setup the update shader
  101279. * @param effect defines the update shader
  101280. */
  101281. PointParticleEmitter.prototype.applyToShader = function (effect) {
  101282. effect.setVector3("direction1", this.direction1);
  101283. effect.setVector3("direction2", this.direction2);
  101284. };
  101285. /**
  101286. * Returns a string to use to update the GPU particles update shader
  101287. * @returns a string containng the defines string
  101288. */
  101289. PointParticleEmitter.prototype.getEffectDefines = function () {
  101290. return "#define POINTEMITTER";
  101291. };
  101292. /**
  101293. * Returns the string "PointParticleEmitter"
  101294. * @returns a string containing the class name
  101295. */
  101296. PointParticleEmitter.prototype.getClassName = function () {
  101297. return "PointParticleEmitter";
  101298. };
  101299. /**
  101300. * Serializes the particle system to a JSON object.
  101301. * @returns the JSON object
  101302. */
  101303. PointParticleEmitter.prototype.serialize = function () {
  101304. var serializationObject = {};
  101305. serializationObject.type = this.getClassName();
  101306. serializationObject.direction1 = this.direction1.asArray();
  101307. serializationObject.direction2 = this.direction2.asArray();
  101308. return serializationObject;
  101309. };
  101310. /**
  101311. * Parse properties from a JSON object
  101312. * @param serializationObject defines the JSON object
  101313. */
  101314. PointParticleEmitter.prototype.parse = function (serializationObject) {
  101315. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101317. };
  101318. return PointParticleEmitter;
  101319. }());
  101320. /***/ }),
  101321. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  101322. /*!*********************************************************!*\
  101323. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  101324. \*********************************************************/
  101325. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  101326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101327. "use strict";
  101328. __webpack_require__.r(__webpack_exports__);
  101329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  101330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  101331. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101333. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101334. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101335. /**
  101336. * Particle emitter emitting particles from the inside of a sphere.
  101337. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101338. */
  101339. var SphereParticleEmitter = /** @class */ (function () {
  101340. /**
  101341. * Creates a new instance SphereParticleEmitter
  101342. * @param radius the radius of the emission sphere (1 by default)
  101343. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101344. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101345. */
  101346. function SphereParticleEmitter(
  101347. /**
  101348. * The radius of the emission sphere.
  101349. */
  101350. radius,
  101351. /**
  101352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101353. */
  101354. radiusRange,
  101355. /**
  101356. * How much to randomize the particle direction [0-1].
  101357. */
  101358. directionRandomizer) {
  101359. if (radius === void 0) { radius = 1; }
  101360. if (radiusRange === void 0) { radiusRange = 1; }
  101361. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101362. this.radius = radius;
  101363. this.radiusRange = radiusRange;
  101364. this.directionRandomizer = directionRandomizer;
  101365. }
  101366. /**
  101367. * Called by the particle System when the direction is computed for the created particle.
  101368. * @param worldMatrix is the world matrix of the particle system
  101369. * @param directionToUpdate is the direction vector to update with the result
  101370. * @param particle is the particle we are computed the direction for
  101371. */
  101372. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101373. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101374. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101375. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101376. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101377. direction.x += randX;
  101378. direction.y += randY;
  101379. direction.z += randZ;
  101380. direction.normalize();
  101381. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101382. };
  101383. /**
  101384. * Called by the particle System when the position is computed for the created particle.
  101385. * @param worldMatrix is the world matrix of the particle system
  101386. * @param positionToUpdate is the position vector to update with the result
  101387. * @param particle is the particle we are computed the position for
  101388. */
  101389. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101390. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101391. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101392. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101393. var theta = Math.acos(2 * v - 1);
  101394. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101395. var randY = randRadius * Math.cos(theta);
  101396. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101397. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101398. };
  101399. /**
  101400. * Clones the current emitter and returns a copy of it
  101401. * @returns the new emitter
  101402. */
  101403. SphereParticleEmitter.prototype.clone = function () {
  101404. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  101405. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101406. return newOne;
  101407. };
  101408. /**
  101409. * Called by the GPUParticleSystem to setup the update shader
  101410. * @param effect defines the update shader
  101411. */
  101412. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  101413. effect.setFloat("radius", this.radius);
  101414. effect.setFloat("radiusRange", this.radiusRange);
  101415. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101416. };
  101417. /**
  101418. * Returns a string to use to update the GPU particles update shader
  101419. * @returns a string containng the defines string
  101420. */
  101421. SphereParticleEmitter.prototype.getEffectDefines = function () {
  101422. return "#define SPHEREEMITTER";
  101423. };
  101424. /**
  101425. * Returns the string "SphereParticleEmitter"
  101426. * @returns a string containing the class name
  101427. */
  101428. SphereParticleEmitter.prototype.getClassName = function () {
  101429. return "SphereParticleEmitter";
  101430. };
  101431. /**
  101432. * Serializes the particle system to a JSON object.
  101433. * @returns the JSON object
  101434. */
  101435. SphereParticleEmitter.prototype.serialize = function () {
  101436. var serializationObject = {};
  101437. serializationObject.type = this.getClassName();
  101438. serializationObject.radius = this.radius;
  101439. serializationObject.radiusRange = this.radiusRange;
  101440. serializationObject.directionRandomizer = this.directionRandomizer;
  101441. return serializationObject;
  101442. };
  101443. /**
  101444. * Parse properties from a JSON object
  101445. * @param serializationObject defines the JSON object
  101446. */
  101447. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  101448. this.radius = serializationObject.radius;
  101449. this.radiusRange = serializationObject.radiusRange;
  101450. this.directionRandomizer = serializationObject.directionRandomizer;
  101451. };
  101452. return SphereParticleEmitter;
  101453. }());
  101454. /**
  101455. * Particle emitter emitting particles from the inside of a sphere.
  101456. * It emits the particles randomly between two vectors.
  101457. */
  101458. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  101459. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  101460. /**
  101461. * Creates a new instance SphereDirectedParticleEmitter
  101462. * @param radius the radius of the emission sphere (1 by default)
  101463. * @param direction1 the min limit of the emission direction (up vector by default)
  101464. * @param direction2 the max limit of the emission direction (up vector by default)
  101465. */
  101466. function SphereDirectedParticleEmitter(radius,
  101467. /**
  101468. * The min limit of the emission direction.
  101469. */
  101470. direction1,
  101471. /**
  101472. * The max limit of the emission direction.
  101473. */
  101474. direction2) {
  101475. if (radius === void 0) { radius = 1; }
  101476. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101477. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101478. var _this = _super.call(this, radius) || this;
  101479. _this.direction1 = direction1;
  101480. _this.direction2 = direction2;
  101481. return _this;
  101482. }
  101483. /**
  101484. * Called by the particle System when the direction is computed for the created particle.
  101485. * @param worldMatrix is the world matrix of the particle system
  101486. * @param directionToUpdate is the direction vector to update with the result
  101487. * @param particle is the particle we are computed the direction for
  101488. */
  101489. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101490. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101491. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101492. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101493. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101494. };
  101495. /**
  101496. * Clones the current emitter and returns a copy of it
  101497. * @returns the new emitter
  101498. */
  101499. SphereDirectedParticleEmitter.prototype.clone = function () {
  101500. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  101501. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101502. return newOne;
  101503. };
  101504. /**
  101505. * Called by the GPUParticleSystem to setup the update shader
  101506. * @param effect defines the update shader
  101507. */
  101508. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101509. effect.setFloat("radius", this.radius);
  101510. effect.setFloat("radiusRange", this.radiusRange);
  101511. effect.setVector3("direction1", this.direction1);
  101512. effect.setVector3("direction2", this.direction2);
  101513. };
  101514. /**
  101515. * Returns a string to use to update the GPU particles update shader
  101516. * @returns a string containng the defines string
  101517. */
  101518. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101519. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  101520. };
  101521. /**
  101522. * Returns the string "SphereDirectedParticleEmitter"
  101523. * @returns a string containing the class name
  101524. */
  101525. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  101526. return "SphereDirectedParticleEmitter";
  101527. };
  101528. /**
  101529. * Serializes the particle system to a JSON object.
  101530. * @returns the JSON object
  101531. */
  101532. SphereDirectedParticleEmitter.prototype.serialize = function () {
  101533. var serializationObject = _super.prototype.serialize.call(this);
  101534. serializationObject.direction1 = this.direction1.asArray();
  101535. serializationObject.direction2 = this.direction2.asArray();
  101536. return serializationObject;
  101537. };
  101538. /**
  101539. * Parse properties from a JSON object
  101540. * @param serializationObject defines the JSON object
  101541. */
  101542. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101543. _super.prototype.parse.call(this, serializationObject);
  101544. this.direction1.copyFrom(serializationObject.direction1);
  101545. this.direction2.copyFrom(serializationObject.direction2);
  101546. };
  101547. return SphereDirectedParticleEmitter;
  101548. }(SphereParticleEmitter));
  101549. /***/ }),
  101550. /***/ "./Particles/baseParticleSystem.ts":
  101551. /*!*****************************************!*\
  101552. !*** ./Particles/baseParticleSystem.ts ***!
  101553. \*****************************************/
  101554. /*! exports provided: BaseParticleSystem */
  101555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101556. "use strict";
  101557. __webpack_require__.r(__webpack_exports__);
  101558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  101559. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101560. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  101561. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  101562. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101563. /**
  101564. * This represents the base class for particle system in Babylon.
  101565. * 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.
  101566. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  101567. * @example https://doc.babylonjs.com/babylon101/particles
  101568. */
  101569. var BaseParticleSystem = /** @class */ (function () {
  101570. /**
  101571. * Instantiates a particle system.
  101572. * 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.
  101573. * @param name The name of the particle system
  101574. */
  101575. function BaseParticleSystem(name) {
  101576. /**
  101577. * List of animations used by the particle system.
  101578. */
  101579. this.animations = [];
  101580. /**
  101581. * The rendering group used by the Particle system to chose when to render.
  101582. */
  101583. this.renderingGroupId = 0;
  101584. /**
  101585. * The emitter represents the Mesh or position we are attaching the particle system to.
  101586. */
  101587. this.emitter = null;
  101588. /**
  101589. * The maximum number of particles to emit per frame
  101590. */
  101591. this.emitRate = 10;
  101592. /**
  101593. * If you want to launch only a few particles at once, that can be done, as well.
  101594. */
  101595. this.manualEmitCount = -1;
  101596. /**
  101597. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101598. */
  101599. this.updateSpeed = 0.01;
  101600. /**
  101601. * The amount of time the particle system is running (depends of the overall update speed).
  101602. */
  101603. this.targetStopDuration = 0;
  101604. /**
  101605. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  101606. */
  101607. this.disposeOnStop = false;
  101608. /**
  101609. * Minimum power of emitting particles.
  101610. */
  101611. this.minEmitPower = 1;
  101612. /**
  101613. * Maximum power of emitting particles.
  101614. */
  101615. this.maxEmitPower = 1;
  101616. /**
  101617. * Minimum life time of emitting particles.
  101618. */
  101619. this.minLifeTime = 1;
  101620. /**
  101621. * Maximum life time of emitting particles.
  101622. */
  101623. this.maxLifeTime = 1;
  101624. /**
  101625. * Minimum Size of emitting particles.
  101626. */
  101627. this.minSize = 1;
  101628. /**
  101629. * Maximum Size of emitting particles.
  101630. */
  101631. this.maxSize = 1;
  101632. /**
  101633. * Minimum scale of emitting particles on X axis.
  101634. */
  101635. this.minScaleX = 1;
  101636. /**
  101637. * Maximum scale of emitting particles on X axis.
  101638. */
  101639. this.maxScaleX = 1;
  101640. /**
  101641. * Minimum scale of emitting particles on Y axis.
  101642. */
  101643. this.minScaleY = 1;
  101644. /**
  101645. * Maximum scale of emitting particles on Y axis.
  101646. */
  101647. this.maxScaleY = 1;
  101648. /**
  101649. * Gets or sets the minimal initial rotation in radians.
  101650. */
  101651. this.minInitialRotation = 0;
  101652. /**
  101653. * Gets or sets the maximal initial rotation in radians.
  101654. */
  101655. this.maxInitialRotation = 0;
  101656. /**
  101657. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  101658. */
  101659. this.minAngularSpeed = 0;
  101660. /**
  101661. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  101662. */
  101663. this.maxAngularSpeed = 0;
  101664. /**
  101665. * The layer mask we are rendering the particles through.
  101666. */
  101667. this.layerMask = 0x0FFFFFFF;
  101668. /**
  101669. * This can help using your own shader to render the particle system.
  101670. * The according effect will be created
  101671. */
  101672. this.customShader = null;
  101673. /**
  101674. * By default particle system starts as soon as they are created. This prevents the
  101675. * automatic start to happen and let you decide when to start emitting particles.
  101676. */
  101677. this.preventAutoStart = false;
  101678. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  101679. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  101680. /**
  101681. * Callback triggered when the particle animation is ending.
  101682. */
  101683. this.onAnimationEnd = null;
  101684. /**
  101685. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  101686. */
  101687. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  101688. /**
  101689. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  101690. * to override the particles.
  101691. */
  101692. this.forceDepthWrite = false;
  101693. /** 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 */
  101694. this.preWarmCycles = 0;
  101695. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  101696. this.preWarmStepOffset = 1;
  101697. /**
  101698. * 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)
  101699. */
  101700. this.spriteCellChangeSpeed = 1;
  101701. /**
  101702. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  101703. */
  101704. this.startSpriteCellID = 0;
  101705. /**
  101706. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  101707. */
  101708. this.endSpriteCellID = 0;
  101709. /**
  101710. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  101711. */
  101712. this.spriteCellWidth = 0;
  101713. /**
  101714. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  101715. */
  101716. this.spriteCellHeight = 0;
  101717. /**
  101718. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  101719. */
  101720. this.spriteRandomStartCell = false;
  101721. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  101722. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101723. /**
  101724. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  101725. */
  101726. this.beginAnimationOnStart = false;
  101727. /**
  101728. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  101729. */
  101730. this.beginAnimationFrom = 0;
  101731. /**
  101732. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  101733. */
  101734. this.beginAnimationTo = 60;
  101735. /**
  101736. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  101737. */
  101738. this.beginAnimationLoop = false;
  101739. /**
  101740. * You can use gravity if you want to give an orientation to your particles.
  101741. */
  101742. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101743. this._colorGradients = null;
  101744. this._sizeGradients = null;
  101745. this._lifeTimeGradients = null;
  101746. this._angularSpeedGradients = null;
  101747. this._velocityGradients = null;
  101748. this._limitVelocityGradients = null;
  101749. this._dragGradients = null;
  101750. this._emitRateGradients = null;
  101751. this._startSizeGradients = null;
  101752. this._rampGradients = null;
  101753. this._colorRemapGradients = null;
  101754. this._alphaRemapGradients = null;
  101755. /**
  101756. * Defines the delay in milliseconds before starting the system (0 by default)
  101757. */
  101758. this.startDelay = 0;
  101759. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  101760. this.limitVelocityDamping = 0.4;
  101761. /**
  101762. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  101763. */
  101764. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101765. /**
  101766. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  101767. */
  101768. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101769. /**
  101770. * Color the particle will have at the end of its lifetime
  101771. */
  101772. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  101773. /**
  101774. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  101775. */
  101776. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101777. /** @hidden */
  101778. this._isSubEmitter = false;
  101779. /**
  101780. * Gets or sets the billboard mode to use when isBillboardBased = true.
  101781. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  101782. */
  101783. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  101784. this._isBillboardBased = true;
  101785. /**
  101786. * Local cache of defines for image processing.
  101787. */
  101788. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  101789. this.id = name;
  101790. this.name = name;
  101791. }
  101792. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  101793. /**
  101794. * Gets or sets a texture used to add random noise to particle positions
  101795. */
  101796. get: function () {
  101797. return this._noiseTexture;
  101798. },
  101799. set: function (value) {
  101800. if (this._noiseTexture === value) {
  101801. return;
  101802. }
  101803. this._noiseTexture = value;
  101804. this._reset();
  101805. },
  101806. enumerable: true,
  101807. configurable: true
  101808. });
  101809. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  101810. /**
  101811. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  101812. */
  101813. get: function () {
  101814. return this._isAnimationSheetEnabled;
  101815. },
  101816. set: function (value) {
  101817. if (this._isAnimationSheetEnabled == value) {
  101818. return;
  101819. }
  101820. this._isAnimationSheetEnabled = value;
  101821. this._reset();
  101822. },
  101823. enumerable: true,
  101824. configurable: true
  101825. });
  101826. /**
  101827. * Get hosting scene
  101828. * @returns the scene
  101829. */
  101830. BaseParticleSystem.prototype.getScene = function () {
  101831. return this._scene;
  101832. };
  101833. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  101834. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  101835. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  101836. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  101837. };
  101838. /**
  101839. * Gets the current list of drag gradients.
  101840. * You must use addDragGradient and removeDragGradient to udpate this list
  101841. * @returns the list of drag gradients
  101842. */
  101843. BaseParticleSystem.prototype.getDragGradients = function () {
  101844. return this._dragGradients;
  101845. };
  101846. /**
  101847. * Gets the current list of limit velocity gradients.
  101848. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  101849. * @returns the list of limit velocity gradients
  101850. */
  101851. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  101852. return this._limitVelocityGradients;
  101853. };
  101854. /**
  101855. * Gets the current list of color gradients.
  101856. * You must use addColorGradient and removeColorGradient to udpate this list
  101857. * @returns the list of color gradients
  101858. */
  101859. BaseParticleSystem.prototype.getColorGradients = function () {
  101860. return this._colorGradients;
  101861. };
  101862. /**
  101863. * Gets the current list of size gradients.
  101864. * You must use addSizeGradient and removeSizeGradient to udpate this list
  101865. * @returns the list of size gradients
  101866. */
  101867. BaseParticleSystem.prototype.getSizeGradients = function () {
  101868. return this._sizeGradients;
  101869. };
  101870. /**
  101871. * Gets the current list of color remap gradients.
  101872. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  101873. * @returns the list of color remap gradients
  101874. */
  101875. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  101876. return this._colorRemapGradients;
  101877. };
  101878. /**
  101879. * Gets the current list of alpha remap gradients.
  101880. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  101881. * @returns the list of alpha remap gradients
  101882. */
  101883. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  101884. return this._alphaRemapGradients;
  101885. };
  101886. /**
  101887. * Gets the current list of life time gradients.
  101888. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  101889. * @returns the list of life time gradients
  101890. */
  101891. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  101892. return this._lifeTimeGradients;
  101893. };
  101894. /**
  101895. * Gets the current list of angular speed gradients.
  101896. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  101897. * @returns the list of angular speed gradients
  101898. */
  101899. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  101900. return this._angularSpeedGradients;
  101901. };
  101902. /**
  101903. * Gets the current list of velocity gradients.
  101904. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  101905. * @returns the list of velocity gradients
  101906. */
  101907. BaseParticleSystem.prototype.getVelocityGradients = function () {
  101908. return this._velocityGradients;
  101909. };
  101910. /**
  101911. * Gets the current list of start size gradients.
  101912. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  101913. * @returns the list of start size gradients
  101914. */
  101915. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  101916. return this._startSizeGradients;
  101917. };
  101918. /**
  101919. * Gets the current list of emit rate gradients.
  101920. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  101921. * @returns the list of emit rate gradients
  101922. */
  101923. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  101924. return this._emitRateGradients;
  101925. };
  101926. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  101927. /**
  101928. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101929. * This only works when particleEmitterTyps is a BoxParticleEmitter
  101930. */
  101931. get: function () {
  101932. if (this.particleEmitterType.direction1) {
  101933. return this.particleEmitterType.direction1;
  101934. }
  101935. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101936. },
  101937. set: function (value) {
  101938. if (this.particleEmitterType.direction1) {
  101939. this.particleEmitterType.direction1 = value;
  101940. }
  101941. },
  101942. enumerable: true,
  101943. configurable: true
  101944. });
  101945. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  101946. /**
  101947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101948. * This only works when particleEmitterTyps is a BoxParticleEmitter
  101949. */
  101950. get: function () {
  101951. if (this.particleEmitterType.direction2) {
  101952. return this.particleEmitterType.direction2;
  101953. }
  101954. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101955. },
  101956. set: function (value) {
  101957. if (this.particleEmitterType.direction2) {
  101958. this.particleEmitterType.direction2 = value;
  101959. }
  101960. },
  101961. enumerable: true,
  101962. configurable: true
  101963. });
  101964. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  101965. /**
  101966. * 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.
  101967. * This only works when particleEmitterTyps is a BoxParticleEmitter
  101968. */
  101969. get: function () {
  101970. if (this.particleEmitterType.minEmitBox) {
  101971. return this.particleEmitterType.minEmitBox;
  101972. }
  101973. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101974. },
  101975. set: function (value) {
  101976. if (this.particleEmitterType.minEmitBox) {
  101977. this.particleEmitterType.minEmitBox = value;
  101978. }
  101979. },
  101980. enumerable: true,
  101981. configurable: true
  101982. });
  101983. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  101984. /**
  101985. * 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.
  101986. * This only works when particleEmitterTyps is a BoxParticleEmitter
  101987. */
  101988. get: function () {
  101989. if (this.particleEmitterType.maxEmitBox) {
  101990. return this.particleEmitterType.maxEmitBox;
  101991. }
  101992. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101993. },
  101994. set: function (value) {
  101995. if (this.particleEmitterType.maxEmitBox) {
  101996. this.particleEmitterType.maxEmitBox = value;
  101997. }
  101998. },
  101999. enumerable: true,
  102000. configurable: true
  102001. });
  102002. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  102003. /**
  102004. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102005. */
  102006. get: function () {
  102007. return this._isBillboardBased;
  102008. },
  102009. set: function (value) {
  102010. if (this._isBillboardBased === value) {
  102011. return;
  102012. }
  102013. this._isBillboardBased = value;
  102014. this._reset();
  102015. },
  102016. enumerable: true,
  102017. configurable: true
  102018. });
  102019. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  102020. /**
  102021. * Gets the image processing configuration used either in this material.
  102022. */
  102023. get: function () {
  102024. return this._imageProcessingConfiguration;
  102025. },
  102026. /**
  102027. * Sets the Default image processing configuration used either in the this material.
  102028. *
  102029. * If sets to null, the scene one is in use.
  102030. */
  102031. set: function (value) {
  102032. this._attachImageProcessingConfiguration(value);
  102033. },
  102034. enumerable: true,
  102035. configurable: true
  102036. });
  102037. /**
  102038. * Attaches a new image processing configuration to the Standard Material.
  102039. * @param configuration
  102040. */
  102041. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  102042. if (configuration === this._imageProcessingConfiguration) {
  102043. return;
  102044. }
  102045. // Pick the scene configuration if needed.
  102046. if (!configuration) {
  102047. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  102048. }
  102049. else {
  102050. this._imageProcessingConfiguration = configuration;
  102051. }
  102052. };
  102053. /** @hidden */
  102054. BaseParticleSystem.prototype._reset = function () {
  102055. };
  102056. /** @hidden */
  102057. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102058. if (!gradients) {
  102059. return this;
  102060. }
  102061. var index = 0;
  102062. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  102063. var valueGradient = gradients_1[_i];
  102064. if (valueGradient.gradient === gradient) {
  102065. gradients.splice(index, 1);
  102066. break;
  102067. }
  102068. index++;
  102069. }
  102070. if (texture) {
  102071. texture.dispose();
  102072. }
  102073. return this;
  102074. };
  102075. /**
  102076. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102077. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102078. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102079. * @returns the emitter
  102080. */
  102081. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  102082. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  102083. particleEmitter.direction1 = direction1;
  102084. particleEmitter.direction2 = direction2;
  102085. this.particleEmitterType = particleEmitter;
  102086. return particleEmitter;
  102087. };
  102088. /**
  102089. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102090. * @param radius The radius of the hemisphere to emit from
  102091. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102092. * @returns the emitter
  102093. */
  102094. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  102095. if (radius === void 0) { radius = 1; }
  102096. if (radiusRange === void 0) { radiusRange = 1; }
  102097. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  102098. this.particleEmitterType = particleEmitter;
  102099. return particleEmitter;
  102100. };
  102101. /**
  102102. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102103. * @param radius The radius of the sphere to emit from
  102104. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102105. * @returns the emitter
  102106. */
  102107. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  102108. if (radius === void 0) { radius = 1; }
  102109. if (radiusRange === void 0) { radiusRange = 1; }
  102110. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  102111. this.particleEmitterType = particleEmitter;
  102112. return particleEmitter;
  102113. };
  102114. /**
  102115. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102116. * @param radius The radius of the sphere to emit from
  102117. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102118. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102119. * @returns the emitter
  102120. */
  102121. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  102122. if (radius === void 0) { radius = 1; }
  102123. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102124. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102125. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  102126. this.particleEmitterType = particleEmitter;
  102127. return particleEmitter;
  102128. };
  102129. /**
  102130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102131. * @param radius The radius of the emission cylinder
  102132. * @param height The height of the emission cylinder
  102133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102135. * @returns the emitter
  102136. */
  102137. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  102138. if (radius === void 0) { radius = 1; }
  102139. if (height === void 0) { height = 1; }
  102140. if (radiusRange === void 0) { radiusRange = 1; }
  102141. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102142. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  102143. this.particleEmitterType = particleEmitter;
  102144. return particleEmitter;
  102145. };
  102146. /**
  102147. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102148. * @param radius The radius of the cylinder to emit from
  102149. * @param height The height of the emission cylinder
  102150. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102151. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102152. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102153. * @returns the emitter
  102154. */
  102155. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  102156. if (radius === void 0) { radius = 1; }
  102157. if (height === void 0) { height = 1; }
  102158. if (radiusRange === void 0) { radiusRange = 1; }
  102159. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102160. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102161. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  102162. this.particleEmitterType = particleEmitter;
  102163. return particleEmitter;
  102164. };
  102165. /**
  102166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102167. * @param radius The radius of the cone to emit from
  102168. * @param angle The base angle of the cone
  102169. * @returns the emitter
  102170. */
  102171. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  102172. if (radius === void 0) { radius = 1; }
  102173. if (angle === void 0) { angle = Math.PI / 4; }
  102174. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  102175. this.particleEmitterType = particleEmitter;
  102176. return particleEmitter;
  102177. };
  102178. /**
  102179. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102182. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102183. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102184. * @returns the emitter
  102185. */
  102186. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  102187. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  102188. this.particleEmitterType = particleEmitter;
  102189. this.direction1 = direction1;
  102190. this.direction2 = direction2;
  102191. this.minEmitBox = minEmitBox;
  102192. this.maxEmitBox = maxEmitBox;
  102193. return particleEmitter;
  102194. };
  102195. /**
  102196. * Source color is added to the destination color without alpha affecting the result
  102197. */
  102198. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  102199. /**
  102200. * Blend current color and particle color using particle’s alpha
  102201. */
  102202. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  102203. /**
  102204. * Add current color and particle color multiplied by particle’s alpha
  102205. */
  102206. BaseParticleSystem.BLENDMODE_ADD = 2;
  102207. /**
  102208. * Multiply current color with particle color
  102209. */
  102210. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  102211. /**
  102212. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  102213. */
  102214. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  102215. return BaseParticleSystem;
  102216. }());
  102217. /***/ }),
  102218. /***/ "./Particles/gpuParticleSystem.ts":
  102219. /*!****************************************!*\
  102220. !*** ./Particles/gpuParticleSystem.ts ***!
  102221. \****************************************/
  102222. /*! exports provided: GPUParticleSystem */
  102223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102224. "use strict";
  102225. __webpack_require__.r(__webpack_exports__);
  102226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  102227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102228. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  102229. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  102230. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102231. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102232. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  102233. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  102234. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  102235. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102236. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  102237. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  102238. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  102239. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102240. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102241. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  102242. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102243. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102244. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102245. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  102246. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  102247. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  102248. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  102249. /**
  102250. * This represents a GPU particle system in Babylon
  102251. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  102252. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  102253. */
  102254. var GPUParticleSystem = /** @class */ (function (_super) {
  102255. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  102256. /**
  102257. * Instantiates a GPU particle system.
  102258. * 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.
  102259. * @param name The name of the particle system
  102260. * @param options The options used to create the system
  102261. * @param scene The scene the particle system belongs to
  102262. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  102263. */
  102264. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  102265. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  102266. var _this = _super.call(this, name) || this;
  102267. /**
  102268. * The layer mask we are rendering the particles through.
  102269. */
  102270. _this.layerMask = 0x0FFFFFFF;
  102271. _this._accumulatedCount = 0;
  102272. _this._targetIndex = 0;
  102273. _this._currentRenderId = -1;
  102274. _this._started = false;
  102275. _this._stopped = false;
  102276. _this._timeDelta = 0;
  102277. _this._actualFrame = 0;
  102278. _this._rawTextureWidth = 256;
  102279. /**
  102280. * An event triggered when the system is disposed.
  102281. */
  102282. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  102283. /**
  102284. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102285. * to override the particles.
  102286. */
  102287. _this.forceDepthWrite = false;
  102288. _this._preWarmDone = false;
  102289. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  102290. // Setup the default processing configuration to the scene.
  102291. _this._attachImageProcessingConfiguration(null);
  102292. _this._engine = _this._scene.getEngine();
  102293. if (!options.randomTextureSize) {
  102294. delete options.randomTextureSize;
  102295. }
  102296. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  102297. var optionsAsNumber = options;
  102298. if (isFinite(optionsAsNumber)) {
  102299. fullOptions.capacity = optionsAsNumber;
  102300. }
  102301. _this._capacity = fullOptions.capacity;
  102302. _this._activeCount = fullOptions.capacity;
  102303. _this._currentActiveCount = 0;
  102304. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  102305. _this._scene.particleSystems.push(_this);
  102306. _this._updateEffectOptions = {
  102307. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  102308. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  102309. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  102310. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  102311. uniformBuffersNames: [],
  102312. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  102313. defines: "",
  102314. fallbacks: null,
  102315. onCompiled: null,
  102316. onError: null,
  102317. indexParameters: null,
  102318. maxSimultaneousLights: 0,
  102319. transformFeedbackVaryings: []
  102320. };
  102321. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  102322. // Random data
  102323. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  102324. var d = [];
  102325. for (var i = 0; i < maxTextureSize; ++i) {
  102326. d.push(Math.random());
  102327. d.push(Math.random());
  102328. d.push(Math.random());
  102329. d.push(Math.random());
  102330. }
  102331. _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);
  102332. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102333. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102334. d = [];
  102335. for (var i = 0; i < maxTextureSize; ++i) {
  102336. d.push(Math.random());
  102337. d.push(Math.random());
  102338. d.push(Math.random());
  102339. d.push(Math.random());
  102340. }
  102341. _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);
  102342. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102343. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102344. _this._randomTextureSize = maxTextureSize;
  102345. return _this;
  102346. }
  102347. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  102348. /**
  102349. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  102350. */
  102351. get: function () {
  102352. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  102353. return false;
  102354. }
  102355. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  102356. },
  102357. enumerable: true,
  102358. configurable: true
  102359. });
  102360. /**
  102361. * Gets the maximum number of particles active at the same time.
  102362. * @returns The max number of active particles.
  102363. */
  102364. GPUParticleSystem.prototype.getCapacity = function () {
  102365. return this._capacity;
  102366. };
  102367. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  102368. /**
  102369. * Gets or set the number of active particles
  102370. */
  102371. get: function () {
  102372. return this._activeCount;
  102373. },
  102374. set: function (value) {
  102375. this._activeCount = Math.min(value, this._capacity);
  102376. },
  102377. enumerable: true,
  102378. configurable: true
  102379. });
  102380. /**
  102381. * Is this system ready to be used/rendered
  102382. * @return true if the system is ready
  102383. */
  102384. GPUParticleSystem.prototype.isReady = function () {
  102385. if (!this._updateEffect) {
  102386. this._recreateUpdateEffect();
  102387. this._recreateRenderEffect();
  102388. return false;
  102389. }
  102390. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  102391. return false;
  102392. }
  102393. return true;
  102394. };
  102395. /**
  102396. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102397. * @returns True if it has been started, otherwise false.
  102398. */
  102399. GPUParticleSystem.prototype.isStarted = function () {
  102400. return this._started;
  102401. };
  102402. /**
  102403. * Starts the particle system and begins to emit
  102404. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  102405. */
  102406. GPUParticleSystem.prototype.start = function (delay) {
  102407. var _this = this;
  102408. if (delay === void 0) { delay = this.startDelay; }
  102409. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  102410. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  102411. }
  102412. if (delay) {
  102413. setTimeout(function () {
  102414. _this.start(0);
  102415. }, delay);
  102416. return;
  102417. }
  102418. this._started = true;
  102419. this._stopped = false;
  102420. this._preWarmDone = false;
  102421. // Animations
  102422. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  102423. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  102424. }
  102425. };
  102426. /**
  102427. * Stops the particle system.
  102428. */
  102429. GPUParticleSystem.prototype.stop = function () {
  102430. this._stopped = true;
  102431. };
  102432. /**
  102433. * Remove all active particles
  102434. */
  102435. GPUParticleSystem.prototype.reset = function () {
  102436. this._releaseBuffers();
  102437. this._releaseVAOs();
  102438. this._currentActiveCount = 0;
  102439. this._targetIndex = 0;
  102440. };
  102441. /**
  102442. * Returns the string "GPUParticleSystem"
  102443. * @returns a string containing the class name
  102444. */
  102445. GPUParticleSystem.prototype.getClassName = function () {
  102446. return "GPUParticleSystem";
  102447. };
  102448. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102449. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  102450. this._releaseBuffers();
  102451. return this;
  102452. };
  102453. /**
  102454. * Adds a new color gradient
  102455. * @param gradient defines the gradient to use (between 0 and 1)
  102456. * @param color1 defines the color to affect to the specified gradient
  102457. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102458. * @returns the current particle system
  102459. */
  102460. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  102461. if (!this._colorGradients) {
  102462. this._colorGradients = [];
  102463. }
  102464. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  102465. colorGradient.gradient = gradient;
  102466. colorGradient.color1 = color1;
  102467. this._colorGradients.push(colorGradient);
  102468. this._colorGradients.sort(function (a, b) {
  102469. if (a.gradient < b.gradient) {
  102470. return -1;
  102471. }
  102472. else if (a.gradient > b.gradient) {
  102473. return 1;
  102474. }
  102475. return 0;
  102476. });
  102477. if (this._colorGradientsTexture) {
  102478. this._colorGradientsTexture.dispose();
  102479. this._colorGradientsTexture = null;
  102480. }
  102481. this._releaseBuffers();
  102482. return this;
  102483. };
  102484. /**
  102485. * Remove a specific color gradient
  102486. * @param gradient defines the gradient to remove
  102487. * @returns the current particle system
  102488. */
  102489. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  102490. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  102491. this._colorGradientsTexture = null;
  102492. return this;
  102493. };
  102494. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  102495. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  102496. valueGradient.gradient = gradient;
  102497. valueGradient.factor1 = factor;
  102498. factorGradients.push(valueGradient);
  102499. factorGradients.sort(function (a, b) {
  102500. if (a.gradient < b.gradient) {
  102501. return -1;
  102502. }
  102503. else if (a.gradient > b.gradient) {
  102504. return 1;
  102505. }
  102506. return 0;
  102507. });
  102508. this._releaseBuffers();
  102509. };
  102510. /**
  102511. * Adds a new size gradient
  102512. * @param gradient defines the gradient to use (between 0 and 1)
  102513. * @param factor defines the size factor to affect to the specified gradient
  102514. * @returns the current particle system
  102515. */
  102516. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  102517. if (!this._sizeGradients) {
  102518. this._sizeGradients = [];
  102519. }
  102520. this._addFactorGradient(this._sizeGradients, gradient, factor);
  102521. if (this._sizeGradientsTexture) {
  102522. this._sizeGradientsTexture.dispose();
  102523. this._sizeGradientsTexture = null;
  102524. }
  102525. this._releaseBuffers();
  102526. return this;
  102527. };
  102528. /**
  102529. * Remove a specific size gradient
  102530. * @param gradient defines the gradient to remove
  102531. * @returns the current particle system
  102532. */
  102533. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  102534. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  102535. this._sizeGradientsTexture = null;
  102536. return this;
  102537. };
  102538. /**
  102539. * Adds a new angular speed gradient
  102540. * @param gradient defines the gradient to use (between 0 and 1)
  102541. * @param factor defines the angular speed to affect to the specified gradient
  102542. * @returns the current particle system
  102543. */
  102544. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  102545. if (!this._angularSpeedGradients) {
  102546. this._angularSpeedGradients = [];
  102547. }
  102548. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  102549. if (this._angularSpeedGradientsTexture) {
  102550. this._angularSpeedGradientsTexture.dispose();
  102551. this._angularSpeedGradientsTexture = null;
  102552. }
  102553. this._releaseBuffers();
  102554. return this;
  102555. };
  102556. /**
  102557. * Remove a specific angular speed gradient
  102558. * @param gradient defines the gradient to remove
  102559. * @returns the current particle system
  102560. */
  102561. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  102562. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  102563. this._angularSpeedGradientsTexture = null;
  102564. return this;
  102565. };
  102566. /**
  102567. * Adds a new velocity gradient
  102568. * @param gradient defines the gradient to use (between 0 and 1)
  102569. * @param factor defines the velocity to affect to the specified gradient
  102570. * @returns the current particle system
  102571. */
  102572. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  102573. if (!this._velocityGradients) {
  102574. this._velocityGradients = [];
  102575. }
  102576. this._addFactorGradient(this._velocityGradients, gradient, factor);
  102577. if (this._velocityGradientsTexture) {
  102578. this._velocityGradientsTexture.dispose();
  102579. this._velocityGradientsTexture = null;
  102580. }
  102581. this._releaseBuffers();
  102582. return this;
  102583. };
  102584. /**
  102585. * Remove a specific velocity gradient
  102586. * @param gradient defines the gradient to remove
  102587. * @returns the current particle system
  102588. */
  102589. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  102590. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  102591. this._velocityGradientsTexture = null;
  102592. return this;
  102593. };
  102594. /**
  102595. * Adds a new limit velocity gradient
  102596. * @param gradient defines the gradient to use (between 0 and 1)
  102597. * @param factor defines the limit velocity value to affect to the specified gradient
  102598. * @returns the current particle system
  102599. */
  102600. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  102601. if (!this._limitVelocityGradients) {
  102602. this._limitVelocityGradients = [];
  102603. }
  102604. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  102605. if (this._limitVelocityGradientsTexture) {
  102606. this._limitVelocityGradientsTexture.dispose();
  102607. this._limitVelocityGradientsTexture = null;
  102608. }
  102609. this._releaseBuffers();
  102610. return this;
  102611. };
  102612. /**
  102613. * Remove a specific limit velocity gradient
  102614. * @param gradient defines the gradient to remove
  102615. * @returns the current particle system
  102616. */
  102617. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  102618. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  102619. this._limitVelocityGradientsTexture = null;
  102620. return this;
  102621. };
  102622. /**
  102623. * Adds a new drag gradient
  102624. * @param gradient defines the gradient to use (between 0 and 1)
  102625. * @param factor defines the drag value to affect to the specified gradient
  102626. * @returns the current particle system
  102627. */
  102628. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  102629. if (!this._dragGradients) {
  102630. this._dragGradients = [];
  102631. }
  102632. this._addFactorGradient(this._dragGradients, gradient, factor);
  102633. if (this._dragGradientsTexture) {
  102634. this._dragGradientsTexture.dispose();
  102635. this._dragGradientsTexture = null;
  102636. }
  102637. this._releaseBuffers();
  102638. return this;
  102639. };
  102640. /**
  102641. * Remove a specific drag gradient
  102642. * @param gradient defines the gradient to remove
  102643. * @returns the current particle system
  102644. */
  102645. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  102646. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  102647. this._dragGradientsTexture = null;
  102648. return this;
  102649. };
  102650. /**
  102651. * Not supported by GPUParticleSystem
  102652. * @param gradient defines the gradient to use (between 0 and 1)
  102653. * @param factor defines the emit rate value to affect to the specified gradient
  102654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102655. * @returns the current particle system
  102656. */
  102657. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  102658. // Do nothing as emit rate is not supported by GPUParticleSystem
  102659. return this;
  102660. };
  102661. /**
  102662. * Not supported by GPUParticleSystem
  102663. * @param gradient defines the gradient to remove
  102664. * @returns the current particle system
  102665. */
  102666. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  102667. // Do nothing as emit rate is not supported by GPUParticleSystem
  102668. return this;
  102669. };
  102670. /**
  102671. * Not supported by GPUParticleSystem
  102672. * @param gradient defines the gradient to use (between 0 and 1)
  102673. * @param factor defines the start size value to affect to the specified gradient
  102674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102675. * @returns the current particle system
  102676. */
  102677. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  102678. // Do nothing as start size is not supported by GPUParticleSystem
  102679. return this;
  102680. };
  102681. /**
  102682. * Not supported by GPUParticleSystem
  102683. * @param gradient defines the gradient to remove
  102684. * @returns the current particle system
  102685. */
  102686. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  102687. // Do nothing as start size is not supported by GPUParticleSystem
  102688. return this;
  102689. };
  102690. /**
  102691. * Not supported by GPUParticleSystem
  102692. * @param gradient defines the gradient to use (between 0 and 1)
  102693. * @param min defines the color remap minimal range
  102694. * @param max defines the color remap maximal range
  102695. * @returns the current particle system
  102696. */
  102697. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  102698. // Do nothing as start size is not supported by GPUParticleSystem
  102699. return this;
  102700. };
  102701. /**
  102702. * Not supported by GPUParticleSystem
  102703. * @param gradient defines the gradient to remove
  102704. * @returns the current particle system
  102705. */
  102706. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  102707. // Do nothing as start size is not supported by GPUParticleSystem
  102708. return this;
  102709. };
  102710. /**
  102711. * Not supported by GPUParticleSystem
  102712. * @param gradient defines the gradient to use (between 0 and 1)
  102713. * @param min defines the alpha remap minimal range
  102714. * @param max defines the alpha remap maximal range
  102715. * @returns the current particle system
  102716. */
  102717. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  102718. // Do nothing as start size is not supported by GPUParticleSystem
  102719. return this;
  102720. };
  102721. /**
  102722. * Not supported by GPUParticleSystem
  102723. * @param gradient defines the gradient to remove
  102724. * @returns the current particle system
  102725. */
  102726. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  102727. // Do nothing as start size is not supported by GPUParticleSystem
  102728. return this;
  102729. };
  102730. /**
  102731. * Not supported by GPUParticleSystem
  102732. * @param gradient defines the gradient to use (between 0 and 1)
  102733. * @param color defines the color to affect to the specified gradient
  102734. * @returns the current particle system
  102735. */
  102736. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  102737. //Not supported by GPUParticleSystem
  102738. return this;
  102739. };
  102740. /**
  102741. * Not supported by GPUParticleSystem
  102742. * @param gradient defines the gradient to remove
  102743. * @returns the current particle system
  102744. */
  102745. GPUParticleSystem.prototype.removeRampGradient = function () {
  102746. //Not supported by GPUParticleSystem
  102747. return this;
  102748. };
  102749. /**
  102750. * Not supported by GPUParticleSystem
  102751. * @returns the list of ramp gradients
  102752. */
  102753. GPUParticleSystem.prototype.getRampGradients = function () {
  102754. return null;
  102755. };
  102756. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  102757. /**
  102758. * Not supported by GPUParticleSystem
  102759. * Gets or sets a boolean indicating that ramp gradients must be used
  102760. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102761. */
  102762. get: function () {
  102763. //Not supported by GPUParticleSystem
  102764. return false;
  102765. },
  102766. set: function (value) {
  102767. //Not supported by GPUParticleSystem
  102768. },
  102769. enumerable: true,
  102770. configurable: true
  102771. });
  102772. /**
  102773. * Not supported by GPUParticleSystem
  102774. * @param gradient defines the gradient to use (between 0 and 1)
  102775. * @param factor defines the life time factor to affect to the specified gradient
  102776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102777. * @returns the current particle system
  102778. */
  102779. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  102780. //Not supported by GPUParticleSystem
  102781. return this;
  102782. };
  102783. /**
  102784. * Not supported by GPUParticleSystem
  102785. * @param gradient defines the gradient to remove
  102786. * @returns the current particle system
  102787. */
  102788. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  102789. //Not supported by GPUParticleSystem
  102790. return this;
  102791. };
  102792. GPUParticleSystem.prototype._reset = function () {
  102793. this._releaseBuffers();
  102794. };
  102795. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  102796. var updateVertexBuffers = {};
  102797. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  102798. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  102799. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  102800. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  102801. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  102802. var offset = 12;
  102803. if (!this._colorGradientsTexture) {
  102804. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  102805. offset += 4;
  102806. }
  102807. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  102808. offset += 3;
  102809. if (!this._isBillboardBased) {
  102810. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  102811. offset += 3;
  102812. }
  102813. if (this._angularSpeedGradientsTexture) {
  102814. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  102815. offset += 1;
  102816. }
  102817. else {
  102818. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  102819. offset += 2;
  102820. }
  102821. if (this._isAnimationSheetEnabled) {
  102822. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  102823. offset += 1;
  102824. if (this.spriteRandomStartCell) {
  102825. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  102826. offset += 1;
  102827. }
  102828. }
  102829. if (this.noiseTexture) {
  102830. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  102831. offset += 3;
  102832. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  102833. offset += 3;
  102834. }
  102835. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  102836. this._engine.bindArrayBuffer(null);
  102837. return vao;
  102838. };
  102839. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  102840. var renderVertexBuffers = {};
  102841. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  102842. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  102843. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  102844. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  102845. var offset = 12;
  102846. if (!this._colorGradientsTexture) {
  102847. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  102848. offset += 4;
  102849. }
  102850. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  102851. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  102852. }
  102853. offset += 3; // Direction
  102854. if (!this._isBillboardBased) {
  102855. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  102856. offset += 3;
  102857. }
  102858. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  102859. if (this._angularSpeedGradientsTexture) {
  102860. offset++;
  102861. }
  102862. else {
  102863. offset += 2;
  102864. }
  102865. if (this._isAnimationSheetEnabled) {
  102866. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  102867. offset += 1;
  102868. if (this.spriteRandomStartCell) {
  102869. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  102870. offset += 1;
  102871. }
  102872. }
  102873. if (this.noiseTexture) {
  102874. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  102875. offset += 3;
  102876. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  102877. offset += 3;
  102878. }
  102879. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  102880. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  102881. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  102882. this._engine.bindArrayBuffer(null);
  102883. return vao;
  102884. };
  102885. GPUParticleSystem.prototype._initialize = function (force) {
  102886. if (force === void 0) { force = false; }
  102887. if (this._buffer0 && !force) {
  102888. return;
  102889. }
  102890. var engine = this._scene.getEngine();
  102891. var data = new Array();
  102892. this._attributesStrideSize = 21;
  102893. this._targetIndex = 0;
  102894. if (!this.isBillboardBased) {
  102895. this._attributesStrideSize += 3;
  102896. }
  102897. if (this._colorGradientsTexture) {
  102898. this._attributesStrideSize -= 4;
  102899. }
  102900. if (this._angularSpeedGradientsTexture) {
  102901. this._attributesStrideSize -= 1;
  102902. }
  102903. if (this._isAnimationSheetEnabled) {
  102904. this._attributesStrideSize += 1;
  102905. if (this.spriteRandomStartCell) {
  102906. this._attributesStrideSize += 1;
  102907. }
  102908. }
  102909. if (this.noiseTexture) {
  102910. this._attributesStrideSize += 6;
  102911. }
  102912. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  102913. // position
  102914. data.push(0.0);
  102915. data.push(0.0);
  102916. data.push(0.0);
  102917. // Age and life
  102918. data.push(0.0); // create the particle as a dead one to create a new one at start
  102919. data.push(0.0);
  102920. // Seed
  102921. data.push(Math.random());
  102922. data.push(Math.random());
  102923. data.push(Math.random());
  102924. data.push(Math.random());
  102925. // Size
  102926. data.push(0.0);
  102927. data.push(0.0);
  102928. data.push(0.0);
  102929. if (!this._colorGradientsTexture) {
  102930. // color
  102931. data.push(0.0);
  102932. data.push(0.0);
  102933. data.push(0.0);
  102934. data.push(0.0);
  102935. }
  102936. // direction
  102937. data.push(0.0);
  102938. data.push(0.0);
  102939. data.push(0.0);
  102940. if (!this.isBillboardBased) {
  102941. // initialDirection
  102942. data.push(0.0);
  102943. data.push(0.0);
  102944. data.push(0.0);
  102945. }
  102946. // angle
  102947. data.push(0.0);
  102948. if (!this._angularSpeedGradientsTexture) {
  102949. data.push(0.0);
  102950. }
  102951. if (this._isAnimationSheetEnabled) {
  102952. data.push(0.0);
  102953. if (this.spriteRandomStartCell) {
  102954. data.push(0.0);
  102955. }
  102956. }
  102957. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  102958. data.push(Math.random());
  102959. data.push(Math.random());
  102960. data.push(Math.random());
  102961. data.push(Math.random());
  102962. data.push(Math.random());
  102963. data.push(Math.random());
  102964. }
  102965. }
  102966. // Sprite data
  102967. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  102968. -0.5, 0.5, 0, 1,
  102969. -0.5, -0.5, 0, 0,
  102970. 0.5, -0.5, 1, 0]);
  102971. // Buffers
  102972. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  102973. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  102974. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  102975. // Update VAO
  102976. this._updateVAO = [];
  102977. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  102978. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  102979. // Render VAO
  102980. this._renderVAO = [];
  102981. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  102982. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  102983. // Links
  102984. this._sourceBuffer = this._buffer0;
  102985. this._targetBuffer = this._buffer1;
  102986. };
  102987. /** @hidden */
  102988. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  102989. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  102990. if (this._isBillboardBased) {
  102991. defines += "\n#define BILLBOARD";
  102992. }
  102993. if (this._colorGradientsTexture) {
  102994. defines += "\n#define COLORGRADIENTS";
  102995. }
  102996. if (this._sizeGradientsTexture) {
  102997. defines += "\n#define SIZEGRADIENTS";
  102998. }
  102999. if (this._angularSpeedGradientsTexture) {
  103000. defines += "\n#define ANGULARSPEEDGRADIENTS";
  103001. }
  103002. if (this._velocityGradientsTexture) {
  103003. defines += "\n#define VELOCITYGRADIENTS";
  103004. }
  103005. if (this._limitVelocityGradientsTexture) {
  103006. defines += "\n#define LIMITVELOCITYGRADIENTS";
  103007. }
  103008. if (this._dragGradientsTexture) {
  103009. defines += "\n#define DRAGGRADIENTS";
  103010. }
  103011. if (this.isAnimationSheetEnabled) {
  103012. defines += "\n#define ANIMATESHEET";
  103013. if (this.spriteRandomStartCell) {
  103014. defines += "\n#define ANIMATESHEETRANDOMSTART";
  103015. }
  103016. }
  103017. if (this.noiseTexture) {
  103018. defines += "\n#define NOISE";
  103019. }
  103020. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  103021. return;
  103022. }
  103023. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  103024. if (!this._colorGradientsTexture) {
  103025. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  103026. }
  103027. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  103028. if (!this._isBillboardBased) {
  103029. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  103030. }
  103031. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  103032. if (this.isAnimationSheetEnabled) {
  103033. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  103034. if (this.spriteRandomStartCell) {
  103035. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  103036. }
  103037. }
  103038. if (this.noiseTexture) {
  103039. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  103040. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  103041. }
  103042. this._updateEffectOptions.defines = defines;
  103043. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  103044. };
  103045. /** @hidden */
  103046. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  103047. var defines = "";
  103048. if (this._scene.clipPlane) {
  103049. defines = "\n#define CLIPPLANE";
  103050. }
  103051. if (this._scene.clipPlane2) {
  103052. defines = "\n#define CLIPPLANE2";
  103053. }
  103054. if (this._scene.clipPlane3) {
  103055. defines = "\n#define CLIPPLANE3";
  103056. }
  103057. if (this._scene.clipPlane4) {
  103058. defines = "\n#define CLIPPLANE4";
  103059. }
  103060. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  103061. defines = "\n#define BLENDMULTIPLYMODE";
  103062. }
  103063. if (this._isBillboardBased) {
  103064. defines += "\n#define BILLBOARD";
  103065. switch (this.billboardMode) {
  103066. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  103067. defines += "\n#define BILLBOARDY";
  103068. break;
  103069. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  103070. defines += "\n#define BILLBOARDSTRETCHED";
  103071. break;
  103072. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  103073. default:
  103074. break;
  103075. }
  103076. }
  103077. if (this._colorGradientsTexture) {
  103078. defines += "\n#define COLORGRADIENTS";
  103079. }
  103080. if (this.isAnimationSheetEnabled) {
  103081. defines += "\n#define ANIMATESHEET";
  103082. }
  103083. if (this._imageProcessingConfiguration) {
  103084. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  103085. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  103086. }
  103087. if (this._renderEffect && this._renderEffect.defines === defines) {
  103088. return;
  103089. }
  103090. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  103091. var samplers = ["textureSampler", "colorGradientSampler"];
  103092. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  103093. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  103094. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  103095. }
  103096. 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);
  103097. };
  103098. /**
  103099. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  103100. * @param preWarm defines if we are in the pre-warmimg phase
  103101. */
  103102. GPUParticleSystem.prototype.animate = function (preWarm) {
  103103. if (preWarm === void 0) { preWarm = false; }
  103104. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  103105. this._actualFrame += this._timeDelta;
  103106. if (!this._stopped) {
  103107. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  103108. this.stop();
  103109. }
  103110. }
  103111. };
  103112. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  103113. var texture = this[textureName];
  103114. if (!factorGradients || !factorGradients.length || texture) {
  103115. return;
  103116. }
  103117. var data = new Float32Array(this._rawTextureWidth);
  103118. for (var x = 0; x < this._rawTextureWidth; x++) {
  103119. var ratio = x / this._rawTextureWidth;
  103120. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  103121. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  103122. });
  103123. }
  103124. 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);
  103125. };
  103126. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  103127. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  103128. };
  103129. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  103130. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  103131. };
  103132. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  103133. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  103134. };
  103135. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  103136. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  103137. };
  103138. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  103139. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  103140. };
  103141. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  103142. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  103143. return;
  103144. }
  103145. var data = new Uint8Array(this._rawTextureWidth * 4);
  103146. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  103147. for (var x = 0; x < this._rawTextureWidth; x++) {
  103148. var ratio = x / this._rawTextureWidth;
  103149. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  103150. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  103151. data[x * 4] = tmpColor.r * 255;
  103152. data[x * 4 + 1] = tmpColor.g * 255;
  103153. data[x * 4 + 2] = tmpColor.b * 255;
  103154. data[x * 4 + 3] = tmpColor.a * 255;
  103155. });
  103156. }
  103157. 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);
  103158. };
  103159. /**
  103160. * Renders the particle system in its current state
  103161. * @param preWarm defines if the system should only update the particles but not render them
  103162. * @returns the current number of particles
  103163. */
  103164. GPUParticleSystem.prototype.render = function (preWarm) {
  103165. if (preWarm === void 0) { preWarm = false; }
  103166. if (!this._started) {
  103167. return 0;
  103168. }
  103169. this._createColorGradientTexture();
  103170. this._createSizeGradientTexture();
  103171. this._createAngularSpeedGradientTexture();
  103172. this._createVelocityGradientTexture();
  103173. this._createLimitVelocityGradientTexture();
  103174. this._createDragGradientTexture();
  103175. this._recreateUpdateEffect();
  103176. this._recreateRenderEffect();
  103177. if (!this.isReady()) {
  103178. return 0;
  103179. }
  103180. if (!preWarm) {
  103181. if (!this._preWarmDone && this.preWarmCycles) {
  103182. for (var index = 0; index < this.preWarmCycles; index++) {
  103183. this.animate(true);
  103184. this.render(true);
  103185. }
  103186. this._preWarmDone = true;
  103187. }
  103188. if (this._currentRenderId === this._scene.getFrameId()) {
  103189. return 0;
  103190. }
  103191. this._currentRenderId = this._scene.getFrameId();
  103192. }
  103193. // Get everything ready to render
  103194. this._initialize();
  103195. this._accumulatedCount += this.emitRate * this._timeDelta;
  103196. if (this._accumulatedCount > 1) {
  103197. var intPart = this._accumulatedCount | 0;
  103198. this._accumulatedCount -= intPart;
  103199. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  103200. }
  103201. if (!this._currentActiveCount) {
  103202. return 0;
  103203. }
  103204. // Enable update effect
  103205. this._engine.enableEffect(this._updateEffect);
  103206. this._engine.setState(false);
  103207. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  103208. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  103209. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  103210. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  103211. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  103212. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  103213. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  103214. if (!this._colorGradientsTexture) {
  103215. this._updateEffect.setDirectColor4("color1", this.color1);
  103216. this._updateEffect.setDirectColor4("color2", this.color2);
  103217. }
  103218. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  103219. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  103220. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  103221. this._updateEffect.setVector3("gravity", this.gravity);
  103222. if (this._sizeGradientsTexture) {
  103223. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  103224. }
  103225. if (this._angularSpeedGradientsTexture) {
  103226. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  103227. }
  103228. if (this._velocityGradientsTexture) {
  103229. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  103230. }
  103231. if (this._limitVelocityGradientsTexture) {
  103232. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  103233. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  103234. }
  103235. if (this._dragGradientsTexture) {
  103236. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  103237. }
  103238. if (this.particleEmitterType) {
  103239. this.particleEmitterType.applyToShader(this._updateEffect);
  103240. }
  103241. if (this._isAnimationSheetEnabled) {
  103242. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  103243. }
  103244. if (this.noiseTexture) {
  103245. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  103246. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  103247. }
  103248. var emitterWM;
  103249. if (this.emitter.position) {
  103250. var emitterMesh = this.emitter;
  103251. emitterWM = emitterMesh.getWorldMatrix();
  103252. }
  103253. else {
  103254. var emitterPosition = this.emitter;
  103255. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  103256. }
  103257. this._updateEffect.setMatrix("emitterWM", emitterWM);
  103258. // Bind source VAO
  103259. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  103260. // Update
  103261. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  103262. this._engine.setRasterizerState(false);
  103263. this._engine.beginTransformFeedback(true);
  103264. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  103265. this._engine.endTransformFeedback();
  103266. this._engine.setRasterizerState(true);
  103267. this._engine.bindTransformFeedbackBuffer(null);
  103268. if (!preWarm) {
  103269. // Enable render effect
  103270. this._engine.enableEffect(this._renderEffect);
  103271. var viewMatrix = this._scene.getViewMatrix();
  103272. this._renderEffect.setMatrix("view", viewMatrix);
  103273. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  103274. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  103275. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  103276. if (this._colorGradientsTexture) {
  103277. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  103278. }
  103279. else {
  103280. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  103281. }
  103282. if (this._isAnimationSheetEnabled && this.particleTexture) {
  103283. var baseSize = this.particleTexture.getBaseSize();
  103284. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  103285. }
  103286. if (this._isBillboardBased) {
  103287. var camera = this._scene.activeCamera;
  103288. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  103289. }
  103290. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  103291. var invView = viewMatrix.clone();
  103292. invView.invert();
  103293. this._renderEffect.setMatrix("invView", invView);
  103294. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  103295. }
  103296. // image processing
  103297. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  103298. this._imageProcessingConfiguration.bind(this._renderEffect);
  103299. }
  103300. // Draw order
  103301. switch (this.blendMode) {
  103302. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  103303. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  103304. break;
  103305. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  103306. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  103307. break;
  103308. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  103309. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  103310. break;
  103311. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  103312. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  103313. break;
  103314. }
  103315. if (this.forceDepthWrite) {
  103316. this._engine.setDepthWrite(true);
  103317. }
  103318. // Bind source VAO
  103319. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  103320. // Render
  103321. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  103322. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  103323. }
  103324. // Switch VAOs
  103325. this._targetIndex++;
  103326. if (this._targetIndex === 2) {
  103327. this._targetIndex = 0;
  103328. }
  103329. // Switch buffers
  103330. var tmpBuffer = this._sourceBuffer;
  103331. this._sourceBuffer = this._targetBuffer;
  103332. this._targetBuffer = tmpBuffer;
  103333. return this._currentActiveCount;
  103334. };
  103335. /**
  103336. * Rebuilds the particle system
  103337. */
  103338. GPUParticleSystem.prototype.rebuild = function () {
  103339. this._initialize(true);
  103340. };
  103341. GPUParticleSystem.prototype._releaseBuffers = function () {
  103342. if (this._buffer0) {
  103343. this._buffer0.dispose();
  103344. this._buffer0 = null;
  103345. }
  103346. if (this._buffer1) {
  103347. this._buffer1.dispose();
  103348. this._buffer1 = null;
  103349. }
  103350. if (this._spriteBuffer) {
  103351. this._spriteBuffer.dispose();
  103352. this._spriteBuffer = null;
  103353. }
  103354. };
  103355. GPUParticleSystem.prototype._releaseVAOs = function () {
  103356. if (!this._updateVAO) {
  103357. return;
  103358. }
  103359. for (var index = 0; index < this._updateVAO.length; index++) {
  103360. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  103361. }
  103362. this._updateVAO = [];
  103363. for (var index = 0; index < this._renderVAO.length; index++) {
  103364. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  103365. }
  103366. this._renderVAO = [];
  103367. };
  103368. /**
  103369. * Disposes the particle system and free the associated resources
  103370. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  103371. */
  103372. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  103373. if (disposeTexture === void 0) { disposeTexture = true; }
  103374. var index = this._scene.particleSystems.indexOf(this);
  103375. if (index > -1) {
  103376. this._scene.particleSystems.splice(index, 1);
  103377. }
  103378. this._releaseBuffers();
  103379. this._releaseVAOs();
  103380. if (this._colorGradientsTexture) {
  103381. this._colorGradientsTexture.dispose();
  103382. this._colorGradientsTexture = null;
  103383. }
  103384. if (this._sizeGradientsTexture) {
  103385. this._sizeGradientsTexture.dispose();
  103386. this._sizeGradientsTexture = null;
  103387. }
  103388. if (this._angularSpeedGradientsTexture) {
  103389. this._angularSpeedGradientsTexture.dispose();
  103390. this._angularSpeedGradientsTexture = null;
  103391. }
  103392. if (this._velocityGradientsTexture) {
  103393. this._velocityGradientsTexture.dispose();
  103394. this._velocityGradientsTexture = null;
  103395. }
  103396. if (this._limitVelocityGradientsTexture) {
  103397. this._limitVelocityGradientsTexture.dispose();
  103398. this._limitVelocityGradientsTexture = null;
  103399. }
  103400. if (this._dragGradientsTexture) {
  103401. this._dragGradientsTexture.dispose();
  103402. this._dragGradientsTexture = null;
  103403. }
  103404. if (this._randomTexture) {
  103405. this._randomTexture.dispose();
  103406. this._randomTexture = null;
  103407. }
  103408. if (this._randomTexture2) {
  103409. this._randomTexture2.dispose();
  103410. this._randomTexture2 = null;
  103411. }
  103412. if (disposeTexture && this.particleTexture) {
  103413. this.particleTexture.dispose();
  103414. this.particleTexture = null;
  103415. }
  103416. if (disposeTexture && this.noiseTexture) {
  103417. this.noiseTexture.dispose();
  103418. this.noiseTexture = null;
  103419. }
  103420. // Callback
  103421. this.onDisposeObservable.notifyObservers(this);
  103422. this.onDisposeObservable.clear();
  103423. };
  103424. /**
  103425. * Clones the particle system.
  103426. * @param name The name of the cloned object
  103427. * @param newEmitter The new emitter to use
  103428. * @returns the cloned particle system
  103429. */
  103430. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  103431. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  103432. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  103433. if (newEmitter === undefined) {
  103434. newEmitter = this.emitter;
  103435. }
  103436. result.emitter = newEmitter;
  103437. if (this.particleTexture) {
  103438. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  103439. }
  103440. return result;
  103441. };
  103442. /**
  103443. * Serializes the particle system to a JSON object.
  103444. * @returns the JSON object
  103445. */
  103446. GPUParticleSystem.prototype.serialize = function () {
  103447. var serializationObject = {};
  103448. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  103449. serializationObject.activeParticleCount = this.activeParticleCount;
  103450. return serializationObject;
  103451. };
  103452. /**
  103453. * Parses a JSON object to create a GPU particle system.
  103454. * @param parsedParticleSystem The JSON object to parse
  103455. * @param scene The scene to create the particle system in
  103456. * @param rootUrl The root url to use to load external dependencies like texture
  103457. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  103458. * @returns the parsed GPU particle system
  103459. */
  103460. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  103461. if (doNotStart === void 0) { doNotStart = false; }
  103462. var name = parsedParticleSystem.name;
  103463. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  103464. if (parsedParticleSystem.activeParticleCount) {
  103465. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  103466. }
  103467. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  103468. // Auto start
  103469. if (parsedParticleSystem.preventAutoStart) {
  103470. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  103471. }
  103472. if (!doNotStart && !particleSystem.preventAutoStart) {
  103473. particleSystem.start();
  103474. }
  103475. return particleSystem;
  103476. };
  103477. return GPUParticleSystem;
  103478. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  103479. /***/ }),
  103480. /***/ "./Particles/index.ts":
  103481. /*!****************************!*\
  103482. !*** ./Particles/index.ts ***!
  103483. \****************************/
  103484. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  103485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103486. "use strict";
  103487. __webpack_require__.r(__webpack_exports__);
  103488. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  103490. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  103491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  103492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  103493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  103494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  103495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  103496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  103497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  103498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  103499. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  103500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  103501. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  103502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  103503. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  103504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  103505. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  103507. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  103508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  103509. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  103510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  103511. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  103512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  103513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  103514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  103515. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  103516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  103517. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  103518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  103519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  103520. /***/ }),
  103521. /***/ "./Particles/particle.ts":
  103522. /*!*******************************!*\
  103523. !*** ./Particles/particle.ts ***!
  103524. \*******************************/
  103525. /*! exports provided: Particle */
  103526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103527. "use strict";
  103528. __webpack_require__.r(__webpack_exports__);
  103529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  103530. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103531. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103532. /**
  103533. * A particle represents one of the element emitted by a particle system.
  103534. * This is mainly define by its coordinates, direction, velocity and age.
  103535. */
  103536. var Particle = /** @class */ (function () {
  103537. /**
  103538. * Creates a new instance Particle
  103539. * @param particleSystem the particle system the particle belongs to
  103540. */
  103541. function Particle(
  103542. /**
  103543. * The particle system the particle belongs to.
  103544. */
  103545. particleSystem) {
  103546. this.particleSystem = particleSystem;
  103547. /**
  103548. * The world position of the particle in the scene.
  103549. */
  103550. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103551. /**
  103552. * The world direction of the particle in the scene.
  103553. */
  103554. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103555. /**
  103556. * The color of the particle.
  103557. */
  103558. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103559. /**
  103560. * The color change of the particle per step.
  103561. */
  103562. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103563. /**
  103564. * Defines how long will the life of the particle be.
  103565. */
  103566. this.lifeTime = 1.0;
  103567. /**
  103568. * The current age of the particle.
  103569. */
  103570. this.age = 0;
  103571. /**
  103572. * The current size of the particle.
  103573. */
  103574. this.size = 0;
  103575. /**
  103576. * The current scale of the particle.
  103577. */
  103578. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  103579. /**
  103580. * The current angle of the particle.
  103581. */
  103582. this.angle = 0;
  103583. /**
  103584. * Defines how fast is the angle changing.
  103585. */
  103586. this.angularSpeed = 0;
  103587. /**
  103588. * Defines the cell index used by the particle to be rendered from a sprite.
  103589. */
  103590. this.cellIndex = 0;
  103591. /** @hidden */
  103592. this._attachedSubEmitters = null;
  103593. /** @hidden */
  103594. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103595. /** @hidden */
  103596. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103597. /** @hidden */
  103598. this._currentSize1 = 0;
  103599. /** @hidden */
  103600. this._currentSize2 = 0;
  103601. /** @hidden */
  103602. this._currentAngularSpeed1 = 0;
  103603. /** @hidden */
  103604. this._currentAngularSpeed2 = 0;
  103605. /** @hidden */
  103606. this._currentVelocity1 = 0;
  103607. /** @hidden */
  103608. this._currentVelocity2 = 0;
  103609. /** @hidden */
  103610. this._currentLimitVelocity1 = 0;
  103611. /** @hidden */
  103612. this._currentLimitVelocity2 = 0;
  103613. /** @hidden */
  103614. this._currentDrag1 = 0;
  103615. /** @hidden */
  103616. this._currentDrag2 = 0;
  103617. this.id = Particle._Count++;
  103618. if (!this.particleSystem.isAnimationSheetEnabled) {
  103619. return;
  103620. }
  103621. this.updateCellInfoFromSystem();
  103622. }
  103623. Particle.prototype.updateCellInfoFromSystem = function () {
  103624. this.cellIndex = this.particleSystem.startSpriteCellID;
  103625. };
  103626. /**
  103627. * Defines how the sprite cell index is updated for the particle
  103628. */
  103629. Particle.prototype.updateCellIndex = function () {
  103630. var offsetAge = this.age;
  103631. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  103632. if (this.particleSystem.spriteRandomStartCell) {
  103633. if (this._randomCellOffset === undefined) {
  103634. this._randomCellOffset = Math.random() * this.lifeTime;
  103635. }
  103636. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  103637. changeSpeed = 1;
  103638. offsetAge = this._randomCellOffset;
  103639. }
  103640. else {
  103641. offsetAge += this._randomCellOffset;
  103642. }
  103643. }
  103644. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  103645. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  103646. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  103647. };
  103648. /** @hidden */
  103649. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  103650. if (subEmitter.particleSystem.emitter.position) {
  103651. var emitterMesh = subEmitter.particleSystem.emitter;
  103652. emitterMesh.position.copyFrom(this.position);
  103653. if (subEmitter.inheritDirection) {
  103654. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103655. // Look at using Y as forward
  103656. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  103657. }
  103658. }
  103659. else {
  103660. var emitterPosition = subEmitter.particleSystem.emitter;
  103661. emitterPosition.copyFrom(this.position);
  103662. }
  103663. // Set inheritedVelocityOffset to be used when new particles are created
  103664. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103665. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103666. };
  103667. /** @hidden */
  103668. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  103669. var _this = this;
  103670. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  103671. this._attachedSubEmitters.forEach(function (subEmitter) {
  103672. _this._inheritParticleInfoToSubEmitter(subEmitter);
  103673. });
  103674. }
  103675. };
  103676. /** @hidden */
  103677. Particle.prototype._reset = function () {
  103678. this.age = 0;
  103679. this._currentColorGradient = null;
  103680. this._currentSizeGradient = null;
  103681. this._currentAngularSpeedGradient = null;
  103682. this._currentVelocityGradient = null;
  103683. this._currentLimitVelocityGradient = null;
  103684. this._currentDragGradient = null;
  103685. this.cellIndex = this.particleSystem.startSpriteCellID;
  103686. this._randomCellOffset = undefined;
  103687. };
  103688. /**
  103689. * Copy the properties of particle to another one.
  103690. * @param other the particle to copy the information to.
  103691. */
  103692. Particle.prototype.copyTo = function (other) {
  103693. other.position.copyFrom(this.position);
  103694. if (this._initialDirection) {
  103695. if (other._initialDirection) {
  103696. other._initialDirection.copyFrom(this._initialDirection);
  103697. }
  103698. else {
  103699. other._initialDirection = this._initialDirection.clone();
  103700. }
  103701. }
  103702. else {
  103703. other._initialDirection = null;
  103704. }
  103705. other.direction.copyFrom(this.direction);
  103706. other.color.copyFrom(this.color);
  103707. other.colorStep.copyFrom(this.colorStep);
  103708. other.lifeTime = this.lifeTime;
  103709. other.age = this.age;
  103710. other._randomCellOffset = this._randomCellOffset;
  103711. other.size = this.size;
  103712. other.scale.copyFrom(this.scale);
  103713. other.angle = this.angle;
  103714. other.angularSpeed = this.angularSpeed;
  103715. other.particleSystem = this.particleSystem;
  103716. other.cellIndex = this.cellIndex;
  103717. other.id = this.id;
  103718. other._attachedSubEmitters = this._attachedSubEmitters;
  103719. if (this._currentColorGradient) {
  103720. other._currentColorGradient = this._currentColorGradient;
  103721. other._currentColor1.copyFrom(this._currentColor1);
  103722. other._currentColor2.copyFrom(this._currentColor2);
  103723. }
  103724. if (this._currentSizeGradient) {
  103725. other._currentSizeGradient = this._currentSizeGradient;
  103726. other._currentSize1 = this._currentSize1;
  103727. other._currentSize2 = this._currentSize2;
  103728. }
  103729. if (this._currentAngularSpeedGradient) {
  103730. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  103731. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  103732. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  103733. }
  103734. if (this._currentVelocityGradient) {
  103735. other._currentVelocityGradient = this._currentVelocityGradient;
  103736. other._currentVelocity1 = this._currentVelocity1;
  103737. other._currentVelocity2 = this._currentVelocity2;
  103738. }
  103739. if (this._currentLimitVelocityGradient) {
  103740. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  103741. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  103742. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  103743. }
  103744. if (this._currentDragGradient) {
  103745. other._currentDragGradient = this._currentDragGradient;
  103746. other._currentDrag1 = this._currentDrag1;
  103747. other._currentDrag2 = this._currentDrag2;
  103748. }
  103749. if (this.particleSystem.isAnimationSheetEnabled) {
  103750. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  103751. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  103752. }
  103753. if (this.particleSystem.useRampGradients) {
  103754. other.remapData.copyFrom(this.remapData);
  103755. }
  103756. if (this._randomNoiseCoordinates1) {
  103757. if (other._randomNoiseCoordinates1) {
  103758. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  103759. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  103760. }
  103761. else {
  103762. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  103763. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  103764. }
  103765. }
  103766. };
  103767. Particle._Count = 0;
  103768. return Particle;
  103769. }());
  103770. /***/ }),
  103771. /***/ "./Particles/particleHelper.ts":
  103772. /*!*************************************!*\
  103773. !*** ./Particles/particleHelper.ts ***!
  103774. \*************************************/
  103775. /*! exports provided: ParticleHelper */
  103776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103777. "use strict";
  103778. __webpack_require__.r(__webpack_exports__);
  103779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  103780. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103781. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103782. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103783. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103784. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  103785. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  103786. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103787. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103788. /**
  103789. * This class is made for on one-liner static method to help creating particle system set.
  103790. */
  103791. var ParticleHelper = /** @class */ (function () {
  103792. function ParticleHelper() {
  103793. }
  103794. /**
  103795. * Create a default particle system that you can tweak
  103796. * @param emitter defines the emitter to use
  103797. * @param capacity defines the system capacity (default is 500 particles)
  103798. * @param scene defines the hosting scene
  103799. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  103800. * @returns the new Particle system
  103801. */
  103802. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  103803. if (capacity === void 0) { capacity = 500; }
  103804. if (useGPU === void 0) { useGPU = false; }
  103805. var system;
  103806. if (useGPU) {
  103807. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  103808. }
  103809. else {
  103810. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  103811. }
  103812. system.emitter = emitter;
  103813. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  103814. system.createConeEmitter(0.1, Math.PI / 4);
  103815. // Particle color
  103816. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  103817. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  103818. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  103819. // Particle Size
  103820. system.minSize = 0.1;
  103821. system.maxSize = 0.1;
  103822. // Emission speed
  103823. system.minEmitPower = 2;
  103824. system.maxEmitPower = 2;
  103825. // Update speed
  103826. system.updateSpeed = 1 / 60;
  103827. system.emitRate = 30;
  103828. return system;
  103829. };
  103830. /**
  103831. * This is the main static method (one-liner) of this helper to create different particle systems
  103832. * @param type This string represents the type to the particle system to create
  103833. * @param scene The scene where the particle system should live
  103834. * @param gpu If the system will use gpu
  103835. * @returns the ParticleSystemSet created
  103836. */
  103837. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  103838. if (gpu === void 0) { gpu = false; }
  103839. if (!scene) {
  103840. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  103841. }
  103842. var token = {};
  103843. scene._addPendingData(token);
  103844. return new Promise(function (resolve, reject) {
  103845. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  103846. scene._removePendingData(token);
  103847. return reject("Particle system with GPU is not supported.");
  103848. }
  103849. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  103850. scene._removePendingData(token);
  103851. var newData = JSON.parse(data.toString());
  103852. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  103853. }, undefined, undefined, undefined, function () {
  103854. scene._removePendingData(token);
  103855. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  103856. });
  103857. });
  103858. };
  103859. /**
  103860. * Static function used to export a particle system to a ParticleSystemSet variable.
  103861. * Please note that the emitter shape is not exported
  103862. * @param systems defines the particle systems to export
  103863. * @returns the created particle system set
  103864. */
  103865. ParticleHelper.ExportSet = function (systems) {
  103866. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  103867. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  103868. var system = systems_1[_i];
  103869. set.systems.push(system);
  103870. }
  103871. return set;
  103872. };
  103873. /**
  103874. * Gets or sets base Assets URL
  103875. */
  103876. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  103877. return ParticleHelper;
  103878. }());
  103879. /***/ }),
  103880. /***/ "./Particles/particleSystem.ts":
  103881. /*!*************************************!*\
  103882. !*** ./Particles/particleSystem.ts ***!
  103883. \*************************************/
  103884. /*! exports provided: ParticleSystem */
  103885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103886. "use strict";
  103887. __webpack_require__.r(__webpack_exports__);
  103888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  103889. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103890. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103891. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103892. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103893. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103894. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103895. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  103896. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103897. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103898. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103899. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103900. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103901. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  103902. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103903. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  103904. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  103905. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103906. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  103907. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  103908. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103909. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  103910. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103911. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  103912. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  103913. /**
  103914. * This represents a particle system in Babylon.
  103915. * 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.
  103916. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  103917. * @example https://doc.babylonjs.com/babylon101/particles
  103918. */
  103919. var ParticleSystem = /** @class */ (function (_super) {
  103920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  103921. /**
  103922. * Instantiates a particle system.
  103923. * 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.
  103924. * @param name The name of the particle system
  103925. * @param capacity The max number of particles alive at the same time
  103926. * @param scene The scene the particle system belongs to
  103927. * @param customEffect a custom effect used to change the way particles are rendered by default
  103928. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103929. * @param epsilon Offset used to render the particles
  103930. */
  103931. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  103932. if (customEffect === void 0) { customEffect = null; }
  103933. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103934. if (epsilon === void 0) { epsilon = 0.01; }
  103935. var _this = _super.call(this, name) || this;
  103936. /**
  103937. * @hidden
  103938. */
  103939. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  103940. /**
  103941. * An event triggered when the system is disposed
  103942. */
  103943. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103944. _this._particles = new Array();
  103945. _this._stockParticles = new Array();
  103946. _this._newPartsExcess = 0;
  103947. _this._vertexBuffers = {};
  103948. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  103949. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  103950. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  103951. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  103952. _this._currentRenderId = -1;
  103953. _this._useInstancing = false;
  103954. _this._started = false;
  103955. _this._stopped = false;
  103956. _this._actualFrame = 0;
  103957. /** @hidden */
  103958. _this._currentEmitRate1 = 0;
  103959. /** @hidden */
  103960. _this._currentEmitRate2 = 0;
  103961. /** @hidden */
  103962. _this._currentStartSize1 = 0;
  103963. /** @hidden */
  103964. _this._currentStartSize2 = 0;
  103965. _this._rawTextureWidth = 256;
  103966. _this._useRampGradients = false;
  103967. /**
  103968. * @hidden
  103969. * If the particle systems emitter should be disposed when the particle system is disposed
  103970. */
  103971. _this._disposeEmitterOnDispose = false;
  103972. // start of sub system methods
  103973. /**
  103974. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  103975. * Its lifetime will start back at 0.
  103976. */
  103977. _this.recycleParticle = function (particle) {
  103978. // move particle from activeParticle list to stock particles
  103979. var lastParticle = _this._particles.pop();
  103980. if (lastParticle !== particle) {
  103981. lastParticle.copyTo(particle);
  103982. }
  103983. _this._stockParticles.push(lastParticle);
  103984. };
  103985. _this._createParticle = function () {
  103986. var particle;
  103987. if (_this._stockParticles.length !== 0) {
  103988. particle = _this._stockParticles.pop();
  103989. particle._reset();
  103990. }
  103991. else {
  103992. particle = new _particle__WEBPACK_IMPORTED_MODULE_17__["Particle"](_this);
  103993. }
  103994. // Attach emitters
  103995. if (_this._subEmitters && _this._subEmitters.length > 0) {
  103996. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  103997. particle._attachedSubEmitters = [];
  103998. subEmitters.forEach(function (subEmitter) {
  103999. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].ATTACHED) {
  104000. var newEmitter = subEmitter.clone();
  104001. particle._attachedSubEmitters.push(newEmitter);
  104002. newEmitter.particleSystem.start();
  104003. }
  104004. });
  104005. }
  104006. return particle;
  104007. };
  104008. _this._emitFromParticle = function (particle) {
  104009. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  104010. return;
  104011. }
  104012. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  104013. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  104014. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].END) {
  104015. var subSystem = subEmitter.clone();
  104016. particle._inheritParticleInfoToSubEmitter(subSystem);
  104017. subSystem.particleSystem._rootParticleSystem = _this;
  104018. _this.activeSubSystems.push(subSystem.particleSystem);
  104019. subSystem.particleSystem.start();
  104020. }
  104021. });
  104022. };
  104023. _this._capacity = capacity;
  104024. _this._epsilon = epsilon;
  104025. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  104026. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  104027. // Setup the default processing configuration to the scene.
  104028. _this._attachImageProcessingConfiguration(null);
  104029. _this._customEffect = customEffect;
  104030. _this._scene.particleSystems.push(_this);
  104031. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  104032. _this._createIndexBuffer();
  104033. _this._createVertexBuffers();
  104034. // Default emitter type
  104035. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  104036. // Update
  104037. _this.updateFunction = function (particles) {
  104038. var noiseTextureSize = null;
  104039. var noiseTextureData = null;
  104040. if (_this.noiseTexture) { // We need to get texture data back to CPU
  104041. noiseTextureSize = _this.noiseTexture.getSize();
  104042. noiseTextureData = (_this.noiseTexture.getContent());
  104043. }
  104044. var _loop_1 = function () {
  104045. particle = particles[index];
  104046. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  104047. var previousAge = particle.age;
  104048. particle.age += scaledUpdateSpeed;
  104049. // Evaluate step to death
  104050. if (particle.age > particle.lifeTime) {
  104051. var diff = particle.age - previousAge;
  104052. var oldDiff = particle.lifeTime - previousAge;
  104053. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  104054. particle.age = particle.lifeTime;
  104055. }
  104056. var ratio = particle.age / particle.lifeTime;
  104057. // Color
  104058. if (_this._colorGradients && _this._colorGradients.length > 0) {
  104059. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  104060. if (currentGradient !== particle._currentColorGradient) {
  104061. particle._currentColor1.copyFrom(particle._currentColor2);
  104062. nextGradient.getColorToRef(particle._currentColor2);
  104063. particle._currentColorGradient = currentGradient;
  104064. }
  104065. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  104066. });
  104067. }
  104068. else {
  104069. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  104070. particle.color.addInPlace(_this._scaledColorStep);
  104071. if (particle.color.a < 0) {
  104072. particle.color.a = 0;
  104073. }
  104074. }
  104075. // Angular speed
  104076. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  104077. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  104078. if (currentGradient !== particle._currentAngularSpeedGradient) {
  104079. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  104080. particle._currentAngularSpeed2 = nextGradient.getFactor();
  104081. particle._currentAngularSpeedGradient = currentGradient;
  104082. }
  104083. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  104084. });
  104085. }
  104086. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  104087. // Direction
  104088. var directionScale = scaledUpdateSpeed;
  104089. /// Velocity
  104090. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  104091. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  104092. if (currentGradient !== particle._currentVelocityGradient) {
  104093. particle._currentVelocity1 = particle._currentVelocity2;
  104094. particle._currentVelocity2 = nextGradient.getFactor();
  104095. particle._currentVelocityGradient = currentGradient;
  104096. }
  104097. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  104098. });
  104099. }
  104100. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  104101. /// Limit velocity
  104102. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  104103. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  104104. if (currentGradient !== particle._currentLimitVelocityGradient) {
  104105. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  104106. particle._currentLimitVelocity2 = nextGradient.getFactor();
  104107. particle._currentLimitVelocityGradient = currentGradient;
  104108. }
  104109. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  104110. var currentVelocity = particle.direction.length();
  104111. if (currentVelocity > limitVelocity) {
  104112. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  104113. }
  104114. });
  104115. }
  104116. /// Drag
  104117. if (_this._dragGradients && _this._dragGradients.length > 0) {
  104118. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  104119. if (currentGradient !== particle._currentDragGradient) {
  104120. particle._currentDrag1 = particle._currentDrag2;
  104121. particle._currentDrag2 = nextGradient.getFactor();
  104122. particle._currentDragGradient = currentGradient;
  104123. }
  104124. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  104125. _this._scaledDirection.scaleInPlace(1.0 - drag);
  104126. });
  104127. }
  104128. particle.position.addInPlace(_this._scaledDirection);
  104129. // Noise
  104130. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  104131. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104132. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104133. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104134. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  104135. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  104136. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  104137. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  104138. particle.direction.addInPlace(scaledForce);
  104139. }
  104140. // Gravity
  104141. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  104142. particle.direction.addInPlace(_this._scaledGravity);
  104143. // Size
  104144. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  104145. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  104146. if (currentGradient !== particle._currentSizeGradient) {
  104147. particle._currentSize1 = particle._currentSize2;
  104148. particle._currentSize2 = nextGradient.getFactor();
  104149. particle._currentSizeGradient = currentGradient;
  104150. }
  104151. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  104152. });
  104153. }
  104154. // Remap data
  104155. if (_this._useRampGradients) {
  104156. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  104157. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  104158. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104159. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104160. particle.remapData.x = min;
  104161. particle.remapData.y = max - min;
  104162. });
  104163. }
  104164. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  104165. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  104166. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104167. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104168. particle.remapData.z = min;
  104169. particle.remapData.w = max - min;
  104170. });
  104171. }
  104172. }
  104173. if (_this._isAnimationSheetEnabled) {
  104174. particle.updateCellIndex();
  104175. }
  104176. // Update the position of the attached sub-emitters to match their attached particle
  104177. particle._inheritParticleInfoToSubEmitters();
  104178. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  104179. _this._emitFromParticle(particle);
  104180. if (particle._attachedSubEmitters) {
  104181. particle._attachedSubEmitters.forEach(function (subEmitter) {
  104182. subEmitter.particleSystem.disposeOnStop = true;
  104183. subEmitter.particleSystem.stop();
  104184. });
  104185. particle._attachedSubEmitters = null;
  104186. }
  104187. _this.recycleParticle(particle);
  104188. index--;
  104189. return "continue";
  104190. }
  104191. };
  104192. var particle;
  104193. for (var index = 0; index < particles.length; index++) {
  104194. _loop_1();
  104195. }
  104196. };
  104197. return _this;
  104198. }
  104199. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  104200. /**
  104201. * Sets a callback that will be triggered when the system is disposed
  104202. */
  104203. set: function (callback) {
  104204. if (this._onDisposeObserver) {
  104205. this.onDisposeObservable.remove(this._onDisposeObserver);
  104206. }
  104207. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  104208. },
  104209. enumerable: true,
  104210. configurable: true
  104211. });
  104212. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  104213. /** Gets or sets a boolean indicating that ramp gradients must be used
  104214. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104215. */
  104216. get: function () {
  104217. return this._useRampGradients;
  104218. },
  104219. set: function (value) {
  104220. if (this._useRampGradients === value) {
  104221. return;
  104222. }
  104223. this._useRampGradients = value;
  104224. this._resetEffect();
  104225. },
  104226. enumerable: true,
  104227. configurable: true
  104228. });
  104229. Object.defineProperty(ParticleSystem.prototype, "particles", {
  104230. //end of Sub-emitter
  104231. /**
  104232. * Gets the current list of active particles
  104233. */
  104234. get: function () {
  104235. return this._particles;
  104236. },
  104237. enumerable: true,
  104238. configurable: true
  104239. });
  104240. /**
  104241. * Returns the string "ParticleSystem"
  104242. * @returns a string containing the class name
  104243. */
  104244. ParticleSystem.prototype.getClassName = function () {
  104245. return "ParticleSystem";
  104246. };
  104247. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  104248. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  104249. newGradient.gradient = gradient;
  104250. newGradient.factor1 = factor;
  104251. newGradient.factor2 = factor2;
  104252. factorGradients.push(newGradient);
  104253. factorGradients.sort(function (a, b) {
  104254. if (a.gradient < b.gradient) {
  104255. return -1;
  104256. }
  104257. else if (a.gradient > b.gradient) {
  104258. return 1;
  104259. }
  104260. return 0;
  104261. });
  104262. };
  104263. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  104264. if (!factorGradients) {
  104265. return;
  104266. }
  104267. var index = 0;
  104268. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  104269. var factorGradient = factorGradients_1[_i];
  104270. if (factorGradient.gradient === gradient) {
  104271. factorGradients.splice(index, 1);
  104272. break;
  104273. }
  104274. index++;
  104275. }
  104276. };
  104277. /**
  104278. * Adds a new life time gradient
  104279. * @param gradient defines the gradient to use (between 0 and 1)
  104280. * @param factor defines the life time factor to affect to the specified gradient
  104281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104282. * @returns the current particle system
  104283. */
  104284. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104285. if (!this._lifeTimeGradients) {
  104286. this._lifeTimeGradients = [];
  104287. }
  104288. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  104289. return this;
  104290. };
  104291. /**
  104292. * Remove a specific life time gradient
  104293. * @param gradient defines the gradient to remove
  104294. * @returns the current particle system
  104295. */
  104296. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104297. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  104298. return this;
  104299. };
  104300. /**
  104301. * Adds a new size gradient
  104302. * @param gradient defines the gradient to use (between 0 and 1)
  104303. * @param factor defines the size factor to affect to the specified gradient
  104304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104305. * @returns the current particle system
  104306. */
  104307. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  104308. if (!this._sizeGradients) {
  104309. this._sizeGradients = [];
  104310. }
  104311. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  104312. return this;
  104313. };
  104314. /**
  104315. * Remove a specific size gradient
  104316. * @param gradient defines the gradient to remove
  104317. * @returns the current particle system
  104318. */
  104319. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  104320. this._removeFactorGradient(this._sizeGradients, gradient);
  104321. return this;
  104322. };
  104323. /**
  104324. * Adds a new color remap gradient
  104325. * @param gradient defines the gradient to use (between 0 and 1)
  104326. * @param min defines the color remap minimal range
  104327. * @param max defines the color remap maximal range
  104328. * @returns the current particle system
  104329. */
  104330. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  104331. if (!this._colorRemapGradients) {
  104332. this._colorRemapGradients = [];
  104333. }
  104334. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  104335. return this;
  104336. };
  104337. /**
  104338. * Remove a specific color remap gradient
  104339. * @param gradient defines the gradient to remove
  104340. * @returns the current particle system
  104341. */
  104342. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  104343. this._removeFactorGradient(this._colorRemapGradients, gradient);
  104344. return this;
  104345. };
  104346. /**
  104347. * Adds a new alpha remap gradient
  104348. * @param gradient defines the gradient to use (between 0 and 1)
  104349. * @param min defines the alpha remap minimal range
  104350. * @param max defines the alpha remap maximal range
  104351. * @returns the current particle system
  104352. */
  104353. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104354. if (!this._alphaRemapGradients) {
  104355. this._alphaRemapGradients = [];
  104356. }
  104357. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  104358. return this;
  104359. };
  104360. /**
  104361. * Remove a specific alpha remap gradient
  104362. * @param gradient defines the gradient to remove
  104363. * @returns the current particle system
  104364. */
  104365. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  104366. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  104367. return this;
  104368. };
  104369. /**
  104370. * Adds a new angular speed gradient
  104371. * @param gradient defines the gradient to use (between 0 and 1)
  104372. * @param factor defines the angular speed to affect to the specified gradient
  104373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104374. * @returns the current particle system
  104375. */
  104376. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  104377. if (!this._angularSpeedGradients) {
  104378. this._angularSpeedGradients = [];
  104379. }
  104380. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  104381. return this;
  104382. };
  104383. /**
  104384. * Remove a specific angular speed gradient
  104385. * @param gradient defines the gradient to remove
  104386. * @returns the current particle system
  104387. */
  104388. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  104389. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  104390. return this;
  104391. };
  104392. /**
  104393. * Adds a new velocity gradient
  104394. * @param gradient defines the gradient to use (between 0 and 1)
  104395. * @param factor defines the velocity to affect to the specified gradient
  104396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104397. * @returns the current particle system
  104398. */
  104399. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  104400. if (!this._velocityGradients) {
  104401. this._velocityGradients = [];
  104402. }
  104403. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  104404. return this;
  104405. };
  104406. /**
  104407. * Remove a specific velocity gradient
  104408. * @param gradient defines the gradient to remove
  104409. * @returns the current particle system
  104410. */
  104411. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  104412. this._removeFactorGradient(this._velocityGradients, gradient);
  104413. return this;
  104414. };
  104415. /**
  104416. * Adds a new limit velocity gradient
  104417. * @param gradient defines the gradient to use (between 0 and 1)
  104418. * @param factor defines the limit velocity value to affect to the specified gradient
  104419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104420. * @returns the current particle system
  104421. */
  104422. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  104423. if (!this._limitVelocityGradients) {
  104424. this._limitVelocityGradients = [];
  104425. }
  104426. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  104427. return this;
  104428. };
  104429. /**
  104430. * Remove a specific limit velocity gradient
  104431. * @param gradient defines the gradient to remove
  104432. * @returns the current particle system
  104433. */
  104434. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  104435. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  104436. return this;
  104437. };
  104438. /**
  104439. * Adds a new drag gradient
  104440. * @param gradient defines the gradient to use (between 0 and 1)
  104441. * @param factor defines the drag value to affect to the specified gradient
  104442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104443. * @returns the current particle system
  104444. */
  104445. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  104446. if (!this._dragGradients) {
  104447. this._dragGradients = [];
  104448. }
  104449. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  104450. return this;
  104451. };
  104452. /**
  104453. * Remove a specific drag gradient
  104454. * @param gradient defines the gradient to remove
  104455. * @returns the current particle system
  104456. */
  104457. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  104458. this._removeFactorGradient(this._dragGradients, gradient);
  104459. return this;
  104460. };
  104461. /**
  104462. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  104463. * @param gradient defines the gradient to use (between 0 and 1)
  104464. * @param factor defines the emit rate value to affect to the specified gradient
  104465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104466. * @returns the current particle system
  104467. */
  104468. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  104469. if (!this._emitRateGradients) {
  104470. this._emitRateGradients = [];
  104471. }
  104472. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  104473. return this;
  104474. };
  104475. /**
  104476. * Remove a specific emit rate gradient
  104477. * @param gradient defines the gradient to remove
  104478. * @returns the current particle system
  104479. */
  104480. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  104481. this._removeFactorGradient(this._emitRateGradients, gradient);
  104482. return this;
  104483. };
  104484. /**
  104485. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  104486. * @param gradient defines the gradient to use (between 0 and 1)
  104487. * @param factor defines the start size value to affect to the specified gradient
  104488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104489. * @returns the current particle system
  104490. */
  104491. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  104492. if (!this._startSizeGradients) {
  104493. this._startSizeGradients = [];
  104494. }
  104495. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  104496. return this;
  104497. };
  104498. /**
  104499. * Remove a specific start size gradient
  104500. * @param gradient defines the gradient to remove
  104501. * @returns the current particle system
  104502. */
  104503. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  104504. this._removeFactorGradient(this._emitRateGradients, gradient);
  104505. return this;
  104506. };
  104507. ParticleSystem.prototype._createRampGradientTexture = function () {
  104508. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  104509. return;
  104510. }
  104511. var data = new Uint8Array(this._rawTextureWidth * 4);
  104512. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  104513. for (var x = 0; x < this._rawTextureWidth; x++) {
  104514. var ratio = x / this._rawTextureWidth;
  104515. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  104516. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  104517. data[x * 4] = tmpColor.r * 255;
  104518. data[x * 4 + 1] = tmpColor.g * 255;
  104519. data[x * 4 + 2] = tmpColor.b * 255;
  104520. data[x * 4 + 3] = 255;
  104521. });
  104522. }
  104523. 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);
  104524. };
  104525. /**
  104526. * Gets the current list of ramp gradients.
  104527. * You must use addRampGradient and removeRampGradient to udpate this list
  104528. * @returns the list of ramp gradients
  104529. */
  104530. ParticleSystem.prototype.getRampGradients = function () {
  104531. return this._rampGradients;
  104532. };
  104533. /**
  104534. * Adds a new ramp gradient used to remap particle colors
  104535. * @param gradient defines the gradient to use (between 0 and 1)
  104536. * @param color defines the color to affect to the specified gradient
  104537. * @returns the current particle system
  104538. */
  104539. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104540. if (!this._rampGradients) {
  104541. this._rampGradients = [];
  104542. }
  104543. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  104544. rampGradient.gradient = gradient;
  104545. rampGradient.color = color;
  104546. this._rampGradients.push(rampGradient);
  104547. this._rampGradients.sort(function (a, b) {
  104548. if (a.gradient < b.gradient) {
  104549. return -1;
  104550. }
  104551. else if (a.gradient > b.gradient) {
  104552. return 1;
  104553. }
  104554. return 0;
  104555. });
  104556. if (this._rampGradientsTexture) {
  104557. this._rampGradientsTexture.dispose();
  104558. this._rampGradientsTexture = null;
  104559. }
  104560. this._createRampGradientTexture();
  104561. return this;
  104562. };
  104563. /**
  104564. * Remove a specific ramp gradient
  104565. * @param gradient defines the gradient to remove
  104566. * @returns the current particle system
  104567. */
  104568. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  104569. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  104570. this._rampGradientsTexture = null;
  104571. if (this._rampGradients && this._rampGradients.length > 0) {
  104572. this._createRampGradientTexture();
  104573. }
  104574. return this;
  104575. };
  104576. /**
  104577. * Adds a new color gradient
  104578. * @param gradient defines the gradient to use (between 0 and 1)
  104579. * @param color1 defines the color to affect to the specified gradient
  104580. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104581. * @returns this particle system
  104582. */
  104583. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  104584. if (!this._colorGradients) {
  104585. this._colorGradients = [];
  104586. }
  104587. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  104588. colorGradient.gradient = gradient;
  104589. colorGradient.color1 = color1;
  104590. colorGradient.color2 = color2;
  104591. this._colorGradients.push(colorGradient);
  104592. this._colorGradients.sort(function (a, b) {
  104593. if (a.gradient < b.gradient) {
  104594. return -1;
  104595. }
  104596. else if (a.gradient > b.gradient) {
  104597. return 1;
  104598. }
  104599. return 0;
  104600. });
  104601. return this;
  104602. };
  104603. /**
  104604. * Remove a specific color gradient
  104605. * @param gradient defines the gradient to remove
  104606. * @returns this particle system
  104607. */
  104608. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  104609. if (!this._colorGradients) {
  104610. return this;
  104611. }
  104612. var index = 0;
  104613. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  104614. var colorGradient = _a[_i];
  104615. if (colorGradient.gradient === gradient) {
  104616. this._colorGradients.splice(index, 1);
  104617. break;
  104618. }
  104619. index++;
  104620. }
  104621. return this;
  104622. };
  104623. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  104624. u = Math.abs(u) * 0.5 + 0.5;
  104625. v = Math.abs(v) * 0.5 + 0.5;
  104626. var wrappedU = ((u * width) % width) | 0;
  104627. var wrappedV = ((v * height) % height) | 0;
  104628. var position = (wrappedU + wrappedV * width) * 4;
  104629. return pixels[position] / 255;
  104630. };
  104631. ParticleSystem.prototype._reset = function () {
  104632. this._resetEffect();
  104633. };
  104634. ParticleSystem.prototype._resetEffect = function () {
  104635. if (this._vertexBuffer) {
  104636. this._vertexBuffer.dispose();
  104637. this._vertexBuffer = null;
  104638. }
  104639. if (this._spriteBuffer) {
  104640. this._spriteBuffer.dispose();
  104641. this._spriteBuffer = null;
  104642. }
  104643. this._createVertexBuffers();
  104644. };
  104645. ParticleSystem.prototype._createVertexBuffers = function () {
  104646. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  104647. if (this._isAnimationSheetEnabled) {
  104648. this._vertexBufferSize += 1;
  104649. }
  104650. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104651. this._vertexBufferSize += 3;
  104652. }
  104653. if (this._useRampGradients) {
  104654. this._vertexBufferSize += 4;
  104655. }
  104656. var engine = this._scene.getEngine();
  104657. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  104658. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  104659. var dataOffset = 0;
  104660. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  104661. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  104662. dataOffset += 3;
  104663. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  104664. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  104665. dataOffset += 4;
  104666. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104667. this._vertexBuffers["angle"] = options;
  104668. dataOffset += 1;
  104669. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  104670. this._vertexBuffers["size"] = size;
  104671. dataOffset += 2;
  104672. if (this._isAnimationSheetEnabled) {
  104673. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104674. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  104675. dataOffset += 1;
  104676. }
  104677. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104678. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  104679. this._vertexBuffers["direction"] = directionBuffer;
  104680. dataOffset += 3;
  104681. }
  104682. if (this._useRampGradients) {
  104683. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  104684. this._vertexBuffers["remapData"] = rampDataBuffer;
  104685. dataOffset += 4;
  104686. }
  104687. var offsets;
  104688. if (this._useInstancing) {
  104689. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  104690. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  104691. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  104692. }
  104693. else {
  104694. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  104695. dataOffset += 2;
  104696. }
  104697. this._vertexBuffers["offset"] = offsets;
  104698. };
  104699. ParticleSystem.prototype._createIndexBuffer = function () {
  104700. if (this._useInstancing) {
  104701. return;
  104702. }
  104703. var indices = [];
  104704. var index = 0;
  104705. for (var count = 0; count < this._capacity; count++) {
  104706. indices.push(index);
  104707. indices.push(index + 1);
  104708. indices.push(index + 2);
  104709. indices.push(index);
  104710. indices.push(index + 2);
  104711. indices.push(index + 3);
  104712. index += 4;
  104713. }
  104714. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  104715. };
  104716. /**
  104717. * Gets the maximum number of particles active at the same time.
  104718. * @returns The max number of active particles.
  104719. */
  104720. ParticleSystem.prototype.getCapacity = function () {
  104721. return this._capacity;
  104722. };
  104723. /**
  104724. * Gets whether there are still active particles in the system.
  104725. * @returns True if it is alive, otherwise false.
  104726. */
  104727. ParticleSystem.prototype.isAlive = function () {
  104728. return this._alive;
  104729. };
  104730. /**
  104731. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104732. * @returns True if it has been started, otherwise false.
  104733. */
  104734. ParticleSystem.prototype.isStarted = function () {
  104735. return this._started;
  104736. };
  104737. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  104738. var _this = this;
  104739. this._subEmitters = new Array();
  104740. if (this.subEmitters) {
  104741. this.subEmitters.forEach(function (subEmitter) {
  104742. if (subEmitter instanceof ParticleSystem) {
  104743. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"](subEmitter)]);
  104744. }
  104745. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]) {
  104746. _this._subEmitters.push([subEmitter]);
  104747. }
  104748. else if (subEmitter instanceof Array) {
  104749. _this._subEmitters.push(subEmitter);
  104750. }
  104751. });
  104752. }
  104753. };
  104754. /**
  104755. * Starts the particle system and begins to emit
  104756. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104757. */
  104758. ParticleSystem.prototype.start = function (delay) {
  104759. var _this = this;
  104760. if (delay === void 0) { delay = this.startDelay; }
  104761. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  104762. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  104763. }
  104764. if (delay) {
  104765. setTimeout(function () {
  104766. _this.start(0);
  104767. }, delay);
  104768. return;
  104769. }
  104770. // Convert the subEmitters field to the constant type field _subEmitters
  104771. this._prepareSubEmitterInternalArray();
  104772. this._started = true;
  104773. this._stopped = false;
  104774. this._actualFrame = 0;
  104775. if (this._subEmitters && this._subEmitters.length != 0) {
  104776. this.activeSubSystems = new Array();
  104777. }
  104778. // Reset emit gradient so it acts the same on every start
  104779. if (this._emitRateGradients) {
  104780. if (this._emitRateGradients.length > 0) {
  104781. this._currentEmitRateGradient = this._emitRateGradients[0];
  104782. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  104783. this._currentEmitRate2 = this._currentEmitRate1;
  104784. }
  104785. if (this._emitRateGradients.length > 1) {
  104786. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  104787. }
  104788. }
  104789. // Reset start size gradient so it acts the same on every start
  104790. if (this._startSizeGradients) {
  104791. if (this._startSizeGradients.length > 0) {
  104792. this._currentStartSizeGradient = this._startSizeGradients[0];
  104793. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  104794. this._currentStartSize2 = this._currentStartSize1;
  104795. }
  104796. if (this._startSizeGradients.length > 1) {
  104797. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  104798. }
  104799. }
  104800. if (this.preWarmCycles) {
  104801. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  104802. this.emitter.computeWorldMatrix(true);
  104803. }
  104804. var noiseTextureAsProcedural_1 = this.noiseTexture;
  104805. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  104806. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  104807. setTimeout(function () {
  104808. for (var index = 0; index < _this.preWarmCycles; index++) {
  104809. _this.animate(true);
  104810. noiseTextureAsProcedural_1.render();
  104811. }
  104812. });
  104813. });
  104814. }
  104815. else {
  104816. for (var index = 0; index < this.preWarmCycles; index++) {
  104817. this.animate(true);
  104818. }
  104819. }
  104820. }
  104821. // Animations
  104822. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  104823. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  104824. }
  104825. };
  104826. /**
  104827. * Stops the particle system.
  104828. * @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.
  104829. */
  104830. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  104831. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  104832. this._stopped = true;
  104833. if (stopSubEmitters) {
  104834. this._stopSubEmitters();
  104835. }
  104836. };
  104837. // animation sheet
  104838. /**
  104839. * Remove all active particles
  104840. */
  104841. ParticleSystem.prototype.reset = function () {
  104842. this._stockParticles = [];
  104843. this._particles = [];
  104844. };
  104845. /**
  104846. * @hidden (for internal use only)
  104847. */
  104848. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  104849. var offset = index * this._vertexBufferSize;
  104850. this._vertexData[offset++] = particle.position.x;
  104851. this._vertexData[offset++] = particle.position.y;
  104852. this._vertexData[offset++] = particle.position.z;
  104853. this._vertexData[offset++] = particle.color.r;
  104854. this._vertexData[offset++] = particle.color.g;
  104855. this._vertexData[offset++] = particle.color.b;
  104856. this._vertexData[offset++] = particle.color.a;
  104857. this._vertexData[offset++] = particle.angle;
  104858. this._vertexData[offset++] = particle.scale.x * particle.size;
  104859. this._vertexData[offset++] = particle.scale.y * particle.size;
  104860. if (this._isAnimationSheetEnabled) {
  104861. this._vertexData[offset++] = particle.cellIndex;
  104862. }
  104863. if (!this._isBillboardBased) {
  104864. if (particle._initialDirection) {
  104865. this._vertexData[offset++] = particle._initialDirection.x;
  104866. this._vertexData[offset++] = particle._initialDirection.y;
  104867. this._vertexData[offset++] = particle._initialDirection.z;
  104868. }
  104869. else {
  104870. this._vertexData[offset++] = particle.direction.x;
  104871. this._vertexData[offset++] = particle.direction.y;
  104872. this._vertexData[offset++] = particle.direction.z;
  104873. }
  104874. }
  104875. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104876. this._vertexData[offset++] = particle.direction.x;
  104877. this._vertexData[offset++] = particle.direction.y;
  104878. this._vertexData[offset++] = particle.direction.z;
  104879. }
  104880. if (this._useRampGradients) {
  104881. this._vertexData[offset++] = particle.remapData.x;
  104882. this._vertexData[offset++] = particle.remapData.y;
  104883. this._vertexData[offset++] = particle.remapData.z;
  104884. this._vertexData[offset++] = particle.remapData.w;
  104885. }
  104886. if (!this._useInstancing) {
  104887. if (this._isAnimationSheetEnabled) {
  104888. if (offsetX === 0) {
  104889. offsetX = this._epsilon;
  104890. }
  104891. else if (offsetX === 1) {
  104892. offsetX = 1 - this._epsilon;
  104893. }
  104894. if (offsetY === 0) {
  104895. offsetY = this._epsilon;
  104896. }
  104897. else if (offsetY === 1) {
  104898. offsetY = 1 - this._epsilon;
  104899. }
  104900. }
  104901. this._vertexData[offset++] = offsetX;
  104902. this._vertexData[offset++] = offsetY;
  104903. }
  104904. };
  104905. ParticleSystem.prototype._stopSubEmitters = function () {
  104906. if (!this.activeSubSystems) {
  104907. return;
  104908. }
  104909. this.activeSubSystems.forEach(function (subSystem) {
  104910. subSystem.stop(true);
  104911. });
  104912. this.activeSubSystems = new Array();
  104913. };
  104914. ParticleSystem.prototype._removeFromRoot = function () {
  104915. if (!this._rootParticleSystem) {
  104916. return;
  104917. }
  104918. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  104919. if (index !== -1) {
  104920. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  104921. }
  104922. this._rootParticleSystem = null;
  104923. };
  104924. // End of sub system methods
  104925. ParticleSystem.prototype._update = function (newParticles) {
  104926. var _this = this;
  104927. // Update current
  104928. this._alive = this._particles.length > 0;
  104929. if (this.emitter.position) {
  104930. var emitterMesh = this.emitter;
  104931. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  104932. }
  104933. else {
  104934. var emitterPosition = this.emitter;
  104935. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104936. }
  104937. this.updateFunction(this._particles);
  104938. // Add new ones
  104939. var particle;
  104940. var _loop_2 = function () {
  104941. if (this_1._particles.length === this_1._capacity) {
  104942. return "break";
  104943. }
  104944. particle = this_1._createParticle();
  104945. this_1._particles.push(particle);
  104946. // Emitter
  104947. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  104948. if (this_1.startPositionFunction) {
  104949. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  104950. }
  104951. else {
  104952. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  104953. }
  104954. if (this_1.startDirectionFunction) {
  104955. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  104956. }
  104957. else {
  104958. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  104959. }
  104960. if (emitPower === 0) {
  104961. if (!particle._initialDirection) {
  104962. particle._initialDirection = particle.direction.clone();
  104963. }
  104964. else {
  104965. particle._initialDirection.copyFrom(particle.direction);
  104966. }
  104967. }
  104968. else {
  104969. particle._initialDirection = null;
  104970. }
  104971. particle.direction.scaleInPlace(emitPower);
  104972. // Life time
  104973. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  104974. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  104975. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  104976. var factorGradient1 = currentGradient;
  104977. var factorGradient2 = nextGradient;
  104978. var lifeTime1 = factorGradient1.getFactor();
  104979. var lifeTime2 = factorGradient2.getFactor();
  104980. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  104981. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  104982. });
  104983. }
  104984. else {
  104985. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  104986. }
  104987. // Size
  104988. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  104989. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  104990. }
  104991. else {
  104992. particle._currentSizeGradient = this_1._sizeGradients[0];
  104993. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  104994. particle.size = particle._currentSize1;
  104995. if (this_1._sizeGradients.length > 1) {
  104996. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  104997. }
  104998. else {
  104999. particle._currentSize2 = particle._currentSize1;
  105000. }
  105001. }
  105002. // Size and scale
  105003. 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));
  105004. // Adjust scale by start size
  105005. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  105006. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  105007. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  105008. if (currentGradient !== _this._currentStartSizeGradient) {
  105009. _this._currentStartSize1 = _this._currentStartSize2;
  105010. _this._currentStartSize2 = nextGradient.getFactor();
  105011. _this._currentStartSizeGradient = currentGradient;
  105012. }
  105013. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  105014. particle.scale.scaleInPlace(value);
  105015. });
  105016. }
  105017. // Angle
  105018. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  105019. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  105020. }
  105021. else {
  105022. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  105023. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  105024. particle._currentAngularSpeed1 = particle.angularSpeed;
  105025. if (this_1._angularSpeedGradients.length > 1) {
  105026. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  105027. }
  105028. else {
  105029. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  105030. }
  105031. }
  105032. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  105033. // Velocity
  105034. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  105035. particle._currentVelocityGradient = this_1._velocityGradients[0];
  105036. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  105037. if (this_1._velocityGradients.length > 1) {
  105038. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  105039. }
  105040. else {
  105041. particle._currentVelocity2 = particle._currentVelocity1;
  105042. }
  105043. }
  105044. // Limit velocity
  105045. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  105046. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  105047. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  105048. if (this_1._limitVelocityGradients.length > 1) {
  105049. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  105050. }
  105051. else {
  105052. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  105053. }
  105054. }
  105055. // Drag
  105056. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  105057. particle._currentDragGradient = this_1._dragGradients[0];
  105058. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  105059. if (this_1._dragGradients.length > 1) {
  105060. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  105061. }
  105062. else {
  105063. particle._currentDrag2 = particle._currentDrag1;
  105064. }
  105065. }
  105066. // Color
  105067. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  105068. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  105069. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  105070. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  105071. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  105072. }
  105073. else {
  105074. particle._currentColorGradient = this_1._colorGradients[0];
  105075. particle._currentColorGradient.getColorToRef(particle.color);
  105076. particle._currentColor1.copyFrom(particle.color);
  105077. if (this_1._colorGradients.length > 1) {
  105078. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  105079. }
  105080. else {
  105081. particle._currentColor2.copyFrom(particle.color);
  105082. }
  105083. }
  105084. // Sheet
  105085. if (this_1._isAnimationSheetEnabled) {
  105086. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  105087. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  105088. }
  105089. // Inherited Velocity
  105090. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  105091. // Ramp
  105092. if (this_1._useRampGradients) {
  105093. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  105094. }
  105095. // Noise texture coordinates
  105096. if (this_1.noiseTexture) {
  105097. if (particle._randomNoiseCoordinates1) {
  105098. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  105099. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  105100. }
  105101. else {
  105102. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105103. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105104. }
  105105. }
  105106. // Update the position of the attached sub-emitters to match their attached particle
  105107. particle._inheritParticleInfoToSubEmitters();
  105108. };
  105109. var this_1 = this, step;
  105110. for (var index = 0; index < newParticles; index++) {
  105111. var state_1 = _loop_2();
  105112. if (state_1 === "break")
  105113. break;
  105114. }
  105115. };
  105116. /** @hidden */
  105117. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  105118. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105119. if (isBillboardBased === void 0) { isBillboardBased = false; }
  105120. if (useRampGradients === void 0) { useRampGradients = false; }
  105121. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  105122. if (isAnimationSheetEnabled) {
  105123. attributeNamesOrOptions.push("cellIndex");
  105124. }
  105125. if (!isBillboardBased) {
  105126. attributeNamesOrOptions.push("direction");
  105127. }
  105128. if (useRampGradients) {
  105129. attributeNamesOrOptions.push("remapData");
  105130. }
  105131. return attributeNamesOrOptions;
  105132. };
  105133. /** @hidden */
  105134. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  105135. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105136. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  105137. if (isAnimationSheetEnabled) {
  105138. effectCreationOption.push("particlesInfos");
  105139. }
  105140. return effectCreationOption;
  105141. };
  105142. /** @hidden */
  105143. ParticleSystem.prototype._getEffect = function (blendMode) {
  105144. if (this._customEffect) {
  105145. return this._customEffect;
  105146. }
  105147. var defines = [];
  105148. if (this._scene.clipPlane) {
  105149. defines.push("#define CLIPPLANE");
  105150. }
  105151. if (this._scene.clipPlane2) {
  105152. defines.push("#define CLIPPLANE2");
  105153. }
  105154. if (this._scene.clipPlane3) {
  105155. defines.push("#define CLIPPLANE3");
  105156. }
  105157. if (this._scene.clipPlane4) {
  105158. defines.push("#define CLIPPLANE4");
  105159. }
  105160. if (this._isAnimationSheetEnabled) {
  105161. defines.push("#define ANIMATESHEET");
  105162. }
  105163. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  105164. defines.push("#define BLENDMULTIPLYMODE");
  105165. }
  105166. if (this._useRampGradients) {
  105167. defines.push("#define RAMPGRADIENT");
  105168. }
  105169. if (this._isBillboardBased) {
  105170. defines.push("#define BILLBOARD");
  105171. switch (this.billboardMode) {
  105172. case ParticleSystem.BILLBOARDMODE_Y:
  105173. defines.push("#define BILLBOARDY");
  105174. break;
  105175. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  105176. defines.push("#define BILLBOARDSTRETCHED");
  105177. break;
  105178. case ParticleSystem.BILLBOARDMODE_ALL:
  105179. default:
  105180. break;
  105181. }
  105182. }
  105183. if (this._imageProcessingConfiguration) {
  105184. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  105185. defines.push(this._imageProcessingConfigurationDefines.toString());
  105186. }
  105187. // Effect
  105188. var join = defines.join("\n");
  105189. if (this._cachedDefines !== join) {
  105190. this._cachedDefines = join;
  105191. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  105192. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  105193. var samplers = ["diffuseSampler", "rampSampler"];
  105194. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  105195. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  105196. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  105197. }
  105198. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  105199. }
  105200. return this._effect;
  105201. };
  105202. /**
  105203. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105204. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  105205. */
  105206. ParticleSystem.prototype.animate = function (preWarmOnly) {
  105207. var _this = this;
  105208. if (preWarmOnly === void 0) { preWarmOnly = false; }
  105209. if (!this._started) {
  105210. return;
  105211. }
  105212. if (!preWarmOnly) {
  105213. // Check
  105214. if (!this.isReady()) {
  105215. return;
  105216. }
  105217. if (this._currentRenderId === this._scene.getFrameId()) {
  105218. return;
  105219. }
  105220. this._currentRenderId = this._scene.getFrameId();
  105221. }
  105222. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  105223. // Determine the number of particles we need to create
  105224. var newParticles;
  105225. if (this.manualEmitCount > -1) {
  105226. newParticles = this.manualEmitCount;
  105227. this._newPartsExcess = 0;
  105228. this.manualEmitCount = 0;
  105229. }
  105230. else {
  105231. var rate_1 = this.emitRate;
  105232. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  105233. var ratio = this._actualFrame / this.targetStopDuration;
  105234. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  105235. if (currentGradient !== _this._currentEmitRateGradient) {
  105236. _this._currentEmitRate1 = _this._currentEmitRate2;
  105237. _this._currentEmitRate2 = nextGradient.getFactor();
  105238. _this._currentEmitRateGradient = currentGradient;
  105239. }
  105240. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  105241. });
  105242. }
  105243. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  105244. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  105245. }
  105246. if (this._newPartsExcess > 1.0) {
  105247. newParticles += this._newPartsExcess >> 0;
  105248. this._newPartsExcess -= this._newPartsExcess >> 0;
  105249. }
  105250. this._alive = false;
  105251. if (!this._stopped) {
  105252. this._actualFrame += this._scaledUpdateSpeed;
  105253. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  105254. this.stop();
  105255. }
  105256. }
  105257. else {
  105258. newParticles = 0;
  105259. }
  105260. this._update(newParticles);
  105261. // Stopped?
  105262. if (this._stopped) {
  105263. if (!this._alive) {
  105264. this._started = false;
  105265. if (this.onAnimationEnd) {
  105266. this.onAnimationEnd();
  105267. }
  105268. if (this.disposeOnStop) {
  105269. this._scene._toBeDisposed.push(this);
  105270. }
  105271. }
  105272. }
  105273. if (!preWarmOnly) {
  105274. // Update VBO
  105275. var offset = 0;
  105276. for (var index = 0; index < this._particles.length; index++) {
  105277. var particle = this._particles[index];
  105278. this._appendParticleVertices(offset, particle);
  105279. offset += this._useInstancing ? 1 : 4;
  105280. }
  105281. if (this._vertexBuffer) {
  105282. this._vertexBuffer.update(this._vertexData);
  105283. }
  105284. }
  105285. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  105286. this.stop();
  105287. }
  105288. };
  105289. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  105290. this._appendParticleVertex(offset++, particle, 0, 0);
  105291. if (!this._useInstancing) {
  105292. this._appendParticleVertex(offset++, particle, 1, 0);
  105293. this._appendParticleVertex(offset++, particle, 1, 1);
  105294. this._appendParticleVertex(offset++, particle, 0, 1);
  105295. }
  105296. };
  105297. /**
  105298. * Rebuilds the particle system.
  105299. */
  105300. ParticleSystem.prototype.rebuild = function () {
  105301. this._createIndexBuffer();
  105302. if (this._vertexBuffer) {
  105303. this._vertexBuffer._rebuild();
  105304. }
  105305. };
  105306. /**
  105307. * Is this system ready to be used/rendered
  105308. * @return true if the system is ready
  105309. */
  105310. ParticleSystem.prototype.isReady = function () {
  105311. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  105312. return false;
  105313. }
  105314. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105315. if (!this._getEffect(this.blendMode).isReady()) {
  105316. return false;
  105317. }
  105318. }
  105319. else {
  105320. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  105321. return false;
  105322. }
  105323. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  105324. return false;
  105325. }
  105326. }
  105327. return true;
  105328. };
  105329. ParticleSystem.prototype._render = function (blendMode) {
  105330. var effect = this._getEffect(blendMode);
  105331. var engine = this._scene.getEngine();
  105332. // Render
  105333. engine.enableEffect(effect);
  105334. var viewMatrix = this._scene.getViewMatrix();
  105335. effect.setTexture("diffuseSampler", this.particleTexture);
  105336. effect.setMatrix("view", viewMatrix);
  105337. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  105338. if (this._isAnimationSheetEnabled && this.particleTexture) {
  105339. var baseSize = this.particleTexture.getBaseSize();
  105340. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  105341. }
  105342. effect.setVector2("translationPivot", this.translationPivot);
  105343. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  105344. if (this._isBillboardBased) {
  105345. var camera = this._scene.activeCamera;
  105346. effect.setVector3("eyePosition", camera.globalPosition);
  105347. }
  105348. if (this._rampGradientsTexture) {
  105349. effect.setTexture("rampSampler", this._rampGradientsTexture);
  105350. }
  105351. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  105352. var invView = viewMatrix.clone();
  105353. invView.invert();
  105354. effect.setMatrix("invView", invView);
  105355. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  105356. }
  105357. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  105358. // image processing
  105359. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  105360. this._imageProcessingConfiguration.bind(effect);
  105361. }
  105362. // Draw order
  105363. switch (blendMode) {
  105364. case ParticleSystem.BLENDMODE_ADD:
  105365. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ADD);
  105366. break;
  105367. case ParticleSystem.BLENDMODE_ONEONE:
  105368. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ONEONE);
  105369. break;
  105370. case ParticleSystem.BLENDMODE_STANDARD:
  105371. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_COMBINE);
  105372. break;
  105373. case ParticleSystem.BLENDMODE_MULTIPLY:
  105374. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_MULTIPLY);
  105375. break;
  105376. }
  105377. if (this._useInstancing) {
  105378. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  105379. }
  105380. else {
  105381. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  105382. }
  105383. return this._particles.length;
  105384. };
  105385. /**
  105386. * Renders the particle system in its current state.
  105387. * @returns the current number of particles
  105388. */
  105389. ParticleSystem.prototype.render = function () {
  105390. // Check
  105391. if (!this.isReady() || !this._particles.length) {
  105392. return 0;
  105393. }
  105394. var engine = this._scene.getEngine();
  105395. engine.setState(false);
  105396. if (this.forceDepthWrite) {
  105397. engine.setDepthWrite(true);
  105398. }
  105399. var outparticles = 0;
  105400. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105401. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  105402. }
  105403. outparticles = this._render(this.blendMode);
  105404. engine.unbindInstanceAttributes();
  105405. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_DISABLE);
  105406. return outparticles;
  105407. };
  105408. /**
  105409. * Disposes the particle system and free the associated resources
  105410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105411. */
  105412. ParticleSystem.prototype.dispose = function (disposeTexture) {
  105413. if (disposeTexture === void 0) { disposeTexture = true; }
  105414. if (this._vertexBuffer) {
  105415. this._vertexBuffer.dispose();
  105416. this._vertexBuffer = null;
  105417. }
  105418. if (this._spriteBuffer) {
  105419. this._spriteBuffer.dispose();
  105420. this._spriteBuffer = null;
  105421. }
  105422. if (this._indexBuffer) {
  105423. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  105424. this._indexBuffer = null;
  105425. }
  105426. if (disposeTexture && this.particleTexture) {
  105427. this.particleTexture.dispose();
  105428. this.particleTexture = null;
  105429. }
  105430. if (disposeTexture && this.noiseTexture) {
  105431. this.noiseTexture.dispose();
  105432. this.noiseTexture = null;
  105433. }
  105434. if (this._rampGradientsTexture) {
  105435. this._rampGradientsTexture.dispose();
  105436. this._rampGradientsTexture = null;
  105437. }
  105438. this._removeFromRoot();
  105439. if (this._subEmitters && this._subEmitters.length) {
  105440. for (var index = 0; index < this._subEmitters.length; index++) {
  105441. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  105442. var subEmitter = _a[_i];
  105443. subEmitter.dispose();
  105444. }
  105445. }
  105446. this._subEmitters = [];
  105447. this.subEmitters = [];
  105448. }
  105449. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  105450. this.emitter.dispose(true);
  105451. }
  105452. // Remove from scene
  105453. var index = this._scene.particleSystems.indexOf(this);
  105454. if (index > -1) {
  105455. this._scene.particleSystems.splice(index, 1);
  105456. }
  105457. this._scene._activeParticleSystems.dispose();
  105458. // Callback
  105459. this.onDisposeObservable.notifyObservers(this);
  105460. this.onDisposeObservable.clear();
  105461. this.reset();
  105462. };
  105463. // Clone
  105464. /**
  105465. * Clones the particle system.
  105466. * @param name The name of the cloned object
  105467. * @param newEmitter The new emitter to use
  105468. * @returns the cloned particle system
  105469. */
  105470. ParticleSystem.prototype.clone = function (name, newEmitter) {
  105471. var custom = null;
  105472. var program = null;
  105473. if (this.customShader != null) {
  105474. program = this.customShader;
  105475. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  105476. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  105477. }
  105478. else if (this._customEffect) {
  105479. custom = this._customEffect;
  105480. }
  105481. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  105482. result.customShader = program;
  105483. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  105484. if (newEmitter === undefined) {
  105485. newEmitter = this.emitter;
  105486. }
  105487. result.noiseTexture = this.noiseTexture;
  105488. result.emitter = newEmitter;
  105489. if (this.particleTexture) {
  105490. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  105491. }
  105492. // Clone gradients
  105493. if (this._colorGradients) {
  105494. this._colorGradients.forEach(function (v) {
  105495. result.addColorGradient(v.gradient, v.color1, v.color2);
  105496. });
  105497. }
  105498. if (this._dragGradients) {
  105499. this._dragGradients.forEach(function (v) {
  105500. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  105501. });
  105502. }
  105503. if (this._angularSpeedGradients) {
  105504. this._angularSpeedGradients.forEach(function (v) {
  105505. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  105506. });
  105507. }
  105508. if (this._emitRateGradients) {
  105509. this._emitRateGradients.forEach(function (v) {
  105510. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  105511. });
  105512. }
  105513. if (this._lifeTimeGradients) {
  105514. this._lifeTimeGradients.forEach(function (v) {
  105515. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  105516. });
  105517. }
  105518. if (this._limitVelocityGradients) {
  105519. this._limitVelocityGradients.forEach(function (v) {
  105520. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  105521. });
  105522. }
  105523. if (this._sizeGradients) {
  105524. this._sizeGradients.forEach(function (v) {
  105525. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  105526. });
  105527. }
  105528. if (this._startSizeGradients) {
  105529. this._startSizeGradients.forEach(function (v) {
  105530. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  105531. });
  105532. }
  105533. if (this._velocityGradients) {
  105534. this._velocityGradients.forEach(function (v) {
  105535. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  105536. });
  105537. }
  105538. if (this._rampGradients) {
  105539. this._rampGradients.forEach(function (v) {
  105540. result.addRampGradient(v.gradient, v.color);
  105541. });
  105542. }
  105543. if (this._colorRemapGradients) {
  105544. this._colorRemapGradients.forEach(function (v) {
  105545. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  105546. });
  105547. }
  105548. if (this._alphaRemapGradients) {
  105549. this._alphaRemapGradients.forEach(function (v) {
  105550. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  105551. });
  105552. }
  105553. if (!this.preventAutoStart) {
  105554. result.start();
  105555. }
  105556. return result;
  105557. };
  105558. /**
  105559. * Serializes the particle system to a JSON object.
  105560. * @returns the JSON object
  105561. */
  105562. ParticleSystem.prototype.serialize = function () {
  105563. var serializationObject = {};
  105564. ParticleSystem._Serialize(serializationObject, this);
  105565. serializationObject.textureMask = this.textureMask.asArray();
  105566. serializationObject.customShader = this.customShader;
  105567. serializationObject.preventAutoStart = this.preventAutoStart;
  105568. // SubEmitters
  105569. if (this.subEmitters) {
  105570. serializationObject.subEmitters = [];
  105571. if (!this._subEmitters) {
  105572. this._prepareSubEmitterInternalArray();
  105573. }
  105574. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  105575. var subs = _a[_i];
  105576. var cell = [];
  105577. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  105578. var sub = subs_1[_b];
  105579. cell.push(sub.serialize());
  105580. }
  105581. serializationObject.subEmitters.push(cell);
  105582. }
  105583. }
  105584. return serializationObject;
  105585. };
  105586. /** @hidden */
  105587. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  105588. serializationObject.name = particleSystem.name;
  105589. serializationObject.id = particleSystem.id;
  105590. serializationObject.capacity = particleSystem.getCapacity();
  105591. // Emitter
  105592. if (particleSystem.emitter.position) {
  105593. var emitterMesh = particleSystem.emitter;
  105594. serializationObject.emitterId = emitterMesh.id;
  105595. }
  105596. else {
  105597. var emitterPosition = particleSystem.emitter;
  105598. serializationObject.emitter = emitterPosition.asArray();
  105599. }
  105600. // Emitter
  105601. if (particleSystem.particleEmitterType) {
  105602. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  105603. }
  105604. if (particleSystem.particleTexture) {
  105605. serializationObject.textureName = particleSystem.particleTexture.name;
  105606. serializationObject.invertY = particleSystem.particleTexture._invertY;
  105607. }
  105608. // Animations
  105609. _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  105610. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  105611. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  105612. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  105613. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  105614. // Particle system
  105615. serializationObject.startDelay = particleSystem.startDelay;
  105616. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  105617. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  105618. serializationObject.billboardMode = particleSystem.billboardMode;
  105619. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  105620. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  105621. serializationObject.minSize = particleSystem.minSize;
  105622. serializationObject.maxSize = particleSystem.maxSize;
  105623. serializationObject.minScaleX = particleSystem.minScaleX;
  105624. serializationObject.maxScaleX = particleSystem.maxScaleX;
  105625. serializationObject.minScaleY = particleSystem.minScaleY;
  105626. serializationObject.maxScaleY = particleSystem.maxScaleY;
  105627. serializationObject.minEmitPower = particleSystem.minEmitPower;
  105628. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  105629. serializationObject.minLifeTime = particleSystem.minLifeTime;
  105630. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  105631. serializationObject.emitRate = particleSystem.emitRate;
  105632. serializationObject.gravity = particleSystem.gravity.asArray();
  105633. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  105634. serializationObject.color1 = particleSystem.color1.asArray();
  105635. serializationObject.color2 = particleSystem.color2.asArray();
  105636. serializationObject.colorDead = particleSystem.colorDead.asArray();
  105637. serializationObject.updateSpeed = particleSystem.updateSpeed;
  105638. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  105639. serializationObject.blendMode = particleSystem.blendMode;
  105640. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  105641. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  105642. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  105643. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  105644. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  105645. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  105646. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  105647. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  105648. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  105649. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  105650. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  105651. var colorGradients = particleSystem.getColorGradients();
  105652. if (colorGradients) {
  105653. serializationObject.colorGradients = [];
  105654. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  105655. var colorGradient = colorGradients_1[_i];
  105656. var serializedGradient = {
  105657. gradient: colorGradient.gradient,
  105658. color1: colorGradient.color1.asArray()
  105659. };
  105660. if (colorGradient.color2) {
  105661. serializedGradient.color2 = colorGradient.color2.asArray();
  105662. }
  105663. serializationObject.colorGradients.push(serializedGradient);
  105664. }
  105665. }
  105666. var rampGradients = particleSystem.getRampGradients();
  105667. if (rampGradients) {
  105668. serializationObject.rampGradients = [];
  105669. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  105670. var rampGradient = rampGradients_1[_a];
  105671. var serializedGradient = {
  105672. gradient: rampGradient.gradient,
  105673. color: rampGradient.color.asArray()
  105674. };
  105675. serializationObject.rampGradients.push(serializedGradient);
  105676. }
  105677. serializationObject.useRampGradients = particleSystem.useRampGradients;
  105678. }
  105679. var colorRemapGradients = particleSystem.getColorRemapGradients();
  105680. if (colorRemapGradients) {
  105681. serializationObject.colorRemapGradients = [];
  105682. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  105683. var colorRemapGradient = colorRemapGradients_1[_b];
  105684. var serializedGradient = {
  105685. gradient: colorRemapGradient.gradient,
  105686. factor1: colorRemapGradient.factor1
  105687. };
  105688. if (colorRemapGradient.factor2 !== undefined) {
  105689. serializedGradient.factor2 = colorRemapGradient.factor2;
  105690. }
  105691. serializationObject.colorRemapGradients.push(serializedGradient);
  105692. }
  105693. }
  105694. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  105695. if (alphaRemapGradients) {
  105696. serializationObject.alphaRemapGradients = [];
  105697. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  105698. var alphaRemapGradient = alphaRemapGradients_1[_c];
  105699. var serializedGradient = {
  105700. gradient: alphaRemapGradient.gradient,
  105701. factor1: alphaRemapGradient.factor1
  105702. };
  105703. if (alphaRemapGradient.factor2 !== undefined) {
  105704. serializedGradient.factor2 = alphaRemapGradient.factor2;
  105705. }
  105706. serializationObject.alphaRemapGradients.push(serializedGradient);
  105707. }
  105708. }
  105709. var sizeGradients = particleSystem.getSizeGradients();
  105710. if (sizeGradients) {
  105711. serializationObject.sizeGradients = [];
  105712. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  105713. var sizeGradient = sizeGradients_1[_d];
  105714. var serializedGradient = {
  105715. gradient: sizeGradient.gradient,
  105716. factor1: sizeGradient.factor1
  105717. };
  105718. if (sizeGradient.factor2 !== undefined) {
  105719. serializedGradient.factor2 = sizeGradient.factor2;
  105720. }
  105721. serializationObject.sizeGradients.push(serializedGradient);
  105722. }
  105723. }
  105724. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  105725. if (angularSpeedGradients) {
  105726. serializationObject.angularSpeedGradients = [];
  105727. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  105728. var angularSpeedGradient = angularSpeedGradients_1[_e];
  105729. var serializedGradient = {
  105730. gradient: angularSpeedGradient.gradient,
  105731. factor1: angularSpeedGradient.factor1
  105732. };
  105733. if (angularSpeedGradient.factor2 !== undefined) {
  105734. serializedGradient.factor2 = angularSpeedGradient.factor2;
  105735. }
  105736. serializationObject.angularSpeedGradients.push(serializedGradient);
  105737. }
  105738. }
  105739. var velocityGradients = particleSystem.getVelocityGradients();
  105740. if (velocityGradients) {
  105741. serializationObject.velocityGradients = [];
  105742. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  105743. var velocityGradient = velocityGradients_1[_f];
  105744. var serializedGradient = {
  105745. gradient: velocityGradient.gradient,
  105746. factor1: velocityGradient.factor1
  105747. };
  105748. if (velocityGradient.factor2 !== undefined) {
  105749. serializedGradient.factor2 = velocityGradient.factor2;
  105750. }
  105751. serializationObject.velocityGradients.push(serializedGradient);
  105752. }
  105753. }
  105754. var dragGradients = particleSystem.getDragGradients();
  105755. if (dragGradients) {
  105756. serializationObject.dragyGradients = [];
  105757. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  105758. var dragGradient = dragGradients_1[_g];
  105759. var serializedGradient = {
  105760. gradient: dragGradient.gradient,
  105761. factor1: dragGradient.factor1
  105762. };
  105763. if (dragGradient.factor2 !== undefined) {
  105764. serializedGradient.factor2 = dragGradient.factor2;
  105765. }
  105766. serializationObject.dragGradients.push(serializedGradient);
  105767. }
  105768. }
  105769. var emitRateGradients = particleSystem.getEmitRateGradients();
  105770. if (emitRateGradients) {
  105771. serializationObject.emitRateGradients = [];
  105772. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  105773. var emitRateGradient = emitRateGradients_1[_h];
  105774. var serializedGradient = {
  105775. gradient: emitRateGradient.gradient,
  105776. factor1: emitRateGradient.factor1
  105777. };
  105778. if (emitRateGradient.factor2 !== undefined) {
  105779. serializedGradient.factor2 = emitRateGradient.factor2;
  105780. }
  105781. serializationObject.emitRateGradients.push(serializedGradient);
  105782. }
  105783. }
  105784. var startSizeGradients = particleSystem.getStartSizeGradients();
  105785. if (startSizeGradients) {
  105786. serializationObject.startSizeGradients = [];
  105787. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  105788. var startSizeGradient = startSizeGradients_1[_j];
  105789. var serializedGradient = {
  105790. gradient: startSizeGradient.gradient,
  105791. factor1: startSizeGradient.factor1
  105792. };
  105793. if (startSizeGradient.factor2 !== undefined) {
  105794. serializedGradient.factor2 = startSizeGradient.factor2;
  105795. }
  105796. serializationObject.startSizeGradients.push(serializedGradient);
  105797. }
  105798. }
  105799. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  105800. if (lifeTimeGradients) {
  105801. serializationObject.lifeTimeGradients = [];
  105802. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  105803. var lifeTimeGradient = lifeTimeGradients_1[_k];
  105804. var serializedGradient = {
  105805. gradient: lifeTimeGradient.gradient,
  105806. factor1: lifeTimeGradient.factor1
  105807. };
  105808. if (lifeTimeGradient.factor2 !== undefined) {
  105809. serializedGradient.factor2 = lifeTimeGradient.factor2;
  105810. }
  105811. serializationObject.lifeTimeGradients.push(serializedGradient);
  105812. }
  105813. }
  105814. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  105815. if (limitVelocityGradients) {
  105816. serializationObject.limitVelocityGradients = [];
  105817. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  105818. var limitVelocityGradient = limitVelocityGradients_1[_l];
  105819. var serializedGradient = {
  105820. gradient: limitVelocityGradient.gradient,
  105821. factor1: limitVelocityGradient.factor1
  105822. };
  105823. if (limitVelocityGradient.factor2 !== undefined) {
  105824. serializedGradient.factor2 = limitVelocityGradient.factor2;
  105825. }
  105826. serializationObject.limitVelocityGradients.push(serializedGradient);
  105827. }
  105828. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  105829. }
  105830. if (particleSystem.noiseTexture) {
  105831. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  105832. }
  105833. };
  105834. /** @hidden */
  105835. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  105836. // Texture
  105837. if (parsedParticleSystem.textureName) {
  105838. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  105839. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  105840. }
  105841. // Emitter
  105842. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  105843. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105844. }
  105845. else if (parsedParticleSystem.emitterId) {
  105846. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  105847. }
  105848. else {
  105849. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  105850. }
  105851. // Misc.
  105852. if (parsedParticleSystem.renderingGroupId !== undefined) {
  105853. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  105854. }
  105855. if (parsedParticleSystem.isBillboardBased !== undefined) {
  105856. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  105857. }
  105858. if (parsedParticleSystem.billboardMode !== undefined) {
  105859. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  105860. }
  105861. // Animations
  105862. if (parsedParticleSystem.animations) {
  105863. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  105864. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  105865. particleSystem.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  105866. }
  105867. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  105868. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  105869. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  105870. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  105871. }
  105872. if (parsedParticleSystem.autoAnimate) {
  105873. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  105874. }
  105875. // Particle system
  105876. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  105877. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  105878. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  105879. particleSystem.minSize = parsedParticleSystem.minSize;
  105880. particleSystem.maxSize = parsedParticleSystem.maxSize;
  105881. if (parsedParticleSystem.minScaleX) {
  105882. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  105883. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  105884. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  105885. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  105886. }
  105887. if (parsedParticleSystem.preWarmCycles !== undefined) {
  105888. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  105889. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  105890. }
  105891. if (parsedParticleSystem.minInitialRotation !== undefined) {
  105892. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  105893. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  105894. }
  105895. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  105896. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  105897. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  105898. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  105899. particleSystem.emitRate = parsedParticleSystem.emitRate;
  105900. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  105901. if (parsedParticleSystem.noiseStrength) {
  105902. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  105903. }
  105904. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  105905. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  105906. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  105907. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  105908. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  105909. particleSystem.blendMode = parsedParticleSystem.blendMode;
  105910. if (parsedParticleSystem.colorGradients) {
  105911. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  105912. var colorGradient = _a[_i];
  105913. 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);
  105914. }
  105915. }
  105916. if (parsedParticleSystem.rampGradients) {
  105917. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  105918. var rampGradient = _c[_b];
  105919. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  105920. }
  105921. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  105922. }
  105923. if (parsedParticleSystem.colorRemapGradients) {
  105924. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  105925. var colorRemapGradient = _e[_d];
  105926. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  105927. }
  105928. }
  105929. if (parsedParticleSystem.alphaRemapGradients) {
  105930. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  105931. var alphaRemapGradient = _g[_f];
  105932. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  105933. }
  105934. }
  105935. if (parsedParticleSystem.sizeGradients) {
  105936. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  105937. var sizeGradient = _j[_h];
  105938. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  105939. }
  105940. }
  105941. if (parsedParticleSystem.sizeGradients) {
  105942. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  105943. var sizeGradient = _l[_k];
  105944. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  105945. }
  105946. }
  105947. if (parsedParticleSystem.angularSpeedGradients) {
  105948. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  105949. var angularSpeedGradient = _o[_m];
  105950. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  105951. }
  105952. }
  105953. if (parsedParticleSystem.velocityGradients) {
  105954. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  105955. var velocityGradient = _q[_p];
  105956. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  105957. }
  105958. }
  105959. if (parsedParticleSystem.dragGradients) {
  105960. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  105961. var dragGradient = _s[_r];
  105962. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  105963. }
  105964. }
  105965. if (parsedParticleSystem.emitRateGradients) {
  105966. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  105967. var emitRateGradient = _u[_t];
  105968. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  105969. }
  105970. }
  105971. if (parsedParticleSystem.startSizeGradients) {
  105972. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  105973. var startSizeGradient = _w[_v];
  105974. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  105975. }
  105976. }
  105977. if (parsedParticleSystem.lifeTimeGradients) {
  105978. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  105979. var lifeTimeGradient = _y[_x];
  105980. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  105981. }
  105982. }
  105983. if (parsedParticleSystem.limitVelocityGradients) {
  105984. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  105985. var limitVelocityGradient = _0[_z];
  105986. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  105987. }
  105988. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  105989. }
  105990. if (parsedParticleSystem.noiseTexture) {
  105991. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  105992. }
  105993. // Emitter
  105994. var emitterType;
  105995. if (parsedParticleSystem.particleEmitterType) {
  105996. switch (parsedParticleSystem.particleEmitterType.type) {
  105997. case "SphereParticleEmitter":
  105998. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereParticleEmitter"]();
  105999. break;
  106000. case "SphereDirectedParticleEmitter":
  106001. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereDirectedParticleEmitter"]();
  106002. break;
  106003. case "ConeEmitter":
  106004. case "ConeParticleEmitter":
  106005. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["ConeParticleEmitter"]();
  106006. break;
  106007. case "CylinderParticleEmitter":
  106008. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["CylinderParticleEmitter"]();
  106009. break;
  106010. case "HemisphericParticleEmitter":
  106011. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["HemisphericParticleEmitter"]();
  106012. break;
  106013. case "BoxEmitter":
  106014. case "BoxParticleEmitter":
  106015. default:
  106016. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106017. break;
  106018. }
  106019. emitterType.parse(parsedParticleSystem.particleEmitterType);
  106020. }
  106021. else {
  106022. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106023. emitterType.parse(parsedParticleSystem);
  106024. }
  106025. particleSystem.particleEmitterType = emitterType;
  106026. // Animation sheet
  106027. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  106028. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  106029. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  106030. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  106031. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  106032. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  106033. };
  106034. /**
  106035. * Parses a JSON object to create a particle system.
  106036. * @param parsedParticleSystem The JSON object to parse
  106037. * @param scene The scene to create the particle system in
  106038. * @param rootUrl The root url to use to load external dependencies like texture
  106039. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106040. * @returns the Parsed particle system
  106041. */
  106042. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106043. if (doNotStart === void 0) { doNotStart = false; }
  106044. var name = parsedParticleSystem.name;
  106045. var custom = null;
  106046. var program = null;
  106047. if (parsedParticleSystem.customShader) {
  106048. program = parsedParticleSystem.customShader;
  106049. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106050. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106051. }
  106052. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  106053. particleSystem.customShader = program;
  106054. if (parsedParticleSystem.id) {
  106055. particleSystem.id = parsedParticleSystem.id;
  106056. }
  106057. // SubEmitters
  106058. if (parsedParticleSystem.subEmitters) {
  106059. particleSystem.subEmitters = [];
  106060. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  106061. var cell = _a[_i];
  106062. var cellArray = [];
  106063. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  106064. var sub = cell_1[_b];
  106065. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"].Parse(sub, scene, rootUrl));
  106066. }
  106067. particleSystem.subEmitters.push(cellArray);
  106068. }
  106069. }
  106070. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106071. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  106072. // Auto start
  106073. if (parsedParticleSystem.preventAutoStart) {
  106074. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106075. }
  106076. if (!doNotStart && !particleSystem.preventAutoStart) {
  106077. particleSystem.start();
  106078. }
  106079. return particleSystem;
  106080. };
  106081. /**
  106082. * Billboard mode will only apply to Y axis
  106083. */
  106084. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  106085. /**
  106086. * Billboard mode will apply to all axes
  106087. */
  106088. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  106089. /**
  106090. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  106091. */
  106092. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  106093. return ParticleSystem;
  106094. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__["BaseParticleSystem"]));
  106095. _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  106096. /***/ }),
  106097. /***/ "./Particles/particleSystemComponent.ts":
  106098. /*!**********************************************!*\
  106099. !*** ./Particles/particleSystemComponent.ts ***!
  106100. \**********************************************/
  106101. /*! exports provided: _IDoNeedToBeInTheBuild */
  106102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106103. "use strict";
  106104. __webpack_require__.r(__webpack_exports__);
  106105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  106106. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106107. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106108. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  106109. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  106110. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106111. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  106112. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  106113. // Adds the parsers to the scene parsers.
  106114. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  106115. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  106116. if (!individualParser) {
  106117. return;
  106118. }
  106119. // Particles Systems
  106120. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  106121. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  106122. var parsedParticleSystem = parsedData.particleSystems[index];
  106123. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  106124. }
  106125. }
  106126. });
  106127. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  106128. if (parsedParticleSystem.activeParticleCount) {
  106129. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106130. return ps;
  106131. }
  106132. else {
  106133. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106134. return ps;
  106135. }
  106136. });
  106137. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  106138. if (uniformsNames === void 0) { uniformsNames = []; }
  106139. if (samplers === void 0) { samplers = []; }
  106140. if (defines === void 0) { defines = ""; }
  106141. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  106142. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  106143. if (defines.indexOf(" BILLBOARD") === -1) {
  106144. defines += "\n#define BILLBOARD\n";
  106145. }
  106146. if (samplers.indexOf("diffuseSampler") === -1) {
  106147. samplers.push("diffuseSampler");
  106148. }
  106149. return this.createEffect({
  106150. vertex: "particles",
  106151. fragmentElement: fragmentName
  106152. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  106153. };
  106154. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  106155. var results = new Array();
  106156. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106157. var particleSystem = this.getScene().particleSystems[index];
  106158. if (particleSystem.emitter === this) {
  106159. results.push(particleSystem);
  106160. }
  106161. }
  106162. return results;
  106163. };
  106164. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  106165. var results = new Array();
  106166. var descendants = this.getDescendants();
  106167. descendants.push(this);
  106168. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106169. var particleSystem = this.getScene().particleSystems[index];
  106170. var emitter = particleSystem.emitter;
  106171. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  106172. results.push(particleSystem);
  106173. }
  106174. }
  106175. return results;
  106176. };
  106177. /**
  106178. * @hidden
  106179. */
  106180. var _IDoNeedToBeInTheBuild = 42;
  106181. /***/ }),
  106182. /***/ "./Particles/particleSystemSet.ts":
  106183. /*!****************************************!*\
  106184. !*** ./Particles/particleSystemSet.ts ***!
  106185. \****************************************/
  106186. /*! exports provided: ParticleSystemSet */
  106187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106188. "use strict";
  106189. __webpack_require__.r(__webpack_exports__);
  106190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  106191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106192. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106193. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106194. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106195. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  106196. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  106197. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106198. /** Internal class used to store shapes for emitters */
  106199. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  106200. function ParticleSystemSetEmitterCreationOptions() {
  106201. }
  106202. return ParticleSystemSetEmitterCreationOptions;
  106203. }());
  106204. /**
  106205. * Represents a set of particle systems working together to create a specific effect
  106206. */
  106207. var ParticleSystemSet = /** @class */ (function () {
  106208. function ParticleSystemSet() {
  106209. /**
  106210. * Gets the particle system list
  106211. */
  106212. this.systems = new Array();
  106213. }
  106214. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  106215. /**
  106216. * Gets the emitter node used with this set
  106217. */
  106218. get: function () {
  106219. return this._emitterNode;
  106220. },
  106221. enumerable: true,
  106222. configurable: true
  106223. });
  106224. /**
  106225. * Creates a new emitter mesh as a sphere
  106226. * @param options defines the options used to create the sphere
  106227. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106228. * @param scene defines the hosting scene
  106229. */
  106230. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  106231. if (this._emitterNode) {
  106232. this._emitterNode.dispose();
  106233. }
  106234. this._emitterCreationOptions = {
  106235. kind: "Sphere",
  106236. options: options,
  106237. renderingGroupId: renderingGroupId
  106238. };
  106239. var emitterMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  106240. emitterMesh.renderingGroupId = renderingGroupId;
  106241. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  106242. material.emissiveColor = options.color;
  106243. emitterMesh.material = material;
  106244. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106245. var system = _a[_i];
  106246. system.emitter = emitterMesh;
  106247. }
  106248. this._emitterNode = emitterMesh;
  106249. };
  106250. /**
  106251. * Starts all particle systems of the set
  106252. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106253. */
  106254. ParticleSystemSet.prototype.start = function (emitter) {
  106255. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106256. var system = _a[_i];
  106257. if (emitter) {
  106258. system.emitter = emitter;
  106259. }
  106260. system.start();
  106261. }
  106262. };
  106263. /**
  106264. * Release all associated resources
  106265. */
  106266. ParticleSystemSet.prototype.dispose = function () {
  106267. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106268. var system = _a[_i];
  106269. system.dispose();
  106270. }
  106271. this.systems = [];
  106272. if (this._emitterNode) {
  106273. this._emitterNode.dispose();
  106274. this._emitterNode = null;
  106275. }
  106276. };
  106277. /**
  106278. * Serialize the set into a JSON compatible object
  106279. * @returns a JSON compatible representation of the set
  106280. */
  106281. ParticleSystemSet.prototype.serialize = function () {
  106282. var result = {};
  106283. result.systems = [];
  106284. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106285. var system = _a[_i];
  106286. result.systems.push(system.serialize());
  106287. }
  106288. if (this._emitterNode) {
  106289. result.emitter = this._emitterCreationOptions;
  106290. }
  106291. return result;
  106292. };
  106293. /**
  106294. * Parse a new ParticleSystemSet from a serialized source
  106295. * @param data defines a JSON compatible representation of the set
  106296. * @param scene defines the hosting scene
  106297. * @param gpu defines if we want GPU particles or CPU particles
  106298. * @returns a new ParticleSystemSet
  106299. */
  106300. ParticleSystemSet.Parse = function (data, scene, gpu) {
  106301. if (gpu === void 0) { gpu = false; }
  106302. var result = new ParticleSystemSet();
  106303. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  106304. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  106305. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  106306. var system = _a[_i];
  106307. 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));
  106308. }
  106309. if (data.emitter) {
  106310. var options = data.emitter.options;
  106311. switch (data.emitter.kind) {
  106312. case "Sphere":
  106313. result.setEmitterAsSphere({
  106314. diameter: options.diameter,
  106315. segments: options.segments,
  106316. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  106317. }, data.emitter.renderingGroupId, scene);
  106318. break;
  106319. }
  106320. }
  106321. return result;
  106322. };
  106323. return ParticleSystemSet;
  106324. }());
  106325. /***/ }),
  106326. /***/ "./Particles/solidParticle.ts":
  106327. /*!************************************!*\
  106328. !*** ./Particles/solidParticle.ts ***!
  106329. \************************************/
  106330. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  106331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106332. "use strict";
  106333. __webpack_require__.r(__webpack_exports__);
  106334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  106335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  106336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  106337. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106338. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106339. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  106340. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  106341. /**
  106342. * Represents one particle of a solid particle system.
  106343. */
  106344. var SolidParticle = /** @class */ (function () {
  106345. /**
  106346. * Creates a Solid Particle object.
  106347. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  106348. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  106349. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  106350. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  106351. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  106352. * @param shapeId (integer) is the model shape identifier in the SPS.
  106353. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  106354. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  106355. */
  106356. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  106357. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  106358. /**
  106359. * particle global index
  106360. */
  106361. this.idx = 0;
  106362. /**
  106363. * The color of the particle
  106364. */
  106365. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106366. /**
  106367. * The world space position of the particle.
  106368. */
  106369. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106370. /**
  106371. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  106372. */
  106373. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106374. /**
  106375. * The scaling of the particle.
  106376. */
  106377. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  106378. /**
  106379. * The uvs of the particle.
  106380. */
  106381. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  106382. /**
  106383. * The current speed of the particle.
  106384. */
  106385. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106386. /**
  106387. * The pivot point in the particle local space.
  106388. */
  106389. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106390. /**
  106391. * Must the particle be translated from its pivot point in its local space ?
  106392. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  106393. * Default : false
  106394. */
  106395. this.translateFromPivot = false;
  106396. /**
  106397. * Is the particle active or not ?
  106398. */
  106399. this.alive = true;
  106400. /**
  106401. * Is the particle visible or not ?
  106402. */
  106403. this.isVisible = true;
  106404. /**
  106405. * Index of this particle in the global "positions" array (Internal use)
  106406. * @hidden
  106407. */
  106408. this._pos = 0;
  106409. /**
  106410. * @hidden Index of this particle in the global "indices" array (Internal use)
  106411. */
  106412. this._ind = 0;
  106413. /**
  106414. * ModelShape id of this particle
  106415. */
  106416. this.shapeId = 0;
  106417. /**
  106418. * Index of the particle in its shape id (Internal use)
  106419. */
  106420. this.idxInShape = 0;
  106421. /**
  106422. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  106423. */
  106424. this._stillInvisible = false;
  106425. /**
  106426. * @hidden Last computed particle rotation matrix
  106427. */
  106428. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  106429. /**
  106430. * Parent particle Id, if any.
  106431. * Default null.
  106432. */
  106433. this.parentId = null;
  106434. /**
  106435. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  106436. * The possible values are :
  106437. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  106438. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106439. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  106440. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  106441. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106442. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  106443. * */
  106444. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  106445. /**
  106446. * @hidden Internal global position in the SPS.
  106447. */
  106448. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106449. this.idx = particleIndex;
  106450. this._pos = positionIndex;
  106451. this._ind = indiceIndex;
  106452. this._model = model;
  106453. this.shapeId = shapeId;
  106454. this.idxInShape = idxInShape;
  106455. this._sps = sps;
  106456. if (modelBoundingInfo) {
  106457. this._modelBoundingInfo = modelBoundingInfo;
  106458. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  106459. }
  106460. }
  106461. Object.defineProperty(SolidParticle.prototype, "scale", {
  106462. /**
  106463. * Legacy support, changed scale to scaling
  106464. */
  106465. get: function () {
  106466. return this.scaling;
  106467. },
  106468. /**
  106469. * Legacy support, changed scale to scaling
  106470. */
  106471. set: function (scale) {
  106472. this.scaling = scale;
  106473. },
  106474. enumerable: true,
  106475. configurable: true
  106476. });
  106477. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  106478. /**
  106479. * Legacy support, changed quaternion to rotationQuaternion
  106480. */
  106481. get: function () {
  106482. return this.rotationQuaternion;
  106483. },
  106484. /**
  106485. * Legacy support, changed quaternion to rotationQuaternion
  106486. */
  106487. set: function (q) {
  106488. this.rotationQuaternion = q;
  106489. },
  106490. enumerable: true,
  106491. configurable: true
  106492. });
  106493. /**
  106494. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  106495. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  106496. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  106497. * @returns true if it intersects
  106498. */
  106499. SolidParticle.prototype.intersectsMesh = function (target) {
  106500. if (!this._boundingInfo || !target._boundingInfo) {
  106501. return false;
  106502. }
  106503. if (this._sps._bSphereOnly) {
  106504. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  106505. }
  106506. return this._boundingInfo.intersects(target._boundingInfo, false);
  106507. };
  106508. /**
  106509. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  106510. * A particle is in the frustum if its bounding box intersects the frustum
  106511. * @param frustumPlanes defines the frustum to test
  106512. * @returns true if the particle is in the frustum planes
  106513. */
  106514. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  106515. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  106516. };
  106517. /**
  106518. * get the rotation matrix of the particle
  106519. * @hidden
  106520. */
  106521. SolidParticle.prototype.getRotationMatrix = function (m) {
  106522. var quaternion;
  106523. if (this.rotationQuaternion) {
  106524. quaternion = this.rotationQuaternion;
  106525. }
  106526. else {
  106527. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  106528. var rotation = this.rotation;
  106529. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  106530. }
  106531. quaternion.toRotationMatrix(m);
  106532. };
  106533. return SolidParticle;
  106534. }());
  106535. /**
  106536. * Represents the shape of the model used by one particle of a solid particle system.
  106537. * SPS internal tool, don't use it manually.
  106538. */
  106539. var ModelShape = /** @class */ (function () {
  106540. /**
  106541. * 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.
  106542. * SPS internal tool, don't use it manually.
  106543. * @hidden
  106544. */
  106545. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  106546. /**
  106547. * length of the shape in the model indices array (internal use)
  106548. * @hidden
  106549. */
  106550. this._indicesLength = 0;
  106551. this.shapeID = id;
  106552. this._shape = shape;
  106553. this._indicesLength = indicesLength;
  106554. this._shapeUV = shapeUV;
  106555. this._positionFunction = posFunction;
  106556. this._vertexFunction = vtxFunction;
  106557. }
  106558. return ModelShape;
  106559. }());
  106560. /**
  106561. * Represents a Depth Sorted Particle in the solid particle system.
  106562. */
  106563. var DepthSortedParticle = /** @class */ (function () {
  106564. function DepthSortedParticle() {
  106565. /**
  106566. * Index of the particle in the "indices" array
  106567. */
  106568. this.ind = 0;
  106569. /**
  106570. * Length of the particle shape in the "indices" array
  106571. */
  106572. this.indicesLength = 0;
  106573. /**
  106574. * Squared distance from the particle to the camera
  106575. */
  106576. this.sqDistance = 0.0;
  106577. }
  106578. return DepthSortedParticle;
  106579. }());
  106580. /***/ }),
  106581. /***/ "./Particles/solidParticleSystem.ts":
  106582. /*!******************************************!*\
  106583. !*** ./Particles/solidParticleSystem.ts ***!
  106584. \******************************************/
  106585. /*! exports provided: SolidParticleSystem */
  106586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106587. "use strict";
  106588. __webpack_require__.r(__webpack_exports__);
  106589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  106590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106591. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106592. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  106593. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106594. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106595. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106596. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  106597. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106598. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  106599. /**
  106600. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  106601. *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.
  106602. * The SPS is also a particle system. It provides some methods to manage the particles.
  106603. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  106604. *
  106605. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  106606. */
  106607. var SolidParticleSystem = /** @class */ (function () {
  106608. /**
  106609. * Creates a SPS (Solid Particle System) object.
  106610. * @param name (String) is the SPS name, this will be the underlying mesh name.
  106611. * @param scene (Scene) is the scene in which the SPS is added.
  106612. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  106613. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  106614. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  106615. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  106616. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  106617. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  106618. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  106619. */
  106620. function SolidParticleSystem(name, scene, options) {
  106621. /**
  106622. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  106623. * Example : var p = SPS.particles[i];
  106624. */
  106625. this.particles = new Array();
  106626. /**
  106627. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  106628. */
  106629. this.nbParticles = 0;
  106630. /**
  106631. * If the particles must ever face the camera (default false). Useful for planar particles.
  106632. */
  106633. this.billboard = false;
  106634. /**
  106635. * Recompute normals when adding a shape
  106636. */
  106637. this.recomputeNormals = true;
  106638. /**
  106639. * This a counter ofr your own usage. It's not set by any SPS functions.
  106640. */
  106641. this.counter = 0;
  106642. /**
  106643. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  106644. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  106645. */
  106646. this.vars = {};
  106647. /**
  106648. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  106649. * @hidden
  106650. */
  106651. this._bSphereOnly = false;
  106652. /**
  106653. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  106654. * @hidden
  106655. */
  106656. this._bSphereRadiusFactor = 1.0;
  106657. this._positions = new Array();
  106658. this._indices = new Array();
  106659. this._normals = new Array();
  106660. this._colors = new Array();
  106661. this._uvs = new Array();
  106662. this._index = 0; // indices index
  106663. this._updatable = true;
  106664. this._pickable = false;
  106665. this._isVisibilityBoxLocked = false;
  106666. this._alwaysVisible = false;
  106667. this._depthSort = false;
  106668. this._shapeCounter = 0;
  106669. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  106670. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106671. this._computeParticleColor = true;
  106672. this._computeParticleTexture = true;
  106673. this._computeParticleRotation = true;
  106674. this._computeParticleVertex = false;
  106675. this._computeBoundingBox = false;
  106676. this._depthSortParticles = true;
  106677. this._mustUnrotateFixedNormals = false;
  106678. this._particlesIntersect = false;
  106679. this._needs32Bits = false;
  106680. this.name = name;
  106681. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  106682. this._camera = scene.activeCamera;
  106683. this._pickable = options ? options.isPickable : false;
  106684. this._depthSort = options ? options.enableDepthSort : false;
  106685. this._particlesIntersect = options ? options.particleIntersection : false;
  106686. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  106687. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  106688. if (options && options.updatable !== undefined) {
  106689. this._updatable = options.updatable;
  106690. }
  106691. else {
  106692. this._updatable = true;
  106693. }
  106694. if (this._pickable) {
  106695. this.pickedParticles = [];
  106696. }
  106697. if (this._depthSort) {
  106698. this.depthSortedParticles = [];
  106699. }
  106700. }
  106701. /**
  106702. * Builds the SPS underlying mesh. Returns a standard Mesh.
  106703. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  106704. * @returns the created mesh
  106705. */
  106706. SolidParticleSystem.prototype.buildMesh = function () {
  106707. if (this.nbParticles === 0) {
  106708. var triangle = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  106709. this.addShape(triangle, 1);
  106710. triangle.dispose();
  106711. }
  106712. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  106713. this._positions32 = new Float32Array(this._positions);
  106714. this._uvs32 = new Float32Array(this._uvs);
  106715. this._colors32 = new Float32Array(this._colors);
  106716. if (this.recomputeNormals) {
  106717. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  106718. }
  106719. this._normals32 = new Float32Array(this._normals);
  106720. this._fixedNormal32 = new Float32Array(this._normals);
  106721. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  106722. this._unrotateFixedNormals();
  106723. }
  106724. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  106725. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  106726. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  106727. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  106728. if (this._uvs32.length > 0) {
  106729. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  106730. }
  106731. if (this._colors32.length > 0) {
  106732. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  106733. }
  106734. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  106735. vertexData.applyToMesh(mesh, this._updatable);
  106736. this.mesh = mesh;
  106737. this.mesh.isPickable = this._pickable;
  106738. // free memory
  106739. if (!this._depthSort) {
  106740. this._indices = null;
  106741. }
  106742. this._positions = null;
  106743. this._normals = null;
  106744. this._uvs = null;
  106745. this._colors = null;
  106746. if (!this._updatable) {
  106747. this.particles.length = 0;
  106748. }
  106749. return mesh;
  106750. };
  106751. /**
  106752. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  106753. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  106754. * Thus the particles generated from `digest()` have their property `position` set yet.
  106755. * @param mesh ( Mesh ) is the mesh to be digested
  106756. * @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
  106757. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  106758. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  106759. * @returns the current SPS
  106760. */
  106761. SolidParticleSystem.prototype.digest = function (mesh, options) {
  106762. var size = (options && options.facetNb) || 1;
  106763. var number = (options && options.number) || 0;
  106764. var delta = (options && options.delta) || 0;
  106765. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  106766. var meshInd = mesh.getIndices();
  106767. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  106768. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  106769. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  106770. var f = 0; // facet counter
  106771. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  106772. // compute size from number
  106773. if (number) {
  106774. number = (number > totalFacets) ? totalFacets : number;
  106775. size = Math.round(totalFacets / number);
  106776. delta = 0;
  106777. }
  106778. else {
  106779. size = (size > totalFacets) ? totalFacets : size;
  106780. }
  106781. var facetPos = []; // submesh positions
  106782. var facetInd = []; // submesh indices
  106783. var facetUV = []; // submesh UV
  106784. var facetCol = []; // submesh colors
  106785. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106786. var sizeO = size;
  106787. while (f < totalFacets) {
  106788. size = sizeO + Math.floor((1 + delta) * Math.random());
  106789. if (f > totalFacets - size) {
  106790. size = totalFacets - f;
  106791. }
  106792. // reset temp arrays
  106793. facetPos.length = 0;
  106794. facetInd.length = 0;
  106795. facetUV.length = 0;
  106796. facetCol.length = 0;
  106797. // iterate over "size" facets
  106798. var fi = 0;
  106799. for (var j = f * 3; j < (f + size) * 3; j++) {
  106800. facetInd.push(fi);
  106801. var i = meshInd[j];
  106802. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  106803. if (meshUV) {
  106804. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  106805. }
  106806. if (meshCol) {
  106807. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  106808. }
  106809. fi++;
  106810. }
  106811. // create a model shape for each single particle
  106812. var idx = this.nbParticles;
  106813. var shape = this._posToShape(facetPos);
  106814. var shapeUV = this._uvsToShapeUV(facetUV);
  106815. // compute the barycenter of the shape
  106816. var v;
  106817. for (v = 0; v < shape.length; v++) {
  106818. barycenter.addInPlace(shape[v]);
  106819. }
  106820. barycenter.scaleInPlace(1 / shape.length);
  106821. // shift the shape from its barycenter to the origin
  106822. for (v = 0; v < shape.length; v++) {
  106823. shape[v].subtractInPlace(barycenter);
  106824. }
  106825. var bInfo;
  106826. if (this._particlesIntersect) {
  106827. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  106828. }
  106829. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  106830. // add the particle in the SPS
  106831. var currentPos = this._positions.length;
  106832. var currentInd = this._indices.length;
  106833. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  106834. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  106835. // initialize the particle position
  106836. this.particles[this.nbParticles].position.addInPlace(barycenter);
  106837. this._index += shape.length;
  106838. idx++;
  106839. this.nbParticles++;
  106840. this._shapeCounter++;
  106841. f += size;
  106842. }
  106843. return this;
  106844. };
  106845. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  106846. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  106847. var index = 0;
  106848. var idx = 0;
  106849. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  106850. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  106851. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  106852. for (var p = 0; p < this.particles.length; p++) {
  106853. var particle = this.particles[p];
  106854. var shape = particle._model._shape;
  106855. // computing the inverse of the rotation matrix from the quaternion
  106856. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  106857. if (particle.rotationQuaternion) {
  106858. particle.rotationQuaternion.conjugateToRef(quaternion);
  106859. }
  106860. else {
  106861. var rotation = particle.rotation;
  106862. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  106863. quaternion.conjugateInPlace();
  106864. }
  106865. quaternion.toRotationMatrix(invertedRotMatrix);
  106866. for (var pt = 0; pt < shape.length; pt++) {
  106867. idx = index + pt * 3;
  106868. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  106869. tmpNormal.toArray(this._fixedNormal32, idx);
  106870. }
  106871. index = idx + 3;
  106872. }
  106873. };
  106874. //reset copy
  106875. SolidParticleSystem.prototype._resetCopy = function () {
  106876. var copy = this._copy;
  106877. copy.position.setAll(0);
  106878. copy.rotation.setAll(0);
  106879. copy.rotationQuaternion = null;
  106880. copy.scaling.setAll(1);
  106881. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  106882. copy.color = null;
  106883. copy.translateFromPivot = false;
  106884. };
  106885. // _meshBuilder : inserts the shape model in the global SPS mesh
  106886. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  106887. var i;
  106888. var u = 0;
  106889. var c = 0;
  106890. var n = 0;
  106891. this._resetCopy();
  106892. var copy = this._copy;
  106893. if (options && options.positionFunction) { // call to custom positionFunction
  106894. options.positionFunction(copy, idx, idxInShape);
  106895. this._mustUnrotateFixedNormals = true;
  106896. }
  106897. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  106898. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  106899. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  106900. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  106901. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  106902. copy.getRotationMatrix(rotMatrix);
  106903. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  106904. if (copy.translateFromPivot) {
  106905. pivotBackTranslation.setAll(0.0);
  106906. }
  106907. else {
  106908. pivotBackTranslation.copyFrom(scaledPivot);
  106909. }
  106910. for (i = 0; i < shape.length; i++) {
  106911. tmpVertex.copyFrom(shape[i]);
  106912. if (options && options.vertexFunction) {
  106913. options.vertexFunction(copy, tmpVertex, i);
  106914. }
  106915. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  106916. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  106917. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  106918. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  106919. if (meshUV) {
  106920. var copyUvs = copy.uvs;
  106921. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  106922. u += 2;
  106923. }
  106924. if (copy.color) {
  106925. this._color = copy.color;
  106926. }
  106927. else {
  106928. var color = this._color;
  106929. if (meshCol && meshCol[c] !== undefined) {
  106930. color.r = meshCol[c];
  106931. color.g = meshCol[c + 1];
  106932. color.b = meshCol[c + 2];
  106933. color.a = meshCol[c + 3];
  106934. }
  106935. else {
  106936. color.r = 1.0;
  106937. color.g = 1.0;
  106938. color.b = 1.0;
  106939. color.a = 1.0;
  106940. }
  106941. }
  106942. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  106943. c += 4;
  106944. if (!this.recomputeNormals && meshNor) {
  106945. tmpVertex.x = meshNor[n];
  106946. tmpVertex.y = meshNor[n + 1];
  106947. tmpVertex.z = meshNor[n + 2];
  106948. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  106949. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  106950. n += 3;
  106951. }
  106952. }
  106953. for (i = 0; i < meshInd.length; i++) {
  106954. var current_ind = p + meshInd[i];
  106955. indices.push(current_ind);
  106956. if (current_ind > 65535) {
  106957. this._needs32Bits = true;
  106958. }
  106959. }
  106960. if (this._pickable) {
  106961. var nbfaces = meshInd.length / 3;
  106962. for (i = 0; i < nbfaces; i++) {
  106963. this.pickedParticles.push({ idx: idx, faceId: i });
  106964. }
  106965. }
  106966. if (this._depthSort) {
  106967. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  106968. }
  106969. return copy;
  106970. };
  106971. // returns a shape array from positions array
  106972. SolidParticleSystem.prototype._posToShape = function (positions) {
  106973. var shape = [];
  106974. for (var i = 0; i < positions.length; i += 3) {
  106975. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  106976. }
  106977. return shape;
  106978. };
  106979. // returns a shapeUV array from a Vector4 uvs
  106980. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  106981. var shapeUV = [];
  106982. if (uvs) {
  106983. for (var i = 0; i < uvs.length; i++) {
  106984. shapeUV.push(uvs[i]);
  106985. }
  106986. }
  106987. return shapeUV;
  106988. };
  106989. // adds a new particle object in the particles array
  106990. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  106991. if (bInfo === void 0) { bInfo = null; }
  106992. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  106993. this.particles.push(sp);
  106994. return sp;
  106995. };
  106996. /**
  106997. * Adds some particles to the SPS from the model shape. Returns the shape id.
  106998. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  106999. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107000. * @param nb (positive integer) the number of particles to be created from this model
  107001. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107002. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107003. * @returns the number of shapes in the system
  107004. */
  107005. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  107006. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107007. var meshInd = mesh.getIndices();
  107008. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107009. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107010. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107011. var bbInfo;
  107012. if (this._particlesIntersect) {
  107013. bbInfo = mesh.getBoundingInfo();
  107014. }
  107015. var shape = this._posToShape(meshPos);
  107016. var shapeUV = this._uvsToShapeUV(meshUV);
  107017. var posfunc = options ? options.positionFunction : null;
  107018. var vtxfunc = options ? options.vertexFunction : null;
  107019. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  107020. // particles
  107021. var sp;
  107022. var currentCopy;
  107023. var idx = this.nbParticles;
  107024. for (var i = 0; i < nb; i++) {
  107025. var currentPos = this._positions.length;
  107026. var currentInd = this._indices.length;
  107027. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  107028. if (this._updatable) {
  107029. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  107030. sp.position.copyFrom(currentCopy.position);
  107031. sp.rotation.copyFrom(currentCopy.rotation);
  107032. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  107033. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  107034. }
  107035. if (currentCopy.color && sp.color) {
  107036. sp.color.copyFrom(currentCopy.color);
  107037. }
  107038. sp.scaling.copyFrom(currentCopy.scaling);
  107039. sp.uvs.copyFrom(currentCopy.uvs);
  107040. }
  107041. this._index += shape.length;
  107042. idx++;
  107043. }
  107044. this.nbParticles += nb;
  107045. this._shapeCounter++;
  107046. return this._shapeCounter - 1;
  107047. };
  107048. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107049. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  107050. this._resetCopy();
  107051. var copy = this._copy;
  107052. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  107053. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  107054. }
  107055. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107056. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107057. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107058. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107059. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107060. copy.getRotationMatrix(rotMatrix);
  107061. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  107062. if (copy.translateFromPivot) {
  107063. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  107064. }
  107065. else {
  107066. pivotBackTranslation.copyFrom(scaledPivot);
  107067. }
  107068. var shape = particle._model._shape;
  107069. for (var pt = 0; pt < shape.length; pt++) {
  107070. tmpVertex.copyFrom(shape[pt]);
  107071. if (particle._model._vertexFunction) {
  107072. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  107073. }
  107074. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107075. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107076. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  107077. }
  107078. particle.position.setAll(0.0);
  107079. particle.rotation.setAll(0.0);
  107080. particle.rotationQuaternion = null;
  107081. particle.scaling.setAll(1.0);
  107082. particle.uvs.setAll(0.0);
  107083. particle.pivot.setAll(0.0);
  107084. particle.translateFromPivot = false;
  107085. particle.parentId = null;
  107086. };
  107087. /**
  107088. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107089. * @returns the SPS.
  107090. */
  107091. SolidParticleSystem.prototype.rebuildMesh = function () {
  107092. for (var p = 0; p < this.particles.length; p++) {
  107093. this._rebuildParticle(this.particles[p]);
  107094. }
  107095. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  107096. return this;
  107097. };
  107098. /**
  107099. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107100. * This method calls `updateParticle()` for each particle of the SPS.
  107101. * For an animated SPS, it is usually called within the render loop.
  107102. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107103. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107104. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107105. * @returns the SPS.
  107106. */
  107107. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  107108. if (start === void 0) { start = 0; }
  107109. if (end === void 0) { end = this.nbParticles - 1; }
  107110. if (update === void 0) { update = true; }
  107111. if (!this._updatable) {
  107112. return this;
  107113. }
  107114. // custom beforeUpdate
  107115. this.beforeUpdateParticles();
  107116. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107117. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  107118. var mesh = this.mesh;
  107119. var colors32 = this._colors32;
  107120. var positions32 = this._positions32;
  107121. var normals32 = this._normals32;
  107122. var uvs32 = this._uvs32;
  107123. var indices32 = this._indices32;
  107124. var indices = this._indices;
  107125. var fixedNormal32 = this._fixedNormal32;
  107126. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  107127. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  107128. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  107129. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  107130. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  107131. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  107132. var camInvertedPosition = tempVectors[10].setAll(0);
  107133. // cases when the World Matrix is to be computed first
  107134. if (this.billboard || this._depthSort) {
  107135. this.mesh.computeWorldMatrix(true);
  107136. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  107137. }
  107138. // if the particles will always face the camera
  107139. if (this.billboard) {
  107140. // compute the camera position and un-rotate it by the current mesh rotation
  107141. var tmpVertex = tempVectors[0];
  107142. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  107143. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  107144. camAxisZ.normalize();
  107145. // same for camera up vector extracted from the cam view matrix
  107146. var view = this._camera.getViewMatrix(true);
  107147. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  107148. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  107149. camAxisY.normalize();
  107150. camAxisX.normalize();
  107151. }
  107152. // if depthSort, compute the camera global position in the mesh local system
  107153. if (this._depthSort) {
  107154. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  107155. }
  107156. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  107157. var idx = 0; // current position index in the global array positions32
  107158. var index = 0; // position start index in the global array positions32 of the current particle
  107159. var colidx = 0; // current color index in the global array colors32
  107160. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  107161. var uvidx = 0; // current uv index in the global array uvs32
  107162. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  107163. var pt = 0; // current index in the particle model shape
  107164. if (this.mesh.isFacetDataEnabled) {
  107165. this._computeBoundingBox = true;
  107166. }
  107167. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  107168. if (this._computeBoundingBox) {
  107169. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  107170. var boundingInfo = this.mesh._boundingInfo;
  107171. if (boundingInfo) {
  107172. minimum.copyFrom(boundingInfo.minimum);
  107173. maximum.copyFrom(boundingInfo.maximum);
  107174. }
  107175. }
  107176. }
  107177. // particle loop
  107178. index = this.particles[start]._pos;
  107179. var vpos = (index / 3) | 0;
  107180. colorIndex = vpos * 4;
  107181. uvIndex = vpos * 2;
  107182. for (var p = start; p <= end; p++) {
  107183. var particle = this.particles[p];
  107184. // call to custom user function to update the particle properties
  107185. this.updateParticle(particle);
  107186. var shape = particle._model._shape;
  107187. var shapeUV = particle._model._shapeUV;
  107188. var particleRotationMatrix = particle._rotationMatrix;
  107189. var particlePosition = particle.position;
  107190. var particleRotation = particle.rotation;
  107191. var particleScaling = particle.scaling;
  107192. var particleGlobalPosition = particle._globalPosition;
  107193. // camera-particle distance for depth sorting
  107194. if (this._depthSort && this._depthSortParticles) {
  107195. var dsp = this.depthSortedParticles[p];
  107196. dsp.ind = particle._ind;
  107197. dsp.indicesLength = particle._model._indicesLength;
  107198. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  107199. }
  107200. // skip the computations for inactive or already invisible particles
  107201. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  107202. // increment indexes for the next particle
  107203. pt = shape.length;
  107204. index += pt * 3;
  107205. colorIndex += pt * 4;
  107206. uvIndex += pt * 2;
  107207. continue;
  107208. }
  107209. if (particle.isVisible) {
  107210. particle._stillInvisible = false; // un-mark permanent invisibility
  107211. var scaledPivot = tempVectors[12];
  107212. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  107213. // particle rotation matrix
  107214. if (this.billboard) {
  107215. particleRotation.x = 0.0;
  107216. particleRotation.y = 0.0;
  107217. }
  107218. if (this._computeParticleRotation || this.billboard) {
  107219. particle.getRotationMatrix(rotMatrix);
  107220. }
  107221. var particleHasParent = (particle.parentId !== null);
  107222. if (particleHasParent) {
  107223. var parent_1 = this.particles[particle.parentId];
  107224. var parentRotationMatrix = parent_1._rotationMatrix;
  107225. var parentGlobalPosition = parent_1._globalPosition;
  107226. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  107227. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  107228. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  107229. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  107230. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  107231. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  107232. if (this._computeParticleRotation || this.billboard) {
  107233. var rotMatrixValues = rotMatrix.m;
  107234. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  107235. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  107236. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  107237. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  107238. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  107239. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  107240. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  107241. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  107242. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  107243. }
  107244. }
  107245. else {
  107246. particleGlobalPosition.x = particlePosition.x;
  107247. particleGlobalPosition.y = particlePosition.y;
  107248. particleGlobalPosition.z = particlePosition.z;
  107249. if (this._computeParticleRotation || this.billboard) {
  107250. var rotMatrixValues = rotMatrix.m;
  107251. particleRotationMatrix[0] = rotMatrixValues[0];
  107252. particleRotationMatrix[1] = rotMatrixValues[1];
  107253. particleRotationMatrix[2] = rotMatrixValues[2];
  107254. particleRotationMatrix[3] = rotMatrixValues[4];
  107255. particleRotationMatrix[4] = rotMatrixValues[5];
  107256. particleRotationMatrix[5] = rotMatrixValues[6];
  107257. particleRotationMatrix[6] = rotMatrixValues[8];
  107258. particleRotationMatrix[7] = rotMatrixValues[9];
  107259. particleRotationMatrix[8] = rotMatrixValues[10];
  107260. }
  107261. }
  107262. var pivotBackTranslation = tempVectors[11];
  107263. if (particle.translateFromPivot) {
  107264. pivotBackTranslation.setAll(0.0);
  107265. }
  107266. else {
  107267. pivotBackTranslation.copyFrom(scaledPivot);
  107268. }
  107269. // particle vertex loop
  107270. for (pt = 0; pt < shape.length; pt++) {
  107271. idx = index + pt * 3;
  107272. colidx = colorIndex + pt * 4;
  107273. uvidx = uvIndex + pt * 2;
  107274. var tmpVertex = tempVectors[0];
  107275. tmpVertex.copyFrom(shape[pt]);
  107276. if (this._computeParticleVertex) {
  107277. this.updateParticleVertex(tmpVertex);
  107278. }
  107279. // positions
  107280. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  107281. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  107282. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  107283. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  107284. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  107285. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  107286. rotatedX += pivotBackTranslation.x;
  107287. rotatedY += pivotBackTranslation.y;
  107288. rotatedZ += pivotBackTranslation.z;
  107289. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107290. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107291. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107292. if (this._computeBoundingBox) {
  107293. minimum.minimizeInPlaceFromFloats(px, py, pz);
  107294. maximum.maximizeInPlaceFromFloats(px, py, pz);
  107295. }
  107296. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  107297. if (!this._computeParticleVertex) {
  107298. var normalx = fixedNormal32[idx];
  107299. var normaly = fixedNormal32[idx + 1];
  107300. var normalz = fixedNormal32[idx + 2];
  107301. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  107302. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  107303. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  107304. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  107305. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  107306. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  107307. }
  107308. if (this._computeParticleColor && particle.color) {
  107309. var color = particle.color;
  107310. var colors32_1 = this._colors32;
  107311. colors32_1[colidx] = color.r;
  107312. colors32_1[colidx + 1] = color.g;
  107313. colors32_1[colidx + 2] = color.b;
  107314. colors32_1[colidx + 3] = color.a;
  107315. }
  107316. if (this._computeParticleTexture) {
  107317. var uvs = particle.uvs;
  107318. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107319. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107320. }
  107321. }
  107322. }
  107323. // particle just set invisible : scaled to zero and positioned at the origin
  107324. else {
  107325. particle._stillInvisible = true; // mark the particle as invisible
  107326. for (pt = 0; pt < shape.length; pt++) {
  107327. idx = index + pt * 3;
  107328. colidx = colorIndex + pt * 4;
  107329. uvidx = uvIndex + pt * 2;
  107330. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  107331. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  107332. if (this._computeParticleColor && particle.color) {
  107333. var color = particle.color;
  107334. colors32[colidx] = color.r;
  107335. colors32[colidx + 1] = color.g;
  107336. colors32[colidx + 2] = color.b;
  107337. colors32[colidx + 3] = color.a;
  107338. }
  107339. if (this._computeParticleTexture) {
  107340. var uvs = particle.uvs;
  107341. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107342. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107343. }
  107344. }
  107345. }
  107346. // if the particle intersections must be computed : update the bbInfo
  107347. if (this._particlesIntersect) {
  107348. var bInfo = particle._boundingInfo;
  107349. var bBox = bInfo.boundingBox;
  107350. var bSphere = bInfo.boundingSphere;
  107351. var modelBoundingInfo = particle._modelBoundingInfo;
  107352. if (!this._bSphereOnly) {
  107353. // place, scale and rotate the particle bbox within the SPS local system, then update it
  107354. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  107355. var tempMin = tempVectors[1];
  107356. var tempMax = tempVectors[2];
  107357. tempMin.setAll(Number.MAX_VALUE);
  107358. tempMax.setAll(-Number.MAX_VALUE);
  107359. for (var b = 0; b < 8; b++) {
  107360. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  107361. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  107362. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  107363. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  107364. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  107365. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  107366. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107367. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107368. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107369. tempMin.minimizeInPlaceFromFloats(x, y, z);
  107370. tempMax.maximizeInPlaceFromFloats(x, y, z);
  107371. }
  107372. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  107373. }
  107374. // place and scale the particle bouding sphere in the SPS local system, then update it
  107375. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  107376. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  107377. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  107378. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  107379. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  107380. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  107381. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  107382. }
  107383. // increment indexes for the next particle
  107384. index = idx + 3;
  107385. colorIndex = colidx + 4;
  107386. uvIndex = uvidx + 2;
  107387. }
  107388. // if the VBO must be updated
  107389. if (update) {
  107390. if (this._computeParticleColor) {
  107391. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  107392. }
  107393. if (this._computeParticleTexture) {
  107394. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  107395. }
  107396. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  107397. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  107398. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  107399. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  107400. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  107401. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  107402. for (var i = 0; i < normals32.length; i++) {
  107403. fixedNormal32[i] = normals32[i];
  107404. }
  107405. }
  107406. if (!mesh.areNormalsFrozen) {
  107407. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  107408. }
  107409. }
  107410. if (this._depthSort && this._depthSortParticles) {
  107411. var depthSortedParticles = this.depthSortedParticles;
  107412. depthSortedParticles.sort(depthSortFunction);
  107413. var dspl = depthSortedParticles.length;
  107414. var sid = 0;
  107415. for (var sorted = 0; sorted < dspl; sorted++) {
  107416. var lind = depthSortedParticles[sorted].indicesLength;
  107417. var sind = depthSortedParticles[sorted].ind;
  107418. for (var i = 0; i < lind; i++) {
  107419. indices32[sid] = indices[sind + i];
  107420. sid++;
  107421. }
  107422. }
  107423. mesh.updateIndices(indices32);
  107424. }
  107425. }
  107426. if (this._computeBoundingBox) {
  107427. if (mesh._boundingInfo) {
  107428. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  107429. }
  107430. else {
  107431. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  107432. }
  107433. }
  107434. this.afterUpdateParticles();
  107435. return this;
  107436. };
  107437. /**
  107438. * Disposes the SPS.
  107439. */
  107440. SolidParticleSystem.prototype.dispose = function () {
  107441. this.mesh.dispose();
  107442. this.vars = null;
  107443. // drop references to internal big arrays for the GC
  107444. this._positions = null;
  107445. this._indices = null;
  107446. this._normals = null;
  107447. this._uvs = null;
  107448. this._colors = null;
  107449. this._indices32 = null;
  107450. this._positions32 = null;
  107451. this._normals32 = null;
  107452. this._fixedNormal32 = null;
  107453. this._uvs32 = null;
  107454. this._colors32 = null;
  107455. this.pickedParticles = null;
  107456. };
  107457. /**
  107458. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107459. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107460. * @returns the SPS.
  107461. */
  107462. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  107463. if (!this._isVisibilityBoxLocked) {
  107464. this.mesh.refreshBoundingInfo();
  107465. }
  107466. return this;
  107467. };
  107468. /**
  107469. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107470. * @param size the size (float) of the visibility box
  107471. * note : this doesn't lock the SPS mesh bounding box.
  107472. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107473. */
  107474. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  107475. var vis = size / 2;
  107476. 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));
  107477. };
  107478. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  107479. /**
  107480. * Gets whether the SPS as always visible or not
  107481. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107482. */
  107483. get: function () {
  107484. return this._alwaysVisible;
  107485. },
  107486. /**
  107487. * Sets the SPS as always visible or not
  107488. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107489. */
  107490. set: function (val) {
  107491. this._alwaysVisible = val;
  107492. this.mesh.alwaysSelectAsActiveMesh = val;
  107493. },
  107494. enumerable: true,
  107495. configurable: true
  107496. });
  107497. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  107498. /**
  107499. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107500. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107501. */
  107502. get: function () {
  107503. return this._isVisibilityBoxLocked;
  107504. },
  107505. /**
  107506. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107507. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107508. */
  107509. set: function (val) {
  107510. this._isVisibilityBoxLocked = val;
  107511. var boundingInfo = this.mesh.getBoundingInfo();
  107512. boundingInfo.isLocked = val;
  107513. },
  107514. enumerable: true,
  107515. configurable: true
  107516. });
  107517. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  107518. /**
  107519. * Gets if `setParticles()` computes the particle rotations or not.
  107520. * Default value : true. The SPS is faster when it's set to false.
  107521. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107522. */
  107523. get: function () {
  107524. return this._computeParticleRotation;
  107525. },
  107526. /**
  107527. * Tells to `setParticles()` to compute the particle rotations or not.
  107528. * Default value : true. The SPS is faster when it's set to false.
  107529. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107530. */
  107531. set: function (val) {
  107532. this._computeParticleRotation = val;
  107533. },
  107534. enumerable: true,
  107535. configurable: true
  107536. });
  107537. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  107538. /**
  107539. * Gets if `setParticles()` computes the particle colors or not.
  107540. * Default value : true. The SPS is faster when it's set to false.
  107541. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107542. */
  107543. get: function () {
  107544. return this._computeParticleColor;
  107545. },
  107546. /**
  107547. * Tells to `setParticles()` to compute the particle colors or not.
  107548. * Default value : true. The SPS is faster when it's set to false.
  107549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107550. */
  107551. set: function (val) {
  107552. this._computeParticleColor = val;
  107553. },
  107554. enumerable: true,
  107555. configurable: true
  107556. });
  107557. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  107558. /**
  107559. * Gets if `setParticles()` computes the particle textures or not.
  107560. * Default value : true. The SPS is faster when it's set to false.
  107561. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107562. */
  107563. get: function () {
  107564. return this._computeParticleTexture;
  107565. },
  107566. set: function (val) {
  107567. this._computeParticleTexture = val;
  107568. },
  107569. enumerable: true,
  107570. configurable: true
  107571. });
  107572. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  107573. /**
  107574. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107575. * Default value : false. The SPS is faster when it's set to false.
  107576. * Note : the particle custom vertex positions aren't stored values.
  107577. */
  107578. get: function () {
  107579. return this._computeParticleVertex;
  107580. },
  107581. /**
  107582. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107583. * Default value : false. The SPS is faster when it's set to false.
  107584. * Note : the particle custom vertex positions aren't stored values.
  107585. */
  107586. set: function (val) {
  107587. this._computeParticleVertex = val;
  107588. },
  107589. enumerable: true,
  107590. configurable: true
  107591. });
  107592. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  107593. /**
  107594. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107595. */
  107596. get: function () {
  107597. return this._computeBoundingBox;
  107598. },
  107599. /**
  107600. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107601. */
  107602. set: function (val) {
  107603. this._computeBoundingBox = val;
  107604. },
  107605. enumerable: true,
  107606. configurable: true
  107607. });
  107608. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  107609. /**
  107610. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107612. * Default : `true`
  107613. */
  107614. get: function () {
  107615. return this._depthSortParticles;
  107616. },
  107617. /**
  107618. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107619. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107620. * Default : `true`
  107621. */
  107622. set: function (val) {
  107623. this._depthSortParticles = val;
  107624. },
  107625. enumerable: true,
  107626. configurable: true
  107627. });
  107628. // =======================================================================
  107629. // Particle behavior logic
  107630. // these following methods may be overwritten by the user to fit his needs
  107631. /**
  107632. * This function does nothing. It may be overwritten to set all the particle first values.
  107633. * The SPS doesn't call this function, you may have to call it by your own.
  107634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107635. */
  107636. SolidParticleSystem.prototype.initParticles = function () {
  107637. };
  107638. /**
  107639. * This function does nothing. It may be overwritten to recycle a particle.
  107640. * The SPS doesn't call this function, you may have to call it by your own.
  107641. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107642. * @param particle The particle to recycle
  107643. * @returns the recycled particle
  107644. */
  107645. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  107646. return particle;
  107647. };
  107648. /**
  107649. * Updates a particle : this function should be overwritten by the user.
  107650. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107652. * @example : just set a particle position or velocity and recycle conditions
  107653. * @param particle The particle to update
  107654. * @returns the updated particle
  107655. */
  107656. SolidParticleSystem.prototype.updateParticle = function (particle) {
  107657. return particle;
  107658. };
  107659. /**
  107660. * Updates a vertex of a particle : it can be overwritten by the user.
  107661. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107662. * @param particle the current particle
  107663. * @param vertex the current index of the current particle
  107664. * @param pt the index of the current vertex in the particle shape
  107665. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  107666. * @example : just set a vertex particle position
  107667. * @returns the updated vertex
  107668. */
  107669. SolidParticleSystem.prototype.updateParticleVertex = function (vertex) {
  107670. return vertex;
  107671. };
  107672. /**
  107673. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107674. * This does nothing and may be overwritten by the user.
  107675. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107676. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107677. * @param update the boolean update value actually passed to setParticles()
  107678. */
  107679. SolidParticleSystem.prototype.beforeUpdateParticles = function () {
  107680. };
  107681. /**
  107682. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107683. * This will be passed three parameters.
  107684. * This does nothing and may be overwritten by the user.
  107685. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107686. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107687. * @param update the boolean update value actually passed to setParticles()
  107688. */
  107689. SolidParticleSystem.prototype.afterUpdateParticles = function () {
  107690. };
  107691. return SolidParticleSystem;
  107692. }());
  107693. /***/ }),
  107694. /***/ "./Particles/subEmitter.ts":
  107695. /*!*********************************!*\
  107696. !*** ./Particles/subEmitter.ts ***!
  107697. \*********************************/
  107698. /*! exports provided: SubEmitterType, SubEmitter */
  107699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107700. "use strict";
  107701. __webpack_require__.r(__webpack_exports__);
  107702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  107703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  107704. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107705. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107706. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107707. /**
  107708. * Type of sub emitter
  107709. */
  107710. var SubEmitterType;
  107711. (function (SubEmitterType) {
  107712. /**
  107713. * Attached to the particle over it's lifetime
  107714. */
  107715. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  107716. /**
  107717. * Created when the particle dies
  107718. */
  107719. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  107720. })(SubEmitterType || (SubEmitterType = {}));
  107721. /**
  107722. * Sub emitter class used to emit particles from an existing particle
  107723. */
  107724. var SubEmitter = /** @class */ (function () {
  107725. /**
  107726. * Creates a sub emitter
  107727. * @param particleSystem the particle system to be used by the sub emitter
  107728. */
  107729. function SubEmitter(
  107730. /**
  107731. * the particle system to be used by the sub emitter
  107732. */
  107733. particleSystem) {
  107734. this.particleSystem = particleSystem;
  107735. /**
  107736. * Type of the submitter (Default: END)
  107737. */
  107738. this.type = SubEmitterType.END;
  107739. /**
  107740. * 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)
  107741. * Note: This only is supported when using an emitter of type Mesh
  107742. */
  107743. this.inheritDirection = false;
  107744. /**
  107745. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  107746. */
  107747. this.inheritedVelocityAmount = 0;
  107748. // Create mesh as emitter to support rotation
  107749. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  107750. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  107751. }
  107752. // Automatically dispose of subemitter when system is disposed
  107753. particleSystem.onDisposeObservable.add(function () {
  107754. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  107755. particleSystem.emitter.dispose();
  107756. }
  107757. });
  107758. }
  107759. /**
  107760. * Clones the sub emitter
  107761. * @returns the cloned sub emitter
  107762. */
  107763. SubEmitter.prototype.clone = function () {
  107764. // Clone particle system
  107765. var emitter = this.particleSystem.emitter;
  107766. if (!emitter) {
  107767. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  107768. }
  107769. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  107770. emitter = emitter.clone();
  107771. }
  107772. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  107773. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  107774. emitter.isVisible = false;
  107775. }
  107776. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  107777. // Clone properties
  107778. clone.type = this.type;
  107779. clone.inheritDirection = this.inheritDirection;
  107780. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  107781. clone.particleSystem._disposeEmitterOnDispose = true;
  107782. clone.particleSystem.disposeOnStop = true;
  107783. return clone;
  107784. };
  107785. /**
  107786. * Serialize current object to a JSON object
  107787. * @returns the serialized object
  107788. */
  107789. SubEmitter.prototype.serialize = function () {
  107790. var serializationObject = {};
  107791. serializationObject.type = this.type;
  107792. serializationObject.inheritDirection = this.inheritDirection;
  107793. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  107794. serializationObject.particleSystem = this.particleSystem.serialize();
  107795. return serializationObject;
  107796. };
  107797. /** @hidden */
  107798. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  107799. throw "Import ParseParticle before parsing SubEmitter.";
  107800. };
  107801. /**
  107802. * Creates a new SubEmitter from a serialized JSON version
  107803. * @param serializationObject defines the JSON object to read from
  107804. * @param scene defines the hosting scene
  107805. * @param rootUrl defines the rootUrl for data loading
  107806. * @returns a new SubEmitter
  107807. */
  107808. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  107809. var system = serializationObject.particleSystem;
  107810. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  107811. subEmitter.type = serializationObject.type;
  107812. subEmitter.inheritDirection = serializationObject.inheritDirection;
  107813. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  107814. subEmitter.particleSystem._isSubEmitter = true;
  107815. return subEmitter;
  107816. };
  107817. /** Release associated resources */
  107818. SubEmitter.prototype.dispose = function () {
  107819. this.particleSystem.dispose();
  107820. };
  107821. return SubEmitter;
  107822. }());
  107823. /***/ }),
  107824. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  107825. /*!*****************************************!*\
  107826. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  107827. \*****************************************/
  107828. /*! exports provided: AmmoJSPlugin */
  107829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107830. "use strict";
  107831. __webpack_require__.r(__webpack_exports__);
  107832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  107833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107834. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  107835. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  107836. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  107837. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  107838. /**
  107839. * AmmoJS Physics plugin
  107840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107841. * @see https://github.com/kripken/ammo.js/
  107842. */
  107843. var AmmoJSPlugin = /** @class */ (function () {
  107844. /**
  107845. * Initializes the ammoJS plugin
  107846. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107847. * @param ammoInjection can be used to inject your own ammo reference
  107848. */
  107849. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  107850. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  107851. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  107852. var _this = this;
  107853. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  107854. /**
  107855. * Name of the plugin
  107856. */
  107857. this.name = "AmmoJSPlugin";
  107858. this._timeStep = 1 / 60;
  107859. this._fixedTimeStep = 1 / 60;
  107860. this._maxSteps = 5;
  107861. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  107862. this._tmpContactCallbackResult = false;
  107863. if (typeof ammoInjection === "function") {
  107864. ammoInjection();
  107865. }
  107866. this.bjsAMMO = ammoInjection;
  107867. if (!this.isSupported()) {
  107868. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  107869. return;
  107870. }
  107871. // Initialize the physics world
  107872. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  107873. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  107874. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  107875. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  107876. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  107877. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  107878. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  107879. // Create temp ammo variables
  107880. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  107881. this._tmpAmmoTransform.setIdentity();
  107882. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  107883. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  107884. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  107885. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  107886. }
  107887. /**
  107888. * Sets the gravity of the physics world (m/(s^2))
  107889. * @param gravity Gravity to set
  107890. */
  107891. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  107892. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  107893. this.world.setGravity(this._tmpAmmoVectorA);
  107894. };
  107895. /**
  107896. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107897. * @param timeStep timestep to use in seconds
  107898. */
  107899. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  107900. this._timeStep = timeStep;
  107901. };
  107902. /**
  107903. * 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)
  107904. * @param fixedTimeStep fixedTimeStep to use in seconds
  107905. */
  107906. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  107907. this._fixedTimeStep = fixedTimeStep;
  107908. };
  107909. /**
  107910. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107911. * @param maxSteps the maximum number of steps by the physics engine per frame
  107912. */
  107913. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  107914. this._maxSteps = maxSteps;
  107915. };
  107916. /**
  107917. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107918. * @returns the current timestep in seconds
  107919. */
  107920. AmmoJSPlugin.prototype.getTimeStep = function () {
  107921. return this._timeStep;
  107922. };
  107923. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  107924. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  107925. this._tmpContactCallbackResult = false;
  107926. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  107927. return this._tmpContactCallbackResult;
  107928. };
  107929. // Ammo's collision events have some weird quirks
  107930. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  107931. // so only fire event if both contactTest and contactPairTest have a hit
  107932. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  107933. this._tmpContactCallbackResult = false;
  107934. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  107935. return this._tmpContactCallbackResult;
  107936. };
  107937. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  107938. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  107939. //
  107940. // When maxSteps is 0 do the entire simulation in one step
  107941. // 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)
  107942. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  107943. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  107944. if (timeStep === void 0) { timeStep = 1 / 60; }
  107945. if (maxSteps === void 0) { maxSteps = 10; }
  107946. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  107947. if (maxSteps == 0) {
  107948. this.world.stepSimulation(timeStep, 0);
  107949. }
  107950. else {
  107951. while (maxSteps > 0 && timeStep > 0) {
  107952. if (timeStep - fixedTimeStep < fixedTimeStep) {
  107953. this.world.stepSimulation(timeStep, 0);
  107954. timeStep = 0;
  107955. }
  107956. else {
  107957. timeStep -= fixedTimeStep;
  107958. this.world.stepSimulation(fixedTimeStep, 0);
  107959. }
  107960. maxSteps--;
  107961. }
  107962. }
  107963. };
  107964. /**
  107965. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107966. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107967. * After the step the babylon meshes are set to the position of the physics imposters
  107968. * @param delta amount of time to step forward
  107969. * @param impostors array of imposters to update before/after the step
  107970. */
  107971. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  107972. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  107973. var impostor = impostors_1[_i];
  107974. // Update physics world objects to match babylon world
  107975. impostor.beforeStep();
  107976. }
  107977. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  107978. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  107979. var mainImpostor = impostors_2[_a];
  107980. // After physics update make babylon world objects match physics world objects
  107981. mainImpostor.afterStep();
  107982. // Handle collision event
  107983. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  107984. if (this._isImpostorInContact(mainImpostor)) {
  107985. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  107986. var collideCallback = _c[_b];
  107987. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  107988. var otherImpostor = _e[_d];
  107989. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  107990. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  107991. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  107992. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  107993. }
  107994. }
  107995. }
  107996. }
  107997. }
  107998. }
  107999. }
  108000. };
  108001. /**
  108002. * Applies an implulse on the imposter
  108003. * @param impostor imposter to apply impulse
  108004. * @param force amount of force to be applied to the imposter
  108005. * @param contactPoint the location to apply the impulse on the imposter
  108006. */
  108007. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108008. var worldPoint = this._tmpAmmoVectorA;
  108009. var impulse = this._tmpAmmoVectorB;
  108010. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108011. impulse.setValue(force.x, force.y, force.z);
  108012. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108013. };
  108014. /**
  108015. * Applies a force on the imposter
  108016. * @param impostor imposter to apply force
  108017. * @param force amount of force to be applied to the imposter
  108018. * @param contactPoint the location to apply the force on the imposter
  108019. */
  108020. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108021. var worldPoint = this._tmpAmmoVectorA;
  108022. var impulse = this._tmpAmmoVectorB;
  108023. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108024. impulse.setValue(force.x, force.y, force.z);
  108025. impostor.physicsBody.applyForce(impulse, worldPoint);
  108026. };
  108027. /**
  108028. * Creates a physics body using the plugin
  108029. * @param impostor the imposter to create the physics body on
  108030. */
  108031. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108032. impostor._pluginData = { toDispose: [] };
  108033. //parent-child relationship
  108034. if (impostor.parent) {
  108035. if (impostor.physicsBody) {
  108036. this.removePhysicsBody(impostor);
  108037. impostor.forceUpdate();
  108038. }
  108039. return;
  108040. }
  108041. if (impostor.isBodyInitRequired()) {
  108042. var colShape = this._createShape(impostor);
  108043. var mass = impostor.getParam("mass");
  108044. impostor._pluginData.mass = mass;
  108045. var localInertia = new Ammo.btVector3(0, 0, 0);
  108046. var startTransform = new Ammo.btTransform();
  108047. startTransform.setIdentity();
  108048. if (mass !== 0) {
  108049. colShape.calculateLocalInertia(mass, localInertia);
  108050. }
  108051. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  108052. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  108053. startTransform.setOrigin(this._tmpAmmoVectorA);
  108054. startTransform.setRotation(this._tmpAmmoQuaternion);
  108055. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  108056. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  108057. var body = new Ammo.btRigidBody(rbInfo);
  108058. // Make objects kinematic if it's mass is 0
  108059. if (mass === 0) {
  108060. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  108061. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  108062. }
  108063. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  108064. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  108065. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  108066. }
  108067. this.world.addRigidBody(body);
  108068. impostor.physicsBody = body;
  108069. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  108070. this.setBodyFriction(impostor, impostor.getParam("friction"));
  108071. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  108072. }
  108073. };
  108074. /**
  108075. * Removes the physics body from the imposter and disposes of the body's memory
  108076. * @param impostor imposter to remove the physics body from
  108077. */
  108078. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  108079. var _this = this;
  108080. if (this.world) {
  108081. this.world.removeRigidBody(impostor.physicsBody);
  108082. impostor._pluginData.toDispose.forEach(function (d) {
  108083. _this.bjsAMMO.destroy(d);
  108084. });
  108085. }
  108086. };
  108087. /**
  108088. * Generates a joint
  108089. * @param impostorJoint the imposter joint to create the joint with
  108090. */
  108091. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  108092. var mainBody = impostorJoint.mainImpostor.physicsBody;
  108093. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  108094. if (!mainBody || !connectedBody) {
  108095. return;
  108096. }
  108097. var jointData = impostorJoint.joint.jointData;
  108098. if (!jointData.mainPivot) {
  108099. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108100. }
  108101. if (!jointData.connectedPivot) {
  108102. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108103. }
  108104. var joint;
  108105. switch (impostorJoint.joint.type) {
  108106. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  108107. var distance = jointData.maxDistance;
  108108. if (distance) {
  108109. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  108110. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  108111. }
  108112. 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));
  108113. break;
  108114. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  108115. if (!jointData.mainAxis) {
  108116. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108117. }
  108118. if (!jointData.connectedAxis) {
  108119. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108120. }
  108121. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  108122. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  108123. 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);
  108124. break;
  108125. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  108126. 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));
  108127. break;
  108128. default:
  108129. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  108130. 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));
  108131. break;
  108132. }
  108133. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  108134. impostorJoint.joint.physicsJoint = joint;
  108135. };
  108136. /**
  108137. * Removes a joint
  108138. * @param impostorJoint the imposter joint to remove the joint from
  108139. */
  108140. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  108141. if (this.world) {
  108142. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  108143. }
  108144. };
  108145. // adds all verticies (including child verticies) to the triangle mesh
  108146. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  108147. var _this = this;
  108148. var triangleCount = 0;
  108149. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  108150. var indices = object.getIndices();
  108151. if (!indices) {
  108152. indices = [];
  108153. }
  108154. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  108155. if (!vertexPositions) {
  108156. vertexPositions = [];
  108157. }
  108158. object.computeWorldMatrix(false);
  108159. var faceCount = indices.length / 3;
  108160. for (var i = 0; i < faceCount; i++) {
  108161. var triPoints = [];
  108162. for (var point = 0; point < 3; point++) {
  108163. 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]);
  108164. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  108165. v.subtractInPlace(topLevelObject.position);
  108166. var vec;
  108167. if (point == 0) {
  108168. vec = this._tmpAmmoVectorA;
  108169. }
  108170. else if (point == 1) {
  108171. vec = this._tmpAmmoVectorB;
  108172. }
  108173. else {
  108174. vec = this._tmpAmmoVectorC;
  108175. }
  108176. vec.setValue(v.x, v.y, v.z);
  108177. triPoints.push(vec);
  108178. }
  108179. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  108180. triangleCount++;
  108181. }
  108182. object.getChildMeshes().forEach(function (m) {
  108183. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  108184. });
  108185. }
  108186. return triangleCount;
  108187. };
  108188. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  108189. var _this = this;
  108190. if (ignoreChildren === void 0) { ignoreChildren = false; }
  108191. var object = impostor.object;
  108192. var returnValue;
  108193. var extendSize = impostor.getObjectExtendSize();
  108194. if (!ignoreChildren) {
  108195. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  108196. returnValue = new Ammo.btCompoundShape();
  108197. // Add shape of all children to the compound shape
  108198. var childrenAdded = 0;
  108199. meshChildren.forEach(function (childMesh) {
  108200. var childImpostor = childMesh.getPhysicsImpostor();
  108201. if (childImpostor) {
  108202. var shape = _this._createShape(childImpostor);
  108203. // Position needs to be scaled based on parent's scaling
  108204. var parentMat = childMesh.parent.getWorldMatrix().clone();
  108205. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108206. parentMat.decompose(s);
  108207. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  108208. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  108209. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  108210. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  108211. childImpostor.dispose();
  108212. childrenAdded++;
  108213. }
  108214. });
  108215. if (childrenAdded > 0) {
  108216. // Add parents shape as a child if present
  108217. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  108218. var shape = this._createShape(impostor, true);
  108219. if (shape) {
  108220. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  108221. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  108222. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  108223. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  108224. }
  108225. }
  108226. return returnValue;
  108227. }
  108228. else {
  108229. // If no children with impostors create the actual shape below instead
  108230. Ammo.destroy(returnValue);
  108231. returnValue = null;
  108232. }
  108233. }
  108234. switch (impostor.type) {
  108235. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  108236. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108237. break;
  108238. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  108239. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108240. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  108241. break;
  108242. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  108243. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  108244. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108245. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  108246. break;
  108247. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  108248. var tetraMesh = new Ammo.btTriangleMesh();
  108249. impostor._pluginData.toDispose.concat([tetraMesh]);
  108250. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  108251. if (triangeCount == 0) {
  108252. returnValue = new Ammo.btCompoundShape();
  108253. }
  108254. else {
  108255. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  108256. }
  108257. break;
  108258. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  108259. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  108260. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108261. break;
  108262. default:
  108263. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  108264. break;
  108265. }
  108266. return returnValue;
  108267. };
  108268. /**
  108269. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108270. * @param impostor imposter containing the physics body and babylon object
  108271. */
  108272. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  108273. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108274. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  108275. if (!impostor.object.rotationQuaternion) {
  108276. if (impostor.object.rotation) {
  108277. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108278. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  108279. }
  108280. }
  108281. else {
  108282. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108283. }
  108284. };
  108285. /**
  108286. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108287. * @param impostor imposter containing the physics body and babylon object
  108288. * @param newPosition new position
  108289. * @param newRotation new rotation
  108290. */
  108291. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  108292. var trans = impostor.physicsBody.getWorldTransform();
  108293. // If rotation/position has changed update and activate riged body
  108294. if (trans.getOrigin().x() != newPosition.x ||
  108295. trans.getOrigin().y() != newPosition.y ||
  108296. trans.getOrigin().z() != newPosition.z ||
  108297. trans.getRotation().x() != newRotation.x ||
  108298. trans.getRotation().y() != newRotation.y ||
  108299. trans.getRotation().z() != newRotation.z ||
  108300. trans.getRotation().w() != newRotation.w) {
  108301. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  108302. trans.setOrigin(this._tmpAmmoVectorA);
  108303. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  108304. trans.setRotation(this._tmpAmmoQuaternion);
  108305. impostor.physicsBody.setWorldTransform(trans);
  108306. if (impostor.mass == 0) {
  108307. // Kinematic objects must be updated using motion state
  108308. var motionState = impostor.physicsBody.getMotionState();
  108309. if (motionState) {
  108310. motionState.setWorldTransform(trans);
  108311. }
  108312. }
  108313. else {
  108314. impostor.physicsBody.activate();
  108315. }
  108316. }
  108317. };
  108318. /**
  108319. * If this plugin is supported
  108320. * @returns true if its supported
  108321. */
  108322. AmmoJSPlugin.prototype.isSupported = function () {
  108323. return this.bjsAMMO !== undefined;
  108324. };
  108325. /**
  108326. * Sets the linear velocity of the physics body
  108327. * @param impostor imposter to set the velocity on
  108328. * @param velocity velocity to set
  108329. */
  108330. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  108331. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108332. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  108333. };
  108334. /**
  108335. * Sets the angular velocity of the physics body
  108336. * @param impostor imposter to set the velocity on
  108337. * @param velocity velocity to set
  108338. */
  108339. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  108340. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108341. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  108342. };
  108343. /**
  108344. * gets the linear velocity
  108345. * @param impostor imposter to get linear velocity from
  108346. * @returns linear velocity
  108347. */
  108348. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  108349. var v = impostor.physicsBody.getLinearVelocity();
  108350. if (!v) {
  108351. return null;
  108352. }
  108353. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108354. };
  108355. /**
  108356. * gets the angular velocity
  108357. * @param impostor imposter to get angular velocity from
  108358. * @returns angular velocity
  108359. */
  108360. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  108361. var v = impostor.physicsBody.getAngularVelocity();
  108362. if (!v) {
  108363. return null;
  108364. }
  108365. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108366. };
  108367. /**
  108368. * Sets the mass of physics body
  108369. * @param impostor imposter to set the mass on
  108370. * @param mass mass to set
  108371. */
  108372. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  108373. impostor.physicsBody.setMassProps(mass);
  108374. impostor._pluginData.mass = mass;
  108375. };
  108376. /**
  108377. * Gets the mass of the physics body
  108378. * @param impostor imposter to get the mass from
  108379. * @returns mass
  108380. */
  108381. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  108382. return impostor._pluginData.mass;
  108383. };
  108384. /**
  108385. * Gets friction of the impostor
  108386. * @param impostor impostor to get friction from
  108387. * @returns friction value
  108388. */
  108389. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  108390. return impostor._pluginData.friction;
  108391. };
  108392. /**
  108393. * Sets friction of the impostor
  108394. * @param impostor impostor to set friction on
  108395. * @param friction friction value
  108396. */
  108397. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  108398. impostor.physicsBody.setFriction(friction);
  108399. impostor._pluginData.friction = friction;
  108400. };
  108401. /**
  108402. * Gets restitution of the impostor
  108403. * @param impostor impostor to get restitution from
  108404. * @returns restitution value
  108405. */
  108406. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  108407. return impostor._pluginData.restitution;
  108408. };
  108409. /**
  108410. * Sets resitution of the impostor
  108411. * @param impostor impostor to set resitution on
  108412. * @param restitution resitution value
  108413. */
  108414. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  108415. impostor.physicsBody.setRestitution(restitution);
  108416. impostor._pluginData.restitution = restitution;
  108417. };
  108418. /**
  108419. * Sleeps the physics body and stops it from being active
  108420. * @param impostor impostor to sleep
  108421. */
  108422. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  108423. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  108424. };
  108425. /**
  108426. * Activates the physics body
  108427. * @param impostor impostor to activate
  108428. */
  108429. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  108430. impostor.physicsBody.activate();
  108431. };
  108432. /**
  108433. * Updates the distance parameters of the joint
  108434. * @param joint joint to update
  108435. * @param maxDistance maximum distance of the joint
  108436. * @param minDistance minimum distance of the joint
  108437. */
  108438. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  108439. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  108440. };
  108441. /**
  108442. * Sets a motor on the joint
  108443. * @param joint joint to set motor on
  108444. * @param speed speed of the motor
  108445. * @param maxForce maximum force of the motor
  108446. * @param motorIndex index of the motor
  108447. */
  108448. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  108449. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  108450. };
  108451. /**
  108452. * Sets the motors limit
  108453. * @param joint joint to set limit on
  108454. * @param upperLimit upper limit
  108455. * @param lowerLimit lower limit
  108456. */
  108457. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  108458. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  108459. };
  108460. /**
  108461. * Syncs the position and rotation of a mesh with the impostor
  108462. * @param mesh mesh to sync
  108463. * @param impostor impostor to update the mesh with
  108464. */
  108465. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  108466. var body = impostor.physicsBody;
  108467. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108468. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  108469. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  108470. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  108471. if (mesh.rotationQuaternion) {
  108472. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  108473. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  108474. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  108475. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  108476. }
  108477. };
  108478. /**
  108479. * Gets the radius of the impostor
  108480. * @param impostor impostor to get radius from
  108481. * @returns the radius
  108482. */
  108483. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  108484. var exntend = impostor.getObjectExtendSize();
  108485. return exntend.x / 2;
  108486. };
  108487. /**
  108488. * Gets the box size of the impostor
  108489. * @param impostor impostor to get box size from
  108490. * @param result the resulting box size
  108491. */
  108492. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  108493. var exntend = impostor.getObjectExtendSize();
  108494. result.x = exntend.x;
  108495. result.y = exntend.y;
  108496. result.z = exntend.z;
  108497. };
  108498. /**
  108499. * Disposes of the impostor
  108500. */
  108501. AmmoJSPlugin.prototype.dispose = function () {
  108502. // Dispose of world
  108503. Ammo.destroy(this.world);
  108504. Ammo.destroy(this._solver);
  108505. Ammo.destroy(this._overlappingPairCache);
  108506. Ammo.destroy(this._dispatcher);
  108507. Ammo.destroy(this._collisionConfiguration);
  108508. // Dispose of tmp variables
  108509. Ammo.destroy(this._tmpAmmoVectorA);
  108510. Ammo.destroy(this._tmpAmmoVectorB);
  108511. Ammo.destroy(this._tmpAmmoVectorC);
  108512. Ammo.destroy(this._tmpAmmoTransform);
  108513. Ammo.destroy(this._tmpAmmoQuaternion);
  108514. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  108515. this.world = null;
  108516. };
  108517. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  108518. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  108519. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  108520. return AmmoJSPlugin;
  108521. }());
  108522. /***/ }),
  108523. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  108524. /*!*******************************************!*\
  108525. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  108526. \*******************************************/
  108527. /*! exports provided: CannonJSPlugin */
  108528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108529. "use strict";
  108530. __webpack_require__.r(__webpack_exports__);
  108531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  108532. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108533. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108534. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108535. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108536. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108537. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  108538. /** @hidden */
  108539. var CannonJSPlugin = /** @class */ (function () {
  108540. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  108541. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108542. if (iterations === void 0) { iterations = 10; }
  108543. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  108544. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108545. this.name = "CannonJSPlugin";
  108546. this._physicsMaterials = new Array();
  108547. this._fixedTimeStep = 1 / 60;
  108548. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  108549. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  108550. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108551. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108552. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  108553. this.BJSCANNON = cannonInjection;
  108554. if (!this.isSupported()) {
  108555. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  108556. return;
  108557. }
  108558. this._extendNamespace();
  108559. this.world = new this.BJSCANNON.World();
  108560. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  108561. this.world.solver.iterations = iterations;
  108562. }
  108563. CannonJSPlugin.prototype.setGravity = function (gravity) {
  108564. this.world.gravity.copy(gravity);
  108565. };
  108566. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  108567. this._fixedTimeStep = timeStep;
  108568. };
  108569. CannonJSPlugin.prototype.getTimeStep = function () {
  108570. return this._fixedTimeStep;
  108571. };
  108572. CannonJSPlugin.prototype.executeStep = function (delta) {
  108573. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  108574. };
  108575. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108576. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108577. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108578. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108579. };
  108580. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108581. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108582. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108583. impostor.physicsBody.applyForce(impulse, worldPoint);
  108584. };
  108585. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108586. //parent-child relationship. Does this impostor has a parent impostor?
  108587. if (impostor.parent) {
  108588. if (impostor.physicsBody) {
  108589. this.removePhysicsBody(impostor);
  108590. //TODO is that needed?
  108591. impostor.forceUpdate();
  108592. }
  108593. return;
  108594. }
  108595. //should a new body be created for this impostor?
  108596. if (impostor.isBodyInitRequired()) {
  108597. var shape = this._createShape(impostor);
  108598. //unregister events, if body is being changed
  108599. var oldBody = impostor.physicsBody;
  108600. if (oldBody) {
  108601. this.removePhysicsBody(impostor);
  108602. }
  108603. //create the body and material
  108604. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  108605. var bodyCreationObject = {
  108606. mass: impostor.getParam("mass"),
  108607. material: material
  108608. };
  108609. // A simple extend, in case native options were used.
  108610. var nativeOptions = impostor.getParam("nativeOptions");
  108611. for (var key in nativeOptions) {
  108612. if (nativeOptions.hasOwnProperty(key)) {
  108613. bodyCreationObject[key] = nativeOptions[key];
  108614. }
  108615. }
  108616. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  108617. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  108618. this.world.addEventListener("preStep", impostor.beforeStep);
  108619. this.world.addEventListener("postStep", impostor.afterStep);
  108620. impostor.physicsBody.addShape(shape);
  108621. this.world.add(impostor.physicsBody);
  108622. //try to keep the body moving in the right direction by taking old properties.
  108623. //Should be tested!
  108624. if (oldBody) {
  108625. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  108626. impostor.physicsBody[param].copy(oldBody[param]);
  108627. });
  108628. }
  108629. this._processChildMeshes(impostor);
  108630. }
  108631. //now update the body's transformation
  108632. this._updatePhysicsBodyTransformation(impostor);
  108633. };
  108634. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  108635. var _this = this;
  108636. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  108637. var currentRotation = mainImpostor.object.rotationQuaternion;
  108638. if (meshChildren.length) {
  108639. var processMesh = function (localPosition, mesh) {
  108640. if (!currentRotation || !mesh.rotationQuaternion) {
  108641. return;
  108642. }
  108643. var childImpostor = mesh.getPhysicsImpostor();
  108644. if (childImpostor) {
  108645. var parent = childImpostor.parent;
  108646. if (parent !== mainImpostor) {
  108647. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  108648. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  108649. if (childImpostor.physicsBody) {
  108650. _this.removePhysicsBody(childImpostor);
  108651. childImpostor.physicsBody = null;
  108652. }
  108653. childImpostor.parent = mainImpostor;
  108654. childImpostor.resetUpdateFlags();
  108655. 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));
  108656. //Add the mass of the children.
  108657. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  108658. }
  108659. }
  108660. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  108661. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  108662. };
  108663. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  108664. }
  108665. };
  108666. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  108667. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  108668. this.world.removeEventListener("preStep", impostor.beforeStep);
  108669. this.world.removeEventListener("postStep", impostor.afterStep);
  108670. this.world.remove(impostor.physicsBody);
  108671. };
  108672. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  108673. var mainBody = impostorJoint.mainImpostor.physicsBody;
  108674. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  108675. if (!mainBody || !connectedBody) {
  108676. return;
  108677. }
  108678. var constraint;
  108679. var jointData = impostorJoint.joint.jointData;
  108680. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  108681. var constraintData = {
  108682. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  108683. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  108684. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  108685. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  108686. maxForce: jointData.nativeParams.maxForce,
  108687. collideConnected: !!jointData.collision
  108688. };
  108689. switch (impostorJoint.joint.type) {
  108690. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  108691. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  108692. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  108693. break;
  108694. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  108695. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  108696. break;
  108697. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  108698. var springData = jointData;
  108699. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  108700. restLength: springData.length,
  108701. stiffness: springData.stiffness,
  108702. damping: springData.damping,
  108703. localAnchorA: constraintData.pivotA,
  108704. localAnchorB: constraintData.pivotB
  108705. });
  108706. break;
  108707. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  108708. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  108709. break;
  108710. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  108711. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  108712. default:
  108713. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  108714. break;
  108715. }
  108716. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  108717. constraint.collideConnected = !!jointData.collision;
  108718. impostorJoint.joint.physicsJoint = constraint;
  108719. //don't add spring as constraint, as it is not one.
  108720. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  108721. this.world.addConstraint(constraint);
  108722. }
  108723. else {
  108724. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  108725. constraint.applyForce();
  108726. };
  108727. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  108728. }
  108729. };
  108730. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  108731. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  108732. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  108733. }
  108734. else {
  108735. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  108736. }
  108737. };
  108738. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  108739. var index;
  108740. var mat;
  108741. for (index = 0; index < this._physicsMaterials.length; index++) {
  108742. mat = this._physicsMaterials[index];
  108743. if (mat.friction === friction && mat.restitution === restitution) {
  108744. return mat;
  108745. }
  108746. }
  108747. var currentMat = new this.BJSCANNON.Material(name);
  108748. currentMat.friction = friction;
  108749. currentMat.restitution = restitution;
  108750. this._physicsMaterials.push(currentMat);
  108751. return currentMat;
  108752. };
  108753. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  108754. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  108755. };
  108756. CannonJSPlugin.prototype._createShape = function (impostor) {
  108757. var object = impostor.object;
  108758. var returnValue;
  108759. var extendSize = impostor.getObjectExtendSize();
  108760. switch (impostor.type) {
  108761. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  108762. var radiusX = extendSize.x;
  108763. var radiusY = extendSize.y;
  108764. var radiusZ = extendSize.z;
  108765. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  108766. break;
  108767. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  108768. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  108769. var nativeParams = impostor.getParam("nativeOptions");
  108770. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  108771. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  108772. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y) / 2;
  108773. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  108774. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  108775. break;
  108776. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  108777. var box = extendSize.scale(0.5);
  108778. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  108779. break;
  108780. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  108781. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  108782. returnValue = new this.BJSCANNON.Plane();
  108783. break;
  108784. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  108785. // should transform the vertex data to world coordinates!!
  108786. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  108787. var rawFaces = object.getIndices ? object.getIndices() : [];
  108788. if (!rawVerts) {
  108789. return;
  108790. }
  108791. // get only scale! so the object could transform correctly.
  108792. var oldPosition = object.position.clone();
  108793. var oldRotation = object.rotation && object.rotation.clone();
  108794. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  108795. object.position.copyFromFloats(0, 0, 0);
  108796. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  108797. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  108798. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  108799. var transform = object.computeWorldMatrix(true);
  108800. // convert rawVerts to object space
  108801. var temp = new Array();
  108802. var index;
  108803. for (index = 0; index < rawVerts.length; index += 3) {
  108804. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  108805. }
  108806. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  108807. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  108808. //now set back the transformation!
  108809. object.position.copyFrom(oldPosition);
  108810. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  108811. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  108812. break;
  108813. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  108814. var oldPosition2 = object.position.clone();
  108815. var oldRotation2 = object.rotation && object.rotation.clone();
  108816. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  108817. object.position.copyFromFloats(0, 0, 0);
  108818. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  108819. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  108820. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  108821. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  108822. returnValue = this._createHeightmap(object);
  108823. object.position.copyFrom(oldPosition2);
  108824. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  108825. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  108826. object.computeWorldMatrix(true);
  108827. break;
  108828. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  108829. returnValue = new this.BJSCANNON.Particle();
  108830. break;
  108831. }
  108832. return returnValue;
  108833. };
  108834. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  108835. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  108836. var transform = object.computeWorldMatrix(true);
  108837. // convert rawVerts to object space
  108838. var temp = new Array();
  108839. var index;
  108840. for (index = 0; index < pos.length; index += 3) {
  108841. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  108842. }
  108843. pos = temp;
  108844. var matrix = new Array();
  108845. //For now pointDepth will not be used and will be automatically calculated.
  108846. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  108847. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  108848. var boundingInfo = object.getBoundingInfo();
  108849. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  108850. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  108851. var elementSize = dim * 2 / arraySize;
  108852. for (var i = 0; i < pos.length; i = i + 3) {
  108853. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  108854. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  108855. var y = -pos[i + 2] + minY;
  108856. if (!matrix[x]) {
  108857. matrix[x] = [];
  108858. }
  108859. if (!matrix[x][z]) {
  108860. matrix[x][z] = y;
  108861. }
  108862. matrix[x][z] = Math.max(y, matrix[x][z]);
  108863. }
  108864. for (var x = 0; x <= arraySize; ++x) {
  108865. if (!matrix[x]) {
  108866. var loc = 1;
  108867. while (!matrix[(x + loc) % arraySize]) {
  108868. loc++;
  108869. }
  108870. matrix[x] = matrix[(x + loc) % arraySize].slice();
  108871. //console.log("missing x", x);
  108872. }
  108873. for (var z = 0; z <= arraySize; ++z) {
  108874. if (!matrix[x][z]) {
  108875. var loc = 1;
  108876. var newValue;
  108877. while (newValue === undefined) {
  108878. newValue = matrix[x][(z + loc++) % arraySize];
  108879. }
  108880. matrix[x][z] = newValue;
  108881. }
  108882. }
  108883. }
  108884. var shape = new this.BJSCANNON.Heightfield(matrix, {
  108885. elementSize: elementSize
  108886. });
  108887. //For future reference, needed for body transformation
  108888. shape.minY = minY;
  108889. return shape;
  108890. };
  108891. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  108892. var object = impostor.object;
  108893. //make sure it is updated...
  108894. object.computeWorldMatrix && object.computeWorldMatrix(true);
  108895. // The delta between the mesh position and the mesh bounding box center
  108896. var bInfo = object.getBoundingInfo();
  108897. if (!bInfo) {
  108898. return;
  108899. }
  108900. var center = impostor.getObjectCenter();
  108901. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  108902. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  108903. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  108904. this._tmpPosition.copyFrom(center);
  108905. var quaternion = object.rotationQuaternion;
  108906. if (!quaternion) {
  108907. return;
  108908. }
  108909. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  108910. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor) {
  108911. //-90 DEG in X, precalculated
  108912. quaternion = quaternion.multiply(this._minus90X);
  108913. //Invert! (Precalculated, 90 deg in X)
  108914. //No need to clone. this will never change.
  108915. impostor.setDeltaRotation(this._plus90X);
  108916. }
  108917. //If it is a heightfield, if should be centered.
  108918. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  108919. var mesh = object;
  108920. var boundingInfo = mesh.getBoundingInfo();
  108921. //calculate the correct body position:
  108922. var rotationQuaternion = mesh.rotationQuaternion;
  108923. mesh.rotationQuaternion = this._tmpUnityRotation;
  108924. mesh.computeWorldMatrix(true);
  108925. //get original center with no rotation
  108926. var c = center.clone();
  108927. var oldPivot = mesh.getPivotMatrix();
  108928. if (oldPivot) {
  108929. // create a copy the pivot Matrix as it is modified in place
  108930. oldPivot = oldPivot.clone();
  108931. }
  108932. else {
  108933. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  108934. }
  108935. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  108936. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  108937. mesh.setPreTransformMatrix(p);
  108938. mesh.computeWorldMatrix(true);
  108939. //calculate the translation
  108940. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  108941. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  108942. //add it inverted to the delta
  108943. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  108944. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  108945. //rotation is back
  108946. mesh.rotationQuaternion = rotationQuaternion;
  108947. mesh.setPreTransformMatrix(oldPivot);
  108948. mesh.computeWorldMatrix(true);
  108949. }
  108950. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  108951. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  108952. //this._tmpPosition.copyFrom(object.position);
  108953. }
  108954. impostor.setDeltaPosition(this._tmpDeltaPosition);
  108955. //Now update the impostor object
  108956. impostor.physicsBody.position.copy(this._tmpPosition);
  108957. impostor.physicsBody.quaternion.copy(quaternion);
  108958. };
  108959. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  108960. impostor.object.position.copyFrom(impostor.physicsBody.position);
  108961. if (impostor.object.rotationQuaternion) {
  108962. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  108963. }
  108964. };
  108965. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  108966. impostor.physicsBody.position.copy(newPosition);
  108967. impostor.physicsBody.quaternion.copy(newRotation);
  108968. };
  108969. CannonJSPlugin.prototype.isSupported = function () {
  108970. return this.BJSCANNON !== undefined;
  108971. };
  108972. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  108973. impostor.physicsBody.velocity.copy(velocity);
  108974. };
  108975. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  108976. impostor.physicsBody.angularVelocity.copy(velocity);
  108977. };
  108978. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  108979. var v = impostor.physicsBody.velocity;
  108980. if (!v) {
  108981. return null;
  108982. }
  108983. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  108984. };
  108985. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  108986. var v = impostor.physicsBody.angularVelocity;
  108987. if (!v) {
  108988. return null;
  108989. }
  108990. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  108991. };
  108992. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  108993. impostor.physicsBody.mass = mass;
  108994. impostor.physicsBody.updateMassProperties();
  108995. };
  108996. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  108997. return impostor.physicsBody.mass;
  108998. };
  108999. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  109000. return impostor.physicsBody.material.friction;
  109001. };
  109002. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109003. impostor.physicsBody.material.friction = friction;
  109004. };
  109005. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109006. return impostor.physicsBody.material.restitution;
  109007. };
  109008. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109009. impostor.physicsBody.material.restitution = restitution;
  109010. };
  109011. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  109012. impostor.physicsBody.sleep();
  109013. };
  109014. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  109015. impostor.physicsBody.wakeUp();
  109016. };
  109017. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  109018. joint.physicsJoint.distance = maxDistance;
  109019. };
  109020. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109021. // if (!motorIndex) {
  109022. // joint.physicsJoint.enableMotor();
  109023. // }
  109024. // }
  109025. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109026. // if (!motorIndex) {
  109027. // joint.physicsJoint.disableMotor();
  109028. // }
  109029. // }
  109030. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109031. if (!motorIndex) {
  109032. joint.physicsJoint.enableMotor();
  109033. joint.physicsJoint.setMotorSpeed(speed);
  109034. if (maxForce) {
  109035. this.setLimit(joint, maxForce);
  109036. }
  109037. }
  109038. };
  109039. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109040. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  109041. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  109042. };
  109043. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109044. var body = impostor.physicsBody;
  109045. mesh.position.x = body.position.x;
  109046. mesh.position.y = body.position.y;
  109047. mesh.position.z = body.position.z;
  109048. if (mesh.rotationQuaternion) {
  109049. mesh.rotationQuaternion.x = body.quaternion.x;
  109050. mesh.rotationQuaternion.y = body.quaternion.y;
  109051. mesh.rotationQuaternion.z = body.quaternion.z;
  109052. mesh.rotationQuaternion.w = body.quaternion.w;
  109053. }
  109054. };
  109055. CannonJSPlugin.prototype.getRadius = function (impostor) {
  109056. var shape = impostor.physicsBody.shapes[0];
  109057. return shape.boundingSphereRadius;
  109058. };
  109059. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109060. var shape = impostor.physicsBody.shapes[0];
  109061. result.x = shape.halfExtents.x * 2;
  109062. result.y = shape.halfExtents.y * 2;
  109063. result.z = shape.halfExtents.z * 2;
  109064. };
  109065. CannonJSPlugin.prototype.dispose = function () {
  109066. };
  109067. CannonJSPlugin.prototype._extendNamespace = function () {
  109068. //this will force cannon to execute at least one step when using interpolation
  109069. var step_tmp1 = new this.BJSCANNON.Vec3();
  109070. var Engine = this.BJSCANNON;
  109071. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  109072. maxSubSteps = maxSubSteps || 10;
  109073. timeSinceLastCalled = timeSinceLastCalled || 0;
  109074. if (timeSinceLastCalled === 0) {
  109075. this.internalStep(dt);
  109076. this.time += dt;
  109077. }
  109078. else {
  109079. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  109080. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  109081. var t0 = performance.now();
  109082. for (var i = 0; i !== internalSteps; i++) {
  109083. this.internalStep(dt);
  109084. if (performance.now() - t0 > dt * 1000) {
  109085. break;
  109086. }
  109087. }
  109088. this.time += timeSinceLastCalled;
  109089. var h = this.time % dt;
  109090. var h_div_dt = h / dt;
  109091. var interpvelo = step_tmp1;
  109092. var bodies = this.bodies;
  109093. for (var j = 0; j !== bodies.length; j++) {
  109094. var b = bodies[j];
  109095. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  109096. b.position.vsub(b.previousPosition, interpvelo);
  109097. interpvelo.scale(h_div_dt, interpvelo);
  109098. b.position.vadd(interpvelo, b.interpolatedPosition);
  109099. }
  109100. else {
  109101. b.interpolatedPosition.copy(b.position);
  109102. b.interpolatedQuaternion.copy(b.quaternion);
  109103. }
  109104. }
  109105. }
  109106. };
  109107. };
  109108. return CannonJSPlugin;
  109109. }());
  109110. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  109111. /***/ }),
  109112. /***/ "./Physics/Plugins/index.ts":
  109113. /*!**********************************!*\
  109114. !*** ./Physics/Plugins/index.ts ***!
  109115. \**********************************/
  109116. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109118. "use strict";
  109119. __webpack_require__.r(__webpack_exports__);
  109120. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  109121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  109122. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  109123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  109124. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  109125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  109126. /***/ }),
  109127. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  109128. /*!*****************************************!*\
  109129. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  109130. \*****************************************/
  109131. /*! exports provided: OimoJSPlugin */
  109132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109133. "use strict";
  109134. __webpack_require__.r(__webpack_exports__);
  109135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  109136. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109137. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109138. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109139. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109140. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109141. /** @hidden */
  109142. var OimoJSPlugin = /** @class */ (function () {
  109143. function OimoJSPlugin(iterations, oimoInjection) {
  109144. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  109145. this.name = "OimoJSPlugin";
  109146. this._tmpImpostorsArray = [];
  109147. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109148. this.BJSOIMO = oimoInjection;
  109149. this.world = new this.BJSOIMO.World({
  109150. iterations: iterations
  109151. });
  109152. this.world.clear();
  109153. }
  109154. OimoJSPlugin.prototype.setGravity = function (gravity) {
  109155. this.world.gravity.copy(gravity);
  109156. };
  109157. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109158. this.world.timeStep = timeStep;
  109159. };
  109160. OimoJSPlugin.prototype.getTimeStep = function () {
  109161. return this.world.timeStep;
  109162. };
  109163. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109164. var _this = this;
  109165. impostors.forEach(function (impostor) {
  109166. impostor.beforeStep();
  109167. });
  109168. this.world.step();
  109169. impostors.forEach(function (impostor) {
  109170. impostor.afterStep();
  109171. //update the ordered impostors array
  109172. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  109173. });
  109174. //check for collisions
  109175. var contact = this.world.contacts;
  109176. while (contact !== null) {
  109177. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  109178. contact = contact.next;
  109179. continue;
  109180. }
  109181. //is this body colliding with any other? get the impostor
  109182. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  109183. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  109184. if (!mainImpostor || !collidingImpostor) {
  109185. contact = contact.next;
  109186. continue;
  109187. }
  109188. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  109189. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  109190. contact = contact.next;
  109191. }
  109192. };
  109193. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109194. var mass = impostor.physicsBody.mass;
  109195. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  109196. };
  109197. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109198. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  109199. this.applyImpulse(impostor, force, contactPoint);
  109200. };
  109201. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109202. var _this = this;
  109203. //parent-child relationship. Does this impostor has a parent impostor?
  109204. if (impostor.parent) {
  109205. if (impostor.physicsBody) {
  109206. this.removePhysicsBody(impostor);
  109207. //TODO is that needed?
  109208. impostor.forceUpdate();
  109209. }
  109210. return;
  109211. }
  109212. if (impostor.isBodyInitRequired()) {
  109213. var bodyConfig = {
  109214. name: impostor.uniqueId,
  109215. //Oimo must have mass, also for static objects.
  109216. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  109217. size: [],
  109218. type: [],
  109219. pos: [],
  109220. posShape: [],
  109221. rot: [],
  109222. rotShape: [],
  109223. move: impostor.getParam("mass") !== 0,
  109224. density: impostor.getParam("mass"),
  109225. friction: impostor.getParam("friction"),
  109226. restitution: impostor.getParam("restitution"),
  109227. //Supporting older versions of Oimo
  109228. world: this.world
  109229. };
  109230. var impostors = [impostor];
  109231. var addToArray = function (parent) {
  109232. if (!parent.getChildMeshes) {
  109233. return;
  109234. }
  109235. parent.getChildMeshes().forEach(function (m) {
  109236. if (m.physicsImpostor) {
  109237. impostors.push(m.physicsImpostor);
  109238. //m.physicsImpostor._init();
  109239. }
  109240. });
  109241. };
  109242. addToArray(impostor.object);
  109243. var checkWithEpsilon_1 = function (value) {
  109244. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  109245. };
  109246. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  109247. impostors.forEach(function (i) {
  109248. if (!i.object.rotationQuaternion) {
  109249. return;
  109250. }
  109251. //get the correct bounding box
  109252. var oldQuaternion = i.object.rotationQuaternion;
  109253. globalQuaternion_1 = oldQuaternion.clone();
  109254. var rot = oldQuaternion.toEulerAngles();
  109255. var extendSize = i.getObjectExtendSize();
  109256. var radToDeg = 57.295779513082320876;
  109257. if (i === impostor) {
  109258. var center = impostor.getObjectCenter();
  109259. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  109260. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  109261. //Can also use Array.prototype.push.apply
  109262. bodyConfig.pos.push(center.x);
  109263. bodyConfig.pos.push(center.y);
  109264. bodyConfig.pos.push(center.z);
  109265. bodyConfig.posShape.push(0, 0, 0);
  109266. bodyConfig.rotShape.push(0, 0, 0);
  109267. }
  109268. else {
  109269. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  109270. bodyConfig.posShape.push(localPosition.x);
  109271. bodyConfig.posShape.push(localPosition.y);
  109272. bodyConfig.posShape.push(localPosition.z);
  109273. bodyConfig.pos.push(0, 0, 0);
  109274. bodyConfig.rotShape.push(rot.x * radToDeg);
  109275. bodyConfig.rotShape.push(rot.y * radToDeg);
  109276. bodyConfig.rotShape.push(rot.z * radToDeg);
  109277. }
  109278. // register mesh
  109279. switch (i.type) {
  109280. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  109281. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  109282. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  109283. var radiusX = extendSize.x;
  109284. var radiusY = extendSize.y;
  109285. var radiusZ = extendSize.z;
  109286. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  109287. bodyConfig.type.push('sphere');
  109288. //due to the way oimo works with compounds, add 3 times
  109289. bodyConfig.size.push(size);
  109290. bodyConfig.size.push(size);
  109291. bodyConfig.size.push(size);
  109292. break;
  109293. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  109294. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  109295. var sizeY = checkWithEpsilon_1(extendSize.y);
  109296. bodyConfig.type.push('cylinder');
  109297. bodyConfig.size.push(sizeX);
  109298. bodyConfig.size.push(sizeY);
  109299. //due to the way oimo works with compounds, add one more value.
  109300. bodyConfig.size.push(sizeY);
  109301. break;
  109302. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  109303. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  109304. default:
  109305. var sizeX = checkWithEpsilon_1(extendSize.x);
  109306. var sizeY = checkWithEpsilon_1(extendSize.y);
  109307. var sizeZ = checkWithEpsilon_1(extendSize.z);
  109308. bodyConfig.type.push('box');
  109309. //if (i === impostor) {
  109310. bodyConfig.size.push(sizeX);
  109311. bodyConfig.size.push(sizeY);
  109312. bodyConfig.size.push(sizeZ);
  109313. //} else {
  109314. // bodyConfig.size.push(0,0,0);
  109315. //}
  109316. break;
  109317. }
  109318. //actually not needed, but hey...
  109319. i.object.rotationQuaternion = oldQuaternion;
  109320. });
  109321. impostor.physicsBody = this.world.add(bodyConfig);
  109322. // set the quaternion, ignoring the previously defined (euler) rotation
  109323. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  109324. // update with delta 0, so the body will reveive the new rotation.
  109325. impostor.physicsBody.updatePosition(0);
  109326. }
  109327. else {
  109328. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  109329. }
  109330. impostor.setDeltaPosition(this._tmpPositionVector);
  109331. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  109332. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  109333. };
  109334. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109335. //impostor.physicsBody.dispose();
  109336. //Same as : (older oimo versions)
  109337. this.world.removeRigidBody(impostor.physicsBody);
  109338. };
  109339. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109340. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109341. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109342. if (!mainBody || !connectedBody) {
  109343. return;
  109344. }
  109345. var jointData = impostorJoint.joint.jointData;
  109346. var options = jointData.nativeParams || {};
  109347. var type;
  109348. var nativeJointData = {
  109349. body1: mainBody,
  109350. body2: connectedBody,
  109351. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  109352. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  109353. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  109354. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  109355. min: options.min,
  109356. max: options.max,
  109357. collision: options.collision || jointData.collision,
  109358. spring: options.spring,
  109359. //supporting older version of Oimo
  109360. world: this.world
  109361. };
  109362. switch (impostorJoint.joint.type) {
  109363. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  109364. type = "jointBall";
  109365. break;
  109366. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  109367. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  109368. var springData = jointData;
  109369. nativeJointData.min = springData.length || nativeJointData.min;
  109370. //Max should also be set, just make sure it is at least min
  109371. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  109372. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  109373. type = "jointDistance";
  109374. nativeJointData.max = jointData.maxDistance;
  109375. break;
  109376. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  109377. type = "jointPrisme";
  109378. break;
  109379. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  109380. type = "jointSlide";
  109381. break;
  109382. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  109383. type = "jointWheel";
  109384. break;
  109385. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  109386. default:
  109387. type = "jointHinge";
  109388. break;
  109389. }
  109390. nativeJointData.type = type;
  109391. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  109392. };
  109393. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109394. //Bug in Oimo prevents us from disposing a joint in the playground
  109395. //joint.joint.physicsJoint.dispose();
  109396. //So we will bruteforce it!
  109397. try {
  109398. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  109399. }
  109400. catch (e) {
  109401. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  109402. }
  109403. };
  109404. OimoJSPlugin.prototype.isSupported = function () {
  109405. return this.BJSOIMO !== undefined;
  109406. };
  109407. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109408. if (!impostor.physicsBody.sleeping) {
  109409. //TODO check that
  109410. /*if (impostor.physicsBody.shapes.next) {
  109411. var parentShape = this._getLastShape(impostor.physicsBody);
  109412. impostor.object.position.copyFrom(parentShape.position);
  109413. console.log(parentShape.position);
  109414. } else {*/
  109415. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  109416. //}
  109417. if (impostor.object.rotationQuaternion) {
  109418. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  109419. }
  109420. }
  109421. };
  109422. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109423. var body = impostor.physicsBody;
  109424. body.position.copy(newPosition);
  109425. body.orientation.copy(newRotation);
  109426. body.syncShapes();
  109427. body.awake();
  109428. };
  109429. /*private _getLastShape(body: any): any {
  109430. var lastShape = body.shapes;
  109431. while (lastShape.next) {
  109432. lastShape = lastShape.next;
  109433. }
  109434. return lastShape;
  109435. }*/
  109436. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109437. impostor.physicsBody.linearVelocity.copy(velocity);
  109438. };
  109439. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109440. impostor.physicsBody.angularVelocity.copy(velocity);
  109441. };
  109442. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109443. var v = impostor.physicsBody.linearVelocity;
  109444. if (!v) {
  109445. return null;
  109446. }
  109447. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109448. };
  109449. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109450. var v = impostor.physicsBody.angularVelocity;
  109451. if (!v) {
  109452. return null;
  109453. }
  109454. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109455. };
  109456. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109457. var staticBody = mass === 0;
  109458. //this will actually set the body's density and not its mass.
  109459. //But this is how oimo treats the mass variable.
  109460. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  109461. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  109462. };
  109463. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  109464. return impostor.physicsBody.shapes.density;
  109465. };
  109466. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109467. return impostor.physicsBody.shapes.friction;
  109468. };
  109469. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109470. impostor.physicsBody.shapes.friction = friction;
  109471. };
  109472. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109473. return impostor.physicsBody.shapes.restitution;
  109474. };
  109475. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109476. impostor.physicsBody.shapes.restitution = restitution;
  109477. };
  109478. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  109479. impostor.physicsBody.sleep();
  109480. };
  109481. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109482. impostor.physicsBody.awake();
  109483. };
  109484. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109485. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  109486. if (minDistance !== void 0) {
  109487. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  109488. }
  109489. };
  109490. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109491. //TODO separate rotational and transational motors.
  109492. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109493. if (motor) {
  109494. motor.setMotor(speed, maxForce);
  109495. }
  109496. };
  109497. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  109498. //TODO separate rotational and transational motors.
  109499. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109500. if (motor) {
  109501. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  109502. }
  109503. };
  109504. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109505. var body = impostor.physicsBody;
  109506. mesh.position.x = body.position.x;
  109507. mesh.position.y = body.position.y;
  109508. mesh.position.z = body.position.z;
  109509. if (mesh.rotationQuaternion) {
  109510. mesh.rotationQuaternion.x = body.orientation.x;
  109511. mesh.rotationQuaternion.y = body.orientation.y;
  109512. mesh.rotationQuaternion.z = body.orientation.z;
  109513. mesh.rotationQuaternion.w = body.orientation.s;
  109514. }
  109515. };
  109516. OimoJSPlugin.prototype.getRadius = function (impostor) {
  109517. return impostor.physicsBody.shapes.radius;
  109518. };
  109519. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109520. var shape = impostor.physicsBody.shapes;
  109521. result.x = shape.halfWidth * 2;
  109522. result.y = shape.halfHeight * 2;
  109523. result.z = shape.halfDepth * 2;
  109524. };
  109525. OimoJSPlugin.prototype.dispose = function () {
  109526. this.world.clear();
  109527. };
  109528. return OimoJSPlugin;
  109529. }());
  109530. /***/ }),
  109531. /***/ "./Physics/index.ts":
  109532. /*!**************************!*\
  109533. !*** ./Physics/index.ts ***!
  109534. \**************************/
  109535. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109537. "use strict";
  109538. __webpack_require__.r(__webpack_exports__);
  109539. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  109540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  109541. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  109542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  109543. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  109544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  109545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  109546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  109547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  109548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  109549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  109550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  109551. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  109552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  109553. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  109554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  109555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  109556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  109557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  109558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  109559. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  109560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  109561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  109562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  109563. /***/ }),
  109564. /***/ "./Physics/physicsEngine.ts":
  109565. /*!**********************************!*\
  109566. !*** ./Physics/physicsEngine.ts ***!
  109567. \**********************************/
  109568. /*! exports provided: PhysicsEngine */
  109569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109570. "use strict";
  109571. __webpack_require__.r(__webpack_exports__);
  109572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  109573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109574. /**
  109575. * Class used to control physics engine
  109576. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109577. */
  109578. var PhysicsEngine = /** @class */ (function () {
  109579. /**
  109580. * Creates a new Physics Engine
  109581. * @param gravity defines the gravity vector used by the simulation
  109582. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  109583. */
  109584. function PhysicsEngine(gravity, _physicsPlugin) {
  109585. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  109586. this._physicsPlugin = _physicsPlugin;
  109587. this._impostors = [];
  109588. this._joints = [];
  109589. if (!this._physicsPlugin.isSupported()) {
  109590. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  109591. + "Please make sure it is included.");
  109592. }
  109593. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  109594. this.setGravity(gravity);
  109595. this.setTimeStep();
  109596. }
  109597. /**
  109598. * Factory used to create the default physics plugin.
  109599. * @returns The default physics plugin
  109600. */
  109601. PhysicsEngine.DefaultPluginFactory = function () {
  109602. throw "Import CannonJSPlugin or Fill DefaultPluginFactory static property on PhysicsEngine before relying on default physics plugin.";
  109603. };
  109604. /**
  109605. * Sets the gravity vector used by the simulation
  109606. * @param gravity defines the gravity vector to use
  109607. */
  109608. PhysicsEngine.prototype.setGravity = function (gravity) {
  109609. this.gravity = gravity;
  109610. this._physicsPlugin.setGravity(this.gravity);
  109611. };
  109612. /**
  109613. * Set the time step of the physics engine.
  109614. * Default is 1/60.
  109615. * To slow it down, enter 1/600 for example.
  109616. * To speed it up, 1/30
  109617. * @param newTimeStep defines the new timestep to apply to this world.
  109618. */
  109619. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  109620. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  109621. this._physicsPlugin.setTimeStep(newTimeStep);
  109622. };
  109623. /**
  109624. * Get the time step of the physics engine.
  109625. * @returns the current time step
  109626. */
  109627. PhysicsEngine.prototype.getTimeStep = function () {
  109628. return this._physicsPlugin.getTimeStep();
  109629. };
  109630. /**
  109631. * Release all resources
  109632. */
  109633. PhysicsEngine.prototype.dispose = function () {
  109634. this._impostors.forEach(function (impostor) {
  109635. impostor.dispose();
  109636. });
  109637. this._physicsPlugin.dispose();
  109638. };
  109639. /**
  109640. * Gets the name of the current physics plugin
  109641. * @returns the name of the plugin
  109642. */
  109643. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  109644. return this._physicsPlugin.name;
  109645. };
  109646. /**
  109647. * Adding a new impostor for the impostor tracking.
  109648. * This will be done by the impostor itself.
  109649. * @param impostor the impostor to add
  109650. */
  109651. PhysicsEngine.prototype.addImpostor = function (impostor) {
  109652. impostor.uniqueId = this._impostors.push(impostor);
  109653. //if no parent, generate the body
  109654. if (!impostor.parent) {
  109655. this._physicsPlugin.generatePhysicsBody(impostor);
  109656. }
  109657. };
  109658. /**
  109659. * Remove an impostor from the engine.
  109660. * This impostor and its mesh will not longer be updated by the physics engine.
  109661. * @param impostor the impostor to remove
  109662. */
  109663. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  109664. var index = this._impostors.indexOf(impostor);
  109665. if (index > -1) {
  109666. var removed = this._impostors.splice(index, 1);
  109667. //Is it needed?
  109668. if (removed.length) {
  109669. //this will also remove it from the world.
  109670. removed[0].physicsBody = null;
  109671. }
  109672. }
  109673. };
  109674. /**
  109675. * Add a joint to the physics engine
  109676. * @param mainImpostor defines the main impostor to which the joint is added.
  109677. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  109678. * @param joint defines the joint that will connect both impostors.
  109679. */
  109680. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  109681. var impostorJoint = {
  109682. mainImpostor: mainImpostor,
  109683. connectedImpostor: connectedImpostor,
  109684. joint: joint
  109685. };
  109686. joint.physicsPlugin = this._physicsPlugin;
  109687. this._joints.push(impostorJoint);
  109688. this._physicsPlugin.generateJoint(impostorJoint);
  109689. };
  109690. /**
  109691. * Removes a joint from the simulation
  109692. * @param mainImpostor defines the impostor used with the joint
  109693. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  109694. * @param joint defines the joint to remove
  109695. */
  109696. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  109697. var matchingJoints = this._joints.filter(function (impostorJoint) {
  109698. return (impostorJoint.connectedImpostor === connectedImpostor
  109699. && impostorJoint.joint === joint
  109700. && impostorJoint.mainImpostor === mainImpostor);
  109701. });
  109702. if (matchingJoints.length) {
  109703. this._physicsPlugin.removeJoint(matchingJoints[0]);
  109704. //TODO remove it from the list as well
  109705. }
  109706. };
  109707. /**
  109708. * Called by the scene. No need to call it.
  109709. * @param delta defines the timespam between frames
  109710. */
  109711. PhysicsEngine.prototype._step = function (delta) {
  109712. var _this = this;
  109713. //check if any mesh has no body / requires an update
  109714. this._impostors.forEach(function (impostor) {
  109715. if (impostor.isBodyInitRequired()) {
  109716. _this._physicsPlugin.generatePhysicsBody(impostor);
  109717. }
  109718. });
  109719. if (delta > 0.1) {
  109720. delta = 0.1;
  109721. }
  109722. else if (delta <= 0) {
  109723. delta = 1.0 / 60.0;
  109724. }
  109725. this._physicsPlugin.executeStep(delta, this._impostors);
  109726. };
  109727. /**
  109728. * Gets the current plugin used to run the simulation
  109729. * @returns current plugin
  109730. */
  109731. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  109732. return this._physicsPlugin;
  109733. };
  109734. /**
  109735. * Gets the list of physic impostors
  109736. * @returns an array of PhysicsImpostor
  109737. */
  109738. PhysicsEngine.prototype.getImpostors = function () {
  109739. return this._impostors;
  109740. };
  109741. /**
  109742. * Gets the impostor for a physics enabled object
  109743. * @param object defines the object impersonated by the impostor
  109744. * @returns the PhysicsImpostor or null if not found
  109745. */
  109746. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  109747. for (var i = 0; i < this._impostors.length; ++i) {
  109748. if (this._impostors[i].object === object) {
  109749. return this._impostors[i];
  109750. }
  109751. }
  109752. return null;
  109753. };
  109754. /**
  109755. * Gets the impostor for a physics body object
  109756. * @param body defines physics body used by the impostor
  109757. * @returns the PhysicsImpostor or null if not found
  109758. */
  109759. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  109760. for (var i = 0; i < this._impostors.length; ++i) {
  109761. if (this._impostors[i].physicsBody === body) {
  109762. return this._impostors[i];
  109763. }
  109764. }
  109765. return null;
  109766. };
  109767. /**
  109768. * Global value used to control the smallest number supported by the simulation
  109769. */
  109770. PhysicsEngine.Epsilon = 0.001;
  109771. return PhysicsEngine;
  109772. }());
  109773. /***/ }),
  109774. /***/ "./Physics/physicsEngineComponent.ts":
  109775. /*!*******************************************!*\
  109776. !*** ./Physics/physicsEngineComponent.ts ***!
  109777. \*******************************************/
  109778. /*! exports provided: PhysicsEngineSceneComponent */
  109779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109780. "use strict";
  109781. __webpack_require__.r(__webpack_exports__);
  109782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  109783. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  109784. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  109785. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109786. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  109787. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  109788. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  109789. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  109790. /**
  109791. * Gets the current physics engine
  109792. * @returns a IPhysicsEngine or null if none attached
  109793. */
  109794. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  109795. return this._physicsEngine;
  109796. };
  109797. /**
  109798. * Enables physics to the current scene
  109799. * @param gravity defines the scene's gravity for the physics engine
  109800. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  109801. * @return a boolean indicating if the physics engine was initialized
  109802. */
  109803. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  109804. if (gravity === void 0) { gravity = null; }
  109805. if (this._physicsEngine) {
  109806. return true;
  109807. }
  109808. // Register the component to the scene
  109809. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  109810. if (!component) {
  109811. component = new PhysicsEngineSceneComponent(this);
  109812. this._addComponent(component);
  109813. }
  109814. try {
  109815. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  109816. return true;
  109817. }
  109818. catch (e) {
  109819. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  109820. return false;
  109821. }
  109822. };
  109823. /**
  109824. * Disables and disposes the physics engine associated with the scene
  109825. */
  109826. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  109827. if (!this._physicsEngine) {
  109828. return;
  109829. }
  109830. this._physicsEngine.dispose();
  109831. this._physicsEngine = null;
  109832. };
  109833. /**
  109834. * Gets a boolean indicating if there is an active physics engine
  109835. * @returns a boolean indicating if there is an active physics engine
  109836. */
  109837. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  109838. return this._physicsEngine !== undefined;
  109839. };
  109840. /**
  109841. * Deletes a physics compound impostor
  109842. * @param compound defines the compound to delete
  109843. */
  109844. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  109845. var mesh = compound.parts[0].mesh;
  109846. if (mesh.physicsImpostor) {
  109847. mesh.physicsImpostor.dispose( /*true*/);
  109848. mesh.physicsImpostor = null;
  109849. }
  109850. };
  109851. /** @hidden */
  109852. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  109853. if (this._physicsEngine) {
  109854. this.onBeforePhysicsObservable.notifyObservers(this);
  109855. this._physicsEngine._step(step / 1000);
  109856. this.onAfterPhysicsObservable.notifyObservers(this);
  109857. }
  109858. };
  109859. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  109860. get: function () {
  109861. return this._physicsImpostor;
  109862. },
  109863. set: function (value) {
  109864. var _this = this;
  109865. if (this._physicsImpostor === value) {
  109866. return;
  109867. }
  109868. if (this._disposePhysicsObserver) {
  109869. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  109870. }
  109871. this._physicsImpostor = value;
  109872. if (value) {
  109873. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  109874. // Physics
  109875. if (_this.physicsImpostor) {
  109876. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  109877. _this.physicsImpostor = null;
  109878. }
  109879. });
  109880. }
  109881. },
  109882. enumerable: true,
  109883. configurable: true
  109884. });
  109885. /**
  109886. * Gets the current physics impostor
  109887. * @see http://doc.babylonjs.com/features/physics_engine
  109888. * @returns a physics impostor or null
  109889. */
  109890. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  109891. return this.physicsImpostor;
  109892. };
  109893. /**
  109894. * Apply a physic impulse to the mesh
  109895. * @param force defines the force to apply
  109896. * @param contactPoint defines where to apply the force
  109897. * @returns the current mesh
  109898. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109899. */
  109900. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  109901. if (!this.physicsImpostor) {
  109902. return this;
  109903. }
  109904. this.physicsImpostor.applyImpulse(force, contactPoint);
  109905. return this;
  109906. };
  109907. /**
  109908. * Creates a physic joint between two meshes
  109909. * @param otherMesh defines the other mesh to use
  109910. * @param pivot1 defines the pivot to use on this mesh
  109911. * @param pivot2 defines the pivot to use on the other mesh
  109912. * @param options defines additional options (can be plugin dependent)
  109913. * @returns the current mesh
  109914. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  109915. */
  109916. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  109917. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  109918. return this;
  109919. }
  109920. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  109921. mainPivot: pivot1,
  109922. connectedPivot: pivot2,
  109923. nativeParams: options
  109924. });
  109925. return this;
  109926. };
  109927. /**
  109928. * Defines the physics engine scene component responsible to manage a physics engine
  109929. */
  109930. var PhysicsEngineSceneComponent = /** @class */ (function () {
  109931. /**
  109932. * Creates a new instance of the component for the given scene
  109933. * @param scene Defines the scene to register the component in
  109934. */
  109935. function PhysicsEngineSceneComponent(scene) {
  109936. var _this = this;
  109937. /**
  109938. * The component name helpful to identify the component in the list of scene components.
  109939. */
  109940. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  109941. this.scene = scene;
  109942. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  109943. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  109944. // Replace the function used to get the deterministic frame time
  109945. this.scene.getDeterministicFrameTime = function () {
  109946. if (_this.scene._physicsEngine) {
  109947. return _this.scene._physicsEngine.getTimeStep() * 1000;
  109948. }
  109949. return 1000.0 / 60.0;
  109950. };
  109951. }
  109952. /**
  109953. * Registers the component in a given scene
  109954. */
  109955. PhysicsEngineSceneComponent.prototype.register = function () {
  109956. };
  109957. /**
  109958. * Rebuilds the elements related to this component in case of
  109959. * context lost for instance.
  109960. */
  109961. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  109962. // Nothing to do for this component
  109963. };
  109964. /**
  109965. * Disposes the component and the associated ressources
  109966. */
  109967. PhysicsEngineSceneComponent.prototype.dispose = function () {
  109968. this.scene.onBeforePhysicsObservable.clear();
  109969. this.scene.onAfterPhysicsObservable.clear();
  109970. if (this.scene._physicsEngine) {
  109971. this.scene.disablePhysicsEngine();
  109972. }
  109973. };
  109974. return PhysicsEngineSceneComponent;
  109975. }());
  109976. /***/ }),
  109977. /***/ "./Physics/physicsHelper.ts":
  109978. /*!**********************************!*\
  109979. !*** ./Physics/physicsHelper.ts ***!
  109980. \**********************************/
  109981. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  109982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109983. "use strict";
  109984. __webpack_require__.r(__webpack_exports__);
  109985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  109986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  109987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  109988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  109989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  109990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  109991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  109992. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  109993. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109994. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  109995. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  109996. /**
  109997. * A helper for physics simulations
  109998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109999. */
  110000. var PhysicsHelper = /** @class */ (function () {
  110001. /**
  110002. * Initializes the Physics helper
  110003. * @param scene Babylon.js scene
  110004. */
  110005. function PhysicsHelper(scene) {
  110006. this._scene = scene;
  110007. this._physicsEngine = this._scene.getPhysicsEngine();
  110008. if (!this._physicsEngine) {
  110009. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  110010. }
  110011. }
  110012. /**
  110013. * Applies a radial explosion impulse
  110014. * @param origin the origin of the explosion
  110015. * @param radius the explosion radius
  110016. * @param strength the explosion strength
  110017. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110018. * @returns A physics radial explosion event, or null
  110019. */
  110020. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  110021. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110022. if (!this._physicsEngine) {
  110023. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  110024. return null;
  110025. }
  110026. var impostors = this._physicsEngine.getImpostors();
  110027. if (impostors.length === 0) {
  110028. return null;
  110029. }
  110030. var event = new PhysicsRadialExplosionEvent(this._scene);
  110031. impostors.forEach(function (impostor) {
  110032. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110033. if (!impostorForceAndContactPoint) {
  110034. return;
  110035. }
  110036. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110037. });
  110038. event.dispose(false);
  110039. return event;
  110040. };
  110041. /**
  110042. * Applies a radial explosion force
  110043. * @param origin the origin of the explosion
  110044. * @param radius the explosion radius
  110045. * @param strength the explosion strength
  110046. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110047. * @returns A physics radial explosion event, or null
  110048. */
  110049. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  110050. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110051. if (!this._physicsEngine) {
  110052. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110053. return null;
  110054. }
  110055. var impostors = this._physicsEngine.getImpostors();
  110056. if (impostors.length === 0) {
  110057. return null;
  110058. }
  110059. var event = new PhysicsRadialExplosionEvent(this._scene);
  110060. impostors.forEach(function (impostor) {
  110061. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110062. if (!impostorForceAndContactPoint) {
  110063. return;
  110064. }
  110065. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110066. });
  110067. event.dispose(false);
  110068. return event;
  110069. };
  110070. /**
  110071. * Creates a gravitational field
  110072. * @param origin the origin of the explosion
  110073. * @param radius the explosion radius
  110074. * @param strength the explosion strength
  110075. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110076. * @returns A physics gravitational field event, or null
  110077. */
  110078. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  110079. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110080. if (!this._physicsEngine) {
  110081. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110082. return null;
  110083. }
  110084. var impostors = this._physicsEngine.getImpostors();
  110085. if (impostors.length === 0) {
  110086. return null;
  110087. }
  110088. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  110089. event.dispose(false);
  110090. return event;
  110091. };
  110092. /**
  110093. * Creates a physics updraft event
  110094. * @param origin the origin of the updraft
  110095. * @param radius the radius of the updraft
  110096. * @param strength the strength of the updraft
  110097. * @param height the height of the updraft
  110098. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110099. * @returns A physics updraft event, or null
  110100. */
  110101. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  110102. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  110103. if (!this._physicsEngine) {
  110104. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110105. return null;
  110106. }
  110107. if (this._physicsEngine.getImpostors().length === 0) {
  110108. return null;
  110109. }
  110110. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  110111. event.dispose(false);
  110112. return event;
  110113. };
  110114. /**
  110115. * Creates a physics vortex event
  110116. * @param origin the of the vortex
  110117. * @param radius the radius of the vortex
  110118. * @param strength the strength of the vortex
  110119. * @param height the height of the vortex
  110120. * @returns a Physics vortex event, or null
  110121. * A physics vortex event or null
  110122. */
  110123. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  110124. if (!this._physicsEngine) {
  110125. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110126. return null;
  110127. }
  110128. if (this._physicsEngine.getImpostors().length === 0) {
  110129. return null;
  110130. }
  110131. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  110132. event.dispose(false);
  110133. return event;
  110134. };
  110135. return PhysicsHelper;
  110136. }());
  110137. /**
  110138. * Represents a physics radial explosion event
  110139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110140. */
  110141. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  110142. /**
  110143. * Initializes a radial explosioin event
  110144. * @param scene BabylonJS scene
  110145. */
  110146. function PhysicsRadialExplosionEvent(scene) {
  110147. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  110148. this._rays = [];
  110149. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  110150. this._scene = scene;
  110151. }
  110152. /**
  110153. * Returns the data related to the radial explosion event (sphere & rays).
  110154. * @returns The radial explosion event data
  110155. */
  110156. PhysicsRadialExplosionEvent.prototype.getData = function () {
  110157. this._dataFetched = true;
  110158. return {
  110159. sphere: this._sphere,
  110160. rays: this._rays,
  110161. };
  110162. };
  110163. /**
  110164. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110165. * @param impostor A physics imposter
  110166. * @param origin the origin of the explosion
  110167. * @param radius the explosion radius
  110168. * @param strength the explosion strength
  110169. * @param falloff possible options: Constant & Linear
  110170. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  110171. */
  110172. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  110173. if (impostor.mass === 0) {
  110174. return null;
  110175. }
  110176. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  110177. return null;
  110178. }
  110179. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110180. return null;
  110181. }
  110182. var impostorObjectCenter = impostor.getObjectCenter();
  110183. var direction = impostorObjectCenter.subtract(origin);
  110184. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, radius);
  110185. this._rays.push(ray);
  110186. var hit = ray.intersectsMesh(impostor.object);
  110187. var contactPoint = hit.pickedPoint;
  110188. if (!contactPoint) {
  110189. return null;
  110190. }
  110191. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  110192. if (distanceFromOrigin > radius) {
  110193. return null;
  110194. }
  110195. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  110196. ? strength
  110197. : strength * (1 - (distanceFromOrigin / radius));
  110198. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110199. return { force: force, contactPoint: contactPoint };
  110200. };
  110201. /**
  110202. * Disposes the sphere.
  110203. * @param force Specifies if the sphere should be disposed by force
  110204. */
  110205. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  110206. var _this = this;
  110207. if (force === void 0) { force = true; }
  110208. if (force) {
  110209. this._sphere.dispose();
  110210. }
  110211. else {
  110212. setTimeout(function () {
  110213. if (!_this._dataFetched) {
  110214. _this._sphere.dispose();
  110215. }
  110216. }, 0);
  110217. }
  110218. };
  110219. /*** Helpers ***/
  110220. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  110221. if (!this._sphere) {
  110222. this._sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  110223. this._sphere.isVisible = false;
  110224. }
  110225. };
  110226. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  110227. var impostorObject = impostor.object;
  110228. this._prepareSphere();
  110229. this._sphere.position = origin;
  110230. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  110231. this._sphere._updateBoundingInfo();
  110232. this._sphere.computeWorldMatrix(true);
  110233. return this._sphere.intersectsMesh(impostorObject, true);
  110234. };
  110235. return PhysicsRadialExplosionEvent;
  110236. }());
  110237. /**
  110238. * Represents a gravitational field event
  110239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110240. */
  110241. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  110242. /**
  110243. * Initializes the physics gravitational field event
  110244. * @param physicsHelper A physics helper
  110245. * @param scene BabylonJS scene
  110246. * @param origin The origin position of the gravitational field event
  110247. * @param radius The radius of the gravitational field event
  110248. * @param strength The strength of the gravitational field event
  110249. * @param falloff The falloff for the gravitational field event
  110250. */
  110251. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  110252. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110253. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110254. this._physicsHelper = physicsHelper;
  110255. this._scene = scene;
  110256. this._origin = origin;
  110257. this._radius = radius;
  110258. this._strength = strength;
  110259. this._falloff = falloff;
  110260. this._tickCallback = this._tick.bind(this);
  110261. }
  110262. /**
  110263. * Returns the data related to the gravitational field event (sphere).
  110264. * @returns A gravitational field event
  110265. */
  110266. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  110267. this._dataFetched = true;
  110268. return {
  110269. sphere: this._sphere,
  110270. };
  110271. };
  110272. /**
  110273. * Enables the gravitational field.
  110274. */
  110275. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  110276. this._tickCallback.call(this);
  110277. this._scene.registerBeforeRender(this._tickCallback);
  110278. };
  110279. /**
  110280. * Disables the gravitational field.
  110281. */
  110282. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  110283. this._scene.unregisterBeforeRender(this._tickCallback);
  110284. };
  110285. /**
  110286. * Disposes the sphere.
  110287. * @param force The force to dispose from the gravitational field event
  110288. */
  110289. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  110290. var _this = this;
  110291. if (force === void 0) { force = true; }
  110292. if (force) {
  110293. this._sphere.dispose();
  110294. }
  110295. else {
  110296. setTimeout(function () {
  110297. if (!_this._dataFetched) {
  110298. _this._sphere.dispose();
  110299. }
  110300. }, 0);
  110301. }
  110302. };
  110303. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  110304. // Since the params won't change, we fetch the event only once
  110305. if (this._sphere) {
  110306. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110307. }
  110308. else {
  110309. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110310. if (radialExplosionEvent) {
  110311. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  110312. }
  110313. }
  110314. };
  110315. return PhysicsGravitationalFieldEvent;
  110316. }());
  110317. /**
  110318. * Represents a physics updraft event
  110319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110320. */
  110321. var PhysicsUpdraftEvent = /** @class */ (function () {
  110322. /**
  110323. * Initializes the physics updraft event
  110324. * @param _scene BabylonJS scene
  110325. * @param _origin The origin position of the updraft
  110326. * @param _radius The radius of the updraft
  110327. * @param _strength The strength of the updraft
  110328. * @param _height The height of the updraft
  110329. * @param _updraftMode The mode of the updraft
  110330. */
  110331. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  110332. this._scene = _scene;
  110333. this._origin = _origin;
  110334. this._radius = _radius;
  110335. this._strength = _strength;
  110336. this._height = _height;
  110337. this._updraftMode = _updraftMode;
  110338. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110339. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  110340. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  110341. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110342. this._physicsEngine = this._scene.getPhysicsEngine();
  110343. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110344. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110345. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110346. this._originDirection = this._origin.subtract(this._originTop).normalize();
  110347. }
  110348. this._tickCallback = this._tick.bind(this);
  110349. this._prepareCylinder();
  110350. }
  110351. /**
  110352. * Returns the data related to the updraft event (cylinder).
  110353. * @returns A physics updraft event
  110354. */
  110355. PhysicsUpdraftEvent.prototype.getData = function () {
  110356. this._dataFetched = true;
  110357. return {
  110358. cylinder: this._cylinder,
  110359. };
  110360. };
  110361. /**
  110362. * Enables the updraft.
  110363. */
  110364. PhysicsUpdraftEvent.prototype.enable = function () {
  110365. this._tickCallback.call(this);
  110366. this._scene.registerBeforeRender(this._tickCallback);
  110367. };
  110368. /**
  110369. * Disables the cortex.
  110370. */
  110371. PhysicsUpdraftEvent.prototype.disable = function () {
  110372. this._scene.unregisterBeforeRender(this._tickCallback);
  110373. };
  110374. /**
  110375. * Disposes the sphere.
  110376. * @param force Specifies if the updraft should be disposed by force
  110377. */
  110378. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  110379. var _this = this;
  110380. if (force === void 0) { force = true; }
  110381. if (!this._cylinder) {
  110382. return;
  110383. }
  110384. if (force) {
  110385. this._cylinder.dispose();
  110386. }
  110387. else {
  110388. setTimeout(function () {
  110389. if (!_this._dataFetched) {
  110390. _this._cylinder.dispose();
  110391. }
  110392. }, 0);
  110393. }
  110394. };
  110395. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110396. if (impostor.mass === 0) {
  110397. return null;
  110398. }
  110399. if (!this._intersectsWithCylinder(impostor)) {
  110400. return null;
  110401. }
  110402. var impostorObjectCenter = impostor.getObjectCenter();
  110403. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110404. var direction = this._originDirection;
  110405. }
  110406. else {
  110407. var direction = impostorObjectCenter.subtract(this._originTop);
  110408. }
  110409. var multiplier = this._strength * -1;
  110410. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110411. return { force: force, contactPoint: impostorObjectCenter };
  110412. };
  110413. PhysicsUpdraftEvent.prototype._tick = function () {
  110414. var _this = this;
  110415. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110416. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110417. if (!impostorForceAndContactPoint) {
  110418. return;
  110419. }
  110420. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110421. });
  110422. };
  110423. /*** Helpers ***/
  110424. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  110425. if (!this._cylinder) {
  110426. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("updraftEventCylinder", {
  110427. height: this._height,
  110428. diameter: this._radius * 2,
  110429. }, this._scene);
  110430. this._cylinder.isVisible = false;
  110431. }
  110432. };
  110433. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  110434. var impostorObject = impostor.object;
  110435. this._cylinder.position = this._cylinderPosition;
  110436. return this._cylinder.intersectsMesh(impostorObject, true);
  110437. };
  110438. return PhysicsUpdraftEvent;
  110439. }());
  110440. /**
  110441. * Represents a physics vortex event
  110442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110443. */
  110444. var PhysicsVortexEvent = /** @class */ (function () {
  110445. /**
  110446. * Initializes the physics vortex event
  110447. * @param _scene The BabylonJS scene
  110448. * @param _origin The origin position of the vortex
  110449. * @param _radius The radius of the vortex
  110450. * @param _strength The strength of the vortex
  110451. * @param _height The height of the vortex
  110452. */
  110453. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  110454. this._scene = _scene;
  110455. this._origin = _origin;
  110456. this._radius = _radius;
  110457. this._strength = _strength;
  110458. this._height = _height;
  110459. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110460. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  110461. this._updraftMultiplier = 0.02;
  110462. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  110463. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110464. this._physicsEngine = this._scene.getPhysicsEngine();
  110465. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110466. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110467. this._tickCallback = this._tick.bind(this);
  110468. this._prepareCylinder();
  110469. }
  110470. /**
  110471. * Returns the data related to the vortex event (cylinder).
  110472. * @returns The physics vortex event data
  110473. */
  110474. PhysicsVortexEvent.prototype.getData = function () {
  110475. this._dataFetched = true;
  110476. return {
  110477. cylinder: this._cylinder,
  110478. };
  110479. };
  110480. /**
  110481. * Enables the vortex.
  110482. */
  110483. PhysicsVortexEvent.prototype.enable = function () {
  110484. this._tickCallback.call(this);
  110485. this._scene.registerBeforeRender(this._tickCallback);
  110486. };
  110487. /**
  110488. * Disables the cortex.
  110489. */
  110490. PhysicsVortexEvent.prototype.disable = function () {
  110491. this._scene.unregisterBeforeRender(this._tickCallback);
  110492. };
  110493. /**
  110494. * Disposes the sphere.
  110495. * @param force
  110496. */
  110497. PhysicsVortexEvent.prototype.dispose = function (force) {
  110498. var _this = this;
  110499. if (force === void 0) { force = true; }
  110500. if (force) {
  110501. this._cylinder.dispose();
  110502. }
  110503. else {
  110504. setTimeout(function () {
  110505. if (!_this._dataFetched) {
  110506. _this._cylinder.dispose();
  110507. }
  110508. }, 0);
  110509. }
  110510. };
  110511. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110512. if (impostor.mass === 0) {
  110513. return null;
  110514. }
  110515. if (!this._intersectsWithCylinder(impostor)) {
  110516. return null;
  110517. }
  110518. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110519. return null;
  110520. }
  110521. var impostorObjectCenter = impostor.getObjectCenter();
  110522. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  110523. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  110524. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  110525. var hit = ray.intersectsMesh(impostor.object);
  110526. var contactPoint = hit.pickedPoint;
  110527. if (!contactPoint) {
  110528. return null;
  110529. }
  110530. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  110531. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  110532. var directionToOrigin = contactPoint.normalize();
  110533. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110534. directionToOrigin = directionToOrigin.negate();
  110535. }
  110536. // TODO: find a more physically based solution
  110537. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110538. var forceX = directionToOrigin.x * this._strength / 8;
  110539. var forceY = directionToOrigin.y * this._updraftMultiplier;
  110540. var forceZ = directionToOrigin.z * this._strength / 8;
  110541. }
  110542. else {
  110543. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  110544. var forceY = this._originTop.y * this._updraftMultiplier;
  110545. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  110546. }
  110547. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  110548. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  110549. return { force: force, contactPoint: impostorObjectCenter };
  110550. };
  110551. PhysicsVortexEvent.prototype._tick = function () {
  110552. var _this = this;
  110553. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110554. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110555. if (!impostorForceAndContactPoint) {
  110556. return;
  110557. }
  110558. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110559. });
  110560. };
  110561. /*** Helpers ***/
  110562. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  110563. if (!this._cylinder) {
  110564. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("vortexEventCylinder", {
  110565. height: this._height,
  110566. diameter: this._radius * 2,
  110567. }, this._scene);
  110568. this._cylinder.isVisible = false;
  110569. }
  110570. };
  110571. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  110572. var impostorObject = impostor.object;
  110573. this._cylinder.position = this._cylinderPosition;
  110574. return this._cylinder.intersectsMesh(impostorObject, true);
  110575. };
  110576. return PhysicsVortexEvent;
  110577. }());
  110578. /**
  110579. * The strenght of the force in correspondence to the distance of the affected object
  110580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110581. */
  110582. var PhysicsRadialImpulseFalloff;
  110583. (function (PhysicsRadialImpulseFalloff) {
  110584. /** Defines that impulse is constant in strength across it's whole radius */
  110585. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  110586. /** DEfines that impulse gets weaker if it's further from the origin */
  110587. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  110588. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  110589. /**
  110590. * The strength of the force in correspondence to the distance of the affected object
  110591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110592. */
  110593. var PhysicsUpdraftMode;
  110594. (function (PhysicsUpdraftMode) {
  110595. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110596. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  110597. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110598. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  110599. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  110600. /***/ }),
  110601. /***/ "./Physics/physicsImpostor.ts":
  110602. /*!************************************!*\
  110603. !*** ./Physics/physicsImpostor.ts ***!
  110604. \************************************/
  110605. /*! exports provided: PhysicsImpostor */
  110606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110607. "use strict";
  110608. __webpack_require__.r(__webpack_exports__);
  110609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  110610. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110611. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  110612. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110613. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110614. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110615. /**
  110616. * Represents a physics imposter
  110617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110618. */
  110619. var PhysicsImpostor = /** @class */ (function () {
  110620. /**
  110621. * Initializes the physics imposter
  110622. * @param object The physics-enabled object used as the physics imposter
  110623. * @param type The type of the physics imposter
  110624. * @param _options The options for the physics imposter
  110625. * @param _scene The Babylon scene
  110626. */
  110627. function PhysicsImpostor(
  110628. /**
  110629. * The physics-enabled object used as the physics imposter
  110630. */
  110631. object,
  110632. /**
  110633. * The type of the physics imposter
  110634. */
  110635. type, _options, _scene) {
  110636. if (_options === void 0) { _options = { mass: 0 }; }
  110637. var _this = this;
  110638. this.object = object;
  110639. this.type = type;
  110640. this._options = _options;
  110641. this._scene = _scene;
  110642. this._bodyUpdateRequired = false;
  110643. this._onBeforePhysicsStepCallbacks = new Array();
  110644. this._onAfterPhysicsStepCallbacks = new Array();
  110645. /** @hidden */
  110646. this._onPhysicsCollideCallbacks = [];
  110647. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  110648. this._isDisposed = false;
  110649. //temp variables for parent rotation calculations
  110650. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  110651. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110652. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110653. /**
  110654. * this function is executed by the physics engine.
  110655. */
  110656. this.beforeStep = function () {
  110657. if (!_this._physicsEngine) {
  110658. return;
  110659. }
  110660. _this.object.translate(_this._deltaPosition, -1);
  110661. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  110662. _this.object.computeWorldMatrix(false);
  110663. if (_this.object.parent && _this.object.rotationQuaternion) {
  110664. _this.getParentsRotation();
  110665. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  110666. }
  110667. else {
  110668. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  110669. }
  110670. if (!_this._options.disableBidirectionalTransformation) {
  110671. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  110672. }
  110673. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  110674. func(_this);
  110675. });
  110676. };
  110677. /**
  110678. * this function is executed by the physics engine
  110679. */
  110680. this.afterStep = function () {
  110681. if (!_this._physicsEngine) {
  110682. return;
  110683. }
  110684. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  110685. func(_this);
  110686. });
  110687. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  110688. // object has now its world rotation. needs to be converted to local.
  110689. if (_this.object.parent && _this.object.rotationQuaternion) {
  110690. _this.getParentsRotation();
  110691. _this._tmpQuat.conjugateInPlace();
  110692. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  110693. }
  110694. // take the position set and make it the absolute position of this object.
  110695. _this.object.setAbsolutePosition(_this.object.position);
  110696. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  110697. _this.object.translate(_this._deltaPosition, 1);
  110698. };
  110699. /**
  110700. * Legacy collision detection event support
  110701. */
  110702. this.onCollideEvent = null;
  110703. /**
  110704. * event and body object due to cannon's event-based architecture.
  110705. */
  110706. this.onCollide = function (e) {
  110707. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  110708. return;
  110709. }
  110710. if (!_this._physicsEngine) {
  110711. return;
  110712. }
  110713. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  110714. if (otherImpostor) {
  110715. // Legacy collision detection event support
  110716. if (_this.onCollideEvent) {
  110717. _this.onCollideEvent(_this, otherImpostor);
  110718. }
  110719. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  110720. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  110721. }).forEach(function (obj) {
  110722. obj.callback(_this, otherImpostor);
  110723. });
  110724. }
  110725. };
  110726. //sanity check!
  110727. if (!this.object) {
  110728. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  110729. return;
  110730. }
  110731. // Legacy support for old syntax.
  110732. if (!this._scene && object.getScene) {
  110733. this._scene = object.getScene();
  110734. }
  110735. if (!this._scene) {
  110736. return;
  110737. }
  110738. this._physicsEngine = this._scene.getPhysicsEngine();
  110739. if (!this._physicsEngine) {
  110740. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  110741. }
  110742. else {
  110743. //set the object's quaternion, if not set
  110744. if (!this.object.rotationQuaternion) {
  110745. if (this.object.rotation) {
  110746. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  110747. }
  110748. else {
  110749. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110750. }
  110751. }
  110752. //default options params
  110753. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  110754. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  110755. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  110756. this._joints = [];
  110757. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  110758. if (!this.object.parent || this._options.ignoreParent) {
  110759. this._init();
  110760. }
  110761. else if (this.object.parent.physicsImpostor) {
  110762. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  110763. }
  110764. }
  110765. }
  110766. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  110767. /**
  110768. * Specifies if the physics imposter is disposed
  110769. */
  110770. get: function () {
  110771. return this._isDisposed;
  110772. },
  110773. enumerable: true,
  110774. configurable: true
  110775. });
  110776. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  110777. /**
  110778. * Gets the mass of the physics imposter
  110779. */
  110780. get: function () {
  110781. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  110782. },
  110783. set: function (value) {
  110784. this.setMass(value);
  110785. },
  110786. enumerable: true,
  110787. configurable: true
  110788. });
  110789. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  110790. /**
  110791. * Gets the coefficient of friction
  110792. */
  110793. get: function () {
  110794. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  110795. },
  110796. /**
  110797. * Sets the coefficient of friction
  110798. */
  110799. set: function (value) {
  110800. if (!this._physicsEngine) {
  110801. return;
  110802. }
  110803. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  110804. },
  110805. enumerable: true,
  110806. configurable: true
  110807. });
  110808. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  110809. /**
  110810. * Gets the coefficient of restitution
  110811. */
  110812. get: function () {
  110813. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  110814. },
  110815. /**
  110816. * Sets the coefficient of restitution
  110817. */
  110818. set: function (value) {
  110819. if (!this._physicsEngine) {
  110820. return;
  110821. }
  110822. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  110823. },
  110824. enumerable: true,
  110825. configurable: true
  110826. });
  110827. /**
  110828. * This function will completly initialize this impostor.
  110829. * It will create a new body - but only if this mesh has no parent.
  110830. * If it has, this impostor will not be used other than to define the impostor
  110831. * of the child mesh.
  110832. * @hidden
  110833. */
  110834. PhysicsImpostor.prototype._init = function () {
  110835. if (!this._physicsEngine) {
  110836. return;
  110837. }
  110838. this._physicsEngine.removeImpostor(this);
  110839. this.physicsBody = null;
  110840. this._parent = this._parent || this._getPhysicsParent();
  110841. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  110842. this._physicsEngine.addImpostor(this);
  110843. }
  110844. };
  110845. PhysicsImpostor.prototype._getPhysicsParent = function () {
  110846. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  110847. var parentMesh = this.object.parent;
  110848. return parentMesh.physicsImpostor;
  110849. }
  110850. return null;
  110851. };
  110852. /**
  110853. * Should a new body be generated.
  110854. * @returns boolean specifying if body initialization is required
  110855. */
  110856. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  110857. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  110858. };
  110859. /**
  110860. * Sets the updated scaling
  110861. * @param updated Specifies if the scaling is updated
  110862. */
  110863. PhysicsImpostor.prototype.setScalingUpdated = function () {
  110864. this.forceUpdate();
  110865. };
  110866. /**
  110867. * Force a regeneration of this or the parent's impostor's body.
  110868. * Use under cautious - This will remove all joints already implemented.
  110869. */
  110870. PhysicsImpostor.prototype.forceUpdate = function () {
  110871. this._init();
  110872. if (this.parent && !this._options.ignoreParent) {
  110873. this.parent.forceUpdate();
  110874. }
  110875. };
  110876. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  110877. /*public get mesh(): AbstractMesh {
  110878. return this._mesh;
  110879. }*/
  110880. /**
  110881. * Gets the body that holds this impostor. Either its own, or its parent.
  110882. */
  110883. get: function () {
  110884. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  110885. },
  110886. /**
  110887. * Set the physics body. Used mainly by the physics engine/plugin
  110888. */
  110889. set: function (physicsBody) {
  110890. if (this._physicsBody && this._physicsEngine) {
  110891. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  110892. }
  110893. this._physicsBody = physicsBody;
  110894. this.resetUpdateFlags();
  110895. },
  110896. enumerable: true,
  110897. configurable: true
  110898. });
  110899. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  110900. /**
  110901. * Get the parent of the physics imposter
  110902. * @returns Physics imposter or null
  110903. */
  110904. get: function () {
  110905. return !this._options.ignoreParent && this._parent ? this._parent : null;
  110906. },
  110907. /**
  110908. * Sets the parent of the physics imposter
  110909. */
  110910. set: function (value) {
  110911. this._parent = value;
  110912. },
  110913. enumerable: true,
  110914. configurable: true
  110915. });
  110916. /**
  110917. * Resets the update flags
  110918. */
  110919. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  110920. this._bodyUpdateRequired = false;
  110921. };
  110922. /**
  110923. * Gets the object extend size
  110924. * @returns the object extend size
  110925. */
  110926. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  110927. if (this.object.getBoundingInfo) {
  110928. var q = this.object.rotationQuaternion;
  110929. //reset rotation
  110930. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  110931. //calculate the world matrix with no rotation
  110932. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  110933. var boundingInfo = this.object.getBoundingInfo();
  110934. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  110935. //bring back the rotation
  110936. this.object.rotationQuaternion = q;
  110937. //calculate the world matrix with the new rotation
  110938. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  110939. return size;
  110940. }
  110941. else {
  110942. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  110943. }
  110944. };
  110945. /**
  110946. * Gets the object center
  110947. * @returns The object center
  110948. */
  110949. PhysicsImpostor.prototype.getObjectCenter = function () {
  110950. if (this.object.getBoundingInfo) {
  110951. var boundingInfo = this.object.getBoundingInfo();
  110952. return boundingInfo.boundingBox.centerWorld;
  110953. }
  110954. else {
  110955. return this.object.position;
  110956. }
  110957. };
  110958. /**
  110959. * Get a specific parametes from the options parameter
  110960. * @param paramName The object parameter name
  110961. * @returns The object parameter
  110962. */
  110963. PhysicsImpostor.prototype.getParam = function (paramName) {
  110964. return this._options[paramName];
  110965. };
  110966. /**
  110967. * Sets a specific parameter in the options given to the physics plugin
  110968. * @param paramName The parameter name
  110969. * @param value The value of the parameter
  110970. */
  110971. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  110972. this._options[paramName] = value;
  110973. this._bodyUpdateRequired = true;
  110974. };
  110975. /**
  110976. * Specifically change the body's mass option. Won't recreate the physics body object
  110977. * @param mass The mass of the physics imposter
  110978. */
  110979. PhysicsImpostor.prototype.setMass = function (mass) {
  110980. if (this.getParam("mass") !== mass) {
  110981. this.setParam("mass", mass);
  110982. }
  110983. if (this._physicsEngine) {
  110984. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  110985. }
  110986. };
  110987. /**
  110988. * Gets the linear velocity
  110989. * @returns linear velocity or null
  110990. */
  110991. PhysicsImpostor.prototype.getLinearVelocity = function () {
  110992. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  110993. };
  110994. /**
  110995. * Sets the linear velocity
  110996. * @param velocity linear velocity or null
  110997. */
  110998. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  110999. if (this._physicsEngine) {
  111000. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  111001. }
  111002. };
  111003. /**
  111004. * Gets the angular velocity
  111005. * @returns angular velocity or null
  111006. */
  111007. PhysicsImpostor.prototype.getAngularVelocity = function () {
  111008. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111009. };
  111010. /**
  111011. * Sets the angular velocity
  111012. * @param velocity The velocity or null
  111013. */
  111014. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  111015. if (this._physicsEngine) {
  111016. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  111017. }
  111018. };
  111019. /**
  111020. * Execute a function with the physics plugin native code
  111021. * Provide a function the will have two variables - the world object and the physics body object
  111022. * @param func The function to execute with the physics plugin native code
  111023. */
  111024. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  111025. if (this._physicsEngine) {
  111026. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  111027. }
  111028. };
  111029. /**
  111030. * Register a function that will be executed before the physics world is stepping forward
  111031. * @param func The function to execute before the physics world is stepped forward
  111032. */
  111033. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  111034. this._onBeforePhysicsStepCallbacks.push(func);
  111035. };
  111036. /**
  111037. * Unregister a function that will be executed before the physics world is stepping forward
  111038. * @param func The function to execute before the physics world is stepped forward
  111039. */
  111040. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  111041. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  111042. if (index > -1) {
  111043. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  111044. }
  111045. else {
  111046. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111047. }
  111048. };
  111049. /**
  111050. * Register a function that will be executed after the physics step
  111051. * @param func The function to execute after physics step
  111052. */
  111053. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  111054. this._onAfterPhysicsStepCallbacks.push(func);
  111055. };
  111056. /**
  111057. * Unregisters a function that will be executed after the physics step
  111058. * @param func The function to execute after physics step
  111059. */
  111060. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  111061. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  111062. if (index > -1) {
  111063. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  111064. }
  111065. else {
  111066. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111067. }
  111068. };
  111069. /**
  111070. * register a function that will be executed when this impostor collides against a different body
  111071. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  111072. * @param func Callback that is executed on collision
  111073. */
  111074. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  111075. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111076. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  111077. };
  111078. /**
  111079. * Unregisters the physics imposter on contact
  111080. * @param collideAgainst The physics object to collide against
  111081. * @param func Callback to execute on collision
  111082. */
  111083. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  111084. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111085. var index = -1;
  111086. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  111087. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  111088. // chcek the arrays match
  111089. var sameList = cbDef.otherImpostors.every(function (impostor) {
  111090. return collidedAgainstList.indexOf(impostor) > -1;
  111091. });
  111092. if (sameList) {
  111093. index = idx;
  111094. }
  111095. return sameList;
  111096. }
  111097. return false;
  111098. });
  111099. if (found) {
  111100. this._onPhysicsCollideCallbacks.splice(index, 1);
  111101. }
  111102. else {
  111103. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111104. }
  111105. };
  111106. /**
  111107. * Get the parent rotation
  111108. * @returns The parent rotation
  111109. */
  111110. PhysicsImpostor.prototype.getParentsRotation = function () {
  111111. var parent = this.object.parent;
  111112. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  111113. while (parent) {
  111114. if (parent.rotationQuaternion) {
  111115. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  111116. }
  111117. else {
  111118. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  111119. }
  111120. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  111121. parent = parent.parent;
  111122. }
  111123. return this._tmpQuat;
  111124. };
  111125. /**
  111126. * Apply a force
  111127. * @param force The force to apply
  111128. * @param contactPoint The contact point for the force
  111129. * @returns The physics imposter
  111130. */
  111131. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  111132. if (this._physicsEngine) {
  111133. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  111134. }
  111135. return this;
  111136. };
  111137. /**
  111138. * Apply an impulse
  111139. * @param force The impulse force
  111140. * @param contactPoint The contact point for the impulse force
  111141. * @returns The physics imposter
  111142. */
  111143. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  111144. if (this._physicsEngine) {
  111145. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  111146. }
  111147. return this;
  111148. };
  111149. /**
  111150. * A help function to create a joint
  111151. * @param otherImpostor A physics imposter used to create a joint
  111152. * @param jointType The type of joint
  111153. * @param jointData The data for the joint
  111154. * @returns The physics imposter
  111155. */
  111156. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  111157. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"](jointType, jointData);
  111158. this.addJoint(otherImpostor, joint);
  111159. return this;
  111160. };
  111161. /**
  111162. * Add a joint to this impostor with a different impostor
  111163. * @param otherImpostor A physics imposter used to add a joint
  111164. * @param joint The joint to add
  111165. * @returns The physics imposter
  111166. */
  111167. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  111168. this._joints.push({
  111169. otherImpostor: otherImpostor,
  111170. joint: joint
  111171. });
  111172. if (this._physicsEngine) {
  111173. this._physicsEngine.addJoint(this, otherImpostor, joint);
  111174. }
  111175. return this;
  111176. };
  111177. /**
  111178. * Will keep this body still, in a sleep mode.
  111179. * @returns the physics imposter
  111180. */
  111181. PhysicsImpostor.prototype.sleep = function () {
  111182. if (this._physicsEngine) {
  111183. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  111184. }
  111185. return this;
  111186. };
  111187. /**
  111188. * Wake the body up.
  111189. * @returns The physics imposter
  111190. */
  111191. PhysicsImpostor.prototype.wakeUp = function () {
  111192. if (this._physicsEngine) {
  111193. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  111194. }
  111195. return this;
  111196. };
  111197. /**
  111198. * Clones the physics imposter
  111199. * @param newObject The physics imposter clones to this physics-enabled object
  111200. * @returns A nullable physics imposter
  111201. */
  111202. PhysicsImpostor.prototype.clone = function (newObject) {
  111203. if (!newObject) {
  111204. return null;
  111205. }
  111206. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  111207. };
  111208. /**
  111209. * Disposes the physics imposter
  111210. */
  111211. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  111212. var _this = this;
  111213. //no dispose if no physics engine is available.
  111214. if (!this._physicsEngine) {
  111215. return;
  111216. }
  111217. this._joints.forEach(function (j) {
  111218. if (_this._physicsEngine) {
  111219. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  111220. }
  111221. });
  111222. //dispose the physics body
  111223. this._physicsEngine.removeImpostor(this);
  111224. if (this.parent) {
  111225. this.parent.forceUpdate();
  111226. }
  111227. else {
  111228. /*this._object.getChildMeshes().forEach(function(mesh) {
  111229. if (mesh.physicsImpostor) {
  111230. if (disposeChildren) {
  111231. mesh.physicsImpostor.dispose();
  111232. mesh.physicsImpostor = null;
  111233. }
  111234. }
  111235. })*/
  111236. }
  111237. this._isDisposed = true;
  111238. };
  111239. /**
  111240. * Sets the delta position
  111241. * @param position The delta position amount
  111242. */
  111243. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  111244. this._deltaPosition.copyFrom(position);
  111245. };
  111246. /**
  111247. * Sets the delta rotation
  111248. * @param rotation The delta rotation amount
  111249. */
  111250. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  111251. if (!this._deltaRotation) {
  111252. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111253. }
  111254. this._deltaRotation.copyFrom(rotation);
  111255. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  111256. };
  111257. /**
  111258. * Gets the box size of the physics imposter and stores the result in the input parameter
  111259. * @param result Stores the box size
  111260. * @returns The physics imposter
  111261. */
  111262. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  111263. if (this._physicsEngine) {
  111264. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  111265. }
  111266. return this;
  111267. };
  111268. /**
  111269. * Gets the radius of the physics imposter
  111270. * @returns Radius of the physics imposter
  111271. */
  111272. PhysicsImpostor.prototype.getRadius = function () {
  111273. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  111274. };
  111275. /**
  111276. * Sync a bone with this impostor
  111277. * @param bone The bone to sync to the impostor.
  111278. * @param boneMesh The mesh that the bone is influencing.
  111279. * @param jointPivot The pivot of the joint / bone in local space.
  111280. * @param distToJoint Optional distance from the impostor to the joint.
  111281. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111282. */
  111283. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  111284. var tempVec = PhysicsImpostor._tmpVecs[0];
  111285. var mesh = this.object;
  111286. if (mesh.rotationQuaternion) {
  111287. if (adjustRotation) {
  111288. var tempQuat = PhysicsImpostor._tmpQuat;
  111289. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  111290. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111291. }
  111292. else {
  111293. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111294. }
  111295. }
  111296. tempVec.x = 0;
  111297. tempVec.y = 0;
  111298. tempVec.z = 0;
  111299. if (jointPivot) {
  111300. tempVec.x = jointPivot.x;
  111301. tempVec.y = jointPivot.y;
  111302. tempVec.z = jointPivot.z;
  111303. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  111304. if (distToJoint === undefined || distToJoint === null) {
  111305. distToJoint = jointPivot.length();
  111306. }
  111307. tempVec.x *= distToJoint;
  111308. tempVec.y *= distToJoint;
  111309. tempVec.z *= distToJoint;
  111310. }
  111311. if (bone.getParent()) {
  111312. tempVec.addInPlace(mesh.getAbsolutePosition());
  111313. bone.setAbsolutePosition(tempVec, boneMesh);
  111314. }
  111315. else {
  111316. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  111317. boneMesh.position.x -= tempVec.x;
  111318. boneMesh.position.y -= tempVec.y;
  111319. boneMesh.position.z -= tempVec.z;
  111320. }
  111321. };
  111322. /**
  111323. * Sync impostor to a bone
  111324. * @param bone The bone that the impostor will be synced to.
  111325. * @param boneMesh The mesh that the bone is influencing.
  111326. * @param jointPivot The pivot of the joint / bone in local space.
  111327. * @param distToJoint Optional distance from the impostor to the joint.
  111328. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111329. * @param boneAxis Optional vector3 axis the bone is aligned with
  111330. */
  111331. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  111332. var mesh = this.object;
  111333. if (mesh.rotationQuaternion) {
  111334. if (adjustRotation) {
  111335. var tempQuat = PhysicsImpostor._tmpQuat;
  111336. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  111337. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  111338. }
  111339. else {
  111340. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  111341. }
  111342. }
  111343. var pos = PhysicsImpostor._tmpVecs[0];
  111344. var boneDir = PhysicsImpostor._tmpVecs[1];
  111345. if (!boneAxis) {
  111346. boneAxis = PhysicsImpostor._tmpVecs[2];
  111347. boneAxis.x = 0;
  111348. boneAxis.y = 1;
  111349. boneAxis.z = 0;
  111350. }
  111351. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  111352. bone.getAbsolutePositionToRef(boneMesh, pos);
  111353. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  111354. distToJoint = jointPivot.length();
  111355. }
  111356. if (distToJoint !== undefined && distToJoint !== null) {
  111357. pos.x += boneDir.x * distToJoint;
  111358. pos.y += boneDir.y * distToJoint;
  111359. pos.z += boneDir.z * distToJoint;
  111360. }
  111361. mesh.setAbsolutePosition(pos);
  111362. };
  111363. /**
  111364. * The default object size of the imposter
  111365. */
  111366. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  111367. /**
  111368. * The identity quaternion of the imposter
  111369. */
  111370. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111371. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  111372. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111373. //Impostor types
  111374. /**
  111375. * No-Imposter type
  111376. */
  111377. PhysicsImpostor.NoImpostor = 0;
  111378. /**
  111379. * Sphere-Imposter type
  111380. */
  111381. PhysicsImpostor.SphereImpostor = 1;
  111382. /**
  111383. * Box-Imposter type
  111384. */
  111385. PhysicsImpostor.BoxImpostor = 2;
  111386. /**
  111387. * Plane-Imposter type
  111388. */
  111389. PhysicsImpostor.PlaneImpostor = 3;
  111390. /**
  111391. * Mesh-imposter type
  111392. */
  111393. PhysicsImpostor.MeshImpostor = 4;
  111394. /**
  111395. * Cylinder-Imposter type
  111396. */
  111397. PhysicsImpostor.CylinderImpostor = 7;
  111398. /**
  111399. * Particle-Imposter type
  111400. */
  111401. PhysicsImpostor.ParticleImpostor = 8;
  111402. /**
  111403. * Heightmap-Imposter type
  111404. */
  111405. PhysicsImpostor.HeightmapImpostor = 9;
  111406. return PhysicsImpostor;
  111407. }());
  111408. /***/ }),
  111409. /***/ "./Physics/physicsJoint.ts":
  111410. /*!*********************************!*\
  111411. !*** ./Physics/physicsJoint.ts ***!
  111412. \*********************************/
  111413. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  111414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111415. "use strict";
  111416. __webpack_require__.r(__webpack_exports__);
  111417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  111418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  111419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  111420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  111421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  111422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111423. /**
  111424. * This is a holder class for the physics joint created by the physics plugin
  111425. * It holds a set of functions to control the underlying joint
  111426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111427. */
  111428. var PhysicsJoint = /** @class */ (function () {
  111429. /**
  111430. * Initializes the physics joint
  111431. * @param type The type of the physics joint
  111432. * @param jointData The data for the physics joint
  111433. */
  111434. function PhysicsJoint(
  111435. /**
  111436. * The type of the physics joint
  111437. */
  111438. type,
  111439. /**
  111440. * The data for the physics joint
  111441. */
  111442. jointData) {
  111443. this.type = type;
  111444. this.jointData = jointData;
  111445. jointData.nativeParams = jointData.nativeParams || {};
  111446. }
  111447. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  111448. /**
  111449. * Gets the physics joint
  111450. */
  111451. get: function () {
  111452. return this._physicsJoint;
  111453. },
  111454. /**
  111455. * Sets the physics joint
  111456. */
  111457. set: function (newJoint) {
  111458. if (this._physicsJoint) {
  111459. //remove from the wolrd
  111460. }
  111461. this._physicsJoint = newJoint;
  111462. },
  111463. enumerable: true,
  111464. configurable: true
  111465. });
  111466. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  111467. /**
  111468. * Sets the physics plugin
  111469. */
  111470. set: function (physicsPlugin) {
  111471. this._physicsPlugin = physicsPlugin;
  111472. },
  111473. enumerable: true,
  111474. configurable: true
  111475. });
  111476. /**
  111477. * Execute a function that is physics-plugin specific.
  111478. * @param {Function} func the function that will be executed.
  111479. * It accepts two parameters: the physics world and the physics joint
  111480. */
  111481. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  111482. func(this._physicsPlugin.world, this._physicsJoint);
  111483. };
  111484. //TODO check if the native joints are the same
  111485. //Joint Types
  111486. /**
  111487. * Distance-Joint type
  111488. */
  111489. PhysicsJoint.DistanceJoint = 0;
  111490. /**
  111491. * Hinge-Joint type
  111492. */
  111493. PhysicsJoint.HingeJoint = 1;
  111494. /**
  111495. * Ball-and-Socket joint type
  111496. */
  111497. PhysicsJoint.BallAndSocketJoint = 2;
  111498. /**
  111499. * Wheel-Joint type
  111500. */
  111501. PhysicsJoint.WheelJoint = 3;
  111502. /**
  111503. * Slider-Joint type
  111504. */
  111505. PhysicsJoint.SliderJoint = 4;
  111506. //OIMO
  111507. /**
  111508. * Prismatic-Joint type
  111509. */
  111510. PhysicsJoint.PrismaticJoint = 5;
  111511. //
  111512. /**
  111513. * Universal-Joint type
  111514. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111515. */
  111516. PhysicsJoint.UniversalJoint = 6;
  111517. /**
  111518. * Hinge-Joint 2 type
  111519. */
  111520. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  111521. //Cannon
  111522. /**
  111523. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111524. */
  111525. PhysicsJoint.PointToPointJoint = 8;
  111526. //Cannon only at the moment
  111527. /**
  111528. * Spring-Joint type
  111529. */
  111530. PhysicsJoint.SpringJoint = 9;
  111531. /**
  111532. * Lock-Joint type
  111533. */
  111534. PhysicsJoint.LockJoint = 10;
  111535. return PhysicsJoint;
  111536. }());
  111537. /**
  111538. * A class representing a physics distance joint
  111539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111540. */
  111541. var DistanceJoint = /** @class */ (function (_super) {
  111542. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  111543. /**
  111544. *
  111545. * @param jointData The data for the Distance-Joint
  111546. */
  111547. function DistanceJoint(jointData) {
  111548. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  111549. }
  111550. /**
  111551. * Update the predefined distance.
  111552. * @param maxDistance The maximum preferred distance
  111553. * @param minDistance The minimum preferred distance
  111554. */
  111555. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  111556. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  111557. };
  111558. return DistanceJoint;
  111559. }(PhysicsJoint));
  111560. /**
  111561. * Represents a Motor-Enabled Joint
  111562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111563. */
  111564. var MotorEnabledJoint = /** @class */ (function (_super) {
  111565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  111566. /**
  111567. * Initializes the Motor-Enabled Joint
  111568. * @param type The type of the joint
  111569. * @param jointData The physica joint data for the joint
  111570. */
  111571. function MotorEnabledJoint(type, jointData) {
  111572. return _super.call(this, type, jointData) || this;
  111573. }
  111574. /**
  111575. * Set the motor values.
  111576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111577. * @param force the force to apply
  111578. * @param maxForce max force for this motor.
  111579. */
  111580. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  111581. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111582. };
  111583. /**
  111584. * Set the motor's limits.
  111585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111586. * @param upperLimit The upper limit of the motor
  111587. * @param lowerLimit The lower limit of the motor
  111588. */
  111589. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111590. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111591. };
  111592. return MotorEnabledJoint;
  111593. }(PhysicsJoint));
  111594. /**
  111595. * This class represents a single physics Hinge-Joint
  111596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111597. */
  111598. var HingeJoint = /** @class */ (function (_super) {
  111599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  111600. /**
  111601. * Initializes the Hinge-Joint
  111602. * @param jointData The joint data for the Hinge-Joint
  111603. */
  111604. function HingeJoint(jointData) {
  111605. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  111606. }
  111607. /**
  111608. * Set the motor values.
  111609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111610. * @param {number} force the force to apply
  111611. * @param {number} maxForce max force for this motor.
  111612. */
  111613. HingeJoint.prototype.setMotor = function (force, maxForce) {
  111614. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111615. };
  111616. /**
  111617. * Set the motor's limits.
  111618. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111619. * @param upperLimit The upper limit of the motor
  111620. * @param lowerLimit The lower limit of the motor
  111621. */
  111622. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111623. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111624. };
  111625. return HingeJoint;
  111626. }(MotorEnabledJoint));
  111627. /**
  111628. * This class represents a dual hinge physics joint (same as wheel joint)
  111629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111630. */
  111631. var Hinge2Joint = /** @class */ (function (_super) {
  111632. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  111633. /**
  111634. * Initializes the Hinge2-Joint
  111635. * @param jointData The joint data for the Hinge2-Joint
  111636. */
  111637. function Hinge2Joint(jointData) {
  111638. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  111639. }
  111640. /**
  111641. * Set the motor values.
  111642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111643. * @param {number} force the force to apply
  111644. * @param {number} maxForce max force for this motor.
  111645. * @param {motorIndex} the motor's index, 0 or 1.
  111646. */
  111647. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  111648. if (motorIndex === void 0) { motorIndex = 0; }
  111649. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  111650. };
  111651. /**
  111652. * Set the motor limits.
  111653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111654. * @param {number} upperLimit the upper limit
  111655. * @param {number} lowerLimit lower limit
  111656. * @param {motorIndex} the motor's index, 0 or 1.
  111657. */
  111658. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  111659. if (motorIndex === void 0) { motorIndex = 0; }
  111660. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  111661. };
  111662. return Hinge2Joint;
  111663. }(MotorEnabledJoint));
  111664. /***/ }),
  111665. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  111666. /*!****************************************************************************!*\
  111667. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  111668. \****************************************************************************/
  111669. /*! exports provided: DefaultRenderingPipeline */
  111670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111671. "use strict";
  111672. __webpack_require__.r(__webpack_exports__);
  111673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  111674. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111675. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  111676. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  111677. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  111678. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  111679. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  111680. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  111681. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  111682. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  111683. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  111684. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  111685. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  111686. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  111687. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  111688. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  111689. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  111690. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  111691. /**
  111692. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111693. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111694. */
  111695. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  111696. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  111697. /**
  111698. * @constructor
  111699. * @param name - The rendering pipeline name (default: "")
  111700. * @param hdr - If high dynamic range textures should be used (default: true)
  111701. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111702. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111703. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111704. */
  111705. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  111706. if (name === void 0) { name = ""; }
  111707. if (hdr === void 0) { hdr = true; }
  111708. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  111709. if (automaticBuild === void 0) { automaticBuild = true; }
  111710. var _this = _super.call(this, scene.getEngine(), name) || this;
  111711. _this._camerasToBeAttached = [];
  111712. /**
  111713. * ID of the sharpen post process,
  111714. */
  111715. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  111716. /**
  111717. * @ignore
  111718. * ID of the image processing post process;
  111719. */
  111720. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  111721. /**
  111722. * @ignore
  111723. * ID of the Fast Approximate Anti-Aliasing post process;
  111724. */
  111725. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  111726. /**
  111727. * ID of the chromatic aberration post process,
  111728. */
  111729. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  111730. /**
  111731. * ID of the grain post process
  111732. */
  111733. _this.GrainPostProcessId = "GrainPostProcessEffect";
  111734. /**
  111735. * Glow post process which adds a glow to emmisive areas of the image
  111736. */
  111737. _this._glowLayer = null;
  111738. /**
  111739. * Animations which can be used to tweak settings over a period of time
  111740. */
  111741. _this.animations = [];
  111742. _this._imageProcessingConfigurationObserver = null;
  111743. // Values
  111744. _this._sharpenEnabled = false;
  111745. _this._bloomEnabled = false;
  111746. _this._depthOfFieldEnabled = false;
  111747. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  111748. _this._fxaaEnabled = false;
  111749. _this._imageProcessingEnabled = true;
  111750. _this._bloomScale = 0.5;
  111751. _this._chromaticAberrationEnabled = false;
  111752. _this._grainEnabled = false;
  111753. _this._buildAllowed = true;
  111754. _this._resizeObserver = null;
  111755. _this._hardwareScaleLevel = 1.0;
  111756. _this._bloomKernel = 64;
  111757. /**
  111758. * Specifies the weight of the bloom in the final rendering
  111759. */
  111760. _this._bloomWeight = 0.15;
  111761. /**
  111762. * Specifies the luma threshold for the area that will be blurred by the bloom
  111763. */
  111764. _this._bloomThreshold = 0.9;
  111765. _this._samples = 1;
  111766. _this._hasCleared = false;
  111767. _this._prevPostProcess = null;
  111768. _this._prevPrevPostProcess = null;
  111769. _this._depthOfFieldSceneObserver = null;
  111770. _this._cameras = cameras || scene.cameras;
  111771. _this._cameras = _this._cameras.slice();
  111772. _this._camerasToBeAttached = _this._cameras.slice();
  111773. _this._buildAllowed = automaticBuild;
  111774. // Initialize
  111775. _this._scene = scene;
  111776. var caps = _this._scene.getEngine().getCaps();
  111777. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  111778. // Misc
  111779. if (_this._hdr) {
  111780. if (caps.textureHalfFloatRender) {
  111781. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  111782. }
  111783. else if (caps.textureFloatRender) {
  111784. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  111785. }
  111786. }
  111787. else {
  111788. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  111789. }
  111790. // Attach
  111791. scene.postProcessRenderPipelineManager.addPipeline(_this);
  111792. var engine = _this._scene.getEngine();
  111793. // Create post processes before hand so they can be modified before enabled.
  111794. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  111795. _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);
  111796. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  111797. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  111798. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  111799. _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);
  111800. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  111801. _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);
  111802. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  111803. _this._resizeObserver = engine.onResizeObservable.add(function () {
  111804. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  111805. _this.bloomKernel = _this.bloomKernel;
  111806. });
  111807. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  111808. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  111809. });
  111810. _this._buildPipeline();
  111811. return _this;
  111812. }
  111813. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  111814. get: function () {
  111815. return this._sharpenEnabled;
  111816. },
  111817. /**
  111818. * Enable or disable the sharpen process from the pipeline
  111819. */
  111820. set: function (enabled) {
  111821. if (this._sharpenEnabled === enabled) {
  111822. return;
  111823. }
  111824. this._sharpenEnabled = enabled;
  111825. this._buildPipeline();
  111826. },
  111827. enumerable: true,
  111828. configurable: true
  111829. });
  111830. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  111831. /**
  111832. * Specifies the size of the bloom blur kernel, relative to the final output size
  111833. */
  111834. get: function () {
  111835. return this._bloomKernel;
  111836. },
  111837. set: function (value) {
  111838. this._bloomKernel = value;
  111839. this.bloom.kernel = value / this._hardwareScaleLevel;
  111840. },
  111841. enumerable: true,
  111842. configurable: true
  111843. });
  111844. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  111845. get: function () {
  111846. return this._bloomWeight;
  111847. },
  111848. /**
  111849. * The strength of the bloom.
  111850. */
  111851. set: function (value) {
  111852. if (this._bloomWeight === value) {
  111853. return;
  111854. }
  111855. this.bloom.weight = value;
  111856. this._bloomWeight = value;
  111857. },
  111858. enumerable: true,
  111859. configurable: true
  111860. });
  111861. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  111862. get: function () {
  111863. return this._bloomThreshold;
  111864. },
  111865. /**
  111866. * The strength of the bloom.
  111867. */
  111868. set: function (value) {
  111869. if (this._bloomThreshold === value) {
  111870. return;
  111871. }
  111872. this.bloom.threshold = value;
  111873. this._bloomThreshold = value;
  111874. },
  111875. enumerable: true,
  111876. configurable: true
  111877. });
  111878. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  111879. get: function () {
  111880. return this._bloomScale;
  111881. },
  111882. /**
  111883. * The scale of the bloom, lower value will provide better performance.
  111884. */
  111885. set: function (value) {
  111886. if (this._bloomScale === value) {
  111887. return;
  111888. }
  111889. this._bloomScale = value;
  111890. // recreate bloom and dispose old as this setting is not dynamic
  111891. this._rebuildBloom();
  111892. this._buildPipeline();
  111893. },
  111894. enumerable: true,
  111895. configurable: true
  111896. });
  111897. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  111898. get: function () {
  111899. return this._bloomEnabled;
  111900. },
  111901. /**
  111902. * Enable or disable the bloom from the pipeline
  111903. */
  111904. set: function (enabled) {
  111905. if (this._bloomEnabled === enabled) {
  111906. return;
  111907. }
  111908. this._bloomEnabled = enabled;
  111909. this._buildPipeline();
  111910. },
  111911. enumerable: true,
  111912. configurable: true
  111913. });
  111914. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  111915. // recreate bloom and dispose old as this setting is not dynamic
  111916. var oldBloom = this.bloom;
  111917. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  111918. this.bloom.threshold = oldBloom.threshold;
  111919. for (var i = 0; i < this._cameras.length; i++) {
  111920. oldBloom.disposeEffects(this._cameras[i]);
  111921. }
  111922. };
  111923. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  111924. /**
  111925. * If the depth of field is enabled.
  111926. */
  111927. get: function () {
  111928. return this._depthOfFieldEnabled;
  111929. },
  111930. set: function (enabled) {
  111931. if (this._depthOfFieldEnabled === enabled) {
  111932. return;
  111933. }
  111934. this._depthOfFieldEnabled = enabled;
  111935. this._buildPipeline();
  111936. },
  111937. enumerable: true,
  111938. configurable: true
  111939. });
  111940. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  111941. /**
  111942. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111943. */
  111944. get: function () {
  111945. return this._depthOfFieldBlurLevel;
  111946. },
  111947. set: function (value) {
  111948. if (this._depthOfFieldBlurLevel === value) {
  111949. return;
  111950. }
  111951. this._depthOfFieldBlurLevel = value;
  111952. // recreate dof and dispose old as this setting is not dynamic
  111953. var oldDof = this.depthOfField;
  111954. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  111955. this.depthOfField.focalLength = oldDof.focalLength;
  111956. this.depthOfField.focusDistance = oldDof.focusDistance;
  111957. this.depthOfField.fStop = oldDof.fStop;
  111958. this.depthOfField.lensSize = oldDof.lensSize;
  111959. for (var i = 0; i < this._cameras.length; i++) {
  111960. oldDof.disposeEffects(this._cameras[i]);
  111961. }
  111962. this._buildPipeline();
  111963. },
  111964. enumerable: true,
  111965. configurable: true
  111966. });
  111967. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  111968. get: function () {
  111969. return this._fxaaEnabled;
  111970. },
  111971. /**
  111972. * If the anti aliasing is enabled.
  111973. */
  111974. set: function (enabled) {
  111975. if (this._fxaaEnabled === enabled) {
  111976. return;
  111977. }
  111978. this._fxaaEnabled = enabled;
  111979. this._buildPipeline();
  111980. },
  111981. enumerable: true,
  111982. configurable: true
  111983. });
  111984. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  111985. get: function () {
  111986. return this._samples;
  111987. },
  111988. /**
  111989. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111990. */
  111991. set: function (sampleCount) {
  111992. if (this._samples === sampleCount) {
  111993. return;
  111994. }
  111995. this._samples = sampleCount;
  111996. this._buildPipeline();
  111997. },
  111998. enumerable: true,
  111999. configurable: true
  112000. });
  112001. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  112002. get: function () {
  112003. return this._imageProcessingEnabled;
  112004. },
  112005. /**
  112006. * If image processing is enabled.
  112007. */
  112008. set: function (enabled) {
  112009. if (this._imageProcessingEnabled === enabled) {
  112010. return;
  112011. }
  112012. this._imageProcessingEnabled = enabled;
  112013. this._buildPipeline();
  112014. },
  112015. enumerable: true,
  112016. configurable: true
  112017. });
  112018. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  112019. get: function () {
  112020. return this._glowLayer == null;
  112021. },
  112022. /**
  112023. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112024. */
  112025. set: function (enabled) {
  112026. if (enabled && !this._glowLayer) {
  112027. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  112028. }
  112029. else if (!enabled && this._glowLayer) {
  112030. this._glowLayer.dispose();
  112031. this._glowLayer = null;
  112032. }
  112033. },
  112034. enumerable: true,
  112035. configurable: true
  112036. });
  112037. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  112038. get: function () {
  112039. return this._chromaticAberrationEnabled;
  112040. },
  112041. /**
  112042. * Enable or disable the chromaticAberration process from the pipeline
  112043. */
  112044. set: function (enabled) {
  112045. if (this._chromaticAberrationEnabled === enabled) {
  112046. return;
  112047. }
  112048. this._chromaticAberrationEnabled = enabled;
  112049. this._buildPipeline();
  112050. },
  112051. enumerable: true,
  112052. configurable: true
  112053. });
  112054. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  112055. get: function () {
  112056. return this._grainEnabled;
  112057. },
  112058. /**
  112059. * Enable or disable the grain process from the pipeline
  112060. */
  112061. set: function (enabled) {
  112062. if (this._grainEnabled === enabled) {
  112063. return;
  112064. }
  112065. this._grainEnabled = enabled;
  112066. this._buildPipeline();
  112067. },
  112068. enumerable: true,
  112069. configurable: true
  112070. });
  112071. /**
  112072. * Force the compilation of the entire pipeline.
  112073. */
  112074. DefaultRenderingPipeline.prototype.prepare = function () {
  112075. var previousState = this._buildAllowed;
  112076. this._buildAllowed = true;
  112077. this._buildPipeline();
  112078. this._buildAllowed = previousState;
  112079. };
  112080. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  112081. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  112082. if (this._hasCleared) {
  112083. postProcess.autoClear = false;
  112084. }
  112085. else {
  112086. postProcess.autoClear = true;
  112087. this._scene.autoClear = false;
  112088. this._hasCleared = true;
  112089. }
  112090. if (!skipTextureSharing) {
  112091. if (this._prevPrevPostProcess) {
  112092. postProcess.shareOutputWith(this._prevPrevPostProcess);
  112093. }
  112094. else {
  112095. postProcess.useOwnOutput();
  112096. }
  112097. if (this._prevPostProcess) {
  112098. this._prevPrevPostProcess = this._prevPostProcess;
  112099. }
  112100. this._prevPostProcess = postProcess;
  112101. }
  112102. };
  112103. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  112104. var _this = this;
  112105. if (!this._buildAllowed) {
  112106. return;
  112107. }
  112108. this._scene.autoClear = true;
  112109. var engine = this._scene.getEngine();
  112110. this._disposePostProcesses();
  112111. if (this._cameras !== null) {
  112112. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112113. // get back cameras to be used to reattach pipeline
  112114. this._cameras = this._camerasToBeAttached.slice();
  112115. }
  112116. this._reset();
  112117. this._prevPostProcess = null;
  112118. this._prevPrevPostProcess = null;
  112119. this._hasCleared = false;
  112120. if (this.depthOfFieldEnabled) {
  112121. // Multi camera suport
  112122. if (this._cameras.length > 1) {
  112123. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  112124. var camera = _a[_i];
  112125. var depthRenderer = this._scene.enableDepthRenderer(camera);
  112126. depthRenderer.useOnlyInActiveCamera = true;
  112127. }
  112128. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  112129. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  112130. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  112131. }
  112132. });
  112133. }
  112134. else {
  112135. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112136. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  112137. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  112138. }
  112139. if (!this.depthOfField._isReady()) {
  112140. this.depthOfField._updateEffects();
  112141. }
  112142. this.addEffect(this.depthOfField);
  112143. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  112144. }
  112145. else {
  112146. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112147. }
  112148. if (this.bloomEnabled) {
  112149. if (!this.bloom._isReady()) {
  112150. this.bloom._updateEffects();
  112151. }
  112152. this.addEffect(this.bloom);
  112153. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  112154. }
  112155. if (this._imageProcessingEnabled) {
  112156. 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);
  112157. if (this._hdr) {
  112158. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  112159. this._setAutoClearAndTextureSharing(this.imageProcessing);
  112160. }
  112161. else {
  112162. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  112163. }
  112164. }
  112165. if (this.sharpenEnabled) {
  112166. if (!this.sharpen.isReady()) {
  112167. this.sharpen.updateEffect();
  112168. }
  112169. this.addEffect(this._sharpenEffect);
  112170. this._setAutoClearAndTextureSharing(this.sharpen);
  112171. }
  112172. if (this.grainEnabled) {
  112173. if (!this.grain.isReady()) {
  112174. this.grain.updateEffect();
  112175. }
  112176. this.addEffect(this._grainEffect);
  112177. this._setAutoClearAndTextureSharing(this.grain);
  112178. }
  112179. if (this.chromaticAberrationEnabled) {
  112180. if (!this.chromaticAberration.isReady()) {
  112181. this.chromaticAberration.updateEffect();
  112182. }
  112183. this.addEffect(this._chromaticAberrationEffect);
  112184. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  112185. }
  112186. if (this.fxaaEnabled) {
  112187. 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);
  112188. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  112189. this._setAutoClearAndTextureSharing(this.fxaa, true);
  112190. }
  112191. if (this._cameras !== null) {
  112192. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  112193. }
  112194. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  112195. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  112196. }
  112197. };
  112198. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  112199. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  112200. for (var i = 0; i < this._cameras.length; i++) {
  112201. var camera = this._cameras[i];
  112202. if (this.imageProcessing) {
  112203. this.imageProcessing.dispose(camera);
  112204. }
  112205. if (this.fxaa) {
  112206. this.fxaa.dispose(camera);
  112207. }
  112208. // These are created in the constructor and should not be disposed on every pipeline change
  112209. if (disposeNonRecreated) {
  112210. if (this.sharpen) {
  112211. this.sharpen.dispose(camera);
  112212. }
  112213. if (this.depthOfField) {
  112214. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112215. this.depthOfField.disposeEffects(camera);
  112216. }
  112217. if (this.bloom) {
  112218. this.bloom.disposeEffects(camera);
  112219. }
  112220. if (this.chromaticAberration) {
  112221. this.chromaticAberration.dispose(camera);
  112222. }
  112223. if (this.grain) {
  112224. this.grain.dispose(camera);
  112225. }
  112226. if (this._glowLayer) {
  112227. this._glowLayer.dispose();
  112228. }
  112229. }
  112230. }
  112231. this.imageProcessing = null;
  112232. this.fxaa = null;
  112233. if (disposeNonRecreated) {
  112234. this.sharpen = null;
  112235. this._sharpenEffect = null;
  112236. this.depthOfField = null;
  112237. this.bloom = null;
  112238. this.chromaticAberration = null;
  112239. this._chromaticAberrationEffect = null;
  112240. this.grain = null;
  112241. this._grainEffect = null;
  112242. this._glowLayer = null;
  112243. }
  112244. };
  112245. /**
  112246. * Adds a camera to the pipeline
  112247. * @param camera the camera to be added
  112248. */
  112249. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  112250. this._camerasToBeAttached.push(camera);
  112251. this._buildPipeline();
  112252. };
  112253. /**
  112254. * Removes a camera from the pipeline
  112255. * @param camera the camera to remove
  112256. */
  112257. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  112258. var index = this._camerasToBeAttached.indexOf(camera);
  112259. this._camerasToBeAttached.splice(index, 1);
  112260. this._buildPipeline();
  112261. };
  112262. /**
  112263. * Dispose of the pipeline and stop all post processes
  112264. */
  112265. DefaultRenderingPipeline.prototype.dispose = function () {
  112266. this._disposePostProcesses(true);
  112267. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112268. this._scene.autoClear = true;
  112269. if (this._resizeObserver) {
  112270. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  112271. this._resizeObserver = null;
  112272. }
  112273. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  112274. _super.prototype.dispose.call(this);
  112275. };
  112276. /**
  112277. * Serialize the rendering pipeline (Used when exporting)
  112278. * @returns the serialized object
  112279. */
  112280. DefaultRenderingPipeline.prototype.serialize = function () {
  112281. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  112282. serializationObject.customType = "DefaultRenderingPipeline";
  112283. return serializationObject;
  112284. };
  112285. /**
  112286. * Parse the serialized pipeline
  112287. * @param source Source pipeline.
  112288. * @param scene The scene to load the pipeline to.
  112289. * @param rootUrl The URL of the serialized pipeline.
  112290. * @returns An instantiated pipeline from the serialized object.
  112291. */
  112292. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  112293. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  112294. };
  112295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112297. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  112298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112300. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  112301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112303. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  112304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112306. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  112307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112309. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  112310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112312. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  112313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112315. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  112316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112318. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  112319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112321. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  112322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112324. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  112325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112327. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  112328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112330. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  112331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112333. ], DefaultRenderingPipeline.prototype, "samples", null);
  112334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112336. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  112337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112339. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  112340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112342. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  112343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112345. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  112346. return DefaultRenderingPipeline;
  112347. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  112348. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  112349. /***/ }),
  112350. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  112351. /*!*********************************************************!*\
  112352. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  112353. \*********************************************************/
  112354. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  112355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112356. "use strict";
  112357. __webpack_require__.r(__webpack_exports__);
  112358. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  112359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  112360. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  112361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  112362. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  112363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  112364. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  112365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  112366. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  112367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  112368. /***/ }),
  112369. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  112370. /*!*************************************************************************!*\
  112371. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  112372. \*************************************************************************/
  112373. /*! exports provided: LensRenderingPipeline */
  112374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112375. "use strict";
  112376. __webpack_require__.r(__webpack_exports__);
  112377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  112378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112379. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112380. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  112381. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  112382. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112383. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112384. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  112385. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  112386. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  112387. /**
  112388. * BABYLON.JS Chromatic Aberration GLSL Shader
  112389. * Author: Olivier Guyot
  112390. * Separates very slightly R, G and B colors on the edges of the screen
  112391. * Inspired by Francois Tarlier & Martins Upitis
  112392. */
  112393. var LensRenderingPipeline = /** @class */ (function (_super) {
  112394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  112395. /**
  112396. * @constructor
  112397. *
  112398. * Effect parameters are as follow:
  112399. * {
  112400. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112401. * edge_blur: number; // from 0 to x (1 for realism)
  112402. * distortion: number; // from 0 to x (1 for realism)
  112403. * grain_amount: number; // from 0 to 1
  112404. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112405. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112406. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112407. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112408. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112409. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112410. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112411. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112412. * }
  112413. * Note: if an effect parameter is unset, effect is disabled
  112414. *
  112415. * @param name The rendering pipeline name
  112416. * @param parameters - An object containing all parameters (see above)
  112417. * @param scene The scene linked to this pipeline
  112418. * @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)
  112419. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112420. */
  112421. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  112422. if (ratio === void 0) { ratio = 1.0; }
  112423. var _this = _super.call(this, scene.getEngine(), name) || this;
  112424. // Lens effects can be of the following:
  112425. // - chromatic aberration (slight shift of RGB colors)
  112426. // - blur on the edge of the lens
  112427. // - lens distortion
  112428. // - depth-of-field blur & highlights enhancing
  112429. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  112430. // - grain effect (noise or custom texture)
  112431. // Two additional texture samplers are needed:
  112432. // - depth map (for depth-of-field)
  112433. // - grain texture
  112434. /**
  112435. * @ignore
  112436. * The chromatic aberration PostProcess id in the pipeline
  112437. */
  112438. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  112439. /**
  112440. * @ignore
  112441. * The highlights enhancing PostProcess id in the pipeline
  112442. */
  112443. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  112444. /**
  112445. * @ignore
  112446. * The depth-of-field PostProcess id in the pipeline
  112447. */
  112448. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  112449. _this._scene = scene;
  112450. // Fetch texture samplers
  112451. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  112452. if (parameters.grain_texture) {
  112453. _this._grainTexture = parameters.grain_texture;
  112454. }
  112455. else {
  112456. _this._createGrainTexture();
  112457. }
  112458. // save parameters
  112459. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  112460. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  112461. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  112462. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  112463. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  112464. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  112465. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  112466. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  112467. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  112468. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  112469. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  112470. // Create effects
  112471. _this._createChromaticAberrationPostProcess(ratio);
  112472. _this._createHighlightsPostProcess(ratio);
  112473. _this._createDepthOfFieldPostProcess(ratio / 4);
  112474. // Set up pipeline
  112475. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  112476. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  112477. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  112478. if (_this._highlightsGain === -1) {
  112479. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  112480. }
  112481. // Finish
  112482. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112483. if (cameras) {
  112484. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  112485. }
  112486. return _this;
  112487. }
  112488. // public methods (self explanatory)
  112489. /**
  112490. * Sets the amount of blur at the edges
  112491. * @param amount blur amount
  112492. */
  112493. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  112494. /**
  112495. * Sets edge blur to 0
  112496. */
  112497. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  112498. /**
  112499. * Sets the amout of grain
  112500. * @param amount Amount of grain
  112501. */
  112502. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  112503. /**
  112504. * Set grain amount to 0
  112505. */
  112506. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  112507. /**
  112508. * Sets the chromatic aberration amount
  112509. * @param amount amount of chromatic aberration
  112510. */
  112511. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  112512. /**
  112513. * Sets chromatic aberration amount to 0
  112514. */
  112515. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  112516. /**
  112517. * Sets the EdgeDistortion amount
  112518. * @param amount amount of EdgeDistortion
  112519. */
  112520. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  112521. /**
  112522. * Sets edge distortion to 0
  112523. */
  112524. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  112525. /**
  112526. * Sets the FocusDistance amount
  112527. * @param amount amount of FocusDistance
  112528. */
  112529. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  112530. /**
  112531. * Disables depth of field
  112532. */
  112533. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  112534. /**
  112535. * Sets the Aperture amount
  112536. * @param amount amount of Aperture
  112537. */
  112538. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  112539. /**
  112540. * Sets the DarkenOutOfFocus amount
  112541. * @param amount amount of DarkenOutOfFocus
  112542. */
  112543. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  112544. /**
  112545. * Creates a pentagon bokeh effect
  112546. */
  112547. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  112548. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  112549. };
  112550. /**
  112551. * Disables the pentagon bokeh effect
  112552. */
  112553. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  112554. this._highlightsPostProcess.updateEffect();
  112555. };
  112556. /**
  112557. * Enables noise blur
  112558. */
  112559. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  112560. /**
  112561. * Disables noise blur
  112562. */
  112563. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  112564. /**
  112565. * Sets the HighlightsGain amount
  112566. * @param amount amount of HighlightsGain
  112567. */
  112568. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  112569. this._highlightsGain = amount;
  112570. };
  112571. /**
  112572. * Sets the HighlightsThreshold amount
  112573. * @param amount amount of HighlightsThreshold
  112574. */
  112575. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  112576. if (this._highlightsGain === -1) {
  112577. this._highlightsGain = 1.0;
  112578. }
  112579. this._highlightsThreshold = amount;
  112580. };
  112581. /**
  112582. * Disables highlights
  112583. */
  112584. LensRenderingPipeline.prototype.disableHighlights = function () {
  112585. this._highlightsGain = -1;
  112586. };
  112587. /**
  112588. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112589. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112590. */
  112591. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  112592. if (disableDepthRender === void 0) { disableDepthRender = false; }
  112593. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  112594. this._chromaticAberrationPostProcess = null;
  112595. this._highlightsPostProcess = null;
  112596. this._depthOfFieldPostProcess = null;
  112597. this._grainTexture.dispose();
  112598. if (disableDepthRender) {
  112599. this._scene.disableDepthRenderer();
  112600. }
  112601. };
  112602. // colors shifting and distortion
  112603. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  112604. var _this = this;
  112605. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  112606. [], // samplers
  112607. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112608. this._chromaticAberrationPostProcess.onApply = function (effect) {
  112609. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  112610. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112611. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112612. effect.setFloat('radialIntensity', 1);
  112613. effect.setFloat2('direction', 17, 17);
  112614. effect.setFloat2('centerPosition', 0.5, 0.5);
  112615. };
  112616. };
  112617. // highlights enhancing
  112618. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  112619. var _this = this;
  112620. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  112621. [], // samplers
  112622. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  112623. this._highlightsPostProcess.onApply = function (effect) {
  112624. effect.setFloat('gain', _this._highlightsGain);
  112625. effect.setFloat('threshold', _this._highlightsThreshold);
  112626. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  112627. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112628. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112629. };
  112630. };
  112631. // colors shifting and distortion
  112632. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  112633. var _this = this;
  112634. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  112635. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  112636. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  112637. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112638. this._depthOfFieldPostProcess.onApply = function (effect) {
  112639. effect.setTexture("depthSampler", _this._depthTexture);
  112640. effect.setTexture("grainSampler", _this._grainTexture);
  112641. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  112642. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  112643. effect.setFloat('grain_amount', _this._grainAmount);
  112644. effect.setBool('blur_noise', _this._blurNoise);
  112645. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112646. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112647. effect.setFloat('distortion', _this._distortion);
  112648. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  112649. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  112650. effect.setFloat('aperture', _this._dofAperture);
  112651. effect.setFloat('darken', _this._dofDarken);
  112652. effect.setFloat('edge_blur', _this._edgeBlur);
  112653. effect.setBool('highlights', (_this._highlightsGain !== -1));
  112654. if (_this._scene.activeCamera) {
  112655. effect.setFloat('near', _this._scene.activeCamera.minZ);
  112656. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  112657. }
  112658. };
  112659. };
  112660. // creates a black and white random noise texture, 512x512
  112661. LensRenderingPipeline.prototype._createGrainTexture = function () {
  112662. var size = 512;
  112663. 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);
  112664. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  112665. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  112666. var context = this._grainTexture.getContext();
  112667. var rand = function (min, max) {
  112668. return Math.random() * (max - min) + min;
  112669. };
  112670. var value;
  112671. for (var x = 0; x < size; x++) {
  112672. for (var y = 0; y < size; y++) {
  112673. value = Math.floor(rand(0.42, 0.58) * 255);
  112674. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  112675. context.fillRect(x, y, 1, 1);
  112676. }
  112677. }
  112678. this._grainTexture.update(false);
  112679. };
  112680. return LensRenderingPipeline;
  112681. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  112682. /***/ }),
  112683. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  112684. /*!**************************************************************************!*\
  112685. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  112686. \**************************************************************************/
  112687. /*! exports provided: SSAO2RenderingPipeline */
  112688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112689. "use strict";
  112690. __webpack_require__.r(__webpack_exports__);
  112691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  112692. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112693. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  112694. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  112695. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  112696. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112697. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  112698. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  112699. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112700. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112701. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  112702. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  112703. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  112704. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  112705. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  112706. /**
  112707. * Render pipeline to produce ssao effect
  112708. */
  112709. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  112710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  112711. /**
  112712. * @constructor
  112713. * @param name The rendering pipeline name
  112714. * @param scene The scene linked to this pipeline
  112715. * @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 }
  112716. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112717. */
  112718. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  112719. var _this = _super.call(this, scene.getEngine(), name) || this;
  112720. // Members
  112721. /**
  112722. * @ignore
  112723. * The PassPostProcess id in the pipeline that contains the original scene color
  112724. */
  112725. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  112726. /**
  112727. * @ignore
  112728. * The SSAO PostProcess id in the pipeline
  112729. */
  112730. _this.SSAORenderEffect = "SSAORenderEffect";
  112731. /**
  112732. * @ignore
  112733. * The horizontal blur PostProcess id in the pipeline
  112734. */
  112735. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  112736. /**
  112737. * @ignore
  112738. * The vertical blur PostProcess id in the pipeline
  112739. */
  112740. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  112741. /**
  112742. * @ignore
  112743. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112744. */
  112745. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  112746. /**
  112747. * The output strength of the SSAO post-process. Default value is 1.0.
  112748. */
  112749. _this.totalStrength = 1.0;
  112750. /**
  112751. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112752. */
  112753. _this.maxZ = 100.0;
  112754. /**
  112755. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112756. */
  112757. _this.minZAspect = 0.2;
  112758. _this._samples = 8;
  112759. _this._textureSamples = 1;
  112760. _this._expensiveBlur = true;
  112761. /**
  112762. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112763. */
  112764. _this.radius = 2.0;
  112765. /**
  112766. * The base color of the SSAO post-process
  112767. * The final result is "base + ssao" between [0, 1]
  112768. */
  112769. _this.base = 0;
  112770. _this._firstUpdate = true;
  112771. _this._bits = new Uint32Array(1);
  112772. _this._scene = scene;
  112773. _this._ratio = ratio;
  112774. if (!_this.isSupported) {
  112775. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  112776. return _this;
  112777. }
  112778. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  112779. var blurRatio = _this._ratio.blurRatio || ratio;
  112780. // Set up assets
  112781. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  112782. _this._createRandomTexture();
  112783. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  112784. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  112785. _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);
  112786. _this._originalColorPostProcess.samples = _this.textureSamples;
  112787. _this._createSSAOPostProcess(1.0);
  112788. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  112789. _this._createSSAOCombinePostProcess(blurRatio);
  112790. // Set up pipeline
  112791. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  112792. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  112793. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  112794. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  112795. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  112796. // Finish
  112797. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112798. if (cameras) {
  112799. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  112800. }
  112801. return _this;
  112802. }
  112803. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  112804. get: function () {
  112805. return this._samples;
  112806. },
  112807. /**
  112808. * Number of samples used for the SSAO calculations. Default value is 8
  112809. */
  112810. set: function (n) {
  112811. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  112812. this._samples = n;
  112813. this._sampleSphere = this._generateHemisphere();
  112814. this._firstUpdate = true;
  112815. },
  112816. enumerable: true,
  112817. configurable: true
  112818. });
  112819. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  112820. get: function () {
  112821. return this._textureSamples;
  112822. },
  112823. /**
  112824. * Number of samples to use for antialiasing
  112825. */
  112826. set: function (n) {
  112827. this._textureSamples = n;
  112828. this._originalColorPostProcess.samples = n;
  112829. this._blurHPostProcess.samples = n;
  112830. this._blurVPostProcess.samples = n;
  112831. this._ssaoPostProcess.samples = n;
  112832. this._ssaoCombinePostProcess.samples = n;
  112833. },
  112834. enumerable: true,
  112835. configurable: true
  112836. });
  112837. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  112838. get: function () {
  112839. return this._expensiveBlur;
  112840. },
  112841. /**
  112842. * If bilateral blur should be used
  112843. */
  112844. set: function (b) {
  112845. 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"]);
  112846. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  112847. this._expensiveBlur = b;
  112848. this._firstUpdate = true;
  112849. },
  112850. enumerable: true,
  112851. configurable: true
  112852. });
  112853. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  112854. /**
  112855. * Support test.
  112856. */
  112857. get: function () {
  112858. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  112859. if (!engine) {
  112860. return false;
  112861. }
  112862. return engine.getCaps().drawBuffersExtension;
  112863. },
  112864. enumerable: true,
  112865. configurable: true
  112866. });
  112867. // Public Methods
  112868. /**
  112869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112870. */
  112871. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  112872. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  112873. for (var i = 0; i < this._scene.cameras.length; i++) {
  112874. var camera = this._scene.cameras[i];
  112875. this._originalColorPostProcess.dispose(camera);
  112876. this._ssaoPostProcess.dispose(camera);
  112877. this._blurHPostProcess.dispose(camera);
  112878. this._blurVPostProcess.dispose(camera);
  112879. this._ssaoCombinePostProcess.dispose(camera);
  112880. }
  112881. this._randomTexture.dispose();
  112882. if (disableGeometryBufferRenderer) {
  112883. this._scene.disableGeometryBufferRenderer();
  112884. }
  112885. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  112886. _super.prototype.dispose.call(this);
  112887. };
  112888. // Private Methods
  112889. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  112890. var _this = this;
  112891. this._samplerOffsets = [];
  112892. var expensive = this.expensiveBlur;
  112893. for (var i = -8; i < 8; i++) {
  112894. this._samplerOffsets.push(i * 2 + 0.5);
  112895. }
  112896. 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");
  112897. this._blurHPostProcess.onApply = function (effect) {
  112898. if (!_this._scene.activeCamera) {
  112899. return;
  112900. }
  112901. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  112902. effect.setFloat("near", _this._scene.activeCamera.minZ);
  112903. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  112904. effect.setFloat("radius", _this.radius);
  112905. effect.setTexture("depthSampler", _this._depthTexture);
  112906. if (_this._firstUpdate) {
  112907. effect.setArray("samplerOffsets", _this._samplerOffsets);
  112908. }
  112909. };
  112910. 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");
  112911. this._blurVPostProcess.onApply = function (effect) {
  112912. if (!_this._scene.activeCamera) {
  112913. return;
  112914. }
  112915. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  112916. effect.setFloat("near", _this._scene.activeCamera.minZ);
  112917. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  112918. effect.setFloat("radius", _this.radius);
  112919. effect.setTexture("depthSampler", _this._depthTexture);
  112920. if (_this._firstUpdate) {
  112921. effect.setArray("samplerOffsets", _this._samplerOffsets);
  112922. _this._firstUpdate = false;
  112923. }
  112924. };
  112925. this._blurHPostProcess.samples = this.textureSamples;
  112926. this._blurVPostProcess.samples = this.textureSamples;
  112927. };
  112928. /** @hidden */
  112929. SSAO2RenderingPipeline.prototype._rebuild = function () {
  112930. this._firstUpdate = true;
  112931. _super.prototype._rebuild.call(this);
  112932. };
  112933. //Van der Corput radical inverse
  112934. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  112935. this._bits[0] = i;
  112936. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  112937. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  112938. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  112939. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  112940. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  112941. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  112942. };
  112943. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  112944. return [i / n, this._radicalInverse_VdC(i)];
  112945. };
  112946. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  112947. var phi = v * 2.0 * Math.PI;
  112948. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  112949. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  112950. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  112951. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  112952. };
  112953. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  112954. var numSamples = this.samples;
  112955. var result = [];
  112956. var vector;
  112957. var i = 0;
  112958. while (i < numSamples) {
  112959. if (numSamples < 16) {
  112960. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  112961. }
  112962. else {
  112963. var rand = this._hammersley(i, numSamples);
  112964. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  112965. }
  112966. result.push(vector.x, vector.y, vector.z);
  112967. i++;
  112968. }
  112969. return result;
  112970. };
  112971. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  112972. var _this = this;
  112973. var numSamples = this.samples;
  112974. this._sampleSphere = this._generateHemisphere();
  112975. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  112976. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  112977. "base", "range", "projection", "near", "far", "texelSize",
  112978. "xViewport", "yViewport", "maxZ", "minZAspect"
  112979. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  112980. this._ssaoPostProcess.onApply = function (effect) {
  112981. if (_this._firstUpdate) {
  112982. effect.setArray3("sampleSphere", _this._sampleSphere);
  112983. effect.setFloat("randTextureTiles", 32.0);
  112984. }
  112985. if (!_this._scene.activeCamera) {
  112986. return;
  112987. }
  112988. effect.setFloat("samplesFactor", 1 / _this.samples);
  112989. effect.setFloat("totalStrength", _this.totalStrength);
  112990. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  112991. effect.setFloat("radius", _this.radius);
  112992. effect.setFloat("maxZ", _this.maxZ);
  112993. effect.setFloat("minZAspect", _this.minZAspect);
  112994. effect.setFloat("base", _this.base);
  112995. effect.setFloat("near", _this._scene.activeCamera.minZ);
  112996. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  112997. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  112998. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  112999. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  113000. effect.setTexture("textureSampler", _this._depthTexture);
  113001. effect.setTexture("normalSampler", _this._normalTexture);
  113002. effect.setTexture("randomSampler", _this._randomTexture);
  113003. };
  113004. this._ssaoPostProcess.samples = this.textureSamples;
  113005. };
  113006. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113007. var _this = this;
  113008. 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);
  113009. this._ssaoCombinePostProcess.onApply = function (effect) {
  113010. var viewport = _this._scene.activeCamera.viewport;
  113011. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  113012. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113013. };
  113014. this._ssaoCombinePostProcess.samples = this.textureSamples;
  113015. };
  113016. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  113017. var size = 128;
  113018. 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);
  113019. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113020. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113021. var context = this._randomTexture.getContext();
  113022. var rand = function (min, max) {
  113023. return Math.random() * (max - min) + min;
  113024. };
  113025. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  113026. for (var x = 0; x < size; x++) {
  113027. for (var y = 0; y < size; y++) {
  113028. randVector.x = rand(0.0, 1.0);
  113029. randVector.y = rand(0.0, 1.0);
  113030. randVector.z = 0.0;
  113031. randVector.normalize();
  113032. randVector.scaleInPlace(255);
  113033. randVector.x = Math.floor(randVector.x);
  113034. randVector.y = Math.floor(randVector.y);
  113035. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113036. context.fillRect(x, y, 1, 1);
  113037. }
  113038. }
  113039. this._randomTexture.update(false);
  113040. };
  113041. /**
  113042. * Serialize the rendering pipeline (Used when exporting)
  113043. * @returns the serialized object
  113044. */
  113045. SSAO2RenderingPipeline.prototype.serialize = function () {
  113046. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  113047. serializationObject.customType = "SSAO2RenderingPipeline";
  113048. return serializationObject;
  113049. };
  113050. /**
  113051. * Parse the serialized pipeline
  113052. * @param source Source pipeline.
  113053. * @param scene The scene to load the pipeline to.
  113054. * @param rootUrl The URL of the serialized pipeline.
  113055. * @returns An instantiated pipeline from the serialized object.
  113056. */
  113057. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  113058. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  113059. };
  113060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113062. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  113063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113065. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  113066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113068. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  113069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  113071. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  113072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  113074. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  113075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113077. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  113078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  113080. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  113081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113083. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  113084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113086. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  113087. return SSAO2RenderingPipeline;
  113088. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  113089. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  113090. /***/ }),
  113091. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  113092. /*!*************************************************************************!*\
  113093. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  113094. \*************************************************************************/
  113095. /*! exports provided: SSAORenderingPipeline */
  113096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113097. "use strict";
  113098. __webpack_require__.r(__webpack_exports__);
  113099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  113100. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113102. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113103. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113104. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113105. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113106. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113107. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113108. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113109. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113110. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113111. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  113112. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113113. /**
  113114. * Render pipeline to produce ssao effect
  113115. */
  113116. var SSAORenderingPipeline = /** @class */ (function (_super) {
  113117. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  113118. /**
  113119. * @constructor
  113120. * @param name - The rendering pipeline name
  113121. * @param scene - The scene linked to this pipeline
  113122. * @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 }
  113123. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113124. */
  113125. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  113126. var _this = _super.call(this, scene.getEngine(), name) || this;
  113127. // Members
  113128. /**
  113129. * @ignore
  113130. * The PassPostProcess id in the pipeline that contains the original scene color
  113131. */
  113132. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113133. /**
  113134. * @ignore
  113135. * The SSAO PostProcess id in the pipeline
  113136. */
  113137. _this.SSAORenderEffect = "SSAORenderEffect";
  113138. /**
  113139. * @ignore
  113140. * The horizontal blur PostProcess id in the pipeline
  113141. */
  113142. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113143. /**
  113144. * @ignore
  113145. * The vertical blur PostProcess id in the pipeline
  113146. */
  113147. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113148. /**
  113149. * @ignore
  113150. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113151. */
  113152. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113153. /**
  113154. * The output strength of the SSAO post-process. Default value is 1.0.
  113155. */
  113156. _this.totalStrength = 1.0;
  113157. /**
  113158. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113159. */
  113160. _this.radius = 0.0001;
  113161. /**
  113162. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113163. * Must not be equal to fallOff and superior to fallOff.
  113164. * Default value is 0.975
  113165. */
  113166. _this.area = 0.0075;
  113167. /**
  113168. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113169. * Must not be equal to area and inferior to area.
  113170. * Default value is 0.0
  113171. */
  113172. _this.fallOff = 0.000001;
  113173. /**
  113174. * The base color of the SSAO post-process
  113175. * The final result is "base + ssao" between [0, 1]
  113176. */
  113177. _this.base = 0.5;
  113178. _this._firstUpdate = true;
  113179. _this._scene = scene;
  113180. // Set up assets
  113181. _this._createRandomTexture();
  113182. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113183. var ssaoRatio = ratio.ssaoRatio || ratio;
  113184. var combineRatio = ratio.combineRatio || ratio;
  113185. _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);
  113186. _this._createSSAOPostProcess(ssaoRatio);
  113187. _this._createBlurPostProcess(ssaoRatio);
  113188. _this._createSSAOCombinePostProcess(combineRatio);
  113189. // Set up pipeline
  113190. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113191. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113192. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113193. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113194. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113195. // Finish
  113196. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113197. if (cameras) {
  113198. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113199. }
  113200. return _this;
  113201. }
  113202. // Public Methods
  113203. /**
  113204. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113205. */
  113206. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113207. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113208. for (var i = 0; i < this._scene.cameras.length; i++) {
  113209. var camera = this._scene.cameras[i];
  113210. this._originalColorPostProcess.dispose(camera);
  113211. this._ssaoPostProcess.dispose(camera);
  113212. this._blurHPostProcess.dispose(camera);
  113213. this._blurVPostProcess.dispose(camera);
  113214. this._ssaoCombinePostProcess.dispose(camera);
  113215. }
  113216. this._randomTexture.dispose();
  113217. if (disableDepthRender) {
  113218. this._scene.disableDepthRenderer();
  113219. }
  113220. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113221. _super.prototype.dispose.call(this);
  113222. };
  113223. // Private Methods
  113224. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  113225. var _this = this;
  113226. var size = 16;
  113227. 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);
  113228. 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);
  113229. this._blurHPostProcess.onActivateObservable.add(function () {
  113230. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  113231. _this._blurHPostProcess.kernel = size * dw;
  113232. });
  113233. this._blurVPostProcess.onActivateObservable.add(function () {
  113234. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  113235. _this._blurVPostProcess.kernel = size * dw;
  113236. });
  113237. };
  113238. /** @hidden */
  113239. SSAORenderingPipeline.prototype._rebuild = function () {
  113240. this._firstUpdate = true;
  113241. _super.prototype._rebuild.call(this);
  113242. };
  113243. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113244. var _this = this;
  113245. var numSamples = 16;
  113246. var sampleSphere = [
  113247. 0.5381, 0.1856, -0.4319,
  113248. 0.1379, 0.2486, 0.4430,
  113249. 0.3371, 0.5679, -0.0057,
  113250. -0.6999, -0.0451, -0.0019,
  113251. 0.0689, -0.1598, -0.8547,
  113252. 0.0560, 0.0069, -0.1843,
  113253. -0.0146, 0.1402, 0.0762,
  113254. 0.0100, -0.1924, -0.0344,
  113255. -0.3577, -0.5301, -0.4358,
  113256. -0.3169, 0.1063, 0.0158,
  113257. 0.0103, -0.5869, 0.0046,
  113258. -0.0897, -0.4940, 0.3287,
  113259. 0.7119, -0.0154, -0.0918,
  113260. -0.0533, 0.0596, -0.5411,
  113261. 0.0352, -0.0631, 0.5460,
  113262. -0.4776, 0.2847, -0.0271
  113263. ];
  113264. var samplesFactor = 1.0 / numSamples;
  113265. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  113266. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113267. "area", "fallOff", "base", "range", "viewport"
  113268. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113269. this._ssaoPostProcess.onApply = function (effect) {
  113270. if (_this._firstUpdate) {
  113271. effect.setArray3("sampleSphere", sampleSphere);
  113272. effect.setFloat("samplesFactor", samplesFactor);
  113273. effect.setFloat("randTextureTiles", 4.0);
  113274. }
  113275. effect.setFloat("totalStrength", _this.totalStrength);
  113276. effect.setFloat("radius", _this.radius);
  113277. effect.setFloat("area", _this.area);
  113278. effect.setFloat("fallOff", _this.fallOff);
  113279. effect.setFloat("base", _this.base);
  113280. effect.setTexture("textureSampler", _this._depthTexture);
  113281. effect.setTexture("randomSampler", _this._randomTexture);
  113282. };
  113283. };
  113284. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113285. var _this = this;
  113286. 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);
  113287. this._ssaoCombinePostProcess.onApply = function (effect) {
  113288. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  113289. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113290. };
  113291. };
  113292. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  113293. var size = 512;
  113294. 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);
  113295. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113296. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113297. var context = this._randomTexture.getContext();
  113298. var rand = function (min, max) {
  113299. return Math.random() * (max - min) + min;
  113300. };
  113301. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113302. for (var x = 0; x < size; x++) {
  113303. for (var y = 0; y < size; y++) {
  113304. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  113305. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  113306. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  113307. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113308. context.fillRect(x, y, 1, 1);
  113309. }
  113310. }
  113311. this._randomTexture.update(false);
  113312. };
  113313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113315. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  113316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113318. ], SSAORenderingPipeline.prototype, "radius", void 0);
  113319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113321. ], SSAORenderingPipeline.prototype, "area", void 0);
  113322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113324. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  113325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113327. ], SSAORenderingPipeline.prototype, "base", void 0);
  113328. return SSAORenderingPipeline;
  113329. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  113330. /***/ }),
  113331. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  113332. /*!*****************************************************************************!*\
  113333. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  113334. \*****************************************************************************/
  113335. /*! exports provided: StandardRenderingPipeline */
  113336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113337. "use strict";
  113338. __webpack_require__.r(__webpack_exports__);
  113339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  113340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113341. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113342. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113343. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113344. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  113345. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113346. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113347. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113348. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113349. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113350. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113351. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113352. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113353. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  113354. /**
  113355. * Standard rendering pipeline
  113356. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113357. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113358. */
  113359. var StandardRenderingPipeline = /** @class */ (function (_super) {
  113360. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  113361. /**
  113362. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113363. * @constructor
  113364. * @param name The rendering pipeline name
  113365. * @param scene The scene linked to this pipeline
  113366. * @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)
  113367. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113369. */
  113370. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  113371. if (originalPostProcess === void 0) { originalPostProcess = null; }
  113372. var _this = _super.call(this, scene.getEngine(), name) || this;
  113373. /**
  113374. * Post-process used to down scale an image x4
  113375. */
  113376. _this.downSampleX4PostProcess = null;
  113377. /**
  113378. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113379. */
  113380. _this.brightPassPostProcess = null;
  113381. /**
  113382. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113383. */
  113384. _this.blurHPostProcesses = [];
  113385. /**
  113386. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113387. */
  113388. _this.blurVPostProcesses = [];
  113389. /**
  113390. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113391. */
  113392. _this.textureAdderPostProcess = null;
  113393. /**
  113394. * Post-process used to create volumetric lighting effect
  113395. */
  113396. _this.volumetricLightPostProcess = null;
  113397. /**
  113398. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113399. */
  113400. _this.volumetricLightSmoothXPostProcess = null;
  113401. /**
  113402. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113403. */
  113404. _this.volumetricLightSmoothYPostProcess = null;
  113405. /**
  113406. * Post-process used to merge the volumetric light effect and the real scene color
  113407. */
  113408. _this.volumetricLightMergePostProces = null;
  113409. /**
  113410. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113411. */
  113412. _this.volumetricLightFinalPostProcess = null;
  113413. /**
  113414. * Base post-process used to calculate the average luminance of the final image for HDR
  113415. */
  113416. _this.luminancePostProcess = null;
  113417. /**
  113418. * Post-processes used to create down sample post-processes in order to get
  113419. * the average luminance of the final image for HDR
  113420. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113421. */
  113422. _this.luminanceDownSamplePostProcesses = [];
  113423. /**
  113424. * Post-process used to create a HDR effect (light adaptation)
  113425. */
  113426. _this.hdrPostProcess = null;
  113427. /**
  113428. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113429. */
  113430. _this.textureAdderFinalPostProcess = null;
  113431. /**
  113432. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113433. */
  113434. _this.lensFlareFinalPostProcess = null;
  113435. /**
  113436. * Post-process used to merge the final HDR post-process and the real scene color
  113437. */
  113438. _this.hdrFinalPostProcess = null;
  113439. /**
  113440. * Post-process used to create a lens flare effect
  113441. */
  113442. _this.lensFlarePostProcess = null;
  113443. /**
  113444. * Post-process that merges the result of the lens flare post-process and the real scene color
  113445. */
  113446. _this.lensFlareComposePostProcess = null;
  113447. /**
  113448. * Post-process used to create a motion blur effect
  113449. */
  113450. _this.motionBlurPostProcess = null;
  113451. /**
  113452. * Post-process used to create a depth of field effect
  113453. */
  113454. _this.depthOfFieldPostProcess = null;
  113455. /**
  113456. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113457. */
  113458. _this.fxaaPostProcess = null;
  113459. // Values
  113460. /**
  113461. * Represents the brightness threshold in order to configure the illuminated surfaces
  113462. */
  113463. _this.brightThreshold = 1.0;
  113464. /**
  113465. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113466. */
  113467. _this.blurWidth = 512.0;
  113468. /**
  113469. * Sets if the blur for highlighted surfaces must be only horizontal
  113470. */
  113471. _this.horizontalBlur = false;
  113472. /**
  113473. * Sets the overall exposure used by the pipeline
  113474. */
  113475. _this.exposure = 1.0;
  113476. /**
  113477. * Texture used typically to simulate "dirty" on camera lens
  113478. */
  113479. _this.lensTexture = null;
  113480. /**
  113481. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113482. */
  113483. _this.volumetricLightCoefficient = 0.2;
  113484. /**
  113485. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113486. */
  113487. _this.volumetricLightPower = 4.0;
  113488. /**
  113489. * Used the set the blur intensity to smooth the volumetric lights
  113490. */
  113491. _this.volumetricLightBlurScale = 64.0;
  113492. /**
  113493. * Light (spot or directional) used to generate the volumetric lights rays
  113494. * The source light must have a shadow generate so the pipeline can get its
  113495. * depth map
  113496. */
  113497. _this.sourceLight = null;
  113498. /**
  113499. * For eye adaptation, represents the minimum luminance the eye can see
  113500. */
  113501. _this.hdrMinimumLuminance = 1.0;
  113502. /**
  113503. * For eye adaptation, represents the decrease luminance speed
  113504. */
  113505. _this.hdrDecreaseRate = 0.5;
  113506. /**
  113507. * For eye adaptation, represents the increase luminance speed
  113508. */
  113509. _this.hdrIncreaseRate = 0.5;
  113510. /**
  113511. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113512. */
  113513. _this.lensColorTexture = null;
  113514. /**
  113515. * The overall strengh for the lens flare effect
  113516. */
  113517. _this.lensFlareStrength = 20.0;
  113518. /**
  113519. * Dispersion coefficient for lens flare ghosts
  113520. */
  113521. _this.lensFlareGhostDispersal = 1.4;
  113522. /**
  113523. * Main lens flare halo width
  113524. */
  113525. _this.lensFlareHaloWidth = 0.7;
  113526. /**
  113527. * Based on the lens distortion effect, defines how much the lens flare result
  113528. * is distorted
  113529. */
  113530. _this.lensFlareDistortionStrength = 16.0;
  113531. /**
  113532. * Lens star texture must be used to simulate rays on the flares and is available
  113533. * in the documentation
  113534. */
  113535. _this.lensStarTexture = null;
  113536. /**
  113537. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113538. * flare effect by taking account of the dirt texture
  113539. */
  113540. _this.lensFlareDirtTexture = null;
  113541. /**
  113542. * Represents the focal length for the depth of field effect
  113543. */
  113544. _this.depthOfFieldDistance = 10.0;
  113545. /**
  113546. * Represents the blur intensity for the blurred part of the depth of field effect
  113547. */
  113548. _this.depthOfFieldBlurWidth = 64.0;
  113549. /**
  113550. * For motion blur, defines how much the image is blurred by the movement
  113551. */
  113552. _this.motionStrength = 1.0;
  113553. /**
  113554. * List of animations for the pipeline (IAnimatable implementation)
  113555. */
  113556. _this.animations = [];
  113557. _this._currentDepthOfFieldSource = null;
  113558. _this._hdrCurrentLuminance = 1.0;
  113559. // Getters and setters
  113560. _this._bloomEnabled = false;
  113561. _this._depthOfFieldEnabled = false;
  113562. _this._vlsEnabled = false;
  113563. _this._lensFlareEnabled = false;
  113564. _this._hdrEnabled = false;
  113565. _this._motionBlurEnabled = false;
  113566. _this._fxaaEnabled = false;
  113567. _this._motionBlurSamples = 64.0;
  113568. _this._volumetricLightStepsCount = 50.0;
  113569. _this._samples = 1;
  113570. _this._cameras = cameras || [];
  113571. // Initialize
  113572. _this._scene = scene;
  113573. _this._basePostProcess = originalPostProcess;
  113574. _this._ratio = ratio;
  113575. // Misc
  113576. _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;
  113577. // Finish
  113578. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113579. _this._buildPipeline();
  113580. return _this;
  113581. }
  113582. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  113583. /**
  113584. * @ignore
  113585. * Specifies if the bloom pipeline is enabled
  113586. */
  113587. get: function () {
  113588. return this._bloomEnabled;
  113589. },
  113590. set: function (enabled) {
  113591. if (this._bloomEnabled === enabled) {
  113592. return;
  113593. }
  113594. this._bloomEnabled = enabled;
  113595. this._buildPipeline();
  113596. },
  113597. enumerable: true,
  113598. configurable: true
  113599. });
  113600. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  113601. /**
  113602. * @ignore
  113603. * Specifies if the depth of field pipeline is enabed
  113604. */
  113605. get: function () {
  113606. return this._depthOfFieldEnabled;
  113607. },
  113608. set: function (enabled) {
  113609. if (this._depthOfFieldEnabled === enabled) {
  113610. return;
  113611. }
  113612. this._depthOfFieldEnabled = enabled;
  113613. this._buildPipeline();
  113614. },
  113615. enumerable: true,
  113616. configurable: true
  113617. });
  113618. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  113619. /**
  113620. * @ignore
  113621. * Specifies if the lens flare pipeline is enabed
  113622. */
  113623. get: function () {
  113624. return this._lensFlareEnabled;
  113625. },
  113626. set: function (enabled) {
  113627. if (this._lensFlareEnabled === enabled) {
  113628. return;
  113629. }
  113630. this._lensFlareEnabled = enabled;
  113631. this._buildPipeline();
  113632. },
  113633. enumerable: true,
  113634. configurable: true
  113635. });
  113636. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  113637. /**
  113638. * @ignore
  113639. * Specifies if the HDR pipeline is enabled
  113640. */
  113641. get: function () {
  113642. return this._hdrEnabled;
  113643. },
  113644. set: function (enabled) {
  113645. if (this._hdrEnabled === enabled) {
  113646. return;
  113647. }
  113648. this._hdrEnabled = enabled;
  113649. this._buildPipeline();
  113650. },
  113651. enumerable: true,
  113652. configurable: true
  113653. });
  113654. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  113655. /**
  113656. * @ignore
  113657. * Specifies if the volumetric lights scattering effect is enabled
  113658. */
  113659. get: function () {
  113660. return this._vlsEnabled;
  113661. },
  113662. set: function (enabled) {
  113663. if (this._vlsEnabled === enabled) {
  113664. return;
  113665. }
  113666. if (enabled) {
  113667. var geometry = this._scene.enableGeometryBufferRenderer();
  113668. if (!geometry) {
  113669. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  113670. return;
  113671. }
  113672. }
  113673. this._vlsEnabled = enabled;
  113674. this._buildPipeline();
  113675. },
  113676. enumerable: true,
  113677. configurable: true
  113678. });
  113679. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  113680. /**
  113681. * @ignore
  113682. * Specifies if the motion blur effect is enabled
  113683. */
  113684. get: function () {
  113685. return this._motionBlurEnabled;
  113686. },
  113687. set: function (enabled) {
  113688. if (this._motionBlurEnabled === enabled) {
  113689. return;
  113690. }
  113691. this._motionBlurEnabled = enabled;
  113692. this._buildPipeline();
  113693. },
  113694. enumerable: true,
  113695. configurable: true
  113696. });
  113697. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  113698. /**
  113699. * Specifies if anti-aliasing is enabled
  113700. */
  113701. get: function () {
  113702. return this._fxaaEnabled;
  113703. },
  113704. set: function (enabled) {
  113705. if (this._fxaaEnabled === enabled) {
  113706. return;
  113707. }
  113708. this._fxaaEnabled = enabled;
  113709. this._buildPipeline();
  113710. },
  113711. enumerable: true,
  113712. configurable: true
  113713. });
  113714. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  113715. /**
  113716. * Specifies the number of steps used to calculate the volumetric lights
  113717. * Typically in interval [50, 200]
  113718. */
  113719. get: function () {
  113720. return this._volumetricLightStepsCount;
  113721. },
  113722. set: function (count) {
  113723. if (this.volumetricLightPostProcess) {
  113724. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  113725. }
  113726. this._volumetricLightStepsCount = count;
  113727. },
  113728. enumerable: true,
  113729. configurable: true
  113730. });
  113731. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  113732. /**
  113733. * Specifies the number of samples used for the motion blur effect
  113734. * Typically in interval [16, 64]
  113735. */
  113736. get: function () {
  113737. return this._motionBlurSamples;
  113738. },
  113739. set: function (samples) {
  113740. if (this.motionBlurPostProcess) {
  113741. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  113742. }
  113743. this._motionBlurSamples = samples;
  113744. },
  113745. enumerable: true,
  113746. configurable: true
  113747. });
  113748. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  113749. /**
  113750. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113751. */
  113752. get: function () {
  113753. return this._samples;
  113754. },
  113755. set: function (sampleCount) {
  113756. if (this._samples === sampleCount) {
  113757. return;
  113758. }
  113759. this._samples = sampleCount;
  113760. this._buildPipeline();
  113761. },
  113762. enumerable: true,
  113763. configurable: true
  113764. });
  113765. StandardRenderingPipeline.prototype._buildPipeline = function () {
  113766. var _this = this;
  113767. var ratio = this._ratio;
  113768. var scene = this._scene;
  113769. this._disposePostProcesses();
  113770. this._reset();
  113771. // Create pass post-process
  113772. if (!this._basePostProcess) {
  113773. 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);
  113774. this.originalPostProcess.onApply = function () {
  113775. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  113776. };
  113777. }
  113778. else {
  113779. this.originalPostProcess = this._basePostProcess;
  113780. }
  113781. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  113782. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  113783. }
  113784. this._currentDepthOfFieldSource = this.originalPostProcess;
  113785. if (this._bloomEnabled) {
  113786. // Create down sample X4 post-process
  113787. this._createDownSampleX4PostProcess(scene, ratio / 2);
  113788. // Create bright pass post-process
  113789. this._createBrightPassPostProcess(scene, ratio / 2);
  113790. // Create gaussian blur post-processes (down sampling blurs)
  113791. this._createBlurPostProcesses(scene, ratio / 4, 1);
  113792. // Create texture adder post-process
  113793. this._createTextureAdderPostProcess(scene, ratio);
  113794. // Create depth-of-field source post-process
  113795. 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);
  113796. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  113797. }
  113798. if (this._vlsEnabled) {
  113799. // Create volumetric light
  113800. this._createVolumetricLightPostProcess(scene, ratio);
  113801. // Create volumetric light final post-process
  113802. 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);
  113803. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  113804. }
  113805. if (this._lensFlareEnabled) {
  113806. // Create lens flare post-process
  113807. this._createLensFlarePostProcess(scene, ratio);
  113808. // Create depth-of-field source post-process post lens-flare and disable it now
  113809. 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);
  113810. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  113811. }
  113812. if (this._hdrEnabled) {
  113813. // Create luminance
  113814. this._createLuminancePostProcesses(scene, this._floatTextureType);
  113815. // Create HDR
  113816. this._createHdrPostProcess(scene, ratio);
  113817. // Create depth-of-field source post-process post hdr and disable it now
  113818. 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);
  113819. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  113820. }
  113821. if (this._depthOfFieldEnabled) {
  113822. // Create gaussian blur used by depth-of-field
  113823. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  113824. // Create depth-of-field post-process
  113825. this._createDepthOfFieldPostProcess(scene, ratio);
  113826. }
  113827. if (this._motionBlurEnabled) {
  113828. // Create motion blur post-process
  113829. this._createMotionBlurPostProcess(scene, ratio);
  113830. }
  113831. if (this._fxaaEnabled) {
  113832. // Create fxaa post-process
  113833. 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);
  113834. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  113835. }
  113836. if (this._cameras !== null) {
  113837. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113838. }
  113839. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  113840. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113841. }
  113842. };
  113843. // Down Sample X4 Post-Processs
  113844. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  113845. var _this = this;
  113846. var downSampleX4Offsets = new Array(32);
  113847. 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);
  113848. this.downSampleX4PostProcess.onApply = function (effect) {
  113849. var id = 0;
  113850. var width = _this.downSampleX4PostProcess.width;
  113851. var height = _this.downSampleX4PostProcess.height;
  113852. for (var i = -2; i < 2; i++) {
  113853. for (var j = -2; j < 2; j++) {
  113854. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  113855. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  113856. id += 2;
  113857. }
  113858. }
  113859. effect.setArray2("dsOffsets", downSampleX4Offsets);
  113860. };
  113861. // Add to pipeline
  113862. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  113863. };
  113864. // Brightpass Post-Process
  113865. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  113866. var _this = this;
  113867. var brightOffsets = new Array(8);
  113868. 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);
  113869. this.brightPassPostProcess.onApply = function (effect) {
  113870. var sU = (1.0 / _this.brightPassPostProcess.width);
  113871. var sV = (1.0 / _this.brightPassPostProcess.height);
  113872. brightOffsets[0] = -0.5 * sU;
  113873. brightOffsets[1] = 0.5 * sV;
  113874. brightOffsets[2] = 0.5 * sU;
  113875. brightOffsets[3] = 0.5 * sV;
  113876. brightOffsets[4] = -0.5 * sU;
  113877. brightOffsets[5] = -0.5 * sV;
  113878. brightOffsets[6] = 0.5 * sU;
  113879. brightOffsets[7] = -0.5 * sV;
  113880. effect.setArray2("dsOffsets", brightOffsets);
  113881. effect.setFloat("brightThreshold", _this.brightThreshold);
  113882. };
  113883. // Add to pipeline
  113884. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  113885. };
  113886. // Create blur H&V post-processes
  113887. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  113888. var _this = this;
  113889. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  113890. var engine = scene.getEngine();
  113891. 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);
  113892. 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);
  113893. blurX.onActivateObservable.add(function () {
  113894. var dw = blurX.width / engine.getRenderWidth();
  113895. blurX.kernel = _this[blurWidthKey] * dw;
  113896. });
  113897. blurY.onActivateObservable.add(function () {
  113898. var dw = blurY.height / engine.getRenderHeight();
  113899. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  113900. });
  113901. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  113902. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  113903. this.blurHPostProcesses.push(blurX);
  113904. this.blurVPostProcesses.push(blurY);
  113905. };
  113906. // Create texture adder post-process
  113907. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  113908. var _this = this;
  113909. 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);
  113910. this.textureAdderPostProcess.onApply = function (effect) {
  113911. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  113912. effect.setTexture("lensSampler", _this.lensTexture);
  113913. effect.setFloat("exposure", _this.exposure);
  113914. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  113915. };
  113916. // Add to pipeline
  113917. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  113918. };
  113919. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  113920. var _this = this;
  113921. var geometryRenderer = scene.enableGeometryBufferRenderer();
  113922. geometryRenderer.enablePosition = true;
  113923. var geometry = geometryRenderer.getGBuffer();
  113924. // Base post-process
  113925. 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));
  113926. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  113927. this.volumetricLightPostProcess.onApply = function (effect) {
  113928. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  113929. var generator = _this.sourceLight.getShadowGenerator();
  113930. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  113931. effect.setTexture("positionSampler", geometry.textures[2]);
  113932. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  113933. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  113934. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  113935. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  113936. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  113937. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  113938. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  113939. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  113940. effect.setVector2("depthValues", depthValues);
  113941. }
  113942. };
  113943. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  113944. // Smooth
  113945. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  113946. // Merge
  113947. 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");
  113948. this.volumetricLightMergePostProces.onApply = function (effect) {
  113949. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  113950. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  113951. };
  113952. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  113953. };
  113954. // Create luminance
  113955. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  113956. var _this = this;
  113957. // Create luminance
  113958. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  113959. 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);
  113960. var offsets = [];
  113961. this.luminancePostProcess.onApply = function (effect) {
  113962. var sU = (1.0 / _this.luminancePostProcess.width);
  113963. var sV = (1.0 / _this.luminancePostProcess.height);
  113964. offsets[0] = -0.5 * sU;
  113965. offsets[1] = 0.5 * sV;
  113966. offsets[2] = 0.5 * sU;
  113967. offsets[3] = 0.5 * sV;
  113968. offsets[4] = -0.5 * sU;
  113969. offsets[5] = -0.5 * sV;
  113970. offsets[6] = 0.5 * sU;
  113971. offsets[7] = -0.5 * sV;
  113972. effect.setArray2("lumOffsets", offsets);
  113973. };
  113974. // Add to pipeline
  113975. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  113976. // Create down sample luminance
  113977. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  113978. var size = Math.pow(3, i);
  113979. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  113980. if (i === 0) {
  113981. defines += "#define FINAL_DOWN_SAMPLER";
  113982. }
  113983. 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);
  113984. this.luminanceDownSamplePostProcesses.push(postProcess);
  113985. }
  113986. // Create callbacks and add effects
  113987. var lastLuminance = this.luminancePostProcess;
  113988. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  113989. var downSampleOffsets = new Array(18);
  113990. pp.onApply = function (effect) {
  113991. if (!lastLuminance) {
  113992. return;
  113993. }
  113994. var id = 0;
  113995. for (var x = -1; x < 2; x++) {
  113996. for (var y = -1; y < 2; y++) {
  113997. downSampleOffsets[id] = x / lastLuminance.width;
  113998. downSampleOffsets[id + 1] = y / lastLuminance.height;
  113999. id += 2;
  114000. }
  114001. }
  114002. effect.setArray2("dsOffsets", downSampleOffsets);
  114003. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  114004. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114005. lastLuminance = _this.luminancePostProcess;
  114006. }
  114007. else {
  114008. lastLuminance = pp;
  114009. }
  114010. };
  114011. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114012. pp.onAfterRender = function () {
  114013. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  114014. 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);
  114015. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  114016. };
  114017. }
  114018. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  114019. });
  114020. };
  114021. // Create HDR post-process
  114022. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  114023. var _this = this;
  114024. 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);
  114025. var outputLiminance = 1;
  114026. var time = 0;
  114027. var lastTime = 0;
  114028. this.hdrPostProcess.onApply = function (effect) {
  114029. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  114030. time += scene.getEngine().getDeltaTime();
  114031. if (outputLiminance < 0) {
  114032. outputLiminance = _this._hdrCurrentLuminance;
  114033. }
  114034. else {
  114035. var dt = (lastTime - time) / 1000.0;
  114036. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  114037. outputLiminance += _this.hdrDecreaseRate * dt;
  114038. }
  114039. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  114040. outputLiminance -= _this.hdrIncreaseRate * dt;
  114041. }
  114042. else {
  114043. outputLiminance = _this._hdrCurrentLuminance;
  114044. }
  114045. }
  114046. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  114047. effect.setFloat("averageLuminance", outputLiminance);
  114048. lastTime = time;
  114049. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  114050. };
  114051. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  114052. };
  114053. // Create lens flare post-process
  114054. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  114055. var _this = this;
  114056. 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);
  114057. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  114058. this._createBlurPostProcesses(scene, ratio / 4, 2);
  114059. 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);
  114060. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  114061. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  114062. // Lens flare
  114063. this.lensFlarePostProcess.onApply = function (effect) {
  114064. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  114065. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  114066. effect.setFloat("strength", _this.lensFlareStrength);
  114067. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  114068. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  114069. // Shift
  114070. resolution.x = _this.lensFlarePostProcess.width;
  114071. resolution.y = _this.lensFlarePostProcess.height;
  114072. effect.setVector2("resolution", resolution);
  114073. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  114074. };
  114075. // Compose
  114076. 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);
  114077. 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);
  114078. this.lensFlareComposePostProcess.onApply = function (effect) {
  114079. if (!_this._scene.activeCamera) {
  114080. return;
  114081. }
  114082. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114083. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  114084. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  114085. // Lens start rotation matrix
  114086. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  114087. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  114088. 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));
  114089. camRot *= 4.0;
  114090. 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);
  114091. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  114092. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  114093. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  114094. };
  114095. };
  114096. // Create depth-of-field post-process
  114097. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  114098. var _this = this;
  114099. 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);
  114100. this.depthOfFieldPostProcess.onApply = function (effect) {
  114101. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114102. effect.setTexture("depthSampler", _this._getDepthTexture());
  114103. effect.setFloat("distance", _this.depthOfFieldDistance);
  114104. };
  114105. // Add to pipeline
  114106. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  114107. };
  114108. // Create motion blur post-process
  114109. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  114110. var _this = this;
  114111. 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);
  114112. var motionScale = 0;
  114113. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114114. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114115. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114116. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114117. this.motionBlurPostProcess.onApply = function (effect) {
  114118. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  114119. viewProjection.invertToRef(invViewProjection);
  114120. effect.setMatrix("inverseViewProjection", invViewProjection);
  114121. effect.setMatrix("prevViewProjection", prevViewProjection);
  114122. prevViewProjection = viewProjection;
  114123. screenSize.x = _this.motionBlurPostProcess.width;
  114124. screenSize.y = _this.motionBlurPostProcess.height;
  114125. effect.setVector2("screenSize", screenSize);
  114126. motionScale = scene.getEngine().getFps() / 60.0;
  114127. effect.setFloat("motionScale", motionScale);
  114128. effect.setFloat("motionStrength", _this.motionStrength);
  114129. effect.setTexture("depthSampler", _this._getDepthTexture());
  114130. };
  114131. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  114132. };
  114133. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  114134. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  114135. var renderer = this._scene.enableGeometryBufferRenderer();
  114136. return renderer.getGBuffer().textures[0];
  114137. }
  114138. return this._scene.enableDepthRenderer().getDepthMap();
  114139. };
  114140. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  114141. for (var i = 0; i < this._cameras.length; i++) {
  114142. var camera = this._cameras[i];
  114143. if (this.originalPostProcess) {
  114144. this.originalPostProcess.dispose(camera);
  114145. }
  114146. if (this.downSampleX4PostProcess) {
  114147. this.downSampleX4PostProcess.dispose(camera);
  114148. }
  114149. if (this.brightPassPostProcess) {
  114150. this.brightPassPostProcess.dispose(camera);
  114151. }
  114152. if (this.textureAdderPostProcess) {
  114153. this.textureAdderPostProcess.dispose(camera);
  114154. }
  114155. if (this.textureAdderFinalPostProcess) {
  114156. this.textureAdderFinalPostProcess.dispose(camera);
  114157. }
  114158. if (this.volumetricLightPostProcess) {
  114159. this.volumetricLightPostProcess.dispose(camera);
  114160. }
  114161. if (this.volumetricLightSmoothXPostProcess) {
  114162. this.volumetricLightSmoothXPostProcess.dispose(camera);
  114163. }
  114164. if (this.volumetricLightSmoothYPostProcess) {
  114165. this.volumetricLightSmoothYPostProcess.dispose(camera);
  114166. }
  114167. if (this.volumetricLightMergePostProces) {
  114168. this.volumetricLightMergePostProces.dispose(camera);
  114169. }
  114170. if (this.volumetricLightFinalPostProcess) {
  114171. this.volumetricLightFinalPostProcess.dispose(camera);
  114172. }
  114173. if (this.lensFlarePostProcess) {
  114174. this.lensFlarePostProcess.dispose(camera);
  114175. }
  114176. if (this.lensFlareComposePostProcess) {
  114177. this.lensFlareComposePostProcess.dispose(camera);
  114178. }
  114179. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  114180. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  114181. }
  114182. if (this.luminancePostProcess) {
  114183. this.luminancePostProcess.dispose(camera);
  114184. }
  114185. if (this.hdrPostProcess) {
  114186. this.hdrPostProcess.dispose(camera);
  114187. }
  114188. if (this.hdrFinalPostProcess) {
  114189. this.hdrFinalPostProcess.dispose(camera);
  114190. }
  114191. if (this.depthOfFieldPostProcess) {
  114192. this.depthOfFieldPostProcess.dispose(camera);
  114193. }
  114194. if (this.motionBlurPostProcess) {
  114195. this.motionBlurPostProcess.dispose(camera);
  114196. }
  114197. if (this.fxaaPostProcess) {
  114198. this.fxaaPostProcess.dispose(camera);
  114199. }
  114200. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  114201. this.blurHPostProcesses[j].dispose(camera);
  114202. }
  114203. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  114204. this.blurVPostProcesses[j].dispose(camera);
  114205. }
  114206. }
  114207. this.originalPostProcess = null;
  114208. this.downSampleX4PostProcess = null;
  114209. this.brightPassPostProcess = null;
  114210. this.textureAdderPostProcess = null;
  114211. this.textureAdderFinalPostProcess = null;
  114212. this.volumetricLightPostProcess = null;
  114213. this.volumetricLightSmoothXPostProcess = null;
  114214. this.volumetricLightSmoothYPostProcess = null;
  114215. this.volumetricLightMergePostProces = null;
  114216. this.volumetricLightFinalPostProcess = null;
  114217. this.lensFlarePostProcess = null;
  114218. this.lensFlareComposePostProcess = null;
  114219. this.luminancePostProcess = null;
  114220. this.hdrPostProcess = null;
  114221. this.hdrFinalPostProcess = null;
  114222. this.depthOfFieldPostProcess = null;
  114223. this.motionBlurPostProcess = null;
  114224. this.fxaaPostProcess = null;
  114225. this.luminanceDownSamplePostProcesses = [];
  114226. this.blurHPostProcesses = [];
  114227. this.blurVPostProcesses = [];
  114228. };
  114229. /**
  114230. * Dispose of the pipeline and stop all post processes
  114231. */
  114232. StandardRenderingPipeline.prototype.dispose = function () {
  114233. this._disposePostProcesses();
  114234. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  114235. _super.prototype.dispose.call(this);
  114236. };
  114237. /**
  114238. * Serialize the rendering pipeline (Used when exporting)
  114239. * @returns the serialized object
  114240. */
  114241. StandardRenderingPipeline.prototype.serialize = function () {
  114242. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  114243. if (this.sourceLight) {
  114244. serializationObject.sourceLightId = this.sourceLight.id;
  114245. }
  114246. serializationObject.customType = "StandardRenderingPipeline";
  114247. return serializationObject;
  114248. };
  114249. /**
  114250. * Parse the serialized pipeline
  114251. * @param source Source pipeline.
  114252. * @param scene The scene to load the pipeline to.
  114253. * @param rootUrl The URL of the serialized pipeline.
  114254. * @returns An instantiated pipeline from the serialized object.
  114255. */
  114256. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  114257. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114258. if (source.sourceLightId) {
  114259. p.sourceLight = scene.getLightByID(source.sourceLightId);
  114260. }
  114261. return p;
  114262. };
  114263. /**
  114264. * Luminance steps
  114265. */
  114266. StandardRenderingPipeline.LuminanceSteps = 6;
  114267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114269. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  114270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114272. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  114273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114275. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  114276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114278. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  114279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  114281. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  114282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114284. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  114285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114287. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  114288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114290. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  114291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114293. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  114294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114296. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  114297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114299. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  114300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  114302. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  114303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114305. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  114306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114308. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  114309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114311. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  114312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114314. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  114315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  114317. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  114318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  114320. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  114321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114323. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  114324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114326. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  114327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114329. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  114330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114332. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  114333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114335. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  114336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114338. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  114339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114341. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  114342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114344. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  114345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114347. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  114348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114350. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  114351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114353. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  114354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114356. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  114357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114359. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  114360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114362. ], StandardRenderingPipeline.prototype, "samples", null);
  114363. return StandardRenderingPipeline;
  114364. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114365. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  114366. /***/ }),
  114367. /***/ "./PostProcesses/RenderPipeline/index.ts":
  114368. /*!***********************************************!*\
  114369. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  114370. \***********************************************/
  114371. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  114372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114373. "use strict";
  114374. __webpack_require__.r(__webpack_exports__);
  114375. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  114376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  114377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  114378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  114379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  114380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  114381. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  114383. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  114385. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  114386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  114387. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  114388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  114389. /***/ }),
  114390. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  114391. /*!*****************************************************************!*\
  114392. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  114393. \*****************************************************************/
  114394. /*! exports provided: PostProcessRenderEffect */
  114395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114396. "use strict";
  114397. __webpack_require__.r(__webpack_exports__);
  114398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  114399. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114400. /**
  114401. * This represents a set of one or more post processes in Babylon.
  114402. * A post process can be used to apply a shader to a texture after it is rendered.
  114403. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114404. */
  114405. var PostProcessRenderEffect = /** @class */ (function () {
  114406. /**
  114407. * Instantiates a post process render effect.
  114408. * A post process can be used to apply a shader to a texture after it is rendered.
  114409. * @param engine The engine the effect is tied to
  114410. * @param name The name of the effect
  114411. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  114412. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  114413. */
  114414. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  114415. this._name = name;
  114416. this._singleInstance = singleInstance || true;
  114417. this._getPostProcesses = getPostProcesses;
  114418. this._cameras = {};
  114419. this._indicesForCamera = {};
  114420. this._postProcesses = {};
  114421. }
  114422. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  114423. /**
  114424. * Checks if all the post processes in the effect are supported.
  114425. */
  114426. get: function () {
  114427. for (var index in this._postProcesses) {
  114428. if (this._postProcesses.hasOwnProperty(index)) {
  114429. var pps = this._postProcesses[index];
  114430. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  114431. if (!pps[ppIndex].isSupported) {
  114432. return false;
  114433. }
  114434. }
  114435. }
  114436. }
  114437. return true;
  114438. },
  114439. enumerable: true,
  114440. configurable: true
  114441. });
  114442. /**
  114443. * Updates the current state of the effect
  114444. * @hidden
  114445. */
  114446. PostProcessRenderEffect.prototype._update = function () {
  114447. };
  114448. /**
  114449. * Attaches the effect on cameras
  114450. * @param cameras The camera to attach to.
  114451. * @hidden
  114452. */
  114453. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  114454. var _this = this;
  114455. var cameraKey;
  114456. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114457. if (!cams) {
  114458. return;
  114459. }
  114460. for (var i = 0; i < cams.length; i++) {
  114461. var camera = cams[i];
  114462. var cameraName = camera.name;
  114463. if (this._singleInstance) {
  114464. cameraKey = 0;
  114465. }
  114466. else {
  114467. cameraKey = cameraName;
  114468. }
  114469. if (!this._postProcesses[cameraKey]) {
  114470. var postProcess = this._getPostProcesses();
  114471. if (postProcess) {
  114472. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  114473. }
  114474. }
  114475. if (!this._indicesForCamera[cameraName]) {
  114476. this._indicesForCamera[cameraName] = [];
  114477. }
  114478. this._postProcesses[cameraKey].forEach(function (postProcess) {
  114479. var index = camera.attachPostProcess(postProcess);
  114480. _this._indicesForCamera[cameraName].push(index);
  114481. });
  114482. if (!this._cameras[cameraName]) {
  114483. this._cameras[cameraName] = camera;
  114484. }
  114485. }
  114486. };
  114487. /**
  114488. * Detatches the effect on cameras
  114489. * @param cameras The camera to detatch from.
  114490. * @hidden
  114491. */
  114492. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  114493. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114494. if (!cams) {
  114495. return;
  114496. }
  114497. for (var i = 0; i < cams.length; i++) {
  114498. var camera = cams[i];
  114499. var cameraName = camera.name;
  114500. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  114501. if (postProcesses) {
  114502. postProcesses.forEach(function (postProcess) {
  114503. camera.detachPostProcess(postProcess);
  114504. });
  114505. }
  114506. if (this._cameras[cameraName]) {
  114507. this._cameras[cameraName] = null;
  114508. }
  114509. }
  114510. };
  114511. /**
  114512. * Enables the effect on given cameras
  114513. * @param cameras The camera to enable.
  114514. * @hidden
  114515. */
  114516. PostProcessRenderEffect.prototype._enable = function (cameras) {
  114517. var _this = this;
  114518. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114519. if (!cams) {
  114520. return;
  114521. }
  114522. for (var i = 0; i < cams.length; i++) {
  114523. var camera = cams[i];
  114524. var cameraName = camera.name;
  114525. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  114526. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  114527. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114528. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  114529. });
  114530. }
  114531. }
  114532. }
  114533. };
  114534. /**
  114535. * Disables the effect on the given cameras
  114536. * @param cameras The camera to disable.
  114537. * @hidden
  114538. */
  114539. PostProcessRenderEffect.prototype._disable = function (cameras) {
  114540. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114541. if (!cams) {
  114542. return;
  114543. }
  114544. for (var i = 0; i < cams.length; i++) {
  114545. var camera = cams[i];
  114546. var cameraName = camera.name;
  114547. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114548. camera.detachPostProcess(postProcess);
  114549. });
  114550. }
  114551. };
  114552. /**
  114553. * Gets a list of the post processes contained in the effect.
  114554. * @param camera The camera to get the post processes on.
  114555. * @returns The list of the post processes in the effect.
  114556. */
  114557. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  114558. if (this._singleInstance) {
  114559. return this._postProcesses[0];
  114560. }
  114561. else {
  114562. if (!camera) {
  114563. return null;
  114564. }
  114565. return this._postProcesses[camera.name];
  114566. }
  114567. };
  114568. return PostProcessRenderEffect;
  114569. }());
  114570. /***/ }),
  114571. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  114572. /*!*******************************************************************!*\
  114573. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  114574. \*******************************************************************/
  114575. /*! exports provided: PostProcessRenderPipeline */
  114576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114577. "use strict";
  114578. __webpack_require__.r(__webpack_exports__);
  114579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  114580. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114581. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114582. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  114583. /**
  114584. * PostProcessRenderPipeline
  114585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114586. */
  114587. var PostProcessRenderPipeline = /** @class */ (function () {
  114588. /**
  114589. * Initializes a PostProcessRenderPipeline
  114590. * @param engine engine to add the pipeline to
  114591. * @param name name of the pipeline
  114592. */
  114593. function PostProcessRenderPipeline(engine, name) {
  114594. this.engine = engine;
  114595. this._name = name;
  114596. this._renderEffects = {};
  114597. this._renderEffectsForIsolatedPass = new Array();
  114598. this._cameras = [];
  114599. }
  114600. /**
  114601. * "PostProcessRenderPipeline"
  114602. * @returns "PostProcessRenderPipeline"
  114603. */
  114604. PostProcessRenderPipeline.prototype.getClassName = function () {
  114605. return "PostProcessRenderPipeline";
  114606. };
  114607. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  114608. /**
  114609. * If all the render effects in the pipeline are support
  114610. */
  114611. get: function () {
  114612. for (var renderEffectName in this._renderEffects) {
  114613. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114614. if (!this._renderEffects[renderEffectName].isSupported) {
  114615. return false;
  114616. }
  114617. }
  114618. }
  114619. return true;
  114620. },
  114621. enumerable: true,
  114622. configurable: true
  114623. });
  114624. /**
  114625. * Adds an effect to the pipeline
  114626. * @param renderEffect the effect to add
  114627. */
  114628. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  114629. this._renderEffects[renderEffect._name] = renderEffect;
  114630. };
  114631. // private
  114632. /** @hidden */
  114633. PostProcessRenderPipeline.prototype._rebuild = function () {
  114634. };
  114635. /** @hidden */
  114636. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  114637. var renderEffects = this._renderEffects[renderEffectName];
  114638. if (!renderEffects) {
  114639. return;
  114640. }
  114641. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114642. };
  114643. /** @hidden */
  114644. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  114645. var renderEffects = this._renderEffects[renderEffectName];
  114646. if (!renderEffects) {
  114647. return;
  114648. }
  114649. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114650. };
  114651. /** @hidden */
  114652. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  114653. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  114654. if (!cams) {
  114655. return;
  114656. }
  114657. var indicesToDelete = [];
  114658. var i;
  114659. for (i = 0; i < cams.length; i++) {
  114660. var camera = cams[i];
  114661. var cameraName = camera.name;
  114662. if (this._cameras.indexOf(camera) === -1) {
  114663. this._cameras[cameraName] = camera;
  114664. }
  114665. else if (unique) {
  114666. indicesToDelete.push(i);
  114667. }
  114668. }
  114669. for (i = 0; i < indicesToDelete.length; i++) {
  114670. cameras.splice(indicesToDelete[i], 1);
  114671. }
  114672. for (var renderEffectName in this._renderEffects) {
  114673. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114674. this._renderEffects[renderEffectName]._attachCameras(cams);
  114675. }
  114676. }
  114677. };
  114678. /** @hidden */
  114679. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  114680. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  114681. if (!cams) {
  114682. return;
  114683. }
  114684. for (var renderEffectName in this._renderEffects) {
  114685. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114686. this._renderEffects[renderEffectName]._detachCameras(cams);
  114687. }
  114688. }
  114689. for (var i = 0; i < cams.length; i++) {
  114690. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  114691. }
  114692. };
  114693. /** @hidden */
  114694. PostProcessRenderPipeline.prototype._update = function () {
  114695. for (var renderEffectName in this._renderEffects) {
  114696. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114697. this._renderEffects[renderEffectName]._update();
  114698. }
  114699. }
  114700. for (var i = 0; i < this._cameras.length; i++) {
  114701. var cameraName = this._cameras[i].name;
  114702. if (this._renderEffectsForIsolatedPass[cameraName]) {
  114703. this._renderEffectsForIsolatedPass[cameraName]._update();
  114704. }
  114705. }
  114706. };
  114707. /** @hidden */
  114708. PostProcessRenderPipeline.prototype._reset = function () {
  114709. this._renderEffects = {};
  114710. this._renderEffectsForIsolatedPass = new Array();
  114711. };
  114712. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  114713. // 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)
  114714. var effectKeys = Object.keys(this._renderEffects);
  114715. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  114716. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  114717. if (postProcesses) {
  114718. postProcesses[0].samples = sampleCount;
  114719. return true;
  114720. }
  114721. }
  114722. return false;
  114723. };
  114724. /**
  114725. * Disposes of the pipeline
  114726. */
  114727. PostProcessRenderPipeline.prototype.dispose = function () {
  114728. // Must be implemented by children
  114729. };
  114730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114732. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  114733. return PostProcessRenderPipeline;
  114734. }());
  114735. /***/ }),
  114736. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  114737. /*!**************************************************************************!*\
  114738. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  114739. \**************************************************************************/
  114740. /*! exports provided: PostProcessRenderPipelineManager */
  114741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114742. "use strict";
  114743. __webpack_require__.r(__webpack_exports__);
  114744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  114745. /**
  114746. * PostProcessRenderPipelineManager class
  114747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114748. */
  114749. var PostProcessRenderPipelineManager = /** @class */ (function () {
  114750. /**
  114751. * Initializes a PostProcessRenderPipelineManager
  114752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114753. */
  114754. function PostProcessRenderPipelineManager() {
  114755. this._renderPipelines = {};
  114756. }
  114757. /**
  114758. * Adds a pipeline to the manager
  114759. * @param renderPipeline The pipeline to add
  114760. */
  114761. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  114762. this._renderPipelines[renderPipeline._name] = renderPipeline;
  114763. };
  114764. /**
  114765. * Attaches a camera to the pipeline
  114766. * @param renderPipelineName The name of the pipeline to attach to
  114767. * @param cameras the camera to attach
  114768. * @param unique if the camera can be attached multiple times to the pipeline
  114769. */
  114770. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  114771. if (unique === void 0) { unique = false; }
  114772. var renderPipeline = this._renderPipelines[renderPipelineName];
  114773. if (!renderPipeline) {
  114774. return;
  114775. }
  114776. renderPipeline._attachCameras(cameras, unique);
  114777. };
  114778. /**
  114779. * Detaches a camera from the pipeline
  114780. * @param renderPipelineName The name of the pipeline to detach from
  114781. * @param cameras the camera to detach
  114782. */
  114783. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  114784. var renderPipeline = this._renderPipelines[renderPipelineName];
  114785. if (!renderPipeline) {
  114786. return;
  114787. }
  114788. renderPipeline._detachCameras(cameras);
  114789. };
  114790. /**
  114791. * Enables an effect by name on a pipeline
  114792. * @param renderPipelineName the name of the pipeline to enable the effect in
  114793. * @param renderEffectName the name of the effect to enable
  114794. * @param cameras the cameras that the effect should be enabled on
  114795. */
  114796. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  114797. var renderPipeline = this._renderPipelines[renderPipelineName];
  114798. if (!renderPipeline) {
  114799. return;
  114800. }
  114801. renderPipeline._enableEffect(renderEffectName, cameras);
  114802. };
  114803. /**
  114804. * Disables an effect by name on a pipeline
  114805. * @param renderPipelineName the name of the pipeline to disable the effect in
  114806. * @param renderEffectName the name of the effect to disable
  114807. * @param cameras the cameras that the effect should be disabled on
  114808. */
  114809. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  114810. var renderPipeline = this._renderPipelines[renderPipelineName];
  114811. if (!renderPipeline) {
  114812. return;
  114813. }
  114814. renderPipeline._disableEffect(renderEffectName, cameras);
  114815. };
  114816. /**
  114817. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  114818. */
  114819. PostProcessRenderPipelineManager.prototype.update = function () {
  114820. for (var renderPipelineName in this._renderPipelines) {
  114821. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  114822. var pipeline = this._renderPipelines[renderPipelineName];
  114823. if (!pipeline.isSupported) {
  114824. pipeline.dispose();
  114825. delete this._renderPipelines[renderPipelineName];
  114826. }
  114827. else {
  114828. pipeline._update();
  114829. }
  114830. }
  114831. }
  114832. };
  114833. /** @hidden */
  114834. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  114835. for (var renderPipelineName in this._renderPipelines) {
  114836. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  114837. var pipeline = this._renderPipelines[renderPipelineName];
  114838. pipeline._rebuild();
  114839. }
  114840. }
  114841. };
  114842. /**
  114843. * Disposes of the manager and pipelines
  114844. */
  114845. PostProcessRenderPipelineManager.prototype.dispose = function () {
  114846. for (var renderPipelineName in this._renderPipelines) {
  114847. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  114848. var pipeline = this._renderPipelines[renderPipelineName];
  114849. pipeline.dispose();
  114850. }
  114851. }
  114852. };
  114853. return PostProcessRenderPipelineManager;
  114854. }());
  114855. /***/ }),
  114856. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  114857. /*!****************************************************************************************!*\
  114858. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  114859. \****************************************************************************************/
  114860. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  114861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114862. "use strict";
  114863. __webpack_require__.r(__webpack_exports__);
  114864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  114865. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  114866. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  114867. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  114868. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  114869. get: function () {
  114870. if (!this._postProcessRenderPipelineManager) {
  114871. // Register the G Buffer component to the scene.
  114872. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  114873. if (!component) {
  114874. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  114875. this._addComponent(component);
  114876. }
  114877. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  114878. }
  114879. return this._postProcessRenderPipelineManager;
  114880. },
  114881. enumerable: true,
  114882. configurable: true
  114883. });
  114884. /**
  114885. * Defines the Render Pipeline scene component responsible to rendering pipelines
  114886. */
  114887. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  114888. /**
  114889. * Creates a new instance of the component for the given scene
  114890. * @param scene Defines the scene to register the component in
  114891. */
  114892. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  114893. /**
  114894. * The component name helpfull to identify the component in the list of scene components.
  114895. */
  114896. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  114897. this.scene = scene;
  114898. }
  114899. /**
  114900. * Registers the component in a given scene
  114901. */
  114902. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  114903. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  114904. };
  114905. /**
  114906. * Rebuilds the elements related to this component in case of
  114907. * context lost for instance.
  114908. */
  114909. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  114910. if (this.scene._postProcessRenderPipelineManager) {
  114911. this.scene._postProcessRenderPipelineManager._rebuild();
  114912. }
  114913. };
  114914. /**
  114915. * Disposes the component and the associated ressources
  114916. */
  114917. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  114918. if (this.scene._postProcessRenderPipelineManager) {
  114919. this.scene._postProcessRenderPipelineManager.dispose();
  114920. }
  114921. };
  114922. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  114923. if (this.scene._postProcessRenderPipelineManager) {
  114924. this.scene._postProcessRenderPipelineManager.update();
  114925. }
  114926. };
  114927. return PostProcessRenderPipelineManagerSceneComponent;
  114928. }());
  114929. /***/ }),
  114930. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  114931. /*!**********************************************!*\
  114932. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  114933. \**********************************************/
  114934. /*! exports provided: AnaglyphPostProcess */
  114935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114936. "use strict";
  114937. __webpack_require__.r(__webpack_exports__);
  114938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  114939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114940. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  114941. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  114942. /**
  114943. * Postprocess used to generate anaglyphic rendering
  114944. */
  114945. var AnaglyphPostProcess = /** @class */ (function (_super) {
  114946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  114947. /**
  114948. * Creates a new AnaglyphPostProcess
  114949. * @param name defines postprocess name
  114950. * @param options defines creation options or target ratio scale
  114951. * @param rigCameras defines cameras using this postprocess
  114952. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114953. * @param engine defines hosting engine
  114954. * @param reusable defines if the postprocess will be reused multiple times per frame
  114955. */
  114956. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  114957. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  114958. _this._passedProcess = rigCameras[0]._rigPostProcess;
  114959. _this.onApplyObservable.add(function (effect) {
  114960. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  114961. });
  114962. return _this;
  114963. }
  114964. return AnaglyphPostProcess;
  114965. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  114966. /***/ }),
  114967. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  114968. /*!***************************************************!*\
  114969. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  114970. \***************************************************/
  114971. /*! exports provided: BlackAndWhitePostProcess */
  114972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114973. "use strict";
  114974. __webpack_require__.r(__webpack_exports__);
  114975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  114976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114977. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  114978. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  114979. /**
  114980. * Post process used to render in black and white
  114981. */
  114982. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  114983. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  114984. /**
  114985. * Creates a black and white post process
  114986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  114987. * @param name The name of the effect.
  114988. * @param options The required width/height ratio to downsize to before computing the render pass.
  114989. * @param camera The camera to apply the render pass to.
  114990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114991. * @param engine The engine which the post process will be applied. (default: current engine)
  114992. * @param reusable If the post process can be reused on the same frame. (default: false)
  114993. */
  114994. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  114995. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  114996. /**
  114997. * Linear about to convert he result to black and white (default: 1)
  114998. */
  114999. _this.degree = 1;
  115000. _this.onApplyObservable.add(function (effect) {
  115001. effect.setFloat("degree", _this.degree);
  115002. });
  115003. return _this;
  115004. }
  115005. return BlackAndWhitePostProcess;
  115006. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115007. /***/ }),
  115008. /***/ "./PostProcesses/bloomEffect.ts":
  115009. /*!**************************************!*\
  115010. !*** ./PostProcesses/bloomEffect.ts ***!
  115011. \**************************************/
  115012. /*! exports provided: BloomEffect */
  115013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115014. "use strict";
  115015. __webpack_require__.r(__webpack_exports__);
  115016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  115017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115018. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115019. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  115020. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115021. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  115022. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115023. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115024. /**
  115025. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  115026. */
  115027. var BloomEffect = /** @class */ (function (_super) {
  115028. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  115029. /**
  115030. * Creates a new instance of @see BloomEffect
  115031. * @param scene The scene the effect belongs to.
  115032. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  115033. * @param bloomKernel The size of the kernel to be used when applying the blur.
  115034. * @param bloomWeight The the strength of bloom.
  115035. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  115036. * @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)
  115037. */
  115038. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  115039. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  115040. if (blockCompilation === void 0) { blockCompilation = false; }
  115041. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  115042. return _this._effects;
  115043. }, true) || this;
  115044. _this.bloomScale = bloomScale;
  115045. /**
  115046. * @hidden Internal
  115047. */
  115048. _this._effects = [];
  115049. _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);
  115050. _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);
  115051. _this._blurX.alwaysForcePOT = true;
  115052. _this._blurX.autoClear = false;
  115053. _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);
  115054. _this._blurY.alwaysForcePOT = true;
  115055. _this._blurY.autoClear = false;
  115056. _this.kernel = bloomKernel;
  115057. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  115058. _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);
  115059. _this._merge.autoClear = false;
  115060. _this._effects.push(_this._merge);
  115061. return _this;
  115062. }
  115063. Object.defineProperty(BloomEffect.prototype, "threshold", {
  115064. /**
  115065. * The luminance threshold to find bright areas of the image to bloom.
  115066. */
  115067. get: function () {
  115068. return this._downscale.threshold;
  115069. },
  115070. set: function (value) {
  115071. this._downscale.threshold = value;
  115072. },
  115073. enumerable: true,
  115074. configurable: true
  115075. });
  115076. Object.defineProperty(BloomEffect.prototype, "weight", {
  115077. /**
  115078. * The strength of the bloom.
  115079. */
  115080. get: function () {
  115081. return this._merge.weight;
  115082. },
  115083. set: function (value) {
  115084. this._merge.weight = value;
  115085. },
  115086. enumerable: true,
  115087. configurable: true
  115088. });
  115089. Object.defineProperty(BloomEffect.prototype, "kernel", {
  115090. /**
  115091. * Specifies the size of the bloom blur kernel, relative to the final output size
  115092. */
  115093. get: function () {
  115094. return this._blurX.kernel / this.bloomScale;
  115095. },
  115096. set: function (value) {
  115097. this._blurX.kernel = value * this.bloomScale;
  115098. this._blurY.kernel = value * this.bloomScale;
  115099. },
  115100. enumerable: true,
  115101. configurable: true
  115102. });
  115103. /**
  115104. * Disposes each of the internal effects for a given camera.
  115105. * @param camera The camera to dispose the effect on.
  115106. */
  115107. BloomEffect.prototype.disposeEffects = function (camera) {
  115108. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115109. this._effects[effectIndex].dispose(camera);
  115110. }
  115111. };
  115112. /**
  115113. * @hidden Internal
  115114. */
  115115. BloomEffect.prototype._updateEffects = function () {
  115116. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115117. this._effects[effectIndex].updateEffect();
  115118. }
  115119. };
  115120. /**
  115121. * Internal
  115122. * @returns if all the contained post processes are ready.
  115123. * @hidden
  115124. */
  115125. BloomEffect.prototype._isReady = function () {
  115126. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115127. if (!this._effects[effectIndex].isReady()) {
  115128. return false;
  115129. }
  115130. }
  115131. return true;
  115132. };
  115133. return BloomEffect;
  115134. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  115135. /***/ }),
  115136. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  115137. /*!************************************************!*\
  115138. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  115139. \************************************************/
  115140. /*! exports provided: BloomMergePostProcess */
  115141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115142. "use strict";
  115143. __webpack_require__.r(__webpack_exports__);
  115144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  115145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115146. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115147. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115148. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  115149. /**
  115150. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  115151. */
  115152. var BloomMergePostProcess = /** @class */ (function (_super) {
  115153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  115154. /**
  115155. * Creates a new instance of @see BloomMergePostProcess
  115156. * @param name The name of the effect.
  115157. * @param originalFromInput Post process which's input will be used for the merge.
  115158. * @param blurred Blurred highlights post process which's output will be used.
  115159. * @param weight Weight of the bloom to be added to the original input.
  115160. * @param options The required width/height ratio to downsize to before computing the render pass.
  115161. * @param camera The camera to apply the render pass to.
  115162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115163. * @param engine The engine which the post process will be applied. (default: current engine)
  115164. * @param reusable If the post process can be reused on the same frame. (default: false)
  115165. * @param textureType Type of textures used when performing the post process. (default: 0)
  115166. * @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)
  115167. */
  115168. function BloomMergePostProcess(name, originalFromInput, blurred,
  115169. /** Weight of the bloom to be added to the original input. */
  115170. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115171. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115172. if (blockCompilation === void 0) { blockCompilation = false; }
  115173. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  115174. _this.weight = weight;
  115175. _this.onApplyObservable.add(function (effect) {
  115176. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  115177. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  115178. effect.setFloat("bloomWeight", _this.weight);
  115179. });
  115180. if (!blockCompilation) {
  115181. _this.updateEffect();
  115182. }
  115183. return _this;
  115184. }
  115185. return BloomMergePostProcess;
  115186. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115187. /***/ }),
  115188. /***/ "./PostProcesses/blurPostProcess.ts":
  115189. /*!******************************************!*\
  115190. !*** ./PostProcesses/blurPostProcess.ts ***!
  115191. \******************************************/
  115192. /*! exports provided: BlurPostProcess */
  115193. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115194. "use strict";
  115195. __webpack_require__.r(__webpack_exports__);
  115196. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  115197. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115198. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115199. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115200. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115201. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  115202. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  115203. /**
  115204. * The Blur Post Process which blurs an image based on a kernel and direction.
  115205. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  115206. */
  115207. var BlurPostProcess = /** @class */ (function (_super) {
  115208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  115209. /**
  115210. * Creates a new instance BlurPostProcess
  115211. * @param name The name of the effect.
  115212. * @param direction The direction in which to blur the image.
  115213. * @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.
  115214. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  115215. * @param camera The camera to apply the render pass to.
  115216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115217. * @param engine The engine which the post process will be applied. (default: current engine)
  115218. * @param reusable If the post process can be reused on the same frame. (default: false)
  115219. * @param textureType Type of textures used when performing the post process. (default: 0)
  115220. * @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)
  115221. */
  115222. function BlurPostProcess(name,
  115223. /** The direction in which to blur the image. */
  115224. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  115225. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  115226. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115227. if (defines === void 0) { defines = ""; }
  115228. if (blockCompilation === void 0) { blockCompilation = false; }
  115229. 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;
  115230. _this.direction = direction;
  115231. _this.blockCompilation = blockCompilation;
  115232. _this._packedFloat = false;
  115233. _this._staticDefines = "";
  115234. _this._staticDefines = defines;
  115235. _this.onApplyObservable.add(function (effect) {
  115236. if (_this._outputTexture) {
  115237. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  115238. }
  115239. else {
  115240. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  115241. }
  115242. });
  115243. _this.kernel = kernel;
  115244. return _this;
  115245. }
  115246. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  115247. /**
  115248. * Gets the length in pixels of the blur sample region
  115249. */
  115250. get: function () {
  115251. return this._idealKernel;
  115252. },
  115253. /**
  115254. * Sets the length in pixels of the blur sample region
  115255. */
  115256. set: function (v) {
  115257. if (this._idealKernel === v) {
  115258. return;
  115259. }
  115260. v = Math.max(v, 1);
  115261. this._idealKernel = v;
  115262. this._kernel = this._nearestBestKernel(v);
  115263. if (!this.blockCompilation) {
  115264. this._updateParameters();
  115265. }
  115266. },
  115267. enumerable: true,
  115268. configurable: true
  115269. });
  115270. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  115271. /**
  115272. * Gets wether or not the blur is unpacking/repacking floats
  115273. */
  115274. get: function () {
  115275. return this._packedFloat;
  115276. },
  115277. /**
  115278. * Sets wether or not the blur needs to unpack/repack floats
  115279. */
  115280. set: function (v) {
  115281. if (this._packedFloat === v) {
  115282. return;
  115283. }
  115284. this._packedFloat = v;
  115285. if (!this.blockCompilation) {
  115286. this._updateParameters();
  115287. }
  115288. },
  115289. enumerable: true,
  115290. configurable: true
  115291. });
  115292. /**
  115293. * Updates the effect with the current post process compile time values and recompiles the shader.
  115294. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  115295. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  115296. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  115297. * @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
  115298. * @param onCompiled Called when the shader has been compiled.
  115299. * @param onError Called if there is an error when compiling a shader.
  115300. */
  115301. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  115302. if (defines === void 0) { defines = null; }
  115303. if (uniforms === void 0) { uniforms = null; }
  115304. if (samplers === void 0) { samplers = null; }
  115305. this._updateParameters(onCompiled, onError);
  115306. };
  115307. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  115308. // Generate sampling offsets and weights
  115309. var N = this._kernel;
  115310. var centerIndex = (N - 1) / 2;
  115311. // Generate Gaussian sampling weights over kernel
  115312. var offsets = [];
  115313. var weights = [];
  115314. var totalWeight = 0;
  115315. for (var i = 0; i < N; i++) {
  115316. var u = i / (N - 1);
  115317. var w = this._gaussianWeight(u * 2.0 - 1);
  115318. offsets[i] = (i - centerIndex);
  115319. weights[i] = w;
  115320. totalWeight += w;
  115321. }
  115322. // Normalize weights
  115323. for (var i = 0; i < weights.length; i++) {
  115324. weights[i] /= totalWeight;
  115325. }
  115326. // Optimize: combine samples to take advantage of hardware linear sampling
  115327. // Walk from left to center, combining pairs (symmetrically)
  115328. var linearSamplingWeights = [];
  115329. var linearSamplingOffsets = [];
  115330. var linearSamplingMap = [];
  115331. for (var i = 0; i <= centerIndex; i += 2) {
  115332. var j = Math.min(i + 1, Math.floor(centerIndex));
  115333. var singleCenterSample = i === j;
  115334. if (singleCenterSample) {
  115335. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115336. }
  115337. else {
  115338. var sharedCell = j === centerIndex;
  115339. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  115340. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  115341. if (offsetLinear === 0) {
  115342. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115343. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  115344. }
  115345. else {
  115346. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  115347. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  115348. }
  115349. }
  115350. }
  115351. for (var i = 0; i < linearSamplingMap.length; i++) {
  115352. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  115353. linearSamplingWeights[i] = linearSamplingMap[i].w;
  115354. }
  115355. // Replace with optimized
  115356. offsets = linearSamplingOffsets;
  115357. weights = linearSamplingWeights;
  115358. // Generate shaders
  115359. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  115360. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  115361. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  115362. var defines = "";
  115363. defines += this._staticDefines;
  115364. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  115365. if (this._staticDefines.indexOf("DOF") != -1) {
  115366. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  115367. varyingCount--;
  115368. }
  115369. for (var i = 0; i < varyingCount; i++) {
  115370. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  115371. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  115372. }
  115373. var depCount = 0;
  115374. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  115375. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  115376. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  115377. depCount++;
  115378. }
  115379. if (this.packedFloat) {
  115380. defines += "#define PACKEDFLOAT 1";
  115381. }
  115382. this.blockCompilation = false;
  115383. _super.prototype.updateEffect.call(this, defines, null, null, {
  115384. varyingCount: varyingCount,
  115385. depCount: depCount
  115386. }, onCompiled, onError);
  115387. };
  115388. /**
  115389. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  115390. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  115391. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  115392. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  115393. * The gaps between physical kernels are compensated for in the weighting of the samples
  115394. * @param idealKernel Ideal blur kernel.
  115395. * @return Nearest best kernel.
  115396. */
  115397. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  115398. var v = Math.round(idealKernel);
  115399. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  115400. var k = _a[_i];
  115401. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  115402. return Math.max(k, 3);
  115403. }
  115404. }
  115405. return Math.max(v, 3);
  115406. };
  115407. /**
  115408. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  115409. * @param x The point on the Gaussian distribution to sample.
  115410. * @return the value of the Gaussian function at x.
  115411. */
  115412. BlurPostProcess.prototype._gaussianWeight = function (x) {
  115413. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  115414. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  115415. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  115416. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  115417. // truncated at around 1.3% of peak strength.
  115418. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  115419. var sigma = (1 / 3);
  115420. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  115421. var exponent = -((x * x) / (2.0 * sigma * sigma));
  115422. var weight = (1.0 / denominator) * Math.exp(exponent);
  115423. return weight;
  115424. };
  115425. /**
  115426. * Generates a string that can be used as a floating point number in GLSL.
  115427. * @param x Value to print.
  115428. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  115429. * @return GLSL float string.
  115430. */
  115431. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  115432. if (decimalFigures === void 0) { decimalFigures = 8; }
  115433. return x.toFixed(decimalFigures).replace(/0+$/, '');
  115434. };
  115435. return BlurPostProcess;
  115436. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115437. /***/ }),
  115438. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  115439. /*!*********************************************************!*\
  115440. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  115441. \*********************************************************/
  115442. /*! exports provided: ChromaticAberrationPostProcess */
  115443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115444. "use strict";
  115445. __webpack_require__.r(__webpack_exports__);
  115446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  115447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115448. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115449. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115450. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115451. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  115452. /**
  115453. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  115454. */
  115455. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  115456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  115457. /**
  115458. * Creates a new instance ChromaticAberrationPostProcess
  115459. * @param name The name of the effect.
  115460. * @param screenWidth The width of the screen to apply the effect on.
  115461. * @param screenHeight The height of the screen to apply the effect on.
  115462. * @param options The required width/height ratio to downsize to before computing the render pass.
  115463. * @param camera The camera to apply the render pass to.
  115464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115465. * @param engine The engine which the post process will be applied. (default: current engine)
  115466. * @param reusable If the post process can be reused on the same frame. (default: false)
  115467. * @param textureType Type of textures used when performing the post process. (default: 0)
  115468. * @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)
  115469. */
  115470. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115471. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115472. if (blockCompilation === void 0) { blockCompilation = false; }
  115473. 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;
  115474. /**
  115475. * The amount of seperation of rgb channels (default: 30)
  115476. */
  115477. _this.aberrationAmount = 30;
  115478. /**
  115479. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  115480. */
  115481. _this.radialIntensity = 0;
  115482. /**
  115483. * 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))
  115484. */
  115485. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  115486. /**
  115487. * 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))
  115488. */
  115489. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  115490. _this.onApplyObservable.add(function (effect) {
  115491. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  115492. effect.setFloat('screen_width', screenWidth);
  115493. effect.setFloat('screen_height', screenHeight);
  115494. effect.setFloat('radialIntensity', _this.radialIntensity);
  115495. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  115496. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  115497. });
  115498. return _this;
  115499. }
  115500. return ChromaticAberrationPostProcess;
  115501. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  115502. /***/ }),
  115503. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  115504. /*!*******************************************************!*\
  115505. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  115506. \*******************************************************/
  115507. /*! exports provided: CircleOfConfusionPostProcess */
  115508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115509. "use strict";
  115510. __webpack_require__.r(__webpack_exports__);
  115511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  115512. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115513. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115514. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115515. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115516. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  115517. /**
  115518. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  115519. */
  115520. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  115521. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  115522. /**
  115523. * Creates a new instance CircleOfConfusionPostProcess
  115524. * @param name The name of the effect.
  115525. * @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.
  115526. * @param options The required width/height ratio to downsize to before computing the render pass.
  115527. * @param camera The camera to apply the render pass to.
  115528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115529. * @param engine The engine which the post process will be applied. (default: current engine)
  115530. * @param reusable If the post process can be reused on the same frame. (default: false)
  115531. * @param textureType Type of textures used when performing the post process. (default: 0)
  115532. * @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)
  115533. */
  115534. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115535. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115536. if (blockCompilation === void 0) { blockCompilation = false; }
  115537. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  115538. /**
  115539. * 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.
  115540. */
  115541. _this.lensSize = 50;
  115542. /**
  115543. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  115544. */
  115545. _this.fStop = 1.4;
  115546. /**
  115547. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  115548. */
  115549. _this.focusDistance = 2000;
  115550. /**
  115551. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  115552. */
  115553. _this.focalLength = 50;
  115554. _this._depthTexture = null;
  115555. _this._depthTexture = depthTexture;
  115556. _this.onApplyObservable.add(function (effect) {
  115557. if (!_this._depthTexture) {
  115558. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  115559. return;
  115560. }
  115561. effect.setTexture("depthSampler", _this._depthTexture);
  115562. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  115563. var aperture = _this.lensSize / _this.fStop;
  115564. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  115565. effect.setFloat('focusDistance', _this.focusDistance);
  115566. effect.setFloat('cocPrecalculation', cocPrecalculation);
  115567. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  115568. });
  115569. return _this;
  115570. }
  115571. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  115572. /**
  115573. * 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.
  115574. */
  115575. set: function (value) {
  115576. this._depthTexture = value;
  115577. },
  115578. enumerable: true,
  115579. configurable: true
  115580. });
  115581. return CircleOfConfusionPostProcess;
  115582. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115583. /***/ }),
  115584. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  115585. /*!*****************************************************!*\
  115586. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  115587. \*****************************************************/
  115588. /*! exports provided: ColorCorrectionPostProcess */
  115589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115590. "use strict";
  115591. __webpack_require__.r(__webpack_exports__);
  115592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  115593. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115594. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115595. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115596. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  115597. /**
  115598. *
  115599. * This post-process allows the modification of rendered colors by using
  115600. * a 'look-up table' (LUT). This effect is also called Color Grading.
  115601. *
  115602. * The object needs to be provided an url to a texture containing the color
  115603. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  115604. * Use an image editing software to tweak the LUT to match your needs.
  115605. *
  115606. * For an example of a color LUT, see here:
  115607. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  115608. * For explanations on color grading, see here:
  115609. * @see http://udn.epicgames.com/Three/ColorGrading.html
  115610. *
  115611. */
  115612. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  115613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  115614. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  115615. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  115616. _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);
  115617. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  115618. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115619. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115620. _this.onApply = function (effect) {
  115621. effect.setTexture("colorTable", _this._colorTableTexture);
  115622. };
  115623. return _this;
  115624. }
  115625. return ColorCorrectionPostProcess;
  115626. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115627. /***/ }),
  115628. /***/ "./PostProcesses/convolutionPostProcess.ts":
  115629. /*!*************************************************!*\
  115630. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  115631. \*************************************************/
  115632. /*! exports provided: ConvolutionPostProcess */
  115633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115634. "use strict";
  115635. __webpack_require__.r(__webpack_exports__);
  115636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  115637. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115638. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115639. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115640. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  115641. /**
  115642. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  115643. * input texture to perform effects such as edge detection or sharpening
  115644. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  115645. */
  115646. var ConvolutionPostProcess = /** @class */ (function (_super) {
  115647. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  115648. /**
  115649. * Creates a new instance ConvolutionPostProcess
  115650. * @param name The name of the effect.
  115651. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  115652. * @param options The required width/height ratio to downsize to before computing the render pass.
  115653. * @param camera The camera to apply the render pass to.
  115654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115655. * @param engine The engine which the post process will be applied. (default: current engine)
  115656. * @param reusable If the post process can be reused on the same frame. (default: false)
  115657. * @param textureType Type of textures used when performing the post process. (default: 0)
  115658. */
  115659. function ConvolutionPostProcess(name,
  115660. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  115661. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  115662. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115663. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  115664. _this.kernel = kernel;
  115665. _this.onApply = function (effect) {
  115666. effect.setFloat2("screenSize", _this.width, _this.height);
  115667. effect.setArray("kernel", _this.kernel);
  115668. };
  115669. return _this;
  115670. }
  115671. // Statics
  115672. /**
  115673. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115674. */
  115675. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  115676. /**
  115677. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115678. */
  115679. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  115680. /**
  115681. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115682. */
  115683. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  115684. /**
  115685. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115686. */
  115687. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  115688. /**
  115689. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115690. */
  115691. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  115692. /**
  115693. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115694. */
  115695. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  115696. return ConvolutionPostProcess;
  115697. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115698. /***/ }),
  115699. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  115700. /*!******************************************************!*\
  115701. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  115702. \******************************************************/
  115703. /*! exports provided: DepthOfFieldBlurPostProcess */
  115704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115705. "use strict";
  115706. __webpack_require__.r(__webpack_exports__);
  115707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  115708. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115709. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115710. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115711. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115712. /**
  115713. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  115714. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  115715. * based on samples that have a large difference in distance than the center pixel.
  115716. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  115717. */
  115718. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  115719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  115720. /**
  115721. * Creates a new instance CircleOfConfusionPostProcess
  115722. * @param name The name of the effect.
  115723. * @param scene The scene the effect belongs to.
  115724. * @param direction The direction the blur should be applied.
  115725. * @param kernel The size of the kernel used to blur.
  115726. * @param options The required width/height ratio to downsize to before computing the render pass.
  115727. * @param camera The camera to apply the render pass to.
  115728. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  115729. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  115730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115731. * @param engine The engine which the post process will be applied. (default: current engine)
  115732. * @param reusable If the post process can be reused on the same frame. (default: false)
  115733. * @param textureType Type of textures used when performing the post process. (default: 0)
  115734. * @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)
  115735. */
  115736. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  115737. if (imageToBlur === void 0) { imageToBlur = null; }
  115738. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  115739. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115740. if (blockCompilation === void 0) { blockCompilation = false; }
  115741. 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;
  115742. _this.direction = direction;
  115743. _this.onApplyObservable.add(function (effect) {
  115744. if (imageToBlur != null) {
  115745. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  115746. }
  115747. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  115748. if (scene.activeCamera) {
  115749. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  115750. }
  115751. });
  115752. return _this;
  115753. }
  115754. return DepthOfFieldBlurPostProcess;
  115755. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  115756. /***/ }),
  115757. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  115758. /*!*********************************************!*\
  115759. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  115760. \*********************************************/
  115761. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  115762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115763. "use strict";
  115764. __webpack_require__.r(__webpack_exports__);
  115765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  115766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  115767. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115769. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115770. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115771. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  115772. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  115773. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  115774. /**
  115775. * Specifies the level of max blur that should be applied when using the depth of field effect
  115776. */
  115777. var DepthOfFieldEffectBlurLevel;
  115778. (function (DepthOfFieldEffectBlurLevel) {
  115779. /**
  115780. * Subtle blur
  115781. */
  115782. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  115783. /**
  115784. * Medium blur
  115785. */
  115786. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  115787. /**
  115788. * Large blur
  115789. */
  115790. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  115791. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  115792. /**
  115793. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  115794. */
  115795. var DepthOfFieldEffect = /** @class */ (function (_super) {
  115796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  115797. /**
  115798. * Creates a new instance DepthOfFieldEffect
  115799. * @param scene The scene the effect belongs to.
  115800. * @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.
  115801. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  115802. * @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)
  115803. */
  115804. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  115805. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  115806. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  115807. if (blockCompilation === void 0) { blockCompilation = false; }
  115808. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  115809. return _this._effects;
  115810. }, true) || this;
  115811. /**
  115812. * @hidden Internal post processes in depth of field effect
  115813. */
  115814. _this._effects = [];
  115815. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  115816. _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);
  115817. // 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)
  115818. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  115819. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  115820. _this._depthOfFieldBlurY = [];
  115821. _this._depthOfFieldBlurX = [];
  115822. var blurCount = 1;
  115823. var kernelSize = 15;
  115824. switch (blurLevel) {
  115825. case DepthOfFieldEffectBlurLevel.High: {
  115826. blurCount = 3;
  115827. kernelSize = 51;
  115828. break;
  115829. }
  115830. case DepthOfFieldEffectBlurLevel.Medium: {
  115831. blurCount = 2;
  115832. kernelSize = 31;
  115833. break;
  115834. }
  115835. default: {
  115836. kernelSize = 15;
  115837. blurCount = 1;
  115838. break;
  115839. }
  115840. }
  115841. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  115842. var ratio = 1.0;
  115843. for (var i = 0; i < blurCount; i++) {
  115844. 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);
  115845. blurY.autoClear = false;
  115846. ratio = 0.75 / Math.pow(2, i);
  115847. 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);
  115848. blurX.autoClear = false;
  115849. _this._depthOfFieldBlurY.push(blurY);
  115850. _this._depthOfFieldBlurX.push(blurX);
  115851. }
  115852. // Set all post processes on the effect.
  115853. _this._effects = [_this._circleOfConfusion];
  115854. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  115855. _this._effects.push(_this._depthOfFieldBlurY[i]);
  115856. _this._effects.push(_this._depthOfFieldBlurX[i]);
  115857. }
  115858. // Merge blurred images with original image based on circleOfConfusion
  115859. _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);
  115860. _this._dofMerge.autoClear = false;
  115861. _this._effects.push(_this._dofMerge);
  115862. return _this;
  115863. }
  115864. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  115865. get: function () {
  115866. return this._circleOfConfusion.focalLength;
  115867. },
  115868. /**
  115869. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  115870. */
  115871. set: function (value) {
  115872. this._circleOfConfusion.focalLength = value;
  115873. },
  115874. enumerable: true,
  115875. configurable: true
  115876. });
  115877. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  115878. get: function () {
  115879. return this._circleOfConfusion.fStop;
  115880. },
  115881. /**
  115882. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  115883. */
  115884. set: function (value) {
  115885. this._circleOfConfusion.fStop = value;
  115886. },
  115887. enumerable: true,
  115888. configurable: true
  115889. });
  115890. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  115891. get: function () {
  115892. return this._circleOfConfusion.focusDistance;
  115893. },
  115894. /**
  115895. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  115896. */
  115897. set: function (value) {
  115898. this._circleOfConfusion.focusDistance = value;
  115899. },
  115900. enumerable: true,
  115901. configurable: true
  115902. });
  115903. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  115904. get: function () {
  115905. return this._circleOfConfusion.lensSize;
  115906. },
  115907. /**
  115908. * 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.
  115909. */
  115910. set: function (value) {
  115911. this._circleOfConfusion.lensSize = value;
  115912. },
  115913. enumerable: true,
  115914. configurable: true
  115915. });
  115916. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  115917. /**
  115918. * 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.
  115919. */
  115920. set: function (value) {
  115921. this._circleOfConfusion.depthTexture = value;
  115922. },
  115923. enumerable: true,
  115924. configurable: true
  115925. });
  115926. /**
  115927. * Disposes each of the internal effects for a given camera.
  115928. * @param camera The camera to dispose the effect on.
  115929. */
  115930. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  115931. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115932. this._effects[effectIndex].dispose(camera);
  115933. }
  115934. };
  115935. /**
  115936. * @hidden Internal
  115937. */
  115938. DepthOfFieldEffect.prototype._updateEffects = function () {
  115939. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115940. this._effects[effectIndex].updateEffect();
  115941. }
  115942. };
  115943. /**
  115944. * Internal
  115945. * @returns if all the contained post processes are ready.
  115946. * @hidden
  115947. */
  115948. DepthOfFieldEffect.prototype._isReady = function () {
  115949. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115950. if (!this._effects[effectIndex].isReady()) {
  115951. return false;
  115952. }
  115953. }
  115954. return true;
  115955. };
  115956. return DepthOfFieldEffect;
  115957. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  115958. /***/ }),
  115959. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  115960. /*!*******************************************************!*\
  115961. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  115962. \*******************************************************/
  115963. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  115964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115965. "use strict";
  115966. __webpack_require__.r(__webpack_exports__);
  115967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  115968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  115969. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115970. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115971. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115972. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  115973. /**
  115974. * Options to be set when merging outputs from the default pipeline.
  115975. */
  115976. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  115977. function DepthOfFieldMergePostProcessOptions() {
  115978. }
  115979. return DepthOfFieldMergePostProcessOptions;
  115980. }());
  115981. /**
  115982. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  115983. */
  115984. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  115985. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  115986. /**
  115987. * Creates a new instance of DepthOfFieldMergePostProcess
  115988. * @param name The name of the effect.
  115989. * @param originalFromInput Post process which's input will be used for the merge.
  115990. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  115991. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  115992. * @param options The required width/height ratio to downsize to before computing the render pass.
  115993. * @param camera The camera to apply the render pass to.
  115994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115995. * @param engine The engine which the post process will be applied. (default: current engine)
  115996. * @param reusable If the post process can be reused on the same frame. (default: false)
  115997. * @param textureType Type of textures used when performing the post process. (default: 0)
  115998. * @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)
  115999. */
  116000. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116001. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116002. if (blockCompilation === void 0) { blockCompilation = false; }
  116003. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116004. _this.blurSteps = blurSteps;
  116005. _this.onApplyObservable.add(function (effect) {
  116006. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116007. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116008. blurSteps.forEach(function (step, index) {
  116009. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  116010. });
  116011. });
  116012. if (!blockCompilation) {
  116013. _this.updateEffect();
  116014. }
  116015. return _this;
  116016. }
  116017. /**
  116018. * Updates the effect with the current post process compile time values and recompiles the shader.
  116019. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116020. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116021. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116022. * @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
  116023. * @param onCompiled Called when the shader has been compiled.
  116024. * @param onError Called if there is an error when compiling a shader.
  116025. */
  116026. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116027. if (defines === void 0) { defines = null; }
  116028. if (uniforms === void 0) { uniforms = null; }
  116029. if (samplers === void 0) { samplers = null; }
  116030. if (!defines) {
  116031. defines = "";
  116032. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  116033. }
  116034. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  116035. };
  116036. return DepthOfFieldMergePostProcess;
  116037. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116038. /***/ }),
  116039. /***/ "./PostProcesses/displayPassPostProcess.ts":
  116040. /*!*************************************************!*\
  116041. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  116042. \*************************************************/
  116043. /*! exports provided: DisplayPassPostProcess */
  116044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116045. "use strict";
  116046. __webpack_require__.r(__webpack_exports__);
  116047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  116048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116049. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116050. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  116051. /**
  116052. * DisplayPassPostProcess which produces an output the same as it's input
  116053. */
  116054. var DisplayPassPostProcess = /** @class */ (function (_super) {
  116055. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  116056. /**
  116057. * Creates the DisplayPassPostProcess
  116058. * @param name The name of the effect.
  116059. * @param options The required width/height ratio to downsize to before computing the render pass.
  116060. * @param camera The camera to apply the render pass to.
  116061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116062. * @param engine The engine which the post process will be applied. (default: current engine)
  116063. * @param reusable If the post process can be reused on the same frame. (default: false)
  116064. */
  116065. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  116066. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  116067. }
  116068. return DisplayPassPostProcess;
  116069. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116070. /***/ }),
  116071. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  116072. /*!*******************************************************!*\
  116073. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  116074. \*******************************************************/
  116075. /*! exports provided: ExtractHighlightsPostProcess */
  116076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116077. "use strict";
  116078. __webpack_require__.r(__webpack_exports__);
  116079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  116080. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116081. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116082. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116083. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116084. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  116085. /**
  116086. * 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.
  116087. */
  116088. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  116089. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  116090. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116091. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116092. if (blockCompilation === void 0) { blockCompilation = false; }
  116093. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116094. /**
  116095. * The luminance threshold, pixels below this value will be set to black.
  116096. */
  116097. _this.threshold = 0.9;
  116098. /** @hidden */
  116099. _this._exposure = 1;
  116100. /**
  116101. * Post process which has the input texture to be used when performing highlight extraction
  116102. * @hidden
  116103. */
  116104. _this._inputPostProcess = null;
  116105. _this.onApplyObservable.add(function (effect) {
  116106. if (_this._inputPostProcess) {
  116107. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  116108. }
  116109. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  116110. effect.setFloat('exposure', _this._exposure);
  116111. });
  116112. return _this;
  116113. }
  116114. return ExtractHighlightsPostProcess;
  116115. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116116. /***/ }),
  116117. /***/ "./PostProcesses/filterPostProcess.ts":
  116118. /*!********************************************!*\
  116119. !*** ./PostProcesses/filterPostProcess.ts ***!
  116120. \********************************************/
  116121. /*! exports provided: FilterPostProcess */
  116122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116123. "use strict";
  116124. __webpack_require__.r(__webpack_exports__);
  116125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  116126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116127. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116128. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  116129. /**
  116130. * Applies a kernel filter to the image
  116131. */
  116132. var FilterPostProcess = /** @class */ (function (_super) {
  116133. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  116134. /**
  116135. *
  116136. * @param name The name of the effect.
  116137. * @param kernelMatrix The matrix to be applied to the image
  116138. * @param options The required width/height ratio to downsize to before computing the render pass.
  116139. * @param camera The camera to apply the render pass to.
  116140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116141. * @param engine The engine which the post process will be applied. (default: current engine)
  116142. * @param reusable If the post process can be reused on the same frame. (default: false)
  116143. */
  116144. function FilterPostProcess(name,
  116145. /** The matrix to be applied to the image */
  116146. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  116147. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  116148. _this.kernelMatrix = kernelMatrix;
  116149. _this.onApply = function (effect) {
  116150. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  116151. };
  116152. return _this;
  116153. }
  116154. return FilterPostProcess;
  116155. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116156. /***/ }),
  116157. /***/ "./PostProcesses/fxaaPostProcess.ts":
  116158. /*!******************************************!*\
  116159. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  116160. \******************************************/
  116161. /*! exports provided: FxaaPostProcess */
  116162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116163. "use strict";
  116164. __webpack_require__.r(__webpack_exports__);
  116165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  116166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116167. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116168. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116169. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116170. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  116171. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  116172. /**
  116173. * Fxaa post process
  116174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  116175. */
  116176. var FxaaPostProcess = /** @class */ (function (_super) {
  116177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  116178. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116179. if (camera === void 0) { camera = null; }
  116180. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116181. 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;
  116182. var defines = _this._getDefines();
  116183. _this.updateEffect(defines);
  116184. _this.onApplyObservable.add(function (effect) {
  116185. var texelSize = _this.texelSize;
  116186. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  116187. });
  116188. return _this;
  116189. }
  116190. FxaaPostProcess.prototype._getDefines = function () {
  116191. var engine = this.getEngine();
  116192. if (!engine) {
  116193. return null;
  116194. }
  116195. var glInfo = engine.getGlInfo();
  116196. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  116197. return "#define MALI 1\n";
  116198. }
  116199. return null;
  116200. };
  116201. return FxaaPostProcess;
  116202. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116203. /***/ }),
  116204. /***/ "./PostProcesses/grainPostProcess.ts":
  116205. /*!*******************************************!*\
  116206. !*** ./PostProcesses/grainPostProcess.ts ***!
  116207. \*******************************************/
  116208. /*! exports provided: GrainPostProcess */
  116209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116210. "use strict";
  116211. __webpack_require__.r(__webpack_exports__);
  116212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  116213. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116214. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116215. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116216. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  116217. /**
  116218. * The GrainPostProcess adds noise to the image at mid luminance levels
  116219. */
  116220. var GrainPostProcess = /** @class */ (function (_super) {
  116221. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  116222. /**
  116223. * Creates a new instance of @see GrainPostProcess
  116224. * @param name The name of the effect.
  116225. * @param options The required width/height ratio to downsize to before computing the render pass.
  116226. * @param camera The camera to apply the render pass to.
  116227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116228. * @param engine The engine which the post process will be applied. (default: current engine)
  116229. * @param reusable If the post process can be reused on the same frame. (default: false)
  116230. * @param textureType Type of textures used when performing the post process. (default: 0)
  116231. * @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)
  116232. */
  116233. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116234. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116235. if (blockCompilation === void 0) { blockCompilation = false; }
  116236. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116237. /**
  116238. * The intensity of the grain added (default: 30)
  116239. */
  116240. _this.intensity = 30;
  116241. /**
  116242. * If the grain should be randomized on every frame
  116243. */
  116244. _this.animated = false;
  116245. _this.onApplyObservable.add(function (effect) {
  116246. effect.setFloat('intensity', _this.intensity);
  116247. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  116248. });
  116249. return _this;
  116250. }
  116251. return GrainPostProcess;
  116252. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116253. /***/ }),
  116254. /***/ "./PostProcesses/highlightsPostProcess.ts":
  116255. /*!************************************************!*\
  116256. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  116257. \************************************************/
  116258. /*! exports provided: HighlightsPostProcess */
  116259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116260. "use strict";
  116261. __webpack_require__.r(__webpack_exports__);
  116262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  116263. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116264. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116265. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116266. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  116267. /**
  116268. * Extracts highlights from the image
  116269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116270. */
  116271. var HighlightsPostProcess = /** @class */ (function (_super) {
  116272. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  116273. /**
  116274. * Extracts highlights from the image
  116275. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116276. * @param name The name of the effect.
  116277. * @param options The required width/height ratio to downsize to before computing the render pass.
  116278. * @param camera The camera to apply the render pass to.
  116279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116280. * @param engine The engine which the post process will be applied. (default: current engine)
  116281. * @param reusable If the post process can be reused on the same frame. (default: false)
  116282. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  116283. */
  116284. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116285. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116286. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116287. }
  116288. return HighlightsPostProcess;
  116289. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116290. /***/ }),
  116291. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  116292. /*!*****************************************************!*\
  116293. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  116294. \*****************************************************/
  116295. /*! exports provided: ImageProcessingPostProcess */
  116296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116297. "use strict";
  116298. __webpack_require__.r(__webpack_exports__);
  116299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  116300. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116301. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  116302. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  116303. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116304. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  116305. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116306. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  116307. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  116308. /**
  116309. * ImageProcessingPostProcess
  116310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116311. */
  116312. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  116313. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  116314. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  116315. if (camera === void 0) { camera = null; }
  116316. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116317. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  116318. _this._fromLinearSpace = true;
  116319. /**
  116320. * Defines cache preventing GC.
  116321. */
  116322. _this._defines = {
  116323. IMAGEPROCESSING: false,
  116324. VIGNETTE: false,
  116325. VIGNETTEBLENDMODEMULTIPLY: false,
  116326. VIGNETTEBLENDMODEOPAQUE: false,
  116327. TONEMAPPING: false,
  116328. TONEMAPPING_ACES: false,
  116329. CONTRAST: false,
  116330. COLORCURVES: false,
  116331. COLORGRADING: false,
  116332. COLORGRADING3D: false,
  116333. FROMLINEARSPACE: false,
  116334. SAMPLER3DGREENDEPTH: false,
  116335. SAMPLER3DBGRMAP: false,
  116336. IMAGEPROCESSINGPOSTPROCESS: false,
  116337. EXPOSURE: false,
  116338. };
  116339. // Setup the configuration as forced by the constructor. This would then not force the
  116340. // scene materials output in linear space and let untouched the default forward pass.
  116341. if (imageProcessingConfiguration) {
  116342. imageProcessingConfiguration.applyByPostProcess = true;
  116343. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  116344. // This will cause the shader to be compiled
  116345. _this.fromLinearSpace = false;
  116346. }
  116347. // Setup the default processing configuration to the scene.
  116348. else {
  116349. _this._attachImageProcessingConfiguration(null, true);
  116350. _this.imageProcessingConfiguration.applyByPostProcess = true;
  116351. }
  116352. _this.onApply = function (effect) {
  116353. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  116354. };
  116355. return _this;
  116356. }
  116357. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  116358. /**
  116359. * Gets the image processing configuration used either in this material.
  116360. */
  116361. get: function () {
  116362. return this._imageProcessingConfiguration;
  116363. },
  116364. /**
  116365. * Sets the Default image processing configuration used either in the this material.
  116366. *
  116367. * If sets to null, the scene one is in use.
  116368. */
  116369. set: function (value) {
  116370. this._attachImageProcessingConfiguration(value);
  116371. },
  116372. enumerable: true,
  116373. configurable: true
  116374. });
  116375. /**
  116376. * Attaches a new image processing configuration to the PBR Material.
  116377. * @param configuration
  116378. */
  116379. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  116380. var _this = this;
  116381. if (doNotBuild === void 0) { doNotBuild = false; }
  116382. if (configuration === this._imageProcessingConfiguration) {
  116383. return;
  116384. }
  116385. // Detaches observer.
  116386. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  116387. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  116388. }
  116389. // Pick the scene configuration if needed.
  116390. if (!configuration) {
  116391. var scene = null;
  116392. var engine = this.getEngine();
  116393. var camera = this.getCamera();
  116394. if (camera) {
  116395. scene = camera.getScene();
  116396. }
  116397. else if (engine && engine.scenes) {
  116398. var scenes = engine.scenes;
  116399. scene = scenes[scenes.length - 1];
  116400. }
  116401. else {
  116402. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  116403. }
  116404. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  116405. }
  116406. else {
  116407. this._imageProcessingConfiguration = configuration;
  116408. }
  116409. // Attaches observer.
  116410. if (this._imageProcessingConfiguration) {
  116411. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  116412. _this._updateParameters();
  116413. });
  116414. }
  116415. // Ensure the effect will be rebuilt.
  116416. if (!doNotBuild) {
  116417. this._updateParameters();
  116418. }
  116419. };
  116420. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  116421. /**
  116422. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116423. */
  116424. get: function () {
  116425. return this.imageProcessingConfiguration.colorCurves;
  116426. },
  116427. /**
  116428. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116429. */
  116430. set: function (value) {
  116431. this.imageProcessingConfiguration.colorCurves = value;
  116432. },
  116433. enumerable: true,
  116434. configurable: true
  116435. });
  116436. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  116437. /**
  116438. * Gets wether the color curves effect is enabled.
  116439. */
  116440. get: function () {
  116441. return this.imageProcessingConfiguration.colorCurvesEnabled;
  116442. },
  116443. /**
  116444. * Sets wether the color curves effect is enabled.
  116445. */
  116446. set: function (value) {
  116447. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  116448. },
  116449. enumerable: true,
  116450. configurable: true
  116451. });
  116452. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  116453. /**
  116454. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116455. */
  116456. get: function () {
  116457. return this.imageProcessingConfiguration.colorGradingTexture;
  116458. },
  116459. /**
  116460. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116461. */
  116462. set: function (value) {
  116463. this.imageProcessingConfiguration.colorGradingTexture = value;
  116464. },
  116465. enumerable: true,
  116466. configurable: true
  116467. });
  116468. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  116469. /**
  116470. * Gets wether the color grading effect is enabled.
  116471. */
  116472. get: function () {
  116473. return this.imageProcessingConfiguration.colorGradingEnabled;
  116474. },
  116475. /**
  116476. * Gets wether the color grading effect is enabled.
  116477. */
  116478. set: function (value) {
  116479. this.imageProcessingConfiguration.colorGradingEnabled = value;
  116480. },
  116481. enumerable: true,
  116482. configurable: true
  116483. });
  116484. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  116485. /**
  116486. * Gets exposure used in the effect.
  116487. */
  116488. get: function () {
  116489. return this.imageProcessingConfiguration.exposure;
  116490. },
  116491. /**
  116492. * Sets exposure used in the effect.
  116493. */
  116494. set: function (value) {
  116495. this.imageProcessingConfiguration.exposure = value;
  116496. },
  116497. enumerable: true,
  116498. configurable: true
  116499. });
  116500. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  116501. /**
  116502. * Gets wether tonemapping is enabled or not.
  116503. */
  116504. get: function () {
  116505. return this._imageProcessingConfiguration.toneMappingEnabled;
  116506. },
  116507. /**
  116508. * Sets wether tonemapping is enabled or not
  116509. */
  116510. set: function (value) {
  116511. this._imageProcessingConfiguration.toneMappingEnabled = value;
  116512. },
  116513. enumerable: true,
  116514. configurable: true
  116515. });
  116516. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  116517. /**
  116518. * Gets contrast used in the effect.
  116519. */
  116520. get: function () {
  116521. return this.imageProcessingConfiguration.contrast;
  116522. },
  116523. /**
  116524. * Sets contrast used in the effect.
  116525. */
  116526. set: function (value) {
  116527. this.imageProcessingConfiguration.contrast = value;
  116528. },
  116529. enumerable: true,
  116530. configurable: true
  116531. });
  116532. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  116533. /**
  116534. * Gets Vignette stretch size.
  116535. */
  116536. get: function () {
  116537. return this.imageProcessingConfiguration.vignetteStretch;
  116538. },
  116539. /**
  116540. * Sets Vignette stretch size.
  116541. */
  116542. set: function (value) {
  116543. this.imageProcessingConfiguration.vignetteStretch = value;
  116544. },
  116545. enumerable: true,
  116546. configurable: true
  116547. });
  116548. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  116549. /**
  116550. * Gets Vignette centre X Offset.
  116551. */
  116552. get: function () {
  116553. return this.imageProcessingConfiguration.vignetteCentreX;
  116554. },
  116555. /**
  116556. * Sets Vignette centre X Offset.
  116557. */
  116558. set: function (value) {
  116559. this.imageProcessingConfiguration.vignetteCentreX = value;
  116560. },
  116561. enumerable: true,
  116562. configurable: true
  116563. });
  116564. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  116565. /**
  116566. * Gets Vignette centre Y Offset.
  116567. */
  116568. get: function () {
  116569. return this.imageProcessingConfiguration.vignetteCentreY;
  116570. },
  116571. /**
  116572. * Sets Vignette centre Y Offset.
  116573. */
  116574. set: function (value) {
  116575. this.imageProcessingConfiguration.vignetteCentreY = value;
  116576. },
  116577. enumerable: true,
  116578. configurable: true
  116579. });
  116580. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  116581. /**
  116582. * Gets Vignette weight or intensity of the vignette effect.
  116583. */
  116584. get: function () {
  116585. return this.imageProcessingConfiguration.vignetteWeight;
  116586. },
  116587. /**
  116588. * Sets Vignette weight or intensity of the vignette effect.
  116589. */
  116590. set: function (value) {
  116591. this.imageProcessingConfiguration.vignetteWeight = value;
  116592. },
  116593. enumerable: true,
  116594. configurable: true
  116595. });
  116596. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  116597. /**
  116598. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116599. * if vignetteEnabled is set to true.
  116600. */
  116601. get: function () {
  116602. return this.imageProcessingConfiguration.vignetteColor;
  116603. },
  116604. /**
  116605. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116606. * if vignetteEnabled is set to true.
  116607. */
  116608. set: function (value) {
  116609. this.imageProcessingConfiguration.vignetteColor = value;
  116610. },
  116611. enumerable: true,
  116612. configurable: true
  116613. });
  116614. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  116615. /**
  116616. * Gets Camera field of view used by the Vignette effect.
  116617. */
  116618. get: function () {
  116619. return this.imageProcessingConfiguration.vignetteCameraFov;
  116620. },
  116621. /**
  116622. * Sets Camera field of view used by the Vignette effect.
  116623. */
  116624. set: function (value) {
  116625. this.imageProcessingConfiguration.vignetteCameraFov = value;
  116626. },
  116627. enumerable: true,
  116628. configurable: true
  116629. });
  116630. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  116631. /**
  116632. * Gets the vignette blend mode allowing different kind of effect.
  116633. */
  116634. get: function () {
  116635. return this.imageProcessingConfiguration.vignetteBlendMode;
  116636. },
  116637. /**
  116638. * Sets the vignette blend mode allowing different kind of effect.
  116639. */
  116640. set: function (value) {
  116641. this.imageProcessingConfiguration.vignetteBlendMode = value;
  116642. },
  116643. enumerable: true,
  116644. configurable: true
  116645. });
  116646. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  116647. /**
  116648. * Gets wether the vignette effect is enabled.
  116649. */
  116650. get: function () {
  116651. return this.imageProcessingConfiguration.vignetteEnabled;
  116652. },
  116653. /**
  116654. * Sets wether the vignette effect is enabled.
  116655. */
  116656. set: function (value) {
  116657. this.imageProcessingConfiguration.vignetteEnabled = value;
  116658. },
  116659. enumerable: true,
  116660. configurable: true
  116661. });
  116662. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  116663. /**
  116664. * Gets wether the input of the processing is in Gamma or Linear Space.
  116665. */
  116666. get: function () {
  116667. return this._fromLinearSpace;
  116668. },
  116669. /**
  116670. * Sets wether the input of the processing is in Gamma or Linear Space.
  116671. */
  116672. set: function (value) {
  116673. if (this._fromLinearSpace === value) {
  116674. return;
  116675. }
  116676. this._fromLinearSpace = value;
  116677. this._updateParameters();
  116678. },
  116679. enumerable: true,
  116680. configurable: true
  116681. });
  116682. /**
  116683. * "ImageProcessingPostProcess"
  116684. * @returns "ImageProcessingPostProcess"
  116685. */
  116686. ImageProcessingPostProcess.prototype.getClassName = function () {
  116687. return "ImageProcessingPostProcess";
  116688. };
  116689. ImageProcessingPostProcess.prototype._updateParameters = function () {
  116690. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  116691. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  116692. var defines = "";
  116693. for (var define in this._defines) {
  116694. if (this._defines[define]) {
  116695. defines += "#define " + define + ";\r\n";
  116696. }
  116697. }
  116698. var samplers = ["textureSampler"];
  116699. var uniforms = ["scale"];
  116700. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  116701. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  116702. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  116703. }
  116704. this.updateEffect(defines, uniforms, samplers);
  116705. };
  116706. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  116707. _super.prototype.dispose.call(this, camera);
  116708. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  116709. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  116710. }
  116711. if (this._imageProcessingConfiguration) {
  116712. this.imageProcessingConfiguration.applyByPostProcess = false;
  116713. }
  116714. };
  116715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116717. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  116718. return ImageProcessingPostProcess;
  116719. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  116720. /***/ }),
  116721. /***/ "./PostProcesses/index.ts":
  116722. /*!********************************!*\
  116723. !*** ./PostProcesses/index.ts ***!
  116724. \********************************/
  116725. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  116726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116727. "use strict";
  116728. __webpack_require__.r(__webpack_exports__);
  116729. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  116730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  116731. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  116732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  116733. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  116734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  116735. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  116737. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  116739. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  116740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  116741. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  116742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  116743. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  116744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  116745. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  116746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  116747. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  116748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  116749. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  116750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  116751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  116752. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  116753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  116754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  116755. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  116756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  116757. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  116759. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  116760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  116761. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  116762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  116763. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  116764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  116765. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  116766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  116767. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  116768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  116769. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  116770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  116771. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  116772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  116773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  116774. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  116776. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  116777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  116778. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  116779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  116780. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  116781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  116782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  116783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  116784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  116785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  116786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  116787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  116788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  116789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  116790. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  116791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  116792. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  116793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  116794. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  116795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  116796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  116797. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  116798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  116799. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  116800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  116801. /***/ }),
  116802. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  116803. /*!************************************************!*\
  116804. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  116805. \************************************************/
  116806. /*! exports provided: MotionBlurPostProcess */
  116807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116808. "use strict";
  116809. __webpack_require__.r(__webpack_exports__);
  116810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  116811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116812. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116813. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116814. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116815. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116816. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  116817. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  116818. /**
  116819. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  116820. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  116821. * As an example, all you have to do is to create the post-process:
  116822. * var mb = new BABYLON.MotionBlurPostProcess(
  116823. * 'mb', // The name of the effect.
  116824. * scene, // The scene containing the objects to blur according to their velocity.
  116825. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  116826. * camera // The camera to apply the render pass to.
  116827. * );
  116828. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  116829. */
  116830. var MotionBlurPostProcess = /** @class */ (function (_super) {
  116831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  116832. /**
  116833. * Creates a new instance MotionBlurPostProcess
  116834. * @param name The name of the effect.
  116835. * @param scene The scene containing the objects to blur according to their velocity.
  116836. * @param options The required width/height ratio to downsize to before computing the render pass.
  116837. * @param camera The camera to apply the render pass to.
  116838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116839. * @param engine The engine which the post process will be applied. (default: current engine)
  116840. * @param reusable If the post process can be reused on the same frame. (default: false)
  116841. * @param textureType Type of textures used when performing the post process. (default: 0)
  116842. * @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)
  116843. */
  116844. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116845. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116846. if (blockCompilation === void 0) { blockCompilation = false; }
  116847. 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;
  116848. /**
  116849. * Defines how much the image is blurred by the movement. Default value is equal to 1
  116850. */
  116851. _this.motionStrength = 1;
  116852. _this._motionBlurSamples = 32;
  116853. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  116854. if (!_this._geometryBufferRenderer) {
  116855. // Geometry buffer renderer is not supported. So, work as a passthrough.
  116856. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  116857. _this.updateEffect();
  116858. }
  116859. else {
  116860. // Geometry buffer renderer is supported.
  116861. _this._geometryBufferRenderer.enableVelocity = true;
  116862. _this.onApply = function (effect) {
  116863. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  116864. effect.setFloat("motionScale", scene.getAnimationRatio());
  116865. effect.setFloat("motionStrength", _this.motionStrength);
  116866. if (_this._geometryBufferRenderer) {
  116867. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  116868. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  116869. }
  116870. };
  116871. }
  116872. return _this;
  116873. }
  116874. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  116875. /**
  116876. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  116877. */
  116878. get: function () {
  116879. return this._motionBlurSamples;
  116880. },
  116881. /**
  116882. * Sets the number of iterations to be used for motion blur quality
  116883. */
  116884. set: function (samples) {
  116885. this._motionBlurSamples = samples;
  116886. if (this._geometryBufferRenderer) {
  116887. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  116888. }
  116889. },
  116890. enumerable: true,
  116891. configurable: true
  116892. });
  116893. /**
  116894. * Disposes the post process.
  116895. * @param camera The camera to dispose the post process on.
  116896. */
  116897. MotionBlurPostProcess.prototype.dispose = function (camera) {
  116898. if (this._geometryBufferRenderer) {
  116899. // Clear previous transformation matrices dictionary used to compute objects velocities
  116900. this._geometryBufferRenderer._previousTransformationMatrices = {};
  116901. }
  116902. _super.prototype.dispose.call(this, camera);
  116903. };
  116904. return MotionBlurPostProcess;
  116905. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  116906. /***/ }),
  116907. /***/ "./PostProcesses/passPostProcess.ts":
  116908. /*!******************************************!*\
  116909. !*** ./PostProcesses/passPostProcess.ts ***!
  116910. \******************************************/
  116911. /*! exports provided: PassPostProcess, PassCubePostProcess */
  116912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116913. "use strict";
  116914. __webpack_require__.r(__webpack_exports__);
  116915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  116916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  116917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116918. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116919. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116920. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  116921. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  116922. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  116923. /**
  116924. * PassPostProcess which produces an output the same as it's input
  116925. */
  116926. var PassPostProcess = /** @class */ (function (_super) {
  116927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  116928. /**
  116929. * Creates the PassPostProcess
  116930. * @param name The name of the effect.
  116931. * @param options The required width/height ratio to downsize to before computing the render pass.
  116932. * @param camera The camera to apply the render pass to.
  116933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116934. * @param engine The engine which the post process will be applied. (default: current engine)
  116935. * @param reusable If the post process can be reused on the same frame. (default: false)
  116936. * @param textureType The type of texture to be used when performing the post processing.
  116937. * @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)
  116938. */
  116939. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116940. if (camera === void 0) { camera = null; }
  116941. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116942. if (blockCompilation === void 0) { blockCompilation = false; }
  116943. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  116944. }
  116945. return PassPostProcess;
  116946. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116947. /**
  116948. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116949. */
  116950. var PassCubePostProcess = /** @class */ (function (_super) {
  116951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  116952. /**
  116953. * Creates the PassCubePostProcess
  116954. * @param name The name of the effect.
  116955. * @param options The required width/height ratio to downsize to before computing the render pass.
  116956. * @param camera The camera to apply the render pass to.
  116957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116958. * @param engine The engine which the post process will be applied. (default: current engine)
  116959. * @param reusable If the post process can be reused on the same frame. (default: false)
  116960. * @param textureType The type of texture to be used when performing the post processing.
  116961. * @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)
  116962. */
  116963. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116964. if (camera === void 0) { camera = null; }
  116965. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116966. if (blockCompilation === void 0) { blockCompilation = false; }
  116967. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  116968. _this._face = 0;
  116969. return _this;
  116970. }
  116971. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  116972. /**
  116973. * Gets or sets the cube face to display.
  116974. * * 0 is +X
  116975. * * 1 is -X
  116976. * * 2 is +Y
  116977. * * 3 is -Y
  116978. * * 4 is +Z
  116979. * * 5 is -Z
  116980. */
  116981. get: function () {
  116982. return this._face;
  116983. },
  116984. set: function (value) {
  116985. if (value < 0 || value > 5) {
  116986. return;
  116987. }
  116988. this._face = value;
  116989. switch (this._face) {
  116990. case 0:
  116991. this.updateEffect("#define POSITIVEX");
  116992. break;
  116993. case 1:
  116994. this.updateEffect("#define NEGATIVEX");
  116995. break;
  116996. case 2:
  116997. this.updateEffect("#define POSITIVEY");
  116998. break;
  116999. case 3:
  117000. this.updateEffect("#define NEGATIVEY");
  117001. break;
  117002. case 4:
  117003. this.updateEffect("#define POSITIVEZ");
  117004. break;
  117005. case 5:
  117006. this.updateEffect("#define NEGATIVEZ");
  117007. break;
  117008. }
  117009. },
  117010. enumerable: true,
  117011. configurable: true
  117012. });
  117013. return PassCubePostProcess;
  117014. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117015. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  117016. 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);
  117017. };
  117018. /***/ }),
  117019. /***/ "./PostProcesses/postProcess.ts":
  117020. /*!**************************************!*\
  117021. !*** ./PostProcesses/postProcess.ts ***!
  117022. \**************************************/
  117023. /*! exports provided: PostProcess */
  117024. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117025. "use strict";
  117026. __webpack_require__.r(__webpack_exports__);
  117027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  117028. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  117029. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  117030. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  117031. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117032. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117033. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117034. /**
  117035. * PostProcess can be used to apply a shader to a texture after it has been rendered
  117036. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117037. */
  117038. var PostProcess = /** @class */ (function () {
  117039. /**
  117040. * Creates a new instance PostProcess
  117041. * @param name The name of the PostProcess.
  117042. * @param fragmentUrl The url of the fragment shader to be used.
  117043. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  117044. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  117045. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  117046. * @param camera The camera to apply the render pass to.
  117047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117048. * @param engine The engine which the post process will be applied. (default: current engine)
  117049. * @param reusable If the post process can be reused on the same frame. (default: false)
  117050. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  117051. * @param textureType Type of textures used when performing the post process. (default: 0)
  117052. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  117053. * @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
  117054. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  117055. */
  117056. function PostProcess(
  117057. /** Name of the PostProcess. */
  117058. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  117059. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  117060. if (defines === void 0) { defines = null; }
  117061. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117062. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  117063. if (blockCompilation === void 0) { blockCompilation = false; }
  117064. this.name = name;
  117065. /**
  117066. * Width of the texture to apply the post process on
  117067. */
  117068. this.width = -1;
  117069. /**
  117070. * Height of the texture to apply the post process on
  117071. */
  117072. this.height = -1;
  117073. /**
  117074. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  117075. * @hidden
  117076. */
  117077. this._outputTexture = null;
  117078. /**
  117079. * If the buffer needs to be cleared before applying the post process. (default: true)
  117080. * Should be set to false if shader will overwrite all previous pixels.
  117081. */
  117082. this.autoClear = true;
  117083. /**
  117084. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  117085. */
  117086. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  117087. /**
  117088. * Animations to be used for the post processing
  117089. */
  117090. this.animations = new Array();
  117091. /**
  117092. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  117093. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  117094. */
  117095. this.enablePixelPerfectMode = false;
  117096. /**
  117097. * Force the postprocess to be applied without taking in account viewport
  117098. */
  117099. this.forceFullscreenViewport = true;
  117100. /**
  117101. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  117102. *
  117103. * | Value | Type | Description |
  117104. * | ----- | ----------------------------------- | ----------- |
  117105. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  117106. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  117107. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  117108. *
  117109. */
  117110. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  117111. /**
  117112. * Force textures to be a power of two (default: false)
  117113. */
  117114. this.alwaysForcePOT = false;
  117115. this._samples = 1;
  117116. /**
  117117. * Modify the scale of the post process to be the same as the viewport (default: false)
  117118. */
  117119. this.adaptScaleToCurrentViewport = false;
  117120. this._reusable = false;
  117121. /**
  117122. * Smart array of input and output textures for the post process.
  117123. * @hidden
  117124. */
  117125. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117126. /**
  117127. * The index in _textures that corresponds to the output texture.
  117128. * @hidden
  117129. */
  117130. this._currentRenderTextureInd = 0;
  117131. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  117132. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117133. // Events
  117134. /**
  117135. * An event triggered when the postprocess is activated.
  117136. */
  117137. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117138. /**
  117139. * An event triggered when the postprocess changes its size.
  117140. */
  117141. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117142. /**
  117143. * An event triggered when the postprocess applies its effect.
  117144. */
  117145. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117146. /**
  117147. * An event triggered before rendering the postprocess
  117148. */
  117149. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117150. /**
  117151. * An event triggered after rendering the postprocess
  117152. */
  117153. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117154. if (camera != null) {
  117155. this._camera = camera;
  117156. this._scene = camera.getScene();
  117157. camera.attachPostProcess(this);
  117158. this._engine = this._scene.getEngine();
  117159. this._scene.postProcesses.push(this);
  117160. }
  117161. else if (engine) {
  117162. this._engine = engine;
  117163. this._engine.postProcesses.push(this);
  117164. }
  117165. this._options = options;
  117166. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  117167. this._reusable = reusable || false;
  117168. this._textureType = textureType;
  117169. this._samplers = samplers || [];
  117170. this._samplers.push("textureSampler");
  117171. this._fragmentUrl = fragmentUrl;
  117172. this._vertexUrl = vertexUrl;
  117173. this._parameters = parameters || [];
  117174. this._parameters.push("scale");
  117175. this._indexParameters = indexParameters;
  117176. if (!blockCompilation) {
  117177. this.updateEffect(defines);
  117178. }
  117179. }
  117180. Object.defineProperty(PostProcess.prototype, "samples", {
  117181. /**
  117182. * Number of sample textures (default: 1)
  117183. */
  117184. get: function () {
  117185. return this._samples;
  117186. },
  117187. set: function (n) {
  117188. var _this = this;
  117189. this._samples = n;
  117190. this._textures.forEach(function (texture) {
  117191. if (texture.samples !== _this._samples) {
  117192. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  117193. }
  117194. });
  117195. },
  117196. enumerable: true,
  117197. configurable: true
  117198. });
  117199. Object.defineProperty(PostProcess.prototype, "onActivate", {
  117200. /**
  117201. * A function that is added to the onActivateObservable
  117202. */
  117203. set: function (callback) {
  117204. if (this._onActivateObserver) {
  117205. this.onActivateObservable.remove(this._onActivateObserver);
  117206. }
  117207. if (callback) {
  117208. this._onActivateObserver = this.onActivateObservable.add(callback);
  117209. }
  117210. },
  117211. enumerable: true,
  117212. configurable: true
  117213. });
  117214. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  117215. /**
  117216. * A function that is added to the onSizeChangedObservable
  117217. */
  117218. set: function (callback) {
  117219. if (this._onSizeChangedObserver) {
  117220. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  117221. }
  117222. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  117223. },
  117224. enumerable: true,
  117225. configurable: true
  117226. });
  117227. Object.defineProperty(PostProcess.prototype, "onApply", {
  117228. /**
  117229. * A function that is added to the onApplyObservable
  117230. */
  117231. set: function (callback) {
  117232. if (this._onApplyObserver) {
  117233. this.onApplyObservable.remove(this._onApplyObserver);
  117234. }
  117235. this._onApplyObserver = this.onApplyObservable.add(callback);
  117236. },
  117237. enumerable: true,
  117238. configurable: true
  117239. });
  117240. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  117241. /**
  117242. * A function that is added to the onBeforeRenderObservable
  117243. */
  117244. set: function (callback) {
  117245. if (this._onBeforeRenderObserver) {
  117246. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  117247. }
  117248. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  117249. },
  117250. enumerable: true,
  117251. configurable: true
  117252. });
  117253. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  117254. /**
  117255. * A function that is added to the onAfterRenderObservable
  117256. */
  117257. set: function (callback) {
  117258. if (this._onAfterRenderObserver) {
  117259. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  117260. }
  117261. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  117262. },
  117263. enumerable: true,
  117264. configurable: true
  117265. });
  117266. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  117267. /**
  117268. * 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
  117269. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  117270. */
  117271. get: function () {
  117272. return this._textures.data[this._currentRenderTextureInd];
  117273. },
  117274. set: function (value) {
  117275. this._forcedOutputTexture = value;
  117276. },
  117277. enumerable: true,
  117278. configurable: true
  117279. });
  117280. /**
  117281. * Gets the camera which post process is applied to.
  117282. * @returns The camera the post process is applied to.
  117283. */
  117284. PostProcess.prototype.getCamera = function () {
  117285. return this._camera;
  117286. };
  117287. Object.defineProperty(PostProcess.prototype, "texelSize", {
  117288. /**
  117289. * Gets the texel size of the postprocess.
  117290. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  117291. */
  117292. get: function () {
  117293. if (this._shareOutputWithPostProcess) {
  117294. return this._shareOutputWithPostProcess.texelSize;
  117295. }
  117296. if (this._forcedOutputTexture) {
  117297. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  117298. }
  117299. return this._texelSize;
  117300. },
  117301. enumerable: true,
  117302. configurable: true
  117303. });
  117304. /**
  117305. * Gets the engine which this post process belongs to.
  117306. * @returns The engine the post process was enabled with.
  117307. */
  117308. PostProcess.prototype.getEngine = function () {
  117309. return this._engine;
  117310. };
  117311. /**
  117312. * The effect that is created when initializing the post process.
  117313. * @returns The created effect corrisponding the the postprocess.
  117314. */
  117315. PostProcess.prototype.getEffect = function () {
  117316. return this._effect;
  117317. };
  117318. /**
  117319. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  117320. * @param postProcess The post process to share the output with.
  117321. * @returns This post process.
  117322. */
  117323. PostProcess.prototype.shareOutputWith = function (postProcess) {
  117324. this._disposeTextures();
  117325. this._shareOutputWithPostProcess = postProcess;
  117326. return this;
  117327. };
  117328. /**
  117329. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  117330. * This should be called if the post process that shares output with this post process is disabled/disposed.
  117331. */
  117332. PostProcess.prototype.useOwnOutput = function () {
  117333. if (this._textures.length == 0) {
  117334. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117335. }
  117336. this._shareOutputWithPostProcess = null;
  117337. };
  117338. /**
  117339. * Updates the effect with the current post process compile time values and recompiles the shader.
  117340. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117341. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117342. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117343. * @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
  117344. * @param onCompiled Called when the shader has been compiled.
  117345. * @param onError Called if there is an error when compiling a shader.
  117346. */
  117347. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117348. if (defines === void 0) { defines = null; }
  117349. if (uniforms === void 0) { uniforms = null; }
  117350. if (samplers === void 0) { samplers = null; }
  117351. 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);
  117352. };
  117353. /**
  117354. * The post process is reusable if it can be used multiple times within one frame.
  117355. * @returns If the post process is reusable
  117356. */
  117357. PostProcess.prototype.isReusable = function () {
  117358. return this._reusable;
  117359. };
  117360. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  117361. PostProcess.prototype.markTextureDirty = function () {
  117362. this.width = -1;
  117363. };
  117364. /**
  117365. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  117366. * 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.
  117367. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  117368. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  117369. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  117370. * @returns The target texture that was bound to be written to.
  117371. */
  117372. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  117373. var _this = this;
  117374. if (sourceTexture === void 0) { sourceTexture = null; }
  117375. camera = camera || this._camera;
  117376. var scene = camera.getScene();
  117377. var engine = scene.getEngine();
  117378. var maxSize = engine.getCaps().maxTextureSize;
  117379. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  117380. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  117381. // 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
  117382. var webVRCamera = camera.parent;
  117383. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  117384. requiredWidth /= 2;
  117385. }
  117386. var desiredWidth = (this._options.width || requiredWidth);
  117387. var desiredHeight = this._options.height || requiredHeight;
  117388. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  117389. if (this.adaptScaleToCurrentViewport) {
  117390. var currentViewport = engine.currentViewport;
  117391. if (currentViewport) {
  117392. desiredWidth *= currentViewport.width;
  117393. desiredHeight *= currentViewport.height;
  117394. }
  117395. }
  117396. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  117397. if (!this._options.width) {
  117398. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  117399. }
  117400. if (!this._options.height) {
  117401. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  117402. }
  117403. }
  117404. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  117405. if (this._textures.length > 0) {
  117406. for (var i = 0; i < this._textures.length; i++) {
  117407. this._engine._releaseTexture(this._textures.data[i]);
  117408. }
  117409. this._textures.reset();
  117410. }
  117411. this.width = desiredWidth;
  117412. this.height = desiredHeight;
  117413. var textureSize = { width: this.width, height: this.height };
  117414. var textureOptions = {
  117415. generateMipMaps: false,
  117416. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  117417. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  117418. samplingMode: this.renderTargetSamplingMode,
  117419. type: this._textureType
  117420. };
  117421. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117422. if (this._reusable) {
  117423. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117424. }
  117425. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  117426. this.onSizeChangedObservable.notifyObservers(this);
  117427. }
  117428. this._textures.forEach(function (texture) {
  117429. if (texture.samples !== _this.samples) {
  117430. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  117431. }
  117432. });
  117433. }
  117434. var target;
  117435. if (this._shareOutputWithPostProcess) {
  117436. target = this._shareOutputWithPostProcess.inputTexture;
  117437. }
  117438. else if (this._forcedOutputTexture) {
  117439. target = this._forcedOutputTexture;
  117440. this.width = this._forcedOutputTexture.width;
  117441. this.height = this._forcedOutputTexture.height;
  117442. }
  117443. else {
  117444. target = this.inputTexture;
  117445. }
  117446. // Bind the input of this post process to be used as the output of the previous post process.
  117447. if (this.enablePixelPerfectMode) {
  117448. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  117449. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  117450. }
  117451. else {
  117452. this._scaleRatio.copyFromFloats(1, 1);
  117453. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  117454. }
  117455. this.onActivateObservable.notifyObservers(camera);
  117456. // Clear
  117457. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  117458. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  117459. }
  117460. if (this._reusable) {
  117461. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  117462. }
  117463. return target;
  117464. };
  117465. Object.defineProperty(PostProcess.prototype, "isSupported", {
  117466. /**
  117467. * If the post process is supported.
  117468. */
  117469. get: function () {
  117470. return this._effect.isSupported;
  117471. },
  117472. enumerable: true,
  117473. configurable: true
  117474. });
  117475. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  117476. /**
  117477. * The aspect ratio of the output texture.
  117478. */
  117479. get: function () {
  117480. if (this._shareOutputWithPostProcess) {
  117481. return this._shareOutputWithPostProcess.aspectRatio;
  117482. }
  117483. if (this._forcedOutputTexture) {
  117484. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  117485. }
  117486. return this.width / this.height;
  117487. },
  117488. enumerable: true,
  117489. configurable: true
  117490. });
  117491. /**
  117492. * Get a value indicating if the post-process is ready to be used
  117493. * @returns true if the post-process is ready (shader is compiled)
  117494. */
  117495. PostProcess.prototype.isReady = function () {
  117496. return this._effect && this._effect.isReady();
  117497. };
  117498. /**
  117499. * Binds all textures and uniforms to the shader, this will be run on every pass.
  117500. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  117501. */
  117502. PostProcess.prototype.apply = function () {
  117503. // Check
  117504. if (!this._effect || !this._effect.isReady()) {
  117505. return null;
  117506. }
  117507. // States
  117508. this._engine.enableEffect(this._effect);
  117509. this._engine.setState(false);
  117510. this._engine.setDepthBuffer(false);
  117511. this._engine.setDepthWrite(false);
  117512. // Alpha
  117513. this._engine.setAlphaMode(this.alphaMode);
  117514. if (this.alphaConstants) {
  117515. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  117516. }
  117517. // Bind the output texture of the preivous post process as the input to this post process.
  117518. var source;
  117519. if (this._shareOutputWithPostProcess) {
  117520. source = this._shareOutputWithPostProcess.inputTexture;
  117521. }
  117522. else if (this._forcedOutputTexture) {
  117523. source = this._forcedOutputTexture;
  117524. }
  117525. else {
  117526. source = this.inputTexture;
  117527. }
  117528. this._effect._bindTexture("textureSampler", source);
  117529. // Parameters
  117530. this._effect.setVector2("scale", this._scaleRatio);
  117531. this.onApplyObservable.notifyObservers(this._effect);
  117532. return this._effect;
  117533. };
  117534. PostProcess.prototype._disposeTextures = function () {
  117535. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  117536. return;
  117537. }
  117538. if (this._textures.length > 0) {
  117539. for (var i = 0; i < this._textures.length; i++) {
  117540. this._engine._releaseTexture(this._textures.data[i]);
  117541. }
  117542. }
  117543. this._textures.dispose();
  117544. };
  117545. /**
  117546. * Disposes the post process.
  117547. * @param camera The camera to dispose the post process on.
  117548. */
  117549. PostProcess.prototype.dispose = function (camera) {
  117550. camera = camera || this._camera;
  117551. this._disposeTextures();
  117552. if (this._scene) {
  117553. var index_1 = this._scene.postProcesses.indexOf(this);
  117554. if (index_1 !== -1) {
  117555. this._scene.postProcesses.splice(index_1, 1);
  117556. }
  117557. }
  117558. else {
  117559. var index_2 = this._engine.postProcesses.indexOf(this);
  117560. if (index_2 !== -1) {
  117561. this._engine.postProcesses.splice(index_2, 1);
  117562. }
  117563. }
  117564. if (!camera) {
  117565. return;
  117566. }
  117567. camera.detachPostProcess(this);
  117568. var index = camera._postProcesses.indexOf(this);
  117569. if (index === 0 && camera._postProcesses.length > 0) {
  117570. var firstPostProcess = this._camera._getFirstPostProcess();
  117571. if (firstPostProcess) {
  117572. firstPostProcess.markTextureDirty();
  117573. }
  117574. }
  117575. this.onActivateObservable.clear();
  117576. this.onAfterRenderObservable.clear();
  117577. this.onApplyObservable.clear();
  117578. this.onBeforeRenderObservable.clear();
  117579. this.onSizeChangedObservable.clear();
  117580. };
  117581. return PostProcess;
  117582. }());
  117583. /***/ }),
  117584. /***/ "./PostProcesses/postProcessManager.ts":
  117585. /*!*********************************************!*\
  117586. !*** ./PostProcesses/postProcessManager.ts ***!
  117587. \*********************************************/
  117588. /*! exports provided: PostProcessManager */
  117589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117590. "use strict";
  117591. __webpack_require__.r(__webpack_exports__);
  117592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  117593. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  117594. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  117595. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117596. /**
  117597. * PostProcessManager is used to manage one or more post processes or post process pipelines
  117598. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117599. */
  117600. var PostProcessManager = /** @class */ (function () {
  117601. /**
  117602. * Creates a new instance PostProcess
  117603. * @param scene The scene that the post process is associated with.
  117604. */
  117605. function PostProcessManager(scene) {
  117606. this._vertexBuffers = {};
  117607. this._scene = scene;
  117608. }
  117609. PostProcessManager.prototype._prepareBuffers = function () {
  117610. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  117611. return;
  117612. }
  117613. // VBO
  117614. var vertices = [];
  117615. vertices.push(1, 1);
  117616. vertices.push(-1, 1);
  117617. vertices.push(-1, -1);
  117618. vertices.push(1, -1);
  117619. 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);
  117620. this._buildIndexBuffer();
  117621. };
  117622. PostProcessManager.prototype._buildIndexBuffer = function () {
  117623. // Indices
  117624. var indices = [];
  117625. indices.push(0);
  117626. indices.push(1);
  117627. indices.push(2);
  117628. indices.push(0);
  117629. indices.push(2);
  117630. indices.push(3);
  117631. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  117632. };
  117633. /**
  117634. * Rebuilds the vertex buffers of the manager.
  117635. * @hidden
  117636. */
  117637. PostProcessManager.prototype._rebuild = function () {
  117638. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  117639. if (!vb) {
  117640. return;
  117641. }
  117642. vb._rebuild();
  117643. this._buildIndexBuffer();
  117644. };
  117645. // Methods
  117646. /**
  117647. * Prepares a frame to be run through a post process.
  117648. * @param sourceTexture The input texture to the post procesess. (default: null)
  117649. * @param postProcesses An array of post processes to be run. (default: null)
  117650. * @returns True if the post processes were able to be run.
  117651. * @hidden
  117652. */
  117653. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  117654. if (sourceTexture === void 0) { sourceTexture = null; }
  117655. if (postProcesses === void 0) { postProcesses = null; }
  117656. var camera = this._scene.activeCamera;
  117657. if (!camera) {
  117658. return false;
  117659. }
  117660. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  117661. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  117662. return false;
  117663. }
  117664. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  117665. return true;
  117666. };
  117667. /**
  117668. * Manually render a set of post processes to a texture.
  117669. * @param postProcesses An array of post processes to be run.
  117670. * @param targetTexture The target texture to render to.
  117671. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  117672. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  117673. * @param lodLevel defines which lod of the texture to render to
  117674. */
  117675. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  117676. if (targetTexture === void 0) { targetTexture = null; }
  117677. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  117678. if (faceIndex === void 0) { faceIndex = 0; }
  117679. if (lodLevel === void 0) { lodLevel = 0; }
  117680. var engine = this._scene.getEngine();
  117681. for (var index = 0; index < postProcesses.length; index++) {
  117682. if (index < postProcesses.length - 1) {
  117683. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  117684. }
  117685. else {
  117686. if (targetTexture) {
  117687. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  117688. }
  117689. else {
  117690. engine.restoreDefaultFramebuffer();
  117691. }
  117692. }
  117693. var pp = postProcesses[index];
  117694. var effect = pp.apply();
  117695. if (effect) {
  117696. pp.onBeforeRenderObservable.notifyObservers(effect);
  117697. // VBOs
  117698. this._prepareBuffers();
  117699. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  117700. // Draw order
  117701. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  117702. pp.onAfterRenderObservable.notifyObservers(effect);
  117703. }
  117704. }
  117705. // Restore depth buffer
  117706. engine.setDepthBuffer(true);
  117707. engine.setDepthWrite(true);
  117708. };
  117709. /**
  117710. * Finalize the result of the output of the postprocesses.
  117711. * @param doNotPresent If true the result will not be displayed to the screen.
  117712. * @param targetTexture The target texture to render to.
  117713. * @param faceIndex The index of the face to bind the target texture to.
  117714. * @param postProcesses The array of post processes to render.
  117715. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  117716. * @hidden
  117717. */
  117718. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  117719. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  117720. var camera = this._scene.activeCamera;
  117721. if (!camera) {
  117722. return;
  117723. }
  117724. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  117725. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  117726. return;
  117727. }
  117728. var engine = this._scene.getEngine();
  117729. for (var index = 0, len = postProcesses.length; index < len; index++) {
  117730. var pp = postProcesses[index];
  117731. if (index < len - 1) {
  117732. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  117733. }
  117734. else {
  117735. if (targetTexture) {
  117736. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  117737. pp._outputTexture = targetTexture;
  117738. }
  117739. else {
  117740. engine.restoreDefaultFramebuffer();
  117741. pp._outputTexture = null;
  117742. }
  117743. }
  117744. if (doNotPresent) {
  117745. break;
  117746. }
  117747. var effect = pp.apply();
  117748. if (effect) {
  117749. pp.onBeforeRenderObservable.notifyObservers(effect);
  117750. // VBOs
  117751. this._prepareBuffers();
  117752. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  117753. // Draw order
  117754. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  117755. pp.onAfterRenderObservable.notifyObservers(effect);
  117756. }
  117757. }
  117758. // Restore states
  117759. engine.setDepthBuffer(true);
  117760. engine.setDepthWrite(true);
  117761. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  117762. };
  117763. /**
  117764. * Disposes of the post process manager.
  117765. */
  117766. PostProcessManager.prototype.dispose = function () {
  117767. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  117768. if (buffer) {
  117769. buffer.dispose();
  117770. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  117771. }
  117772. if (this._indexBuffer) {
  117773. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  117774. this._indexBuffer = null;
  117775. }
  117776. };
  117777. return PostProcessManager;
  117778. }());
  117779. /***/ }),
  117780. /***/ "./PostProcesses/refractionPostProcess.ts":
  117781. /*!************************************************!*\
  117782. !*** ./PostProcesses/refractionPostProcess.ts ***!
  117783. \************************************************/
  117784. /*! exports provided: RefractionPostProcess */
  117785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117786. "use strict";
  117787. __webpack_require__.r(__webpack_exports__);
  117788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  117789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117790. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117791. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117792. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  117793. /**
  117794. * Post process which applies a refractin texture
  117795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117796. */
  117797. var RefractionPostProcess = /** @class */ (function (_super) {
  117798. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  117799. /**
  117800. * Initializes the RefractionPostProcess
  117801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117802. * @param name The name of the effect.
  117803. * @param refractionTextureUrl Url of the refraction texture to use
  117804. * @param color the base color of the refraction (used to taint the rendering)
  117805. * @param depth simulated refraction depth
  117806. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117807. * @param camera The camera to apply the render pass to.
  117808. * @param options The required width/height ratio to downsize to before computing the render pass.
  117809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117810. * @param engine The engine which the post process will be applied. (default: current engine)
  117811. * @param reusable If the post process can be reused on the same frame. (default: false)
  117812. */
  117813. function RefractionPostProcess(name, refractionTextureUrl,
  117814. /** the base color of the refraction (used to taint the rendering) */
  117815. color,
  117816. /** simulated refraction depth */
  117817. depth,
  117818. /** the coefficient of the base color (0 to remove base color tainting) */
  117819. colorLevel, options, camera, samplingMode, engine, reusable) {
  117820. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  117821. _this.color = color;
  117822. _this.depth = depth;
  117823. _this.colorLevel = colorLevel;
  117824. _this._ownRefractionTexture = true;
  117825. _this.onActivateObservable.add(function (cam) {
  117826. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  117827. });
  117828. _this.onApplyObservable.add(function (effect) {
  117829. effect.setColor3("baseColor", _this.color);
  117830. effect.setFloat("depth", _this.depth);
  117831. effect.setFloat("colorLevel", _this.colorLevel);
  117832. effect.setTexture("refractionSampler", _this._refTexture);
  117833. });
  117834. return _this;
  117835. }
  117836. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  117837. /**
  117838. * Gets or sets the refraction texture
  117839. * Please note that you are responsible for disposing the texture if you set it manually
  117840. */
  117841. get: function () {
  117842. return this._refTexture;
  117843. },
  117844. set: function (value) {
  117845. if (this._refTexture && this._ownRefractionTexture) {
  117846. this._refTexture.dispose();
  117847. }
  117848. this._refTexture = value;
  117849. this._ownRefractionTexture = false;
  117850. },
  117851. enumerable: true,
  117852. configurable: true
  117853. });
  117854. // Methods
  117855. /**
  117856. * Disposes of the post process
  117857. * @param camera Camera to dispose post process on
  117858. */
  117859. RefractionPostProcess.prototype.dispose = function (camera) {
  117860. if (this._refTexture && this._ownRefractionTexture) {
  117861. this._refTexture.dispose();
  117862. this._refTexture = null;
  117863. }
  117864. _super.prototype.dispose.call(this, camera);
  117865. };
  117866. return RefractionPostProcess;
  117867. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117868. /***/ }),
  117869. /***/ "./PostProcesses/sharpenPostProcess.ts":
  117870. /*!*********************************************!*\
  117871. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  117872. \*********************************************/
  117873. /*! exports provided: SharpenPostProcess */
  117874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117875. "use strict";
  117876. __webpack_require__.r(__webpack_exports__);
  117877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  117878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117879. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117880. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117881. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  117882. /**
  117883. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117884. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117885. */
  117886. var SharpenPostProcess = /** @class */ (function (_super) {
  117887. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  117888. /**
  117889. * Creates a new instance ConvolutionPostProcess
  117890. * @param name The name of the effect.
  117891. * @param options The required width/height ratio to downsize to before computing the render pass.
  117892. * @param camera The camera to apply the render pass to.
  117893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117894. * @param engine The engine which the post process will be applied. (default: current engine)
  117895. * @param reusable If the post process can be reused on the same frame. (default: false)
  117896. * @param textureType Type of textures used when performing the post process. (default: 0)
  117897. * @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)
  117898. */
  117899. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117900. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117901. if (blockCompilation === void 0) { blockCompilation = false; }
  117902. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117903. /**
  117904. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117905. */
  117906. _this.colorAmount = 1.0;
  117907. /**
  117908. * How much sharpness should be applied (default: 0.3)
  117909. */
  117910. _this.edgeAmount = 0.3;
  117911. _this.onApply = function (effect) {
  117912. effect.setFloat2("screenSize", _this.width, _this.height);
  117913. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  117914. };
  117915. return _this;
  117916. }
  117917. return SharpenPostProcess;
  117918. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117919. /***/ }),
  117920. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  117921. /*!***********************************************************!*\
  117922. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  117923. \***********************************************************/
  117924. /*! exports provided: StereoscopicInterlacePostProcess */
  117925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117926. "use strict";
  117927. __webpack_require__.r(__webpack_exports__);
  117928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  117929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117930. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117931. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117932. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  117933. /**
  117934. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  117935. */
  117936. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  117937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  117938. /**
  117939. * Initializes a StereoscopicInterlacePostProcess
  117940. * @param name The name of the effect.
  117941. * @param rigCameras The rig cameras to be appled to the post process
  117942. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  117943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117944. * @param engine The engine which the post process will be applied. (default: current engine)
  117945. * @param reusable If the post process can be reused on the same frame. (default: false)
  117946. */
  117947. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  117948. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  117949. _this._passedProcess = rigCameras[0]._rigPostProcess;
  117950. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  117951. _this.onSizeChangedObservable.add(function () {
  117952. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  117953. });
  117954. _this.onApplyObservable.add(function (effect) {
  117955. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  117956. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  117957. });
  117958. return _this;
  117959. }
  117960. return StereoscopicInterlacePostProcess;
  117961. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117962. /***/ }),
  117963. /***/ "./PostProcesses/tonemapPostProcess.ts":
  117964. /*!*********************************************!*\
  117965. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  117966. \*********************************************/
  117967. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  117968. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117969. "use strict";
  117970. __webpack_require__.r(__webpack_exports__);
  117971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  117972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  117973. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117974. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117975. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117976. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  117977. /** Defines operator used for tonemapping */
  117978. var TonemappingOperator;
  117979. (function (TonemappingOperator) {
  117980. /** Hable */
  117981. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  117982. /** Reinhard */
  117983. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  117984. /** HejiDawson */
  117985. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  117986. /** Photographic */
  117987. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  117988. })(TonemappingOperator || (TonemappingOperator = {}));
  117989. /**
  117990. * Defines a post process to apply tone mapping
  117991. */
  117992. var TonemapPostProcess = /** @class */ (function (_super) {
  117993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  117994. /**
  117995. * Creates a new TonemapPostProcess
  117996. * @param name defines the name of the postprocess
  117997. * @param _operator defines the operator to use
  117998. * @param exposureAdjustment defines the required exposure adjustement
  117999. * @param camera defines the camera to use (can be null)
  118000. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118001. * @param engine defines the hosting engine (can be ignore if camera is set)
  118002. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118003. */
  118004. function TonemapPostProcess(name, _operator,
  118005. /** Defines the required exposure adjustement */
  118006. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  118007. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  118008. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118009. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  118010. _this._operator = _operator;
  118011. _this.exposureAdjustment = exposureAdjustment;
  118012. var defines = "#define ";
  118013. if (_this._operator === TonemappingOperator.Hable) {
  118014. defines += "HABLE_TONEMAPPING";
  118015. }
  118016. else if (_this._operator === TonemappingOperator.Reinhard) {
  118017. defines += "REINHARD_TONEMAPPING";
  118018. }
  118019. else if (_this._operator === TonemappingOperator.HejiDawson) {
  118020. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  118021. }
  118022. else if (_this._operator === TonemappingOperator.Photographic) {
  118023. defines += "PHOTOGRAPHIC_TONEMAPPING";
  118024. }
  118025. //sadly a second call to create the effect.
  118026. _this.updateEffect(defines);
  118027. _this.onApply = function (effect) {
  118028. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  118029. };
  118030. return _this;
  118031. }
  118032. return TonemapPostProcess;
  118033. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118034. /***/ }),
  118035. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  118036. /*!***************************************************************!*\
  118037. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  118038. \***************************************************************/
  118039. /*! exports provided: VolumetricLightScatteringPostProcess */
  118040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118041. "use strict";
  118042. __webpack_require__.r(__webpack_exports__);
  118043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  118044. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118045. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118046. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118047. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118048. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118049. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118050. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  118051. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118052. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  118053. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118054. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118055. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118056. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118057. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  118058. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  118059. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  118060. /**
  118061. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  118062. */
  118063. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  118064. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  118065. /**
  118066. * @constructor
  118067. * @param name The post-process name
  118068. * @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)
  118069. * @param camera The camera that the post-process will be attached to
  118070. * @param mesh The mesh used to create the light scattering
  118071. * @param samples The post-process quality, default 100
  118072. * @param samplingModeThe post-process filtering mode
  118073. * @param engine The babylon engine
  118074. * @param reusable If the post-process is reusable
  118075. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  118076. */
  118077. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  118078. if (samples === void 0) { samples = 100; }
  118079. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  118080. 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;
  118081. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118082. /**
  118083. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  118084. */
  118085. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118086. /**
  118087. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  118088. */
  118089. _this.useCustomMeshPosition = false;
  118090. /**
  118091. * If the post-process should inverse the light scattering direction
  118092. */
  118093. _this.invert = true;
  118094. /**
  118095. * Array containing the excluded meshes not rendered in the internal pass
  118096. */
  118097. _this.excludedMeshes = new Array();
  118098. /**
  118099. * Controls the overall intensity of the post-process
  118100. */
  118101. _this.exposure = 0.3;
  118102. /**
  118103. * Dissipates each sample's contribution in range [0, 1]
  118104. */
  118105. _this.decay = 0.96815;
  118106. /**
  118107. * Controls the overall intensity of each sample
  118108. */
  118109. _this.weight = 0.58767;
  118110. /**
  118111. * Controls the density of each sample
  118112. */
  118113. _this.density = 0.926;
  118114. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  118115. engine = scene.getEngine();
  118116. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  118117. // Configure mesh
  118118. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  118119. // Configure
  118120. _this._createPass(scene, ratio.passRatio || ratio);
  118121. _this.onActivate = function (camera) {
  118122. if (!_this.isSupported) {
  118123. _this.dispose(camera);
  118124. }
  118125. _this.onActivate = null;
  118126. };
  118127. _this.onApplyObservable.add(function (effect) {
  118128. _this._updateMeshScreenCoordinates(scene);
  118129. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  118130. effect.setFloat("exposure", _this.exposure);
  118131. effect.setFloat("decay", _this.decay);
  118132. effect.setFloat("weight", _this.weight);
  118133. effect.setFloat("density", _this.density);
  118134. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  118135. });
  118136. return _this;
  118137. }
  118138. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  118139. /**
  118140. * @hidden
  118141. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  118142. */
  118143. get: function () {
  118144. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118145. return false;
  118146. },
  118147. set: function (useDiffuseColor) {
  118148. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118149. },
  118150. enumerable: true,
  118151. configurable: true
  118152. });
  118153. /**
  118154. * Returns the string "VolumetricLightScatteringPostProcess"
  118155. * @returns "VolumetricLightScatteringPostProcess"
  118156. */
  118157. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  118158. return "VolumetricLightScatteringPostProcess";
  118159. };
  118160. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  118161. var mesh = subMesh.getMesh();
  118162. // Render this.mesh as default
  118163. if (mesh === this.mesh && mesh.material) {
  118164. return mesh.material.isReady(mesh);
  118165. }
  118166. var defines = [];
  118167. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  118168. var material = subMesh.getMaterial();
  118169. // Alpha test
  118170. if (material) {
  118171. if (material.needAlphaTesting()) {
  118172. defines.push("#define ALPHATEST");
  118173. }
  118174. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  118175. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  118176. defines.push("#define UV1");
  118177. }
  118178. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  118179. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  118180. defines.push("#define UV2");
  118181. }
  118182. }
  118183. // Bones
  118184. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  118185. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  118186. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  118187. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  118188. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  118189. }
  118190. else {
  118191. defines.push("#define NUM_BONE_INFLUENCERS 0");
  118192. }
  118193. // Instances
  118194. if (useInstances) {
  118195. defines.push("#define INSTANCES");
  118196. attribs.push("world0");
  118197. attribs.push("world1");
  118198. attribs.push("world2");
  118199. attribs.push("world3");
  118200. }
  118201. // Get correct effect
  118202. var join = defines.join("\n");
  118203. if (this._cachedDefines !== join) {
  118204. this._cachedDefines = join;
  118205. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  118206. }
  118207. return this._volumetricLightScatteringPass.isReady();
  118208. };
  118209. /**
  118210. * Sets the new light position for light scattering effect
  118211. * @param position The new custom light position
  118212. */
  118213. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  118214. this.customMeshPosition = position;
  118215. };
  118216. /**
  118217. * Returns the light position for light scattering effect
  118218. * @return Vector3 The custom light position
  118219. */
  118220. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  118221. return this.customMeshPosition;
  118222. };
  118223. /**
  118224. * Disposes the internal assets and detaches the post-process from the camera
  118225. */
  118226. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  118227. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  118228. if (rttIndex !== -1) {
  118229. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  118230. }
  118231. this._volumetricLightScatteringRTT.dispose();
  118232. _super.prototype.dispose.call(this, camera);
  118233. };
  118234. /**
  118235. * Returns the render target texture used by the post-process
  118236. * @return the render target texture used by the post-process
  118237. */
  118238. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  118239. return this._volumetricLightScatteringRTT;
  118240. };
  118241. // Private methods
  118242. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  118243. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  118244. return true;
  118245. }
  118246. return false;
  118247. };
  118248. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  118249. var _this = this;
  118250. var engine = scene.getEngine();
  118251. 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);
  118252. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118253. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118254. this._volumetricLightScatteringRTT.renderList = null;
  118255. this._volumetricLightScatteringRTT.renderParticles = false;
  118256. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  118257. var camera = this.getCamera();
  118258. if (camera) {
  118259. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118260. }
  118261. else {
  118262. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118263. }
  118264. // Custom render function for submeshes
  118265. var renderSubMesh = function (subMesh) {
  118266. var mesh = subMesh.getRenderingMesh();
  118267. if (_this._meshExcluded(mesh)) {
  118268. return;
  118269. }
  118270. var material = subMesh.getMaterial();
  118271. if (!material) {
  118272. return;
  118273. }
  118274. var scene = mesh.getScene();
  118275. var engine = scene.getEngine();
  118276. // Culling
  118277. engine.setState(material.backFaceCulling);
  118278. // Managing instances
  118279. var batch = mesh._getInstancesRenderList(subMesh._id);
  118280. if (batch.mustReturn) {
  118281. return;
  118282. }
  118283. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  118284. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  118285. var effect = _this._volumetricLightScatteringPass;
  118286. if (mesh === _this.mesh) {
  118287. if (subMesh.effect) {
  118288. effect = subMesh.effect;
  118289. }
  118290. else {
  118291. effect = material.getEffect();
  118292. }
  118293. }
  118294. engine.enableEffect(effect);
  118295. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  118296. if (mesh === _this.mesh) {
  118297. material.bind(mesh.getWorldMatrix(), mesh);
  118298. }
  118299. else {
  118300. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  118301. // Alpha test
  118302. if (material && material.needAlphaTesting()) {
  118303. var alphaTexture = material.getAlphaTestTexture();
  118304. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  118305. if (alphaTexture) {
  118306. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  118307. }
  118308. }
  118309. // Bones
  118310. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  118311. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  118312. }
  118313. }
  118314. // Draw
  118315. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  118316. }
  118317. };
  118318. // Render target texture callbacks
  118319. var savedSceneClearColor;
  118320. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  118321. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  118322. savedSceneClearColor = scene.clearColor;
  118323. scene.clearColor = sceneClearColor;
  118324. });
  118325. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  118326. scene.clearColor = savedSceneClearColor;
  118327. });
  118328. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  118329. var engine = scene.getEngine();
  118330. var index;
  118331. if (depthOnlySubMeshes.length) {
  118332. engine.setColorWrite(false);
  118333. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  118334. renderSubMesh(depthOnlySubMeshes.data[index]);
  118335. }
  118336. engine.setColorWrite(true);
  118337. }
  118338. for (index = 0; index < opaqueSubMeshes.length; index++) {
  118339. renderSubMesh(opaqueSubMeshes.data[index]);
  118340. }
  118341. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  118342. renderSubMesh(alphaTestSubMeshes.data[index]);
  118343. }
  118344. if (transparentSubMeshes.length) {
  118345. // Sort sub meshes
  118346. for (index = 0; index < transparentSubMeshes.length; index++) {
  118347. var submesh = transparentSubMeshes.data[index];
  118348. var boundingInfo = submesh.getBoundingInfo();
  118349. if (boundingInfo && scene.activeCamera) {
  118350. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  118351. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  118352. }
  118353. }
  118354. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  118355. sortedArray.sort(function (a, b) {
  118356. // Alpha index first
  118357. if (a._alphaIndex > b._alphaIndex) {
  118358. return 1;
  118359. }
  118360. if (a._alphaIndex < b._alphaIndex) {
  118361. return -1;
  118362. }
  118363. // Then distance to camera
  118364. if (a._distanceToCamera < b._distanceToCamera) {
  118365. return 1;
  118366. }
  118367. if (a._distanceToCamera > b._distanceToCamera) {
  118368. return -1;
  118369. }
  118370. return 0;
  118371. });
  118372. // Render sub meshes
  118373. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  118374. for (index = 0; index < sortedArray.length; index++) {
  118375. renderSubMesh(sortedArray[index]);
  118376. }
  118377. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  118378. }
  118379. };
  118380. };
  118381. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  118382. var transform = scene.getTransformMatrix();
  118383. var meshPosition;
  118384. if (this.useCustomMeshPosition) {
  118385. meshPosition = this.customMeshPosition;
  118386. }
  118387. else if (this.attachedNode) {
  118388. meshPosition = this.attachedNode.position;
  118389. }
  118390. else {
  118391. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  118392. }
  118393. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  118394. this._screenCoordinates.x = pos.x / this._viewPort.width;
  118395. this._screenCoordinates.y = pos.y / this._viewPort.height;
  118396. if (this.invert) {
  118397. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  118398. }
  118399. };
  118400. // Static methods
  118401. /**
  118402. * Creates a default mesh for the Volumeric Light Scattering post-process
  118403. * @param name The mesh name
  118404. * @param scene The scene where to create the mesh
  118405. * @return the default mesh
  118406. */
  118407. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  118408. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  118409. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  118410. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  118411. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  118412. mesh.material = material;
  118413. return mesh;
  118414. };
  118415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  118417. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  118418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118420. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  118421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118423. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  118424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  118426. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  118427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118429. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  118430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118432. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  118433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118435. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  118436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118438. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  118439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118441. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  118442. return VolumetricLightScatteringPostProcess;
  118443. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  118444. /***/ }),
  118445. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  118446. /*!************************************************************!*\
  118447. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  118448. \************************************************************/
  118449. /*! exports provided: VRDistortionCorrectionPostProcess */
  118450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118451. "use strict";
  118452. __webpack_require__.r(__webpack_exports__);
  118453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  118454. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118455. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118456. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118457. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118458. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  118459. /**
  118460. * VRDistortionCorrectionPostProcess used for mobile VR
  118461. */
  118462. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  118463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  118464. /**
  118465. * Initializes the VRDistortionCorrectionPostProcess
  118466. * @param name The name of the effect.
  118467. * @param camera The camera to apply the render pass to.
  118468. * @param isRightEye If this is for the right eye distortion
  118469. * @param vrMetrics All the required metrics for the VR camera
  118470. */
  118471. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  118472. var _this = _super.call(this, name, "vrDistortionCorrection", [
  118473. 'LensCenter',
  118474. 'Scale',
  118475. 'ScaleIn',
  118476. 'HmdWarpParam'
  118477. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  118478. _this._isRightEye = isRightEye;
  118479. _this._distortionFactors = vrMetrics.distortionK;
  118480. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  118481. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  118482. _this.adaptScaleToCurrentViewport = true;
  118483. _this.onSizeChangedObservable.add(function () {
  118484. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  118485. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  118486. _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);
  118487. });
  118488. _this.onApplyObservable.add(function (effect) {
  118489. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  118490. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  118491. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  118492. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  118493. });
  118494. return _this;
  118495. }
  118496. return VRDistortionCorrectionPostProcess;
  118497. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118498. /***/ }),
  118499. /***/ "./Probes/index.ts":
  118500. /*!*************************!*\
  118501. !*** ./Probes/index.ts ***!
  118502. \*************************/
  118503. /*! exports provided: ReflectionProbe */
  118504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118505. "use strict";
  118506. __webpack_require__.r(__webpack_exports__);
  118507. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  118508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  118509. /***/ }),
  118510. /***/ "./Probes/reflectionProbe.ts":
  118511. /*!***********************************!*\
  118512. !*** ./Probes/reflectionProbe.ts ***!
  118513. \***********************************/
  118514. /*! exports provided: ReflectionProbe */
  118515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118516. "use strict";
  118517. __webpack_require__.r(__webpack_exports__);
  118518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  118519. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118520. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118521. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118522. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118523. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  118524. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118525. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  118526. if (!this.reflectionProbes) {
  118527. return -1;
  118528. }
  118529. var index = this.reflectionProbes.indexOf(toRemove);
  118530. if (index !== -1) {
  118531. this.reflectionProbes.splice(index, 1);
  118532. }
  118533. return index;
  118534. };
  118535. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  118536. if (!this.reflectionProbes) {
  118537. this.reflectionProbes = [];
  118538. }
  118539. this.reflectionProbes.push(newReflectionProbe);
  118540. };
  118541. /**
  118542. * Class used to generate realtime reflection / refraction cube textures
  118543. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118544. */
  118545. var ReflectionProbe = /** @class */ (function () {
  118546. /**
  118547. * Creates a new reflection probe
  118548. * @param name defines the name of the probe
  118549. * @param size defines the texture resolution (for each face)
  118550. * @param scene defines the hosting scene
  118551. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118552. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118553. */
  118554. function ReflectionProbe(
  118555. /** defines the name of the probe */
  118556. name, size, scene, generateMipMaps, useFloat) {
  118557. if (generateMipMaps === void 0) { generateMipMaps = true; }
  118558. if (useFloat === void 0) { useFloat = false; }
  118559. var _this = this;
  118560. this.name = name;
  118561. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  118562. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118563. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118564. this._invertYAxis = false;
  118565. /** Gets or sets probe position (center of the cube map) */
  118566. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118567. this._scene = scene;
  118568. // Create the scene field if not exist.
  118569. if (!this._scene.reflectionProbes) {
  118570. this._scene.reflectionProbes = new Array();
  118571. }
  118572. this._scene.reflectionProbes.push(this);
  118573. 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);
  118574. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  118575. switch (faceIndex) {
  118576. case 0:
  118577. _this._add.copyFromFloats(1, 0, 0);
  118578. break;
  118579. case 1:
  118580. _this._add.copyFromFloats(-1, 0, 0);
  118581. break;
  118582. case 2:
  118583. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  118584. break;
  118585. case 3:
  118586. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  118587. break;
  118588. case 4:
  118589. _this._add.copyFromFloats(0, 0, 1);
  118590. break;
  118591. case 5:
  118592. _this._add.copyFromFloats(0, 0, -1);
  118593. break;
  118594. }
  118595. if (_this._attachedMesh) {
  118596. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  118597. }
  118598. _this.position.addToRef(_this._add, _this._target);
  118599. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  118600. if (scene.activeCamera) {
  118601. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  118602. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  118603. }
  118604. scene._forcedViewPosition = _this.position;
  118605. });
  118606. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  118607. scene._forcedViewPosition = null;
  118608. scene.updateTransformMatrix(true);
  118609. });
  118610. }
  118611. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  118612. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118613. get: function () {
  118614. return this._renderTargetTexture.samples;
  118615. },
  118616. set: function (value) {
  118617. this._renderTargetTexture.samples = value;
  118618. },
  118619. enumerable: true,
  118620. configurable: true
  118621. });
  118622. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  118623. /** Gets or sets the refresh rate to use (on every frame by default) */
  118624. get: function () {
  118625. return this._renderTargetTexture.refreshRate;
  118626. },
  118627. set: function (value) {
  118628. this._renderTargetTexture.refreshRate = value;
  118629. },
  118630. enumerable: true,
  118631. configurable: true
  118632. });
  118633. /**
  118634. * Gets the hosting scene
  118635. * @returns a Scene
  118636. */
  118637. ReflectionProbe.prototype.getScene = function () {
  118638. return this._scene;
  118639. };
  118640. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  118641. /** Gets the internal CubeTexture used to render to */
  118642. get: function () {
  118643. return this._renderTargetTexture;
  118644. },
  118645. enumerable: true,
  118646. configurable: true
  118647. });
  118648. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  118649. /** Gets the list of meshes to render */
  118650. get: function () {
  118651. return this._renderTargetTexture.renderList;
  118652. },
  118653. enumerable: true,
  118654. configurable: true
  118655. });
  118656. /**
  118657. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118658. * @param mesh defines the mesh to attach to
  118659. */
  118660. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  118661. this._attachedMesh = mesh;
  118662. };
  118663. /**
  118664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118665. * @param renderingGroupId The rendering group id corresponding to its index
  118666. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118667. */
  118668. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  118669. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  118670. };
  118671. /**
  118672. * Clean all associated resources
  118673. */
  118674. ReflectionProbe.prototype.dispose = function () {
  118675. var index = this._scene.reflectionProbes.indexOf(this);
  118676. if (index !== -1) {
  118677. // Remove from the scene if found
  118678. this._scene.reflectionProbes.splice(index, 1);
  118679. }
  118680. if (this._renderTargetTexture) {
  118681. this._renderTargetTexture.dispose();
  118682. this._renderTargetTexture = null;
  118683. }
  118684. };
  118685. /**
  118686. * Converts the reflection probe information to a readable string for debug purpose.
  118687. * @param fullDetails Supports for multiple levels of logging within scene loading
  118688. * @returns the human readable reflection probe info
  118689. */
  118690. ReflectionProbe.prototype.toString = function (fullDetails) {
  118691. var ret = "Name: " + this.name;
  118692. if (fullDetails) {
  118693. ret += ", position: " + this.position.toString();
  118694. if (this._attachedMesh) {
  118695. ret += ", attached mesh: " + this._attachedMesh.name;
  118696. }
  118697. }
  118698. return ret;
  118699. };
  118700. /**
  118701. * Get the class name of the relfection probe.
  118702. * @returns "ReflectionProbe"
  118703. */
  118704. ReflectionProbe.prototype.getClassName = function () {
  118705. return "ReflectionProbe";
  118706. };
  118707. /**
  118708. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118709. * @returns The JSON representation of the texture
  118710. */
  118711. ReflectionProbe.prototype.serialize = function () {
  118712. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  118713. serializationObject.isReflectionProbe = true;
  118714. return serializationObject;
  118715. };
  118716. /**
  118717. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118718. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118719. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118720. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118721. * @returns The parsed reflection probe if successful
  118722. */
  118723. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  118724. var reflectionProbe = null;
  118725. if (scene.reflectionProbes) {
  118726. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  118727. var rp = scene.reflectionProbes[index];
  118728. if (rp.name === parsedReflectionProbe.name) {
  118729. reflectionProbe = rp;
  118730. break;
  118731. }
  118732. }
  118733. }
  118734. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  118735. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  118736. if (parsedReflectionProbe._attachedMesh) {
  118737. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  118738. }
  118739. return reflectionProbe;
  118740. };
  118741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118742. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  118743. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  118744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  118746. ], ReflectionProbe.prototype, "position", void 0);
  118747. return ReflectionProbe;
  118748. }());
  118749. /***/ }),
  118750. /***/ "./Rendering/boundingBoxRenderer.ts":
  118751. /*!******************************************!*\
  118752. !*** ./Rendering/boundingBoxRenderer.ts ***!
  118753. \******************************************/
  118754. /*! exports provided: BoundingBoxRenderer */
  118755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118756. "use strict";
  118757. __webpack_require__.r(__webpack_exports__);
  118758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  118759. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  118760. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118761. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118762. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  118763. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118764. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118765. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  118766. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118767. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  118768. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  118769. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  118770. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  118771. get: function () {
  118772. return this._forceShowBoundingBoxes || false;
  118773. },
  118774. set: function (value) {
  118775. this._forceShowBoundingBoxes = value;
  118776. // Lazyly creates a BB renderer if needed.
  118777. if (value) {
  118778. this.getBoundingBoxRenderer();
  118779. }
  118780. },
  118781. enumerable: true,
  118782. configurable: true
  118783. });
  118784. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  118785. if (!this._boundingBoxRenderer) {
  118786. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  118787. }
  118788. return this._boundingBoxRenderer;
  118789. };
  118790. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  118791. get: function () {
  118792. return this._showBoundingBox || false;
  118793. },
  118794. set: function (value) {
  118795. this._showBoundingBox = value;
  118796. // Lazyly creates a BB renderer if needed.
  118797. if (value) {
  118798. this.getScene().getBoundingBoxRenderer();
  118799. }
  118800. },
  118801. enumerable: true,
  118802. configurable: true
  118803. });
  118804. /**
  118805. * Component responsible of rendering the bounding box of the meshes in a scene.
  118806. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  118807. */
  118808. var BoundingBoxRenderer = /** @class */ (function () {
  118809. /**
  118810. * Instantiates a new bounding box renderer in a scene.
  118811. * @param scene the scene the renderer renders in
  118812. */
  118813. function BoundingBoxRenderer(scene) {
  118814. /**
  118815. * The component name helpfull to identify the component in the list of scene components.
  118816. */
  118817. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  118818. /**
  118819. * Color of the bounding box lines placed in front of an object
  118820. */
  118821. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  118822. /**
  118823. * Color of the bounding box lines placed behind an object
  118824. */
  118825. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  118826. /**
  118827. * Defines if the renderer should show the back lines or not
  118828. */
  118829. this.showBackLines = true;
  118830. /**
  118831. * @hidden
  118832. */
  118833. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  118834. this._vertexBuffers = {};
  118835. this.scene = scene;
  118836. scene._addComponent(this);
  118837. }
  118838. /**
  118839. * Registers the component in a given scene
  118840. */
  118841. BoundingBoxRenderer.prototype.register = function () {
  118842. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  118843. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  118844. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  118845. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  118846. };
  118847. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  118848. if (mesh.showSubMeshesBoundingBox) {
  118849. var boundingInfo = subMesh.getBoundingInfo();
  118850. if (boundingInfo !== null && boundingInfo !== undefined) {
  118851. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  118852. this.renderList.push(boundingInfo.boundingBox);
  118853. }
  118854. }
  118855. };
  118856. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  118857. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  118858. var boundingInfo = sourceMesh.getBoundingInfo();
  118859. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  118860. this.renderList.push(boundingInfo.boundingBox);
  118861. }
  118862. };
  118863. BoundingBoxRenderer.prototype._prepareRessources = function () {
  118864. if (this._colorShader) {
  118865. return;
  118866. }
  118867. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  118868. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  118869. uniforms: ["world", "viewProjection", "color"]
  118870. });
  118871. var engine = this.scene.getEngine();
  118872. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  118873. 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);
  118874. this._createIndexBuffer();
  118875. };
  118876. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  118877. var engine = this.scene.getEngine();
  118878. 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]);
  118879. };
  118880. /**
  118881. * Rebuilds the elements related to this component in case of
  118882. * context lost for instance.
  118883. */
  118884. BoundingBoxRenderer.prototype.rebuild = function () {
  118885. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118886. if (vb) {
  118887. vb._rebuild();
  118888. }
  118889. this._createIndexBuffer();
  118890. };
  118891. /**
  118892. * @hidden
  118893. */
  118894. BoundingBoxRenderer.prototype.reset = function () {
  118895. this.renderList.reset();
  118896. };
  118897. /**
  118898. * Render the bounding boxes of a specific rendering group
  118899. * @param renderingGroupId defines the rendering group to render
  118900. */
  118901. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  118902. if (this.renderList.length === 0) {
  118903. return;
  118904. }
  118905. this._prepareRessources();
  118906. if (!this._colorShader.isReady()) {
  118907. return;
  118908. }
  118909. var engine = this.scene.getEngine();
  118910. engine.setDepthWrite(false);
  118911. this._colorShader._preBind();
  118912. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  118913. var boundingBox = this.renderList.data[boundingBoxIndex];
  118914. if (boundingBox._tag !== renderingGroupId) {
  118915. continue;
  118916. }
  118917. var min = boundingBox.minimum;
  118918. var max = boundingBox.maximum;
  118919. var diff = max.subtract(min);
  118920. var median = min.add(diff.scale(0.5));
  118921. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  118922. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  118923. .multiply(boundingBox.getWorldMatrix());
  118924. // VBOs
  118925. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  118926. if (this.showBackLines) {
  118927. // Back
  118928. engine.setDepthFunctionToGreaterOrEqual();
  118929. this.scene.resetCachedMaterial();
  118930. this._colorShader.setColor4("color", this.backColor.toColor4());
  118931. this._colorShader.bind(worldMatrix);
  118932. // Draw order
  118933. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  118934. }
  118935. // Front
  118936. engine.setDepthFunctionToLess();
  118937. this.scene.resetCachedMaterial();
  118938. this._colorShader.setColor4("color", this.frontColor.toColor4());
  118939. this._colorShader.bind(worldMatrix);
  118940. // Draw order
  118941. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  118942. }
  118943. this._colorShader.unbind();
  118944. engine.setDepthFunctionToLessOrEqual();
  118945. engine.setDepthWrite(true);
  118946. };
  118947. /**
  118948. * In case of occlusion queries, we can render the occlusion bounding box through this method
  118949. * @param mesh Define the mesh to render the occlusion bounding box for
  118950. */
  118951. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  118952. this._prepareRessources();
  118953. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  118954. return;
  118955. }
  118956. var engine = this.scene.getEngine();
  118957. engine.setDepthWrite(false);
  118958. engine.setColorWrite(false);
  118959. this._colorShader._preBind();
  118960. var boundingBox = mesh._boundingInfo.boundingBox;
  118961. var min = boundingBox.minimum;
  118962. var max = boundingBox.maximum;
  118963. var diff = max.subtract(min);
  118964. var median = min.add(diff.scale(0.5));
  118965. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  118966. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  118967. .multiply(boundingBox.getWorldMatrix());
  118968. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  118969. engine.setDepthFunctionToLess();
  118970. this.scene.resetCachedMaterial();
  118971. this._colorShader.bind(worldMatrix);
  118972. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  118973. this._colorShader.unbind();
  118974. engine.setDepthFunctionToLessOrEqual();
  118975. engine.setDepthWrite(true);
  118976. engine.setColorWrite(true);
  118977. };
  118978. /**
  118979. * Dispose and release the resources attached to this renderer.
  118980. */
  118981. BoundingBoxRenderer.prototype.dispose = function () {
  118982. if (!this._colorShader) {
  118983. return;
  118984. }
  118985. this.renderList.dispose();
  118986. this._colorShader.dispose();
  118987. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  118988. if (buffer) {
  118989. buffer.dispose();
  118990. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  118991. }
  118992. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  118993. };
  118994. return BoundingBoxRenderer;
  118995. }());
  118996. /***/ }),
  118997. /***/ "./Rendering/depthRenderer.ts":
  118998. /*!************************************!*\
  118999. !*** ./Rendering/depthRenderer.ts ***!
  119000. \************************************/
  119001. /*! exports provided: DepthRenderer */
  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__, "DepthRenderer", function() { return DepthRenderer; });
  119006. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119007. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.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_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119010. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119011. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119012. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  119013. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119014. /**
  119015. * This represents a depth renderer in Babylon.
  119016. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119017. */
  119018. var DepthRenderer = /** @class */ (function () {
  119019. /**
  119020. * Instantiates a depth renderer
  119021. * @param scene The scene the renderer belongs to
  119022. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119023. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119024. */
  119025. function DepthRenderer(scene, type, camera) {
  119026. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  119027. if (camera === void 0) { camera = null; }
  119028. var _this = this;
  119029. /**
  119030. * Specifiess that the depth renderer will only be used within
  119031. * the camera it is created for.
  119032. * This can help forcing its rendering during the camera processing.
  119033. */
  119034. this.useOnlyInActiveCamera = false;
  119035. this._scene = scene;
  119036. DepthRenderer._SceneComponentInitialization(this._scene);
  119037. this._camera = camera;
  119038. var engine = scene.getEngine();
  119039. // Render target
  119040. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  119041. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119042. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119043. this._depthMap.refreshRate = 1;
  119044. this._depthMap.renderParticles = false;
  119045. this._depthMap.renderList = null;
  119046. // Camera to get depth map from to support multiple concurrent cameras
  119047. this._depthMap.activeCamera = this._camera;
  119048. this._depthMap.ignoreCameraViewport = true;
  119049. this._depthMap.useCameraPostProcesses = false;
  119050. // set default depth value to 1.0 (far away)
  119051. this._depthMap.onClearObservable.add(function (engine) {
  119052. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  119053. });
  119054. // Custom render function
  119055. var renderSubMesh = function (subMesh) {
  119056. var mesh = subMesh.getRenderingMesh();
  119057. var scene = _this._scene;
  119058. var engine = scene.getEngine();
  119059. var material = subMesh.getMaterial();
  119060. if (!material) {
  119061. return;
  119062. }
  119063. // Culling and reverse (right handed system)
  119064. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  119065. // Managing instances
  119066. var batch = mesh._getInstancesRenderList(subMesh._id);
  119067. if (batch.mustReturn) {
  119068. return;
  119069. }
  119070. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119071. var camera = _this._camera || scene.activeCamera;
  119072. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  119073. engine.enableEffect(_this._effect);
  119074. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  119075. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  119076. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  119077. // Alpha test
  119078. if (material && material.needAlphaTesting()) {
  119079. var alphaTexture = material.getAlphaTestTexture();
  119080. if (alphaTexture) {
  119081. _this._effect.setTexture("diffuseSampler", alphaTexture);
  119082. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119083. }
  119084. }
  119085. // Bones
  119086. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119087. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119088. }
  119089. // Draw
  119090. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  119091. }
  119092. };
  119093. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119094. var index;
  119095. if (depthOnlySubMeshes.length) {
  119096. engine.setColorWrite(false);
  119097. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119098. renderSubMesh(depthOnlySubMeshes.data[index]);
  119099. }
  119100. engine.setColorWrite(true);
  119101. }
  119102. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119103. renderSubMesh(opaqueSubMeshes.data[index]);
  119104. }
  119105. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119106. renderSubMesh(alphaTestSubMeshes.data[index]);
  119107. }
  119108. };
  119109. }
  119110. /**
  119111. * Creates the depth rendering effect and checks if the effect is ready.
  119112. * @param subMesh The submesh to be used to render the depth map of
  119113. * @param useInstances If multiple world instances should be used
  119114. * @returns if the depth renderer is ready to render the depth map
  119115. */
  119116. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  119117. var material = subMesh.getMaterial();
  119118. if (material.disableDepthWrite) {
  119119. return false;
  119120. }
  119121. var defines = [];
  119122. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119123. var mesh = subMesh.getMesh();
  119124. // Alpha test
  119125. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  119126. defines.push("#define ALPHATEST");
  119127. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  119128. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  119129. defines.push("#define UV1");
  119130. }
  119131. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  119132. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  119133. defines.push("#define UV2");
  119134. }
  119135. }
  119136. // Bones
  119137. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119138. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  119139. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  119140. if (mesh.numBoneInfluencers > 4) {
  119141. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  119142. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  119143. }
  119144. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119145. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  119146. }
  119147. else {
  119148. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119149. }
  119150. // Instances
  119151. if (useInstances) {
  119152. defines.push("#define INSTANCES");
  119153. attribs.push("world0");
  119154. attribs.push("world1");
  119155. attribs.push("world2");
  119156. attribs.push("world3");
  119157. }
  119158. // Get correct effect
  119159. var join = defines.join("\n");
  119160. if (this._cachedDefines !== join) {
  119161. this._cachedDefines = join;
  119162. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  119163. }
  119164. return this._effect.isReady();
  119165. };
  119166. /**
  119167. * Gets the texture which the depth map will be written to.
  119168. * @returns The depth map texture
  119169. */
  119170. DepthRenderer.prototype.getDepthMap = function () {
  119171. return this._depthMap;
  119172. };
  119173. /**
  119174. * Disposes of the depth renderer.
  119175. */
  119176. DepthRenderer.prototype.dispose = function () {
  119177. this._depthMap.dispose();
  119178. };
  119179. /** @hidden */
  119180. DepthRenderer._SceneComponentInitialization = function (_) {
  119181. throw "Import DepthRendererSceneComponent before creating DepthRenderer.";
  119182. };
  119183. return DepthRenderer;
  119184. }());
  119185. /***/ }),
  119186. /***/ "./Rendering/depthRendererSceneComponent.ts":
  119187. /*!**************************************************!*\
  119188. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  119189. \**************************************************/
  119190. /*! exports provided: DepthRendererSceneComponent */
  119191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119192. "use strict";
  119193. __webpack_require__.r(__webpack_exports__);
  119194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  119195. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119196. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  119197. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119198. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119199. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  119200. camera = camera || this.activeCamera;
  119201. if (!camera) {
  119202. throw "No camera available to enable depth renderer";
  119203. }
  119204. if (!this._depthRenderer) {
  119205. this._depthRenderer = {};
  119206. }
  119207. if (!this._depthRenderer[camera.id]) {
  119208. var textureType = 0;
  119209. if (this.getEngine().getCaps().textureHalfFloatRender) {
  119210. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  119211. }
  119212. else if (this.getEngine().getCaps().textureFloatRender) {
  119213. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  119214. }
  119215. else {
  119216. throw "Depth renderer does not support int texture type";
  119217. }
  119218. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  119219. }
  119220. return this._depthRenderer[camera.id];
  119221. };
  119222. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  119223. camera = camera || this.activeCamera;
  119224. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  119225. return;
  119226. }
  119227. this._depthRenderer[camera.id].dispose();
  119228. delete this._depthRenderer[camera.id];
  119229. };
  119230. /**
  119231. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119232. * in several rendering techniques.
  119233. */
  119234. var DepthRendererSceneComponent = /** @class */ (function () {
  119235. /**
  119236. * Creates a new instance of the component for the given scene
  119237. * @param scene Defines the scene to register the component in
  119238. */
  119239. function DepthRendererSceneComponent(scene) {
  119240. /**
  119241. * The component name helpfull to identify the component in the list of scene components.
  119242. */
  119243. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  119244. this.scene = scene;
  119245. }
  119246. /**
  119247. * Registers the component in a given scene
  119248. */
  119249. DepthRendererSceneComponent.prototype.register = function () {
  119250. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  119251. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  119252. };
  119253. /**
  119254. * Rebuilds the elements related to this component in case of
  119255. * context lost for instance.
  119256. */
  119257. DepthRendererSceneComponent.prototype.rebuild = function () {
  119258. // Nothing to do for this component
  119259. };
  119260. /**
  119261. * Disposes the component and the associated ressources
  119262. */
  119263. DepthRendererSceneComponent.prototype.dispose = function () {
  119264. for (var key in this.scene._depthRenderer) {
  119265. this.scene._depthRenderer[key].dispose();
  119266. }
  119267. };
  119268. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  119269. if (this.scene._depthRenderer) {
  119270. for (var key in this.scene._depthRenderer) {
  119271. var depthRenderer = this.scene._depthRenderer[key];
  119272. if (!depthRenderer.useOnlyInActiveCamera) {
  119273. renderTargets.push(depthRenderer.getDepthMap());
  119274. }
  119275. }
  119276. }
  119277. };
  119278. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  119279. if (this.scene._depthRenderer) {
  119280. for (var key in this.scene._depthRenderer) {
  119281. var depthRenderer = this.scene._depthRenderer[key];
  119282. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  119283. renderTargets.push(depthRenderer.getDepthMap());
  119284. }
  119285. }
  119286. }
  119287. };
  119288. return DepthRendererSceneComponent;
  119289. }());
  119290. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  119291. // Register the G Buffer component to the scene.
  119292. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  119293. if (!component) {
  119294. component = new DepthRendererSceneComponent(scene);
  119295. scene._addComponent(component);
  119296. }
  119297. };
  119298. /***/ }),
  119299. /***/ "./Rendering/edgesRenderer.ts":
  119300. /*!************************************!*\
  119301. !*** ./Rendering/edgesRenderer.ts ***!
  119302. \************************************/
  119303. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  119304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119305. "use strict";
  119306. __webpack_require__.r(__webpack_exports__);
  119307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  119308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  119309. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119310. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119311. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119312. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  119313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119314. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119315. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119316. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  119317. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119318. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  119319. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  119320. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  119321. if (this._edgesRenderer) {
  119322. this._edgesRenderer.dispose();
  119323. this._edgesRenderer = null;
  119324. }
  119325. return this;
  119326. };
  119327. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119328. if (epsilon === void 0) { epsilon = 0.95; }
  119329. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119330. this.disableEdgesRendering();
  119331. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119332. return this;
  119333. };
  119334. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  119335. get: function () {
  119336. return this._edgesRenderer;
  119337. },
  119338. enumerable: true,
  119339. configurable: true
  119340. });
  119341. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119342. if (epsilon === void 0) { epsilon = 0.95; }
  119343. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119344. this.disableEdgesRendering();
  119345. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119346. return this;
  119347. };
  119348. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119349. if (epsilon === void 0) { epsilon = 0.95; }
  119350. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119351. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  119352. return this;
  119353. };
  119354. /**
  119355. * FaceAdjacencies Helper class to generate edges
  119356. */
  119357. var FaceAdjacencies = /** @class */ (function () {
  119358. function FaceAdjacencies() {
  119359. this.edges = new Array();
  119360. this.edgesConnectedCount = 0;
  119361. }
  119362. return FaceAdjacencies;
  119363. }());
  119364. /**
  119365. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  119366. */
  119367. var EdgesRenderer = /** @class */ (function () {
  119368. /**
  119369. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  119370. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  119371. * @param source Mesh used to create edges
  119372. * @param epsilon sum of angles in adjacency to check for edge
  119373. * @param checkVerticesInsteadOfIndices
  119374. * @param generateEdgesLines - should generate Lines or only prepare resources.
  119375. */
  119376. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  119377. if (epsilon === void 0) { epsilon = 0.95; }
  119378. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119379. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  119380. var _this = this;
  119381. /**
  119382. * Define the size of the edges with an orthographic camera
  119383. */
  119384. this.edgesWidthScalerForOrthographic = 1000.0;
  119385. /**
  119386. * Define the size of the edges with a perspective camera
  119387. */
  119388. this.edgesWidthScalerForPerspective = 50.0;
  119389. this._linesPositions = new Array();
  119390. this._linesNormals = new Array();
  119391. this._linesIndices = new Array();
  119392. this._buffers = {};
  119393. this._checkVerticesInsteadOfIndices = false;
  119394. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  119395. this.isEnabled = true;
  119396. this._source = source;
  119397. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  119398. this._epsilon = epsilon;
  119399. this._prepareRessources();
  119400. if (generateEdgesLines) {
  119401. this._generateEdgesLines();
  119402. }
  119403. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  119404. _this._rebuild();
  119405. });
  119406. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  119407. _this.dispose();
  119408. });
  119409. }
  119410. EdgesRenderer.prototype._prepareRessources = function () {
  119411. if (this._lineShader) {
  119412. return;
  119413. }
  119414. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  119415. attributes: ["position", "normal"],
  119416. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  119417. });
  119418. this._lineShader.disableDepthWrite = true;
  119419. this._lineShader.backFaceCulling = false;
  119420. };
  119421. /** @hidden */
  119422. EdgesRenderer.prototype._rebuild = function () {
  119423. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119424. if (buffer) {
  119425. buffer._rebuild();
  119426. }
  119427. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119428. if (buffer) {
  119429. buffer._rebuild();
  119430. }
  119431. var scene = this._source.getScene();
  119432. var engine = scene.getEngine();
  119433. this._ib = engine.createIndexBuffer(this._linesIndices);
  119434. };
  119435. /**
  119436. * Releases the required resources for the edges renderer
  119437. */
  119438. EdgesRenderer.prototype.dispose = function () {
  119439. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  119440. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  119441. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119442. if (buffer) {
  119443. buffer.dispose();
  119444. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119445. }
  119446. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119447. if (buffer) {
  119448. buffer.dispose();
  119449. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  119450. }
  119451. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  119452. this._lineShader.dispose();
  119453. };
  119454. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  119455. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  119456. return 0;
  119457. }
  119458. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  119459. return 1;
  119460. }
  119461. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  119462. return 2;
  119463. }
  119464. return -1;
  119465. };
  119466. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  119467. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  119468. return 0;
  119469. }
  119470. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  119471. return 1;
  119472. }
  119473. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  119474. return 2;
  119475. }
  119476. return -1;
  119477. };
  119478. /**
  119479. * Checks if the pair of p0 and p1 is en edge
  119480. * @param faceIndex
  119481. * @param edge
  119482. * @param faceNormals
  119483. * @param p0
  119484. * @param p1
  119485. * @private
  119486. */
  119487. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  119488. var needToCreateLine;
  119489. if (edge === undefined) {
  119490. needToCreateLine = true;
  119491. }
  119492. else {
  119493. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  119494. needToCreateLine = dotProduct < this._epsilon;
  119495. }
  119496. if (needToCreateLine) {
  119497. this.createLine(p0, p1, this._linesPositions.length / 3);
  119498. }
  119499. };
  119500. /**
  119501. * push line into the position, normal and index buffer
  119502. * @protected
  119503. */
  119504. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  119505. // Positions
  119506. 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);
  119507. // Normals
  119508. 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);
  119509. // Indices
  119510. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  119511. };
  119512. /**
  119513. * Generates lines edges from adjacencjes
  119514. * @private
  119515. */
  119516. EdgesRenderer.prototype._generateEdgesLines = function () {
  119517. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  119518. var indices = this._source.getIndices();
  119519. if (!indices || !positions) {
  119520. return;
  119521. }
  119522. // First let's find adjacencies
  119523. var adjacencies = new Array();
  119524. var faceNormals = new Array();
  119525. var index;
  119526. var faceAdjacencies;
  119527. // Prepare faces
  119528. for (index = 0; index < indices.length; index += 3) {
  119529. faceAdjacencies = new FaceAdjacencies();
  119530. var p0Index = indices[index];
  119531. var p1Index = indices[index + 1];
  119532. var p2Index = indices[index + 2];
  119533. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  119534. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  119535. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  119536. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  119537. faceNormal.normalize();
  119538. faceNormals.push(faceNormal);
  119539. adjacencies.push(faceAdjacencies);
  119540. }
  119541. // Scan
  119542. for (index = 0; index < adjacencies.length; index++) {
  119543. faceAdjacencies = adjacencies[index];
  119544. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  119545. var otherFaceAdjacencies = adjacencies[otherIndex];
  119546. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  119547. break;
  119548. }
  119549. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  119550. continue;
  119551. }
  119552. var otherP0 = indices[otherIndex * 3];
  119553. var otherP1 = indices[otherIndex * 3 + 1];
  119554. var otherP2 = indices[otherIndex * 3 + 2];
  119555. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  119556. var otherEdgeIndex = 0;
  119557. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  119558. continue;
  119559. }
  119560. switch (edgeIndex) {
  119561. case 0:
  119562. if (this._checkVerticesInsteadOfIndices) {
  119563. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119564. }
  119565. else {
  119566. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  119567. }
  119568. break;
  119569. case 1:
  119570. if (this._checkVerticesInsteadOfIndices) {
  119571. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119572. }
  119573. else {
  119574. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  119575. }
  119576. break;
  119577. case 2:
  119578. if (this._checkVerticesInsteadOfIndices) {
  119579. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119580. }
  119581. else {
  119582. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  119583. }
  119584. break;
  119585. }
  119586. if (otherEdgeIndex === -1) {
  119587. continue;
  119588. }
  119589. faceAdjacencies.edges[edgeIndex] = otherIndex;
  119590. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  119591. faceAdjacencies.edgesConnectedCount++;
  119592. otherFaceAdjacencies.edgesConnectedCount++;
  119593. if (faceAdjacencies.edgesConnectedCount === 3) {
  119594. break;
  119595. }
  119596. }
  119597. }
  119598. }
  119599. // Create lines
  119600. for (index = 0; index < adjacencies.length; index++) {
  119601. // 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
  119602. var current = adjacencies[index];
  119603. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  119604. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  119605. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  119606. }
  119607. // Merge into a single mesh
  119608. var engine = this._source.getScene().getEngine();
  119609. 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);
  119610. 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);
  119611. this._ib = engine.createIndexBuffer(this._linesIndices);
  119612. this._indicesCount = this._linesIndices.length;
  119613. };
  119614. /**
  119615. * Checks wether or not the edges renderer is ready to render.
  119616. * @return true if ready, otherwise false.
  119617. */
  119618. EdgesRenderer.prototype.isReady = function () {
  119619. return this._lineShader.isReady();
  119620. };
  119621. /**
  119622. * Renders the edges of the attached mesh,
  119623. */
  119624. EdgesRenderer.prototype.render = function () {
  119625. var scene = this._source.getScene();
  119626. if (!this.isReady() || !scene.activeCamera) {
  119627. return;
  119628. }
  119629. var engine = scene.getEngine();
  119630. this._lineShader._preBind();
  119631. if (this._source.edgesColor.a !== 1) {
  119632. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  119633. }
  119634. else {
  119635. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  119636. }
  119637. // VBOs
  119638. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  119639. scene.resetCachedMaterial();
  119640. this._lineShader.setColor4("color", this._source.edgesColor);
  119641. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  119642. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  119643. }
  119644. else {
  119645. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  119646. }
  119647. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  119648. this._lineShader.bind(this._source.getWorldMatrix());
  119649. // Draw order
  119650. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  119651. this._lineShader.unbind();
  119652. };
  119653. return EdgesRenderer;
  119654. }());
  119655. /**
  119656. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  119657. */
  119658. var LineEdgesRenderer = /** @class */ (function (_super) {
  119659. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  119660. /**
  119661. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  119662. * @param source LineMesh used to generate edges
  119663. * @param epsilon not important (specified angle for edge detection)
  119664. * @param checkVerticesInsteadOfIndices not important for LineMesh
  119665. */
  119666. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  119667. if (epsilon === void 0) { epsilon = 0.95; }
  119668. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119669. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  119670. _this._generateEdgesLines();
  119671. return _this;
  119672. }
  119673. /**
  119674. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  119675. */
  119676. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  119677. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  119678. var indices = this._source.getIndices();
  119679. if (!indices || !positions) {
  119680. return;
  119681. }
  119682. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  119683. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  119684. var len = indices.length - 1;
  119685. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  119686. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  119687. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  119688. this.createLine(p0, p1, offset);
  119689. }
  119690. // Merge into a single mesh
  119691. var engine = this._source.getScene().getEngine();
  119692. 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);
  119693. 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);
  119694. this._ib = engine.createIndexBuffer(this._linesIndices);
  119695. this._indicesCount = this._linesIndices.length;
  119696. };
  119697. return LineEdgesRenderer;
  119698. }(EdgesRenderer));
  119699. /***/ }),
  119700. /***/ "./Rendering/geometryBufferRenderer.ts":
  119701. /*!*********************************************!*\
  119702. !*** ./Rendering/geometryBufferRenderer.ts ***!
  119703. \*********************************************/
  119704. /*! exports provided: GeometryBufferRenderer */
  119705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119706. "use strict";
  119707. __webpack_require__.r(__webpack_exports__);
  119708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  119709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119710. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119711. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119712. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119713. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  119714. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119715. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  119716. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  119717. /**
  119718. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  119719. */
  119720. var GeometryBufferRenderer = /** @class */ (function () {
  119721. /**
  119722. * Creates a new G Buffer for the scene
  119723. * @param scene The scene the buffer belongs to
  119724. * @param ratio How big is the buffer related to the main canvas.
  119725. */
  119726. function GeometryBufferRenderer(scene, ratio) {
  119727. if (ratio === void 0) { ratio = 1; }
  119728. /**
  119729. * Dictionary used to store the previous transformation matrices of each rendered mesh
  119730. * in order to compute objects velocities when enableVelocity is set to "true"
  119731. * @hidden
  119732. */
  119733. this._previousTransformationMatrices = {};
  119734. this._enablePosition = false;
  119735. this._enableVelocity = false;
  119736. this._positionIndex = -1;
  119737. this._velocityIndex = -1;
  119738. this._scene = scene;
  119739. this._ratio = ratio;
  119740. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  119741. // Render target
  119742. this._createRenderTargets();
  119743. }
  119744. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  119745. /**
  119746. * Set the render list (meshes to be rendered) used in the G buffer.
  119747. */
  119748. set: function (meshes) {
  119749. this._multiRenderTarget.renderList = meshes;
  119750. },
  119751. enumerable: true,
  119752. configurable: true
  119753. });
  119754. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  119755. /**
  119756. * Gets wether or not G buffer are supported by the running hardware.
  119757. * This requires draw buffer supports
  119758. */
  119759. get: function () {
  119760. return this._multiRenderTarget.isSupported;
  119761. },
  119762. enumerable: true,
  119763. configurable: true
  119764. });
  119765. /**
  119766. * Returns the index of the given texture type in the G-Buffer textures array
  119767. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  119768. * @returns the index of the given texture type in the G-Buffer textures array
  119769. */
  119770. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  119771. switch (textureType) {
  119772. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  119773. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  119774. default: return -1;
  119775. }
  119776. };
  119777. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  119778. /**
  119779. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  119780. */
  119781. get: function () {
  119782. return this._enablePosition;
  119783. },
  119784. /**
  119785. * Sets whether or not objects positions are enabled for the G buffer.
  119786. */
  119787. set: function (enable) {
  119788. this._enablePosition = enable;
  119789. this.dispose();
  119790. this._createRenderTargets();
  119791. },
  119792. enumerable: true,
  119793. configurable: true
  119794. });
  119795. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  119796. /**
  119797. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  119798. */
  119799. get: function () {
  119800. return this._enableVelocity;
  119801. },
  119802. /**
  119803. * Sets wether or not objects velocities are enabled for the G buffer.
  119804. */
  119805. set: function (enable) {
  119806. this._enableVelocity = enable;
  119807. this.dispose();
  119808. this._createRenderTargets();
  119809. },
  119810. enumerable: true,
  119811. configurable: true
  119812. });
  119813. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  119814. /**
  119815. * Gets the scene associated with the buffer.
  119816. */
  119817. get: function () {
  119818. return this._scene;
  119819. },
  119820. enumerable: true,
  119821. configurable: true
  119822. });
  119823. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  119824. /**
  119825. * Gets the ratio used by the buffer during its creation.
  119826. * How big is the buffer related to the main canvas.
  119827. */
  119828. get: function () {
  119829. return this._ratio;
  119830. },
  119831. enumerable: true,
  119832. configurable: true
  119833. });
  119834. /**
  119835. * Checks wether everything is ready to render a submesh to the G buffer.
  119836. * @param subMesh the submesh to check readiness for
  119837. * @param useInstances is the mesh drawn using instance or not
  119838. * @returns true if ready otherwise false
  119839. */
  119840. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  119841. var material = subMesh.getMaterial();
  119842. if (material && material.disableDepthWrite) {
  119843. return false;
  119844. }
  119845. var defines = [];
  119846. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119847. var mesh = subMesh.getMesh();
  119848. // Alpha test
  119849. if (material && material.needAlphaTesting()) {
  119850. defines.push("#define ALPHATEST");
  119851. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  119852. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  119853. defines.push("#define UV1");
  119854. }
  119855. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  119856. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  119857. defines.push("#define UV2");
  119858. }
  119859. }
  119860. // Buffers
  119861. if (this._enablePosition) {
  119862. defines.push("#define POSITION");
  119863. defines.push("#define POSITION_INDEX " + this._positionIndex);
  119864. }
  119865. if (this._enableVelocity) {
  119866. defines.push("#define VELOCITY");
  119867. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  119868. }
  119869. // Bones
  119870. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119871. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  119872. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  119873. if (mesh.numBoneInfluencers > 4) {
  119874. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  119875. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  119876. }
  119877. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119878. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  119879. }
  119880. else {
  119881. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119882. }
  119883. // Instances
  119884. if (useInstances) {
  119885. defines.push("#define INSTANCES");
  119886. attribs.push("world0");
  119887. attribs.push("world1");
  119888. attribs.push("world2");
  119889. attribs.push("world3");
  119890. }
  119891. // Setup textures count
  119892. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  119893. // Get correct effect
  119894. var join = defines.join("\n");
  119895. if (this._cachedDefines !== join) {
  119896. this._cachedDefines = join;
  119897. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  119898. }
  119899. return this._effect.isReady();
  119900. };
  119901. /**
  119902. * Gets the current underlying G Buffer.
  119903. * @returns the buffer
  119904. */
  119905. GeometryBufferRenderer.prototype.getGBuffer = function () {
  119906. return this._multiRenderTarget;
  119907. };
  119908. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  119909. /**
  119910. * Gets the number of samples used to render the buffer (anti aliasing).
  119911. */
  119912. get: function () {
  119913. return this._multiRenderTarget.samples;
  119914. },
  119915. /**
  119916. * Sets the number of samples used to render the buffer (anti aliasing).
  119917. */
  119918. set: function (value) {
  119919. this._multiRenderTarget.samples = value;
  119920. },
  119921. enumerable: true,
  119922. configurable: true
  119923. });
  119924. /**
  119925. * Disposes the renderer and frees up associated resources.
  119926. */
  119927. GeometryBufferRenderer.prototype.dispose = function () {
  119928. this.getGBuffer().dispose();
  119929. };
  119930. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  119931. var _this = this;
  119932. var engine = this._scene.getEngine();
  119933. var count = 2;
  119934. if (this._enablePosition) {
  119935. this._positionIndex = count;
  119936. count++;
  119937. }
  119938. if (this._enableVelocity) {
  119939. this._velocityIndex = count;
  119940. count++;
  119941. }
  119942. 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 });
  119943. if (!this.isSupported) {
  119944. return;
  119945. }
  119946. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  119947. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  119948. this._multiRenderTarget.refreshRate = 1;
  119949. this._multiRenderTarget.renderParticles = false;
  119950. this._multiRenderTarget.renderList = null;
  119951. // set default depth value to 1.0 (far away)
  119952. this._multiRenderTarget.onClearObservable.add(function (engine) {
  119953. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  119954. });
  119955. // Custom render function
  119956. var renderSubMesh = function (subMesh) {
  119957. var mesh = subMesh.getRenderingMesh();
  119958. var scene = _this._scene;
  119959. var engine = scene.getEngine();
  119960. var material = subMesh.getMaterial();
  119961. if (!material) {
  119962. return;
  119963. }
  119964. // Velocity
  119965. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  119966. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  119967. }
  119968. // Culling
  119969. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  119970. // Managing instances
  119971. var batch = mesh._getInstancesRenderList(subMesh._id);
  119972. if (batch.mustReturn) {
  119973. return;
  119974. }
  119975. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119976. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  119977. engine.enableEffect(_this._effect);
  119978. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  119979. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  119980. _this._effect.setMatrix("view", scene.getViewMatrix());
  119981. // Alpha test
  119982. if (material && material.needAlphaTesting()) {
  119983. var alphaTexture = material.getAlphaTestTexture();
  119984. if (alphaTexture) {
  119985. _this._effect.setTexture("diffuseSampler", alphaTexture);
  119986. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119987. }
  119988. }
  119989. // Bones
  119990. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119991. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119992. }
  119993. // Velocity
  119994. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  119995. // Draw
  119996. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  119997. }
  119998. // Velocity
  119999. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  120000. };
  120001. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120002. var index;
  120003. if (depthOnlySubMeshes.length) {
  120004. engine.setColorWrite(false);
  120005. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120006. renderSubMesh(depthOnlySubMeshes.data[index]);
  120007. }
  120008. engine.setColorWrite(true);
  120009. }
  120010. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120011. renderSubMesh(opaqueSubMeshes.data[index]);
  120012. }
  120013. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120014. renderSubMesh(alphaTestSubMeshes.data[index]);
  120015. }
  120016. };
  120017. };
  120018. /**
  120019. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120020. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120021. */
  120022. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  120023. /**
  120024. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120025. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120026. */
  120027. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  120028. /** @hidden */
  120029. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  120030. throw "Import GeometryBufferRendererSceneComponent before creating GeometryBufferRenderer.";
  120031. };
  120032. return GeometryBufferRenderer;
  120033. }());
  120034. /***/ }),
  120035. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  120036. /*!***********************************************************!*\
  120037. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  120038. \***********************************************************/
  120039. /*! exports provided: GeometryBufferRendererSceneComponent */
  120040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120041. "use strict";
  120042. __webpack_require__.r(__webpack_exports__);
  120043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  120044. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120045. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120046. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120047. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  120048. get: function () {
  120049. this._geometryBufferRenderer;
  120050. },
  120051. set: function (value) {
  120052. if (value && value.isSupported) {
  120053. this._geometryBufferRenderer = value;
  120054. }
  120055. },
  120056. enumerable: true,
  120057. configurable: true
  120058. });
  120059. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  120060. if (ratio === void 0) { ratio = 1; }
  120061. if (this._geometryBufferRenderer) {
  120062. return this._geometryBufferRenderer;
  120063. }
  120064. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  120065. if (!this._geometryBufferRenderer.isSupported) {
  120066. this._geometryBufferRenderer = null;
  120067. }
  120068. return this._geometryBufferRenderer;
  120069. };
  120070. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  120071. if (!this._geometryBufferRenderer) {
  120072. return;
  120073. }
  120074. this._geometryBufferRenderer.dispose();
  120075. this._geometryBufferRenderer = null;
  120076. };
  120077. /**
  120078. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120079. * in several rendering techniques.
  120080. */
  120081. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  120082. /**
  120083. * Creates a new instance of the component for the given scene
  120084. * @param scene Defines the scene to register the component in
  120085. */
  120086. function GeometryBufferRendererSceneComponent(scene) {
  120087. /**
  120088. * The component name helpful to identify the component in the list of scene components.
  120089. */
  120090. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  120091. this.scene = scene;
  120092. }
  120093. /**
  120094. * Registers the component in a given scene
  120095. */
  120096. GeometryBufferRendererSceneComponent.prototype.register = function () {
  120097. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  120098. };
  120099. /**
  120100. * Rebuilds the elements related to this component in case of
  120101. * context lost for instance.
  120102. */
  120103. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  120104. // Nothing to do for this component
  120105. };
  120106. /**
  120107. * Disposes the component and the associated ressources
  120108. */
  120109. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  120110. // Nothing to do for this component
  120111. };
  120112. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120113. if (this.scene._geometryBufferRenderer) {
  120114. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  120115. }
  120116. };
  120117. return GeometryBufferRendererSceneComponent;
  120118. }());
  120119. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  120120. // Register the G Buffer component to the scene.
  120121. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  120122. if (!component) {
  120123. component = new GeometryBufferRendererSceneComponent(scene);
  120124. scene._addComponent(component);
  120125. }
  120126. };
  120127. /***/ }),
  120128. /***/ "./Rendering/index.ts":
  120129. /*!****************************!*\
  120130. !*** ./Rendering/index.ts ***!
  120131. \****************************/
  120132. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  120133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120134. "use strict";
  120135. __webpack_require__.r(__webpack_exports__);
  120136. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  120137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  120138. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  120140. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  120141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  120142. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  120143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  120144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  120145. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  120147. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  120148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  120149. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  120150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  120151. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  120152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  120153. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  120154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  120155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  120156. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  120157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  120158. /***/ }),
  120159. /***/ "./Rendering/outlineRenderer.ts":
  120160. /*!**************************************!*\
  120161. !*** ./Rendering/outlineRenderer.ts ***!
  120162. \**************************************/
  120163. /*! exports provided: OutlineRenderer */
  120164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120165. "use strict";
  120166. __webpack_require__.r(__webpack_exports__);
  120167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  120168. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120169. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120170. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120171. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120172. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120173. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120174. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  120175. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  120176. /**
  120177. * Gets the outline renderer associated with the scene
  120178. * @returns a OutlineRenderer
  120179. */
  120180. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  120181. if (!this._outlineRenderer) {
  120182. this._outlineRenderer = new OutlineRenderer(this);
  120183. }
  120184. return this._outlineRenderer;
  120185. };
  120186. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  120187. get: function () {
  120188. return this._renderOutline;
  120189. },
  120190. set: function (value) {
  120191. if (value) {
  120192. // Lazy Load the component.
  120193. this.getScene().getOutlineRenderer();
  120194. }
  120195. this._renderOutline = value;
  120196. },
  120197. enumerable: true,
  120198. configurable: true
  120199. });
  120200. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  120201. get: function () {
  120202. return this._renderOverlay;
  120203. },
  120204. set: function (value) {
  120205. if (value) {
  120206. // Lazy Load the component.
  120207. this.getScene().getOutlineRenderer();
  120208. }
  120209. this._renderOverlay = value;
  120210. },
  120211. enumerable: true,
  120212. configurable: true
  120213. });
  120214. /**
  120215. * This class is responsible to draw bothe outline/overlay of meshes.
  120216. * It should not be used directly but through the available method on mesh.
  120217. */
  120218. var OutlineRenderer = /** @class */ (function () {
  120219. /**
  120220. * Instantiates a new outline renderer. (There could be only one per scene).
  120221. * @param scene Defines the scene it belongs to
  120222. */
  120223. function OutlineRenderer(scene) {
  120224. /**
  120225. * The name of the component. Each component must have a unique name.
  120226. */
  120227. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  120228. /**
  120229. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120230. */
  120231. this.zOffset = 1;
  120232. this.scene = scene;
  120233. this._engine = scene.getEngine();
  120234. this.scene._addComponent(this);
  120235. }
  120236. /**
  120237. * Register the component to one instance of a scene.
  120238. */
  120239. OutlineRenderer.prototype.register = function () {
  120240. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  120241. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  120242. };
  120243. /**
  120244. * Rebuilds the elements related to this component in case of
  120245. * context lost for instance.
  120246. */
  120247. OutlineRenderer.prototype.rebuild = function () {
  120248. // Nothing to do here.
  120249. };
  120250. /**
  120251. * Disposes the component and the associated ressources.
  120252. */
  120253. OutlineRenderer.prototype.dispose = function () {
  120254. // Nothing to do here.
  120255. };
  120256. /**
  120257. * Renders the outline in the canvas.
  120258. * @param subMesh Defines the sumesh to render
  120259. * @param batch Defines the batch of meshes in case of instances
  120260. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120261. */
  120262. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  120263. var _this = this;
  120264. if (useOverlay === void 0) { useOverlay = false; }
  120265. var scene = this.scene;
  120266. var engine = scene.getEngine();
  120267. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  120268. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  120269. return;
  120270. }
  120271. var mesh = subMesh.getRenderingMesh();
  120272. var material = subMesh.getMaterial();
  120273. if (!material || !scene.activeCamera) {
  120274. return;
  120275. }
  120276. engine.enableEffect(this._effect);
  120277. // Logarithmic depth
  120278. if (material.useLogarithmicDepth) {
  120279. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  120280. }
  120281. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  120282. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  120283. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120284. // Bones
  120285. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120286. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120287. }
  120288. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120289. // Alpha test
  120290. if (material && material.needAlphaTesting()) {
  120291. var alphaTexture = material.getAlphaTestTexture();
  120292. if (alphaTexture) {
  120293. this._effect.setTexture("diffuseSampler", alphaTexture);
  120294. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120295. }
  120296. }
  120297. engine.setZOffset(-this.zOffset);
  120298. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  120299. engine.setZOffset(0);
  120300. };
  120301. /**
  120302. * Returns whether or not the outline renderer is ready for a given submesh.
  120303. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120304. * @param subMesh Defines the submesh to check readyness for
  120305. * @param useInstances Defines wheter wee are trying to render instances or not
  120306. * @returns true if ready otherwise false
  120307. */
  120308. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  120309. var defines = [];
  120310. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  120311. var mesh = subMesh.getMesh();
  120312. var material = subMesh.getMaterial();
  120313. if (material) {
  120314. // Alpha test
  120315. if (material.needAlphaTesting()) {
  120316. defines.push("#define ALPHATEST");
  120317. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  120318. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  120319. defines.push("#define UV1");
  120320. }
  120321. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  120322. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  120323. defines.push("#define UV2");
  120324. }
  120325. }
  120326. //Logarithmic depth
  120327. if (material.useLogarithmicDepth) {
  120328. defines.push("#define LOGARITHMICDEPTH");
  120329. }
  120330. }
  120331. // Bones
  120332. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120333. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  120334. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  120335. if (mesh.numBoneInfluencers > 4) {
  120336. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  120337. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  120338. }
  120339. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120340. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120341. }
  120342. else {
  120343. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120344. }
  120345. // Instances
  120346. if (useInstances) {
  120347. defines.push("#define INSTANCES");
  120348. attribs.push("world0");
  120349. attribs.push("world1");
  120350. attribs.push("world2");
  120351. attribs.push("world3");
  120352. }
  120353. // Get correct effect
  120354. var join = defines.join("\n");
  120355. if (this._cachedDefines !== join) {
  120356. this._cachedDefines = join;
  120357. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  120358. }
  120359. return this._effect.isReady();
  120360. };
  120361. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  120362. // Outline - step 1
  120363. this._savedDepthWrite = this._engine.getDepthWrite();
  120364. if (mesh.renderOutline) {
  120365. this._engine.setDepthWrite(false);
  120366. this.render(subMesh, batch);
  120367. this._engine.setDepthWrite(this._savedDepthWrite);
  120368. }
  120369. };
  120370. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  120371. // Outline - step 2
  120372. if (mesh.renderOutline && this._savedDepthWrite) {
  120373. this._engine.setDepthWrite(true);
  120374. this._engine.setColorWrite(false);
  120375. this.render(subMesh, batch);
  120376. this._engine.setColorWrite(true);
  120377. }
  120378. // Overlay
  120379. if (mesh.renderOverlay) {
  120380. var currentMode = this._engine.getAlphaMode();
  120381. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  120382. this.render(subMesh, batch, true);
  120383. this._engine.setAlphaMode(currentMode);
  120384. }
  120385. };
  120386. return OutlineRenderer;
  120387. }());
  120388. /***/ }),
  120389. /***/ "./Rendering/renderingGroup.ts":
  120390. /*!*************************************!*\
  120391. !*** ./Rendering/renderingGroup.ts ***!
  120392. \*************************************/
  120393. /*! exports provided: RenderingGroup */
  120394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120395. "use strict";
  120396. __webpack_require__.r(__webpack_exports__);
  120397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  120398. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120400. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120401. /**
  120402. * This represents the object necessary to create a rendering group.
  120403. * This is exclusively used and created by the rendering manager.
  120404. * To modify the behavior, you use the available helpers in your scene or meshes.
  120405. * @hidden
  120406. */
  120407. var RenderingGroup = /** @class */ (function () {
  120408. /**
  120409. * Creates a new rendering group.
  120410. * @param index The rendering group index
  120411. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  120412. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  120413. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  120414. */
  120415. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  120416. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  120417. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  120418. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  120419. this.index = index;
  120420. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120421. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120422. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120423. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120424. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120425. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120426. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  120427. this._scene = scene;
  120428. this.opaqueSortCompareFn = opaqueSortCompareFn;
  120429. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  120430. this.transparentSortCompareFn = transparentSortCompareFn;
  120431. }
  120432. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  120433. /**
  120434. * Set the opaque sort comparison function.
  120435. * If null the sub meshes will be render in the order they were created
  120436. */
  120437. set: function (value) {
  120438. this._opaqueSortCompareFn = value;
  120439. if (value) {
  120440. this._renderOpaque = this.renderOpaqueSorted;
  120441. }
  120442. else {
  120443. this._renderOpaque = RenderingGroup.renderUnsorted;
  120444. }
  120445. },
  120446. enumerable: true,
  120447. configurable: true
  120448. });
  120449. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  120450. /**
  120451. * Set the alpha test sort comparison function.
  120452. * If null the sub meshes will be render in the order they were created
  120453. */
  120454. set: function (value) {
  120455. this._alphaTestSortCompareFn = value;
  120456. if (value) {
  120457. this._renderAlphaTest = this.renderAlphaTestSorted;
  120458. }
  120459. else {
  120460. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  120461. }
  120462. },
  120463. enumerable: true,
  120464. configurable: true
  120465. });
  120466. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  120467. /**
  120468. * Set the transparent sort comparison function.
  120469. * If null the sub meshes will be render in the order they were created
  120470. */
  120471. set: function (value) {
  120472. if (value) {
  120473. this._transparentSortCompareFn = value;
  120474. }
  120475. else {
  120476. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  120477. }
  120478. this._renderTransparent = this.renderTransparentSorted;
  120479. },
  120480. enumerable: true,
  120481. configurable: true
  120482. });
  120483. /**
  120484. * Render all the sub meshes contained in the group.
  120485. * @param customRenderFunction Used to override the default render behaviour of the group.
  120486. * @returns true if rendered some submeshes.
  120487. */
  120488. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  120489. if (customRenderFunction) {
  120490. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  120491. return;
  120492. }
  120493. var engine = this._scene.getEngine();
  120494. // Depth only
  120495. if (this._depthOnlySubMeshes.length !== 0) {
  120496. engine.setColorWrite(false);
  120497. this._renderAlphaTest(this._depthOnlySubMeshes);
  120498. engine.setColorWrite(true);
  120499. }
  120500. // Opaque
  120501. if (this._opaqueSubMeshes.length !== 0) {
  120502. this._renderOpaque(this._opaqueSubMeshes);
  120503. }
  120504. // Alpha test
  120505. if (this._alphaTestSubMeshes.length !== 0) {
  120506. this._renderAlphaTest(this._alphaTestSubMeshes);
  120507. }
  120508. var stencilState = engine.getStencilBuffer();
  120509. engine.setStencilBuffer(false);
  120510. // Sprites
  120511. if (renderSprites) {
  120512. this._renderSprites();
  120513. }
  120514. // Particles
  120515. if (renderParticles) {
  120516. this._renderParticles(activeMeshes);
  120517. }
  120518. if (this.onBeforeTransparentRendering) {
  120519. this.onBeforeTransparentRendering();
  120520. }
  120521. // Transparent
  120522. if (this._transparentSubMeshes.length !== 0) {
  120523. this._renderTransparent(this._transparentSubMeshes);
  120524. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120525. }
  120526. // Set back stencil to false in case it changes before the edge renderer.
  120527. engine.setStencilBuffer(false);
  120528. // Edges
  120529. if (this._edgesRenderers.length) {
  120530. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  120531. this._edgesRenderers.data[edgesRendererIndex].render();
  120532. }
  120533. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120534. }
  120535. // Restore Stencil state.
  120536. engine.setStencilBuffer(stencilState);
  120537. };
  120538. /**
  120539. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  120540. * @param subMeshes The submeshes to render
  120541. */
  120542. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  120543. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  120544. };
  120545. /**
  120546. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  120547. * @param subMeshes The submeshes to render
  120548. */
  120549. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  120550. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  120551. };
  120552. /**
  120553. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  120554. * @param subMeshes The submeshes to render
  120555. */
  120556. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  120557. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  120558. };
  120559. /**
  120560. * Renders the submeshes in a specified order.
  120561. * @param subMeshes The submeshes to sort before render
  120562. * @param sortCompareFn The comparison function use to sort
  120563. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  120564. * @param transparent Specifies to activate blending if true
  120565. */
  120566. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  120567. var subIndex = 0;
  120568. var subMesh;
  120569. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120570. for (; subIndex < subMeshes.length; subIndex++) {
  120571. subMesh = subMeshes.data[subIndex];
  120572. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  120573. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  120574. }
  120575. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  120576. if (sortCompareFn) {
  120577. sortedArray.sort(sortCompareFn);
  120578. }
  120579. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  120580. subMesh = sortedArray[subIndex];
  120581. if (transparent) {
  120582. var material = subMesh.getMaterial();
  120583. if (material && material.needDepthPrePass) {
  120584. var engine = material.getScene().getEngine();
  120585. engine.setColorWrite(false);
  120586. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120587. subMesh.render(false);
  120588. engine.setColorWrite(true);
  120589. }
  120590. }
  120591. subMesh.render(transparent);
  120592. }
  120593. };
  120594. /**
  120595. * Renders the submeshes in the order they were dispatched (no sort applied).
  120596. * @param subMeshes The submeshes to render
  120597. */
  120598. RenderingGroup.renderUnsorted = function (subMeshes) {
  120599. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  120600. var submesh = subMeshes.data[subIndex];
  120601. submesh.render(false);
  120602. }
  120603. };
  120604. /**
  120605. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120606. * are rendered back to front if in the same alpha index.
  120607. *
  120608. * @param a The first submesh
  120609. * @param b The second submesh
  120610. * @returns The result of the comparison
  120611. */
  120612. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  120613. // Alpha index first
  120614. if (a._alphaIndex > b._alphaIndex) {
  120615. return 1;
  120616. }
  120617. if (a._alphaIndex < b._alphaIndex) {
  120618. return -1;
  120619. }
  120620. // Then distance to camera
  120621. return RenderingGroup.backToFrontSortCompare(a, b);
  120622. };
  120623. /**
  120624. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120625. * are rendered back to front.
  120626. *
  120627. * @param a The first submesh
  120628. * @param b The second submesh
  120629. * @returns The result of the comparison
  120630. */
  120631. RenderingGroup.backToFrontSortCompare = function (a, b) {
  120632. // Then distance to camera
  120633. if (a._distanceToCamera < b._distanceToCamera) {
  120634. return 1;
  120635. }
  120636. if (a._distanceToCamera > b._distanceToCamera) {
  120637. return -1;
  120638. }
  120639. return 0;
  120640. };
  120641. /**
  120642. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120643. * are rendered front to back (prevent overdraw).
  120644. *
  120645. * @param a The first submesh
  120646. * @param b The second submesh
  120647. * @returns The result of the comparison
  120648. */
  120649. RenderingGroup.frontToBackSortCompare = function (a, b) {
  120650. // Then distance to camera
  120651. if (a._distanceToCamera < b._distanceToCamera) {
  120652. return -1;
  120653. }
  120654. if (a._distanceToCamera > b._distanceToCamera) {
  120655. return 1;
  120656. }
  120657. return 0;
  120658. };
  120659. /**
  120660. * Resets the different lists of submeshes to prepare a new frame.
  120661. */
  120662. RenderingGroup.prototype.prepare = function () {
  120663. this._opaqueSubMeshes.reset();
  120664. this._transparentSubMeshes.reset();
  120665. this._alphaTestSubMeshes.reset();
  120666. this._depthOnlySubMeshes.reset();
  120667. this._particleSystems.reset();
  120668. this._spriteManagers.reset();
  120669. this._edgesRenderers.reset();
  120670. };
  120671. RenderingGroup.prototype.dispose = function () {
  120672. this._opaqueSubMeshes.dispose();
  120673. this._transparentSubMeshes.dispose();
  120674. this._alphaTestSubMeshes.dispose();
  120675. this._depthOnlySubMeshes.dispose();
  120676. this._particleSystems.dispose();
  120677. this._spriteManagers.dispose();
  120678. this._edgesRenderers.dispose();
  120679. };
  120680. /**
  120681. * Inserts the submesh in its correct queue depending on its material.
  120682. * @param subMesh The submesh to dispatch
  120683. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  120684. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  120685. */
  120686. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  120687. // Get mesh and materials if not provided
  120688. if (mesh === undefined) {
  120689. mesh = subMesh.getMesh();
  120690. }
  120691. if (material === undefined) {
  120692. material = subMesh.getMaterial();
  120693. }
  120694. if (material === null || material === undefined) {
  120695. return;
  120696. }
  120697. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  120698. this._transparentSubMeshes.push(subMesh);
  120699. }
  120700. else if (material.needAlphaTesting()) { // Alpha test
  120701. if (material.needDepthPrePass) {
  120702. this._depthOnlySubMeshes.push(subMesh);
  120703. }
  120704. this._alphaTestSubMeshes.push(subMesh);
  120705. }
  120706. else {
  120707. if (material.needDepthPrePass) {
  120708. this._depthOnlySubMeshes.push(subMesh);
  120709. }
  120710. this._opaqueSubMeshes.push(subMesh); // Opaque
  120711. }
  120712. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  120713. this._edgesRenderers.push(mesh._edgesRenderer);
  120714. }
  120715. };
  120716. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  120717. this._spriteManagers.push(spriteManager);
  120718. };
  120719. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  120720. this._particleSystems.push(particleSystem);
  120721. };
  120722. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  120723. if (this._particleSystems.length === 0) {
  120724. return;
  120725. }
  120726. // Particles
  120727. var activeCamera = this._scene.activeCamera;
  120728. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  120729. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  120730. var particleSystem = this._particleSystems.data[particleIndex];
  120731. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  120732. continue;
  120733. }
  120734. var emitter = particleSystem.emitter;
  120735. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  120736. this._scene._activeParticles.addCount(particleSystem.render(), false);
  120737. }
  120738. }
  120739. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  120740. };
  120741. RenderingGroup.prototype._renderSprites = function () {
  120742. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  120743. return;
  120744. }
  120745. // Sprites
  120746. var activeCamera = this._scene.activeCamera;
  120747. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  120748. for (var id = 0; id < this._spriteManagers.length; id++) {
  120749. var spriteManager = this._spriteManagers.data[id];
  120750. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  120751. spriteManager.render();
  120752. }
  120753. }
  120754. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  120755. };
  120756. return RenderingGroup;
  120757. }());
  120758. /***/ }),
  120759. /***/ "./Rendering/renderingManager.ts":
  120760. /*!***************************************!*\
  120761. !*** ./Rendering/renderingManager.ts ***!
  120762. \***************************************/
  120763. /*! exports provided: RenderingGroupInfo, RenderingManager */
  120764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120765. "use strict";
  120766. __webpack_require__.r(__webpack_exports__);
  120767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  120768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  120769. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  120770. /**
  120771. * This class is used by the onRenderingGroupObservable
  120772. */
  120773. var RenderingGroupInfo = /** @class */ (function () {
  120774. function RenderingGroupInfo() {
  120775. }
  120776. return RenderingGroupInfo;
  120777. }());
  120778. /**
  120779. * This is the manager responsible of all the rendering for meshes sprites and particles.
  120780. * It is enable to manage the different groups as well as the different necessary sort functions.
  120781. * This should not be used directly aside of the few static configurations
  120782. */
  120783. var RenderingManager = /** @class */ (function () {
  120784. /**
  120785. * Instantiates a new rendering group for a particular scene
  120786. * @param scene Defines the scene the groups belongs to
  120787. */
  120788. function RenderingManager(scene) {
  120789. /**
  120790. * @hidden
  120791. */
  120792. this._useSceneAutoClearSetup = false;
  120793. this._renderingGroups = new Array();
  120794. this._autoClearDepthStencil = {};
  120795. this._customOpaqueSortCompareFn = {};
  120796. this._customAlphaTestSortCompareFn = {};
  120797. this._customTransparentSortCompareFn = {};
  120798. this._renderingGroupInfo = new RenderingGroupInfo();
  120799. this._scene = scene;
  120800. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  120801. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  120802. }
  120803. }
  120804. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  120805. if (depth === void 0) { depth = true; }
  120806. if (stencil === void 0) { stencil = true; }
  120807. if (this._depthStencilBufferAlreadyCleaned) {
  120808. return;
  120809. }
  120810. this._scene.getEngine().clear(null, false, depth, stencil);
  120811. this._depthStencilBufferAlreadyCleaned = true;
  120812. };
  120813. /**
  120814. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  120815. * @hidden
  120816. */
  120817. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  120818. // Update the observable context (not null as it only goes away on dispose)
  120819. var info = this._renderingGroupInfo;
  120820. info.scene = this._scene;
  120821. info.camera = this._scene.activeCamera;
  120822. // Dispatch sprites
  120823. if (this._scene.spriteManagers && renderSprites) {
  120824. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  120825. var manager = this._scene.spriteManagers[index];
  120826. this.dispatchSprites(manager);
  120827. }
  120828. }
  120829. // Render
  120830. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  120831. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  120832. var renderingGroup = this._renderingGroups[index];
  120833. if (!renderingGroup) {
  120834. continue;
  120835. }
  120836. var renderingGroupMask = Math.pow(2, index);
  120837. info.renderingGroupId = index;
  120838. // Before Observable
  120839. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  120840. // Clear depth/stencil if needed
  120841. if (RenderingManager.AUTOCLEAR) {
  120842. var autoClear = this._useSceneAutoClearSetup ?
  120843. this._scene.getAutoClearDepthStencilSetup(index) :
  120844. this._autoClearDepthStencil[index];
  120845. if (autoClear && autoClear.autoClear) {
  120846. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  120847. }
  120848. }
  120849. // Render
  120850. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  120851. var step = _a[_i];
  120852. step.action(index);
  120853. }
  120854. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  120855. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  120856. var step = _c[_b];
  120857. step.action(index);
  120858. }
  120859. // After Observable
  120860. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  120861. }
  120862. };
  120863. /**
  120864. * Resets the different information of the group to prepare a new frame
  120865. * @hidden
  120866. */
  120867. RenderingManager.prototype.reset = function () {
  120868. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  120869. var renderingGroup = this._renderingGroups[index];
  120870. if (renderingGroup) {
  120871. renderingGroup.prepare();
  120872. }
  120873. }
  120874. };
  120875. /**
  120876. * Dispose and release the group and its associated resources.
  120877. * @hidden
  120878. */
  120879. RenderingManager.prototype.dispose = function () {
  120880. this.freeRenderingGroups();
  120881. this._renderingGroups.length = 0;
  120882. this._renderingGroupInfo = null;
  120883. };
  120884. /**
  120885. * Clear the info related to rendering groups preventing retention points during dispose.
  120886. */
  120887. RenderingManager.prototype.freeRenderingGroups = function () {
  120888. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  120889. var renderingGroup = this._renderingGroups[index];
  120890. if (renderingGroup) {
  120891. renderingGroup.dispose();
  120892. }
  120893. }
  120894. };
  120895. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  120896. if (this._renderingGroups[renderingGroupId] === undefined) {
  120897. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  120898. }
  120899. };
  120900. /**
  120901. * Add a sprite manager to the rendering manager in order to render it this frame.
  120902. * @param spriteManager Define the sprite manager to render
  120903. */
  120904. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  120905. var renderingGroupId = spriteManager.renderingGroupId || 0;
  120906. this._prepareRenderingGroup(renderingGroupId);
  120907. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  120908. };
  120909. /**
  120910. * Add a particle system to the rendering manager in order to render it this frame.
  120911. * @param particleSystem Define the particle system to render
  120912. */
  120913. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  120914. var renderingGroupId = particleSystem.renderingGroupId || 0;
  120915. this._prepareRenderingGroup(renderingGroupId);
  120916. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  120917. };
  120918. /**
  120919. * Add a submesh to the manager in order to render it this frame
  120920. * @param subMesh The submesh to dispatch
  120921. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  120922. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  120923. */
  120924. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  120925. if (mesh === undefined) {
  120926. mesh = subMesh.getMesh();
  120927. }
  120928. var renderingGroupId = mesh.renderingGroupId || 0;
  120929. this._prepareRenderingGroup(renderingGroupId);
  120930. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  120931. };
  120932. /**
  120933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120934. * This allowed control for front to back rendering or reversly depending of the special needs.
  120935. *
  120936. * @param renderingGroupId The rendering group id corresponding to its index
  120937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120940. */
  120941. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  120942. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  120943. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  120944. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  120945. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  120946. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  120947. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  120948. if (this._renderingGroups[renderingGroupId]) {
  120949. var group = this._renderingGroups[renderingGroupId];
  120950. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  120951. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  120952. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  120953. }
  120954. };
  120955. /**
  120956. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120957. *
  120958. * @param renderingGroupId The rendering group id corresponding to its index
  120959. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120960. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120961. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120962. */
  120963. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  120964. if (depth === void 0) { depth = true; }
  120965. if (stencil === void 0) { stencil = true; }
  120966. this._autoClearDepthStencil[renderingGroupId] = {
  120967. autoClear: autoClearDepthStencil,
  120968. depth: depth,
  120969. stencil: stencil
  120970. };
  120971. };
  120972. /**
  120973. * Gets the current auto clear configuration for one rendering group of the rendering
  120974. * manager.
  120975. * @param index the rendering group index to get the information for
  120976. * @returns The auto clear setup for the requested rendering group
  120977. */
  120978. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  120979. return this._autoClearDepthStencil[index];
  120980. };
  120981. /**
  120982. * The max id used for rendering groups (not included)
  120983. */
  120984. RenderingManager.MAX_RENDERINGGROUPS = 4;
  120985. /**
  120986. * The min id used for rendering groups (included)
  120987. */
  120988. RenderingManager.MIN_RENDERINGGROUPS = 0;
  120989. /**
  120990. * Used to globally prevent autoclearing scenes.
  120991. */
  120992. RenderingManager.AUTOCLEAR = true;
  120993. return RenderingManager;
  120994. }());
  120995. /***/ }),
  120996. /***/ "./Rendering/utilityLayerRenderer.ts":
  120997. /*!*******************************************!*\
  120998. !*** ./Rendering/utilityLayerRenderer.ts ***!
  120999. \*******************************************/
  121000. /*! exports provided: UtilityLayerRenderer */
  121001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121002. "use strict";
  121003. __webpack_require__.r(__webpack_exports__);
  121004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  121005. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121006. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  121007. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  121008. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  121009. /**
  121010. * Renders a layer on top of an existing scene
  121011. */
  121012. var UtilityLayerRenderer = /** @class */ (function () {
  121013. /**
  121014. * Instantiates a UtilityLayerRenderer
  121015. * @param originalScene the original scene that will be rendered on top of
  121016. * @param handleEvents boolean indicating if the utility layer should handle events
  121017. */
  121018. function UtilityLayerRenderer(
  121019. /** the original scene that will be rendered on top of */
  121020. originalScene, handleEvents) {
  121021. if (handleEvents === void 0) { handleEvents = true; }
  121022. var _this = this;
  121023. this.originalScene = originalScene;
  121024. this._pointerCaptures = {};
  121025. this._lastPointerEvents = {};
  121026. /**
  121027. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  121028. */
  121029. this.pickUtilitySceneFirst = true;
  121030. /**
  121031. * If the utility layer should automatically be rendered on top of existing scene
  121032. */
  121033. this.shouldRender = true;
  121034. /**
  121035. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  121036. */
  121037. this.onlyCheckPointerDownEvents = true;
  121038. /**
  121039. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  121040. */
  121041. this.processAllEvents = false;
  121042. /**
  121043. * Observable raised when the pointer move from the utility layer scene to the main scene
  121044. */
  121045. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  121046. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  121047. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  121048. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  121049. this.utilityLayerScene._allowPostProcessClearColor = false;
  121050. originalScene.getEngine().scenes.pop();
  121051. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  121052. this.utilityLayerScene.detachControl();
  121053. if (handleEvents) {
  121054. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  121055. if (!_this.utilityLayerScene.activeCamera) {
  121056. return;
  121057. }
  121058. if (!_this.processAllEvents) {
  121059. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  121060. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  121061. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121062. return;
  121063. }
  121064. }
  121065. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  121066. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  121067. var pointerEvent = (prePointerInfo.event);
  121068. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  121069. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121070. return;
  121071. }
  121072. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  121073. if (!prePointerInfo.ray && utilityScenePick) {
  121074. prePointerInfo.ray = utilityScenePick.ray;
  121075. }
  121076. // always fire the prepointer oversvable
  121077. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  121078. // allow every non pointer down event to flow to the utility layer
  121079. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121080. if (!prePointerInfo.skipOnPointerObservable) {
  121081. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121082. }
  121083. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  121084. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121085. }
  121086. return;
  121087. }
  121088. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  121089. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  121090. if (utilityScenePick && utilityScenePick.hit) {
  121091. if (!prePointerInfo.skipOnPointerObservable) {
  121092. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121093. }
  121094. prePointerInfo.skipOnPointerObservable = true;
  121095. }
  121096. }
  121097. else {
  121098. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  121099. var pointerEvent_1 = (prePointerInfo.event);
  121100. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  121101. if (originalScenePick && utilityScenePick) {
  121102. // No pick in utility scene
  121103. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  121104. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121105. // We touched an utility mesh present in the main scene
  121106. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121107. prePointerInfo.skipOnPointerObservable = true;
  121108. }
  121109. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121110. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  121111. }
  121112. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121113. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121114. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121115. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121116. }
  121117. }
  121118. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  121119. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  121120. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  121121. // If a previous utility layer set this, do not unset this
  121122. if (!prePointerInfo.skipOnPointerObservable) {
  121123. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  121124. }
  121125. }
  121126. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  121127. // We have a pick in both scenes but main is closer than utility
  121128. // We touched an utility mesh present in the main scene
  121129. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121130. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121131. prePointerInfo.skipOnPointerObservable = true;
  121132. }
  121133. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121134. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121135. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121136. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121137. }
  121138. }
  121139. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  121140. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  121141. }
  121142. }
  121143. }
  121144. });
  121145. }
  121146. // Render directly on top of existing scene without clearing
  121147. this.utilityLayerScene.autoClear = false;
  121148. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  121149. if (_this.shouldRender) {
  121150. _this.render();
  121151. }
  121152. });
  121153. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  121154. _this.dispose();
  121155. });
  121156. this._updateCamera();
  121157. }
  121158. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  121159. /**
  121160. * 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)
  121161. */
  121162. get: function () {
  121163. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  121164. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121165. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121166. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121167. });
  121168. }
  121169. return UtilityLayerRenderer._DefaultUtilityLayer;
  121170. },
  121171. enumerable: true,
  121172. configurable: true
  121173. });
  121174. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  121175. /**
  121176. * 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)
  121177. */
  121178. get: function () {
  121179. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  121180. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121181. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  121182. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121183. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121184. });
  121185. }
  121186. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  121187. },
  121188. enumerable: true,
  121189. configurable: true
  121190. });
  121191. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  121192. if (!prePointerInfo.skipOnPointerObservable) {
  121193. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  121194. this._lastPointerEvents[pointerEvent.pointerId] = true;
  121195. }
  121196. };
  121197. /**
  121198. * Renders the utility layers scene on top of the original scene
  121199. */
  121200. UtilityLayerRenderer.prototype.render = function () {
  121201. this._updateCamera();
  121202. if (this.utilityLayerScene.activeCamera) {
  121203. // Set the camera's scene to utility layers scene
  121204. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  121205. var camera = this.utilityLayerScene.activeCamera;
  121206. camera._scene = this.utilityLayerScene;
  121207. if (camera.leftCamera) {
  121208. camera.leftCamera._scene = this.utilityLayerScene;
  121209. }
  121210. if (camera.rightCamera) {
  121211. camera.rightCamera._scene = this.utilityLayerScene;
  121212. }
  121213. this.utilityLayerScene.render(false);
  121214. // Reset camera's scene back to original
  121215. camera._scene = oldScene;
  121216. if (camera.leftCamera) {
  121217. camera.leftCamera._scene = oldScene;
  121218. }
  121219. if (camera.rightCamera) {
  121220. camera.rightCamera._scene = oldScene;
  121221. }
  121222. }
  121223. };
  121224. /**
  121225. * Disposes of the renderer
  121226. */
  121227. UtilityLayerRenderer.prototype.dispose = function () {
  121228. this.onPointerOutObservable.clear();
  121229. if (this._afterRenderObserver) {
  121230. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  121231. }
  121232. if (this._sceneDisposeObserver) {
  121233. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  121234. }
  121235. if (this._originalPointerObserver) {
  121236. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  121237. }
  121238. this.utilityLayerScene.dispose();
  121239. };
  121240. UtilityLayerRenderer.prototype._updateCamera = function () {
  121241. if (this.originalScene.activeCameras.length > 1) {
  121242. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[0];
  121243. }
  121244. else {
  121245. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  121246. }
  121247. };
  121248. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121249. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121250. return UtilityLayerRenderer;
  121251. }());
  121252. /***/ }),
  121253. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  121254. /*!*****************************************************************!*\
  121255. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  121256. \*****************************************************************/
  121257. /*! exports provided: backgroundFragmentDeclaration */
  121258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121259. "use strict";
  121260. __webpack_require__.r(__webpack_exports__);
  121261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  121262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121263. var name = 'backgroundFragmentDeclaration';
  121264. 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";
  121265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121266. /** @hidden */
  121267. var backgroundFragmentDeclaration = { name: name, shader: shader };
  121268. /***/ }),
  121269. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  121270. /*!************************************************************!*\
  121271. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  121272. \************************************************************/
  121273. /*! exports provided: backgroundUboDeclaration */
  121274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121275. "use strict";
  121276. __webpack_require__.r(__webpack_exports__);
  121277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  121278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121279. var name = 'backgroundUboDeclaration';
  121280. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  121281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121282. /** @hidden */
  121283. var backgroundUboDeclaration = { name: name, shader: shader };
  121284. /***/ }),
  121285. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  121286. /*!***************************************************************!*\
  121287. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  121288. \***************************************************************/
  121289. /*! exports provided: backgroundVertexDeclaration */
  121290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121291. "use strict";
  121292. __webpack_require__.r(__webpack_exports__);
  121293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  121294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121295. var name = 'backgroundVertexDeclaration';
  121296. 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";
  121297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121298. /** @hidden */
  121299. var backgroundVertexDeclaration = { name: name, shader: shader };
  121300. /***/ }),
  121301. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  121302. /*!****************************************************!*\
  121303. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  121304. \****************************************************/
  121305. /*! exports provided: bonesDeclaration */
  121306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121307. "use strict";
  121308. __webpack_require__.r(__webpack_exports__);
  121309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  121310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121311. var name = 'bonesDeclaration';
  121312. 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";
  121313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121314. /** @hidden */
  121315. var bonesDeclaration = { name: name, shader: shader };
  121316. /***/ }),
  121317. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  121318. /*!***********************************************!*\
  121319. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  121320. \***********************************************/
  121321. /*! exports provided: bonesVertex */
  121322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121323. "use strict";
  121324. __webpack_require__.r(__webpack_exports__);
  121325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  121326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121327. var name = 'bonesVertex';
  121328. 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";
  121329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121330. /** @hidden */
  121331. var bonesVertex = { name: name, shader: shader };
  121332. /***/ }),
  121333. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  121334. /*!************************************************!*\
  121335. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  121336. \************************************************/
  121337. /*! exports provided: bumpFragment */
  121338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121339. "use strict";
  121340. __webpack_require__.r(__webpack_exports__);
  121341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  121342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121343. var name = 'bumpFragment';
  121344. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  121345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121346. /** @hidden */
  121347. var bumpFragment = { name: name, shader: shader };
  121348. /***/ }),
  121349. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  121350. /*!*********************************************************!*\
  121351. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  121352. \*********************************************************/
  121353. /*! exports provided: bumpFragmentFunctions */
  121354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121355. "use strict";
  121356. __webpack_require__.r(__webpack_exports__);
  121357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  121358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121359. var name = 'bumpFragmentFunctions';
  121360. var shader = "#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";
  121361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121362. /** @hidden */
  121363. var bumpFragmentFunctions = { name: name, shader: shader };
  121364. /***/ }),
  121365. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  121366. /*!**********************************************!*\
  121367. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  121368. \**********************************************/
  121369. /*! exports provided: bumpVertex */
  121370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121371. "use strict";
  121372. __webpack_require__.r(__webpack_exports__);
  121373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  121374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121375. var name = 'bumpVertex';
  121376. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  121377. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121378. /** @hidden */
  121379. var bumpVertex = { name: name, shader: shader };
  121380. /***/ }),
  121381. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  121382. /*!*********************************************************!*\
  121383. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  121384. \*********************************************************/
  121385. /*! exports provided: bumpVertexDeclaration */
  121386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121387. "use strict";
  121388. __webpack_require__.r(__webpack_exports__);
  121389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  121390. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121391. var name = 'bumpVertexDeclaration';
  121392. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  121393. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121394. /** @hidden */
  121395. var bumpVertexDeclaration = { name: name, shader: shader };
  121396. /***/ }),
  121397. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  121398. /*!*****************************************************!*\
  121399. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  121400. \*****************************************************/
  121401. /*! exports provided: clipPlaneFragment */
  121402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121403. "use strict";
  121404. __webpack_require__.r(__webpack_exports__);
  121405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  121406. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121407. var name = 'clipPlaneFragment';
  121408. 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";
  121409. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121410. /** @hidden */
  121411. var clipPlaneFragment = { name: name, shader: shader };
  121412. /***/ }),
  121413. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  121414. /*!****************************************************************!*\
  121415. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  121416. \****************************************************************/
  121417. /*! exports provided: clipPlaneFragmentDeclaration */
  121418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121419. "use strict";
  121420. __webpack_require__.r(__webpack_exports__);
  121421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  121422. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121423. var name = 'clipPlaneFragmentDeclaration';
  121424. 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";
  121425. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121426. /** @hidden */
  121427. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  121428. /***/ }),
  121429. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  121430. /*!*****************************************************************!*\
  121431. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  121432. \*****************************************************************/
  121433. /*! exports provided: clipPlaneFragmentDeclaration2 */
  121434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121435. "use strict";
  121436. __webpack_require__.r(__webpack_exports__);
  121437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  121438. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121439. var name = 'clipPlaneFragmentDeclaration2';
  121440. 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";
  121441. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121442. /** @hidden */
  121443. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  121444. /***/ }),
  121445. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  121446. /*!***************************************************!*\
  121447. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  121448. \***************************************************/
  121449. /*! exports provided: clipPlaneVertex */
  121450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121451. "use strict";
  121452. __webpack_require__.r(__webpack_exports__);
  121453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  121454. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121455. var name = 'clipPlaneVertex';
  121456. 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";
  121457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121458. /** @hidden */
  121459. var clipPlaneVertex = { name: name, shader: shader };
  121460. /***/ }),
  121461. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  121462. /*!**************************************************************!*\
  121463. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  121464. \**************************************************************/
  121465. /*! exports provided: clipPlaneVertexDeclaration */
  121466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121467. "use strict";
  121468. __webpack_require__.r(__webpack_exports__);
  121469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  121470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121471. var name = 'clipPlaneVertexDeclaration';
  121472. 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";
  121473. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121474. /** @hidden */
  121475. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  121476. /***/ }),
  121477. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  121478. /*!***************************************************************!*\
  121479. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  121480. \***************************************************************/
  121481. /*! exports provided: clipPlaneVertexDeclaration2 */
  121482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121483. "use strict";
  121484. __webpack_require__.r(__webpack_exports__);
  121485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  121486. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121487. var name = 'clipPlaneVertexDeclaration2';
  121488. 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";
  121489. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121490. /** @hidden */
  121491. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  121492. /***/ }),
  121493. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  121494. /*!**************************************************************!*\
  121495. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  121496. \**************************************************************/
  121497. /*! exports provided: defaultFragmentDeclaration */
  121498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121499. "use strict";
  121500. __webpack_require__.r(__webpack_exports__);
  121501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  121502. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121503. var name = 'defaultFragmentDeclaration';
  121504. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  121505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121506. /** @hidden */
  121507. var defaultFragmentDeclaration = { name: name, shader: shader };
  121508. /***/ }),
  121509. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  121510. /*!*********************************************************!*\
  121511. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  121512. \*********************************************************/
  121513. /*! exports provided: defaultUboDeclaration */
  121514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121515. "use strict";
  121516. __webpack_require__.r(__webpack_exports__);
  121517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  121518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121519. var name = 'defaultUboDeclaration';
  121520. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  121521. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121522. /** @hidden */
  121523. var defaultUboDeclaration = { name: name, shader: shader };
  121524. /***/ }),
  121525. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  121526. /*!************************************************************!*\
  121527. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  121528. \************************************************************/
  121529. /*! exports provided: defaultVertexDeclaration */
  121530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121531. "use strict";
  121532. __webpack_require__.r(__webpack_exports__);
  121533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  121534. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121535. var name = 'defaultVertexDeclaration';
  121536. 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";
  121537. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121538. /** @hidden */
  121539. var defaultVertexDeclaration = { name: name, shader: shader };
  121540. /***/ }),
  121541. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  121542. /*!************************************************!*\
  121543. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  121544. \************************************************/
  121545. /*! exports provided: depthPrePass */
  121546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121547. "use strict";
  121548. __webpack_require__.r(__webpack_exports__);
  121549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  121550. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121551. var name = 'depthPrePass';
  121552. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  121553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121554. /** @hidden */
  121555. var depthPrePass = { name: name, shader: shader };
  121556. /***/ }),
  121557. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  121558. /*!***********************************************!*\
  121559. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  121560. \***********************************************/
  121561. /*! exports provided: fogFragment */
  121562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121563. "use strict";
  121564. __webpack_require__.r(__webpack_exports__);
  121565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  121566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121567. var name = 'fogFragment';
  121568. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  121569. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121570. /** @hidden */
  121571. var fogFragment = { name: name, shader: shader };
  121572. /***/ }),
  121573. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  121574. /*!**********************************************************!*\
  121575. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  121576. \**********************************************************/
  121577. /*! exports provided: fogFragmentDeclaration */
  121578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121579. "use strict";
  121580. __webpack_require__.r(__webpack_exports__);
  121581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  121582. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121583. var name = 'fogFragmentDeclaration';
  121584. 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";
  121585. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121586. /** @hidden */
  121587. var fogFragmentDeclaration = { name: name, shader: shader };
  121588. /***/ }),
  121589. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  121590. /*!*********************************************!*\
  121591. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  121592. \*********************************************/
  121593. /*! exports provided: fogVertex */
  121594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121595. "use strict";
  121596. __webpack_require__.r(__webpack_exports__);
  121597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  121598. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121599. var name = 'fogVertex';
  121600. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  121601. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121602. /** @hidden */
  121603. var fogVertex = { name: name, shader: shader };
  121604. /***/ }),
  121605. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  121606. /*!********************************************************!*\
  121607. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  121608. \********************************************************/
  121609. /*! exports provided: fogVertexDeclaration */
  121610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121611. "use strict";
  121612. __webpack_require__.r(__webpack_exports__);
  121613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  121614. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121615. var name = 'fogVertexDeclaration';
  121616. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  121617. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121618. /** @hidden */
  121619. var fogVertexDeclaration = { name: name, shader: shader };
  121620. /***/ }),
  121621. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  121622. /*!***************************************************!*\
  121623. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  121624. \***************************************************/
  121625. /*! exports provided: fresnelFunction */
  121626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121627. "use strict";
  121628. __webpack_require__.r(__webpack_exports__);
  121629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  121630. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121631. var name = 'fresnelFunction';
  121632. 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";
  121633. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121634. /** @hidden */
  121635. var fresnelFunction = { name: name, shader: shader };
  121636. /***/ }),
  121637. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  121638. /*!******************************************************!*\
  121639. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  121640. \******************************************************/
  121641. /*! exports provided: harmonicsFunctions */
  121642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121643. "use strict";
  121644. __webpack_require__.r(__webpack_exports__);
  121645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  121646. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121647. var name = 'harmonicsFunctions';
  121648. 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";
  121649. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121650. /** @hidden */
  121651. var harmonicsFunctions = { name: name, shader: shader };
  121652. /***/ }),
  121653. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  121654. /*!***************************************************!*\
  121655. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  121656. \***************************************************/
  121657. /*! exports provided: helperFunctions */
  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__, "helperFunctions", function() { return helperFunctions; });
  121662. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121663. var name = 'helperFunctions';
  121664. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  121665. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121666. /** @hidden */
  121667. var helperFunctions = { name: name, shader: shader };
  121668. /***/ }),
  121669. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  121670. /*!**************************************************************!*\
  121671. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  121672. \**************************************************************/
  121673. /*! exports provided: imageProcessingDeclaration */
  121674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121675. "use strict";
  121676. __webpack_require__.r(__webpack_exports__);
  121677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  121678. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121679. var name = 'imageProcessingDeclaration';
  121680. 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";
  121681. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121682. /** @hidden */
  121683. var imageProcessingDeclaration = { name: name, shader: shader };
  121684. /***/ }),
  121685. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  121686. /*!************************************************************!*\
  121687. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  121688. \************************************************************/
  121689. /*! exports provided: imageProcessingFunctions */
  121690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121691. "use strict";
  121692. __webpack_require__.r(__webpack_exports__);
  121693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  121694. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121695. var name = 'imageProcessingFunctions';
  121696. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  121697. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121698. /** @hidden */
  121699. var imageProcessingFunctions = { name: name, shader: shader };
  121700. /***/ }),
  121701. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  121702. /*!********************************************************!*\
  121703. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  121704. \********************************************************/
  121705. /*! exports provided: instancesDeclaration */
  121706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121707. "use strict";
  121708. __webpack_require__.r(__webpack_exports__);
  121709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  121710. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121711. var name = 'instancesDeclaration';
  121712. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  121713. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121714. /** @hidden */
  121715. var instancesDeclaration = { name: name, shader: shader };
  121716. /***/ }),
  121717. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  121718. /*!***************************************************!*\
  121719. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  121720. \***************************************************/
  121721. /*! exports provided: instancesVertex */
  121722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121723. "use strict";
  121724. __webpack_require__.r(__webpack_exports__);
  121725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  121726. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121727. var name = 'instancesVertex';
  121728. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  121729. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121730. /** @hidden */
  121731. var instancesVertex = { name: name, shader: shader };
  121732. /***/ }),
  121733. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  121734. /*!******************************************************!*\
  121735. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  121736. \******************************************************/
  121737. /*! exports provided: kernelBlurFragment */
  121738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121739. "use strict";
  121740. __webpack_require__.r(__webpack_exports__);
  121741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  121742. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121743. var name = 'kernelBlurFragment';
  121744. 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";
  121745. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121746. /** @hidden */
  121747. var kernelBlurFragment = { name: name, shader: shader };
  121748. /***/ }),
  121749. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  121750. /*!*******************************************************!*\
  121751. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  121752. \*******************************************************/
  121753. /*! exports provided: kernelBlurFragment2 */
  121754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121755. "use strict";
  121756. __webpack_require__.r(__webpack_exports__);
  121757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  121758. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121759. var name = 'kernelBlurFragment2';
  121760. 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";
  121761. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121762. /** @hidden */
  121763. var kernelBlurFragment2 = { name: name, shader: shader };
  121764. /***/ }),
  121765. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  121766. /*!****************************************************************!*\
  121767. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  121768. \****************************************************************/
  121769. /*! exports provided: kernelBlurVaryingDeclaration */
  121770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121771. "use strict";
  121772. __webpack_require__.r(__webpack_exports__);
  121773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  121774. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121775. var name = 'kernelBlurVaryingDeclaration';
  121776. var shader = "varying vec2 sampleCoord{X};";
  121777. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121778. /** @hidden */
  121779. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  121780. /***/ }),
  121781. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  121782. /*!****************************************************!*\
  121783. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  121784. \****************************************************/
  121785. /*! exports provided: kernelBlurVertex */
  121786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121787. "use strict";
  121788. __webpack_require__.r(__webpack_exports__);
  121789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  121790. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121791. var name = 'kernelBlurVertex';
  121792. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  121793. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121794. /** @hidden */
  121795. var kernelBlurVertex = { name: name, shader: shader };
  121796. /***/ }),
  121797. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  121798. /*!*************************************************!*\
  121799. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  121800. \*************************************************/
  121801. /*! exports provided: lightFragment */
  121802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121803. "use strict";
  121804. __webpack_require__.r(__webpack_exports__);
  121805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  121806. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121807. var name = 'lightFragment';
  121808. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  121809. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121810. /** @hidden */
  121811. var lightFragment = { name: name, shader: shader };
  121812. /***/ }),
  121813. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  121814. /*!************************************************************!*\
  121815. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  121816. \************************************************************/
  121817. /*! exports provided: lightFragmentDeclaration */
  121818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121819. "use strict";
  121820. __webpack_require__.r(__webpack_exports__);
  121821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  121822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121823. var name = 'lightFragmentDeclaration';
  121824. 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";
  121825. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121826. /** @hidden */
  121827. var lightFragmentDeclaration = { name: name, shader: shader };
  121828. /***/ }),
  121829. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  121830. /*!*******************************************************!*\
  121831. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  121832. \*******************************************************/
  121833. /*! exports provided: lightUboDeclaration */
  121834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121835. "use strict";
  121836. __webpack_require__.r(__webpack_exports__);
  121837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  121838. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121839. var name = 'lightUboDeclaration';
  121840. 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";
  121841. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121842. /** @hidden */
  121843. var lightUboDeclaration = { name: name, shader: shader };
  121844. /***/ }),
  121845. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  121846. /*!***********************************************************!*\
  121847. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  121848. \***********************************************************/
  121849. /*! exports provided: lightsFragmentFunctions */
  121850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121851. "use strict";
  121852. __webpack_require__.r(__webpack_exports__);
  121853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  121854. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121855. var name = 'lightsFragmentFunctions';
  121856. 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}";
  121857. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121858. /** @hidden */
  121859. var lightsFragmentFunctions = { name: name, shader: shader };
  121860. /***/ }),
  121861. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  121862. /*!*******************************************************!*\
  121863. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  121864. \*******************************************************/
  121865. /*! exports provided: logDepthDeclaration */
  121866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121867. "use strict";
  121868. __webpack_require__.r(__webpack_exports__);
  121869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  121870. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121871. var name = 'logDepthDeclaration';
  121872. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  121873. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121874. /** @hidden */
  121875. var logDepthDeclaration = { name: name, shader: shader };
  121876. /***/ }),
  121877. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  121878. /*!****************************************************!*\
  121879. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  121880. \****************************************************/
  121881. /*! exports provided: logDepthFragment */
  121882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121883. "use strict";
  121884. __webpack_require__.r(__webpack_exports__);
  121885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  121886. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121887. var name = 'logDepthFragment';
  121888. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  121889. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121890. /** @hidden */
  121891. var logDepthFragment = { name: name, shader: shader };
  121892. /***/ }),
  121893. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  121894. /*!**************************************************!*\
  121895. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  121896. \**************************************************/
  121897. /*! exports provided: logDepthVertex */
  121898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121899. "use strict";
  121900. __webpack_require__.r(__webpack_exports__);
  121901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  121902. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121903. var name = 'logDepthVertex';
  121904. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  121905. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121906. /** @hidden */
  121907. var logDepthVertex = { name: name, shader: shader };
  121908. /***/ }),
  121909. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  121910. /*!******************************************************!*\
  121911. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  121912. \******************************************************/
  121913. /*! exports provided: morphTargetsVertex */
  121914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121915. "use strict";
  121916. __webpack_require__.r(__webpack_exports__);
  121917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  121918. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121919. var name = 'morphTargetsVertex';
  121920. 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";
  121921. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121922. /** @hidden */
  121923. var morphTargetsVertex = { name: name, shader: shader };
  121924. /***/ }),
  121925. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  121926. /*!*****************************************************************!*\
  121927. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  121928. \*****************************************************************/
  121929. /*! exports provided: morphTargetsVertexDeclaration */
  121930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121931. "use strict";
  121932. __webpack_require__.r(__webpack_exports__);
  121933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  121934. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121935. var name = 'morphTargetsVertexDeclaration';
  121936. 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";
  121937. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121938. /** @hidden */
  121939. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  121940. /***/ }),
  121941. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  121942. /*!***********************************************************************!*\
  121943. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  121944. \***********************************************************************/
  121945. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  121946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121947. "use strict";
  121948. __webpack_require__.r(__webpack_exports__);
  121949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  121950. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121951. var name = 'morphTargetsVertexGlobalDeclaration';
  121952. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  121953. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121954. /** @hidden */
  121955. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  121956. /***/ }),
  121957. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  121958. /*!**********************************************************!*\
  121959. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  121960. \**********************************************************/
  121961. /*! exports provided: mrtFragmentDeclaration */
  121962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121963. "use strict";
  121964. __webpack_require__.r(__webpack_exports__);
  121965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  121966. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121967. var name = 'mrtFragmentDeclaration';
  121968. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  121969. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121970. /** @hidden */
  121971. var mrtFragmentDeclaration = { name: name, shader: shader };
  121972. /***/ }),
  121973. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  121974. /*!**********************************************************!*\
  121975. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  121976. \**********************************************************/
  121977. /*! exports provided: pbrFragmentDeclaration */
  121978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121979. "use strict";
  121980. __webpack_require__.r(__webpack_exports__);
  121981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  121982. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121983. var name = 'pbrFragmentDeclaration';
  121984. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif";
  121985. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121986. /** @hidden */
  121987. var pbrFragmentDeclaration = { name: name, shader: shader };
  121988. /***/ }),
  121989. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  121990. /*!************************************************!*\
  121991. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  121992. \************************************************/
  121993. /*! exports provided: pbrFunctions */
  121994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121995. "use strict";
  121996. __webpack_require__.r(__webpack_exports__);
  121997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  121998. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121999. var name = 'pbrFunctions';
  122000. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  122001. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122002. /** @hidden */
  122003. var pbrFunctions = { name: name, shader: shader };
  122004. /***/ }),
  122005. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  122006. /*!*****************************************************!*\
  122007. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  122008. \*****************************************************/
  122009. /*! exports provided: pbrLightFunctions */
  122010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122011. "use strict";
  122012. __webpack_require__.r(__webpack_exports__);
  122013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  122014. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122015. var name = 'pbrLightFunctions';
  122016. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}";
  122017. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122018. /** @hidden */
  122019. var pbrLightFunctions = { name: name, shader: shader };
  122020. /***/ }),
  122021. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  122022. /*!*****************************************************!*\
  122023. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  122024. \*****************************************************/
  122025. /*! exports provided: pbrUboDeclaration */
  122026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122027. "use strict";
  122028. __webpack_require__.r(__webpack_exports__);
  122029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  122030. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122031. var name = 'pbrUboDeclaration';
  122032. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  122033. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122034. /** @hidden */
  122035. var pbrUboDeclaration = { name: name, shader: shader };
  122036. /***/ }),
  122037. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  122038. /*!********************************************************!*\
  122039. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  122040. \********************************************************/
  122041. /*! exports provided: pbrVertexDeclaration */
  122042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122043. "use strict";
  122044. __webpack_require__.r(__webpack_exports__);
  122045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  122046. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122047. var name = 'pbrVertexDeclaration';
  122048. 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";
  122049. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122050. /** @hidden */
  122051. var pbrVertexDeclaration = { name: name, shader: shader };
  122052. /***/ }),
  122053. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  122054. /*!****************************************************!*\
  122055. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  122056. \****************************************************/
  122057. /*! exports provided: pointCloudVertex */
  122058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122059. "use strict";
  122060. __webpack_require__.r(__webpack_exports__);
  122061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  122062. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122063. var name = 'pointCloudVertex';
  122064. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  122065. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122066. /** @hidden */
  122067. var pointCloudVertex = { name: name, shader: shader };
  122068. /***/ }),
  122069. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  122070. /*!******************************************************!*\
  122071. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  122072. \******************************************************/
  122073. /*! exports provided: reflectionFunction */
  122074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122075. "use strict";
  122076. __webpack_require__.r(__webpack_exports__);
  122077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  122078. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122079. var name = 'reflectionFunction';
  122080. 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}";
  122081. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122082. /** @hidden */
  122083. var reflectionFunction = { name: name, shader: shader };
  122084. /***/ }),
  122085. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  122086. /*!************************************************************!*\
  122087. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  122088. \************************************************************/
  122089. /*! exports provided: shadowsFragmentFunctions */
  122090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122091. "use strict";
  122092. __webpack_require__.r(__webpack_exports__);
  122093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  122094. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122095. var name = 'shadowsFragmentFunctions';
  122096. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  122097. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122098. /** @hidden */
  122099. var shadowsFragmentFunctions = { name: name, shader: shader };
  122100. /***/ }),
  122101. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  122102. /*!*************************************************!*\
  122103. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  122104. \*************************************************/
  122105. /*! exports provided: shadowsVertex */
  122106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122107. "use strict";
  122108. __webpack_require__.r(__webpack_exports__);
  122109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  122110. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122111. var name = 'shadowsVertex';
  122112. 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";
  122113. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122114. /** @hidden */
  122115. var shadowsVertex = { name: name, shader: shader };
  122116. /***/ }),
  122117. /***/ "./Shaders/anaglyph.fragment.ts":
  122118. /*!**************************************!*\
  122119. !*** ./Shaders/anaglyph.fragment.ts ***!
  122120. \**************************************/
  122121. /*! exports provided: anaglyphPixelShader */
  122122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122123. "use strict";
  122124. __webpack_require__.r(__webpack_exports__);
  122125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  122126. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122127. var name = 'anaglyphPixelShader';
  122128. 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}";
  122129. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122130. /** @hidden */
  122131. var anaglyphPixelShader = { name: name, shader: shader };
  122132. /***/ }),
  122133. /***/ "./Shaders/background.fragment.ts":
  122134. /*!****************************************!*\
  122135. !*** ./Shaders/background.fragment.ts ***!
  122136. \****************************************/
  122137. /*! exports provided: backgroundPixelShader */
  122138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122139. "use strict";
  122140. __webpack_require__.r(__webpack_exports__);
  122141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  122142. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122143. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  122144. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122145. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122146. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122147. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122148. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122149. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122150. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122151. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122152. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122153. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122154. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122155. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122156. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122157. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122158. var name = 'backgroundPixelShader';
  122159. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  122160. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122161. /** @hidden */
  122162. var backgroundPixelShader = { name: name, shader: shader };
  122163. /***/ }),
  122164. /***/ "./Shaders/background.vertex.ts":
  122165. /*!**************************************!*\
  122166. !*** ./Shaders/background.vertex.ts ***!
  122167. \**************************************/
  122168. /*! exports provided: backgroundVertexShader */
  122169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122170. "use strict";
  122171. __webpack_require__.r(__webpack_exports__);
  122172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  122173. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122174. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  122175. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122176. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122177. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122178. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122179. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122180. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122181. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122182. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122183. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122184. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122185. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122186. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122187. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122188. var name = 'backgroundVertexShader';
  122189. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  122190. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122191. /** @hidden */
  122192. var backgroundVertexShader = { name: name, shader: shader };
  122193. /***/ }),
  122194. /***/ "./Shaders/blackAndWhite.fragment.ts":
  122195. /*!*******************************************!*\
  122196. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  122197. \*******************************************/
  122198. /*! exports provided: blackAndWhitePixelShader */
  122199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122200. "use strict";
  122201. __webpack_require__.r(__webpack_exports__);
  122202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  122203. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122204. var name = 'blackAndWhitePixelShader';
  122205. 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}";
  122206. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122207. /** @hidden */
  122208. var blackAndWhitePixelShader = { name: name, shader: shader };
  122209. /***/ }),
  122210. /***/ "./Shaders/bloomMerge.fragment.ts":
  122211. /*!****************************************!*\
  122212. !*** ./Shaders/bloomMerge.fragment.ts ***!
  122213. \****************************************/
  122214. /*! exports provided: bloomMergePixelShader */
  122215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122216. "use strict";
  122217. __webpack_require__.r(__webpack_exports__);
  122218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  122219. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122220. var name = 'bloomMergePixelShader';
  122221. 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";
  122222. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122223. /** @hidden */
  122224. var bloomMergePixelShader = { name: name, shader: shader };
  122225. /***/ }),
  122226. /***/ "./Shaders/chromaticAberration.fragment.ts":
  122227. /*!*************************************************!*\
  122228. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  122229. \*************************************************/
  122230. /*! exports provided: chromaticAberrationPixelShader */
  122231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122232. "use strict";
  122233. __webpack_require__.r(__webpack_exports__);
  122234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  122235. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122236. var name = 'chromaticAberrationPixelShader';
  122237. 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}";
  122238. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122239. /** @hidden */
  122240. var chromaticAberrationPixelShader = { name: name, shader: shader };
  122241. /***/ }),
  122242. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  122243. /*!***********************************************!*\
  122244. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  122245. \***********************************************/
  122246. /*! exports provided: circleOfConfusionPixelShader */
  122247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122248. "use strict";
  122249. __webpack_require__.r(__webpack_exports__);
  122250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  122251. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122252. var name = 'circleOfConfusionPixelShader';
  122253. 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";
  122254. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122255. /** @hidden */
  122256. var circleOfConfusionPixelShader = { name: name, shader: shader };
  122257. /***/ }),
  122258. /***/ "./Shaders/color.fragment.ts":
  122259. /*!***********************************!*\
  122260. !*** ./Shaders/color.fragment.ts ***!
  122261. \***********************************/
  122262. /*! exports provided: colorPixelShader */
  122263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122264. "use strict";
  122265. __webpack_require__.r(__webpack_exports__);
  122266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  122267. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122268. var name = 'colorPixelShader';
  122269. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  122270. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122271. /** @hidden */
  122272. var colorPixelShader = { name: name, shader: shader };
  122273. /***/ }),
  122274. /***/ "./Shaders/color.vertex.ts":
  122275. /*!*********************************!*\
  122276. !*** ./Shaders/color.vertex.ts ***!
  122277. \*********************************/
  122278. /*! exports provided: colorVertexShader */
  122279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122280. "use strict";
  122281. __webpack_require__.r(__webpack_exports__);
  122282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  122283. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122284. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122285. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122286. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122287. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122288. var name = 'colorVertexShader';
  122289. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  122290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122291. /** @hidden */
  122292. var colorVertexShader = { name: name, shader: shader };
  122293. /***/ }),
  122294. /***/ "./Shaders/colorCorrection.fragment.ts":
  122295. /*!*********************************************!*\
  122296. !*** ./Shaders/colorCorrection.fragment.ts ***!
  122297. \*********************************************/
  122298. /*! exports provided: colorCorrectionPixelShader */
  122299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122300. "use strict";
  122301. __webpack_require__.r(__webpack_exports__);
  122302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  122303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122304. var name = 'colorCorrectionPixelShader';
  122305. 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}";
  122306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122307. /** @hidden */
  122308. var colorCorrectionPixelShader = { name: name, shader: shader };
  122309. /***/ }),
  122310. /***/ "./Shaders/convolution.fragment.ts":
  122311. /*!*****************************************!*\
  122312. !*** ./Shaders/convolution.fragment.ts ***!
  122313. \*****************************************/
  122314. /*! exports provided: convolutionPixelShader */
  122315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122316. "use strict";
  122317. __webpack_require__.r(__webpack_exports__);
  122318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  122319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122320. var name = 'convolutionPixelShader';
  122321. 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}";
  122322. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122323. /** @hidden */
  122324. var convolutionPixelShader = { name: name, shader: shader };
  122325. /***/ }),
  122326. /***/ "./Shaders/default.fragment.ts":
  122327. /*!*************************************!*\
  122328. !*** ./Shaders/default.fragment.ts ***!
  122329. \*************************************/
  122330. /*! exports provided: defaultPixelShader */
  122331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122332. "use strict";
  122333. __webpack_require__.r(__webpack_exports__);
  122334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  122335. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122336. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  122337. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122338. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122339. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122340. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122341. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122342. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122343. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  122344. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122345. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122346. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122347. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  122348. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122349. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122350. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122351. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122352. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  122353. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  122354. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122355. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  122356. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122357. var name = 'defaultPixelShader';
  122358. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  122359. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122360. /** @hidden */
  122361. var defaultPixelShader = { name: name, shader: shader };
  122362. /***/ }),
  122363. /***/ "./Shaders/default.vertex.ts":
  122364. /*!***********************************!*\
  122365. !*** ./Shaders/default.vertex.ts ***!
  122366. \***********************************/
  122367. /*! exports provided: defaultVertexShader */
  122368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122369. "use strict";
  122370. __webpack_require__.r(__webpack_exports__);
  122371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  122372. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122373. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  122374. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122375. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122376. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122377. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122378. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  122379. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122380. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122381. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122382. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122383. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122384. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122385. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122386. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122387. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122388. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122389. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  122390. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122391. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122392. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122393. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  122394. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  122395. var name = 'defaultVertexShader';
  122396. var shader = "#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  122397. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122398. /** @hidden */
  122399. var defaultVertexShader = { name: name, shader: shader };
  122400. /***/ }),
  122401. /***/ "./Shaders/depth.fragment.ts":
  122402. /*!***********************************!*\
  122403. !*** ./Shaders/depth.fragment.ts ***!
  122404. \***********************************/
  122405. /*! exports provided: depthPixelShader */
  122406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122407. "use strict";
  122408. __webpack_require__.r(__webpack_exports__);
  122409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  122410. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122411. var name = 'depthPixelShader';
  122412. 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}";
  122413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122414. /** @hidden */
  122415. var depthPixelShader = { name: name, shader: shader };
  122416. /***/ }),
  122417. /***/ "./Shaders/depth.vertex.ts":
  122418. /*!*********************************!*\
  122419. !*** ./Shaders/depth.vertex.ts ***!
  122420. \*********************************/
  122421. /*! exports provided: depthVertexShader */
  122422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122423. "use strict";
  122424. __webpack_require__.r(__webpack_exports__);
  122425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  122426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122427. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122428. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122429. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122430. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122431. var name = 'depthVertexShader';
  122432. 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}";
  122433. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122434. /** @hidden */
  122435. var depthVertexShader = { name: name, shader: shader };
  122436. /***/ }),
  122437. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  122438. /*!******************************************!*\
  122439. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  122440. \******************************************/
  122441. /*! exports provided: depthBoxBlurPixelShader */
  122442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122443. "use strict";
  122444. __webpack_require__.r(__webpack_exports__);
  122445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  122446. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122447. var name = 'depthBoxBlurPixelShader';
  122448. 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}";
  122449. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122450. /** @hidden */
  122451. var depthBoxBlurPixelShader = { name: name, shader: shader };
  122452. /***/ }),
  122453. /***/ "./Shaders/depthOfField.fragment.ts":
  122454. /*!******************************************!*\
  122455. !*** ./Shaders/depthOfField.fragment.ts ***!
  122456. \******************************************/
  122457. /*! exports provided: depthOfFieldPixelShader */
  122458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122459. "use strict";
  122460. __webpack_require__.r(__webpack_exports__);
  122461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  122462. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122463. var name = 'depthOfFieldPixelShader';
  122464. 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";
  122465. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122466. /** @hidden */
  122467. var depthOfFieldPixelShader = { name: name, shader: shader };
  122468. /***/ }),
  122469. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  122470. /*!***********************************************!*\
  122471. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  122472. \***********************************************/
  122473. /*! exports provided: depthOfFieldMergePixelShader */
  122474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122475. "use strict";
  122476. __webpack_require__.r(__webpack_exports__);
  122477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  122478. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122479. var name = 'depthOfFieldMergePixelShader';
  122480. 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";
  122481. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122482. /** @hidden */
  122483. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  122484. /***/ }),
  122485. /***/ "./Shaders/displayPass.fragment.ts":
  122486. /*!*****************************************!*\
  122487. !*** ./Shaders/displayPass.fragment.ts ***!
  122488. \*****************************************/
  122489. /*! exports provided: displayPassPixelShader */
  122490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122491. "use strict";
  122492. __webpack_require__.r(__webpack_exports__);
  122493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  122494. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122495. var name = 'displayPassPixelShader';
  122496. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  122497. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122498. /** @hidden */
  122499. var displayPassPixelShader = { name: name, shader: shader };
  122500. /***/ }),
  122501. /***/ "./Shaders/extractHighlights.fragment.ts":
  122502. /*!***********************************************!*\
  122503. !*** ./Shaders/extractHighlights.fragment.ts ***!
  122504. \***********************************************/
  122505. /*! exports provided: extractHighlightsPixelShader */
  122506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122507. "use strict";
  122508. __webpack_require__.r(__webpack_exports__);
  122509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  122510. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122511. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122512. var name = 'extractHighlightsPixelShader';
  122513. 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}";
  122514. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122515. /** @hidden */
  122516. var extractHighlightsPixelShader = { name: name, shader: shader };
  122517. /***/ }),
  122518. /***/ "./Shaders/filter.fragment.ts":
  122519. /*!************************************!*\
  122520. !*** ./Shaders/filter.fragment.ts ***!
  122521. \************************************/
  122522. /*! exports provided: filterPixelShader */
  122523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122524. "use strict";
  122525. __webpack_require__.r(__webpack_exports__);
  122526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  122527. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122528. var name = 'filterPixelShader';
  122529. 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}";
  122530. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122531. /** @hidden */
  122532. var filterPixelShader = { name: name, shader: shader };
  122533. /***/ }),
  122534. /***/ "./Shaders/fxaa.fragment.ts":
  122535. /*!**********************************!*\
  122536. !*** ./Shaders/fxaa.fragment.ts ***!
  122537. \**********************************/
  122538. /*! exports provided: fxaaPixelShader */
  122539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122540. "use strict";
  122541. __webpack_require__.r(__webpack_exports__);
  122542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  122543. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122544. var name = 'fxaaPixelShader';
  122545. 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}";
  122546. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122547. /** @hidden */
  122548. var fxaaPixelShader = { name: name, shader: shader };
  122549. /***/ }),
  122550. /***/ "./Shaders/fxaa.vertex.ts":
  122551. /*!********************************!*\
  122552. !*** ./Shaders/fxaa.vertex.ts ***!
  122553. \********************************/
  122554. /*! exports provided: fxaaVertexShader */
  122555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122556. "use strict";
  122557. __webpack_require__.r(__webpack_exports__);
  122558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  122559. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122560. var name = 'fxaaVertexShader';
  122561. 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}";
  122562. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122563. /** @hidden */
  122564. var fxaaVertexShader = { name: name, shader: shader };
  122565. /***/ }),
  122566. /***/ "./Shaders/geometry.fragment.ts":
  122567. /*!**************************************!*\
  122568. !*** ./Shaders/geometry.fragment.ts ***!
  122569. \**************************************/
  122570. /*! exports provided: geometryPixelShader */
  122571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122572. "use strict";
  122573. __webpack_require__.r(__webpack_exports__);
  122574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  122575. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122576. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  122577. var name = 'geometryPixelShader';
  122578. 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}";
  122579. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122580. /** @hidden */
  122581. var geometryPixelShader = { name: name, shader: shader };
  122582. /***/ }),
  122583. /***/ "./Shaders/geometry.vertex.ts":
  122584. /*!************************************!*\
  122585. !*** ./Shaders/geometry.vertex.ts ***!
  122586. \************************************/
  122587. /*! exports provided: geometryVertexShader */
  122588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122589. "use strict";
  122590. __webpack_require__.r(__webpack_exports__);
  122591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  122592. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122593. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122594. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122595. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122596. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122597. var name = 'geometryVertexShader';
  122598. 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}";
  122599. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122600. /** @hidden */
  122601. var geometryVertexShader = { name: name, shader: shader };
  122602. /***/ }),
  122603. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  122604. /*!*************************************************!*\
  122605. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  122606. \*************************************************/
  122607. /*! exports provided: glowBlurPostProcessPixelShader */
  122608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122609. "use strict";
  122610. __webpack_require__.r(__webpack_exports__);
  122611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  122612. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122613. var name = 'glowBlurPostProcessPixelShader';
  122614. 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}";
  122615. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122616. /** @hidden */
  122617. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  122618. /***/ }),
  122619. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  122620. /*!***********************************************!*\
  122621. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  122622. \***********************************************/
  122623. /*! exports provided: glowMapGenerationPixelShader */
  122624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122625. "use strict";
  122626. __webpack_require__.r(__webpack_exports__);
  122627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  122628. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122629. var name = 'glowMapGenerationPixelShader';
  122630. 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}";
  122631. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122632. /** @hidden */
  122633. var glowMapGenerationPixelShader = { name: name, shader: shader };
  122634. /***/ }),
  122635. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  122636. /*!*********************************************!*\
  122637. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  122638. \*********************************************/
  122639. /*! exports provided: glowMapGenerationVertexShader */
  122640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122641. "use strict";
  122642. __webpack_require__.r(__webpack_exports__);
  122643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  122644. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122645. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122646. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122647. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122648. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122649. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122650. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122651. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122652. var name = 'glowMapGenerationVertexShader';
  122653. 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}";
  122654. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122655. /** @hidden */
  122656. var glowMapGenerationVertexShader = { name: name, shader: shader };
  122657. /***/ }),
  122658. /***/ "./Shaders/glowMapMerge.fragment.ts":
  122659. /*!******************************************!*\
  122660. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  122661. \******************************************/
  122662. /*! exports provided: glowMapMergePixelShader */
  122663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122664. "use strict";
  122665. __webpack_require__.r(__webpack_exports__);
  122666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  122667. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122668. var name = 'glowMapMergePixelShader';
  122669. 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}";
  122670. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122671. /** @hidden */
  122672. var glowMapMergePixelShader = { name: name, shader: shader };
  122673. /***/ }),
  122674. /***/ "./Shaders/glowMapMerge.vertex.ts":
  122675. /*!****************************************!*\
  122676. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  122677. \****************************************/
  122678. /*! exports provided: glowMapMergeVertexShader */
  122679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122680. "use strict";
  122681. __webpack_require__.r(__webpack_exports__);
  122682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  122683. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122684. var name = 'glowMapMergeVertexShader';
  122685. 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}";
  122686. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122687. /** @hidden */
  122688. var glowMapMergeVertexShader = { name: name, shader: shader };
  122689. /***/ }),
  122690. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  122691. /*!************************************************!*\
  122692. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  122693. \************************************************/
  122694. /*! exports provided: gpuRenderParticlesPixelShader */
  122695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122696. "use strict";
  122697. __webpack_require__.r(__webpack_exports__);
  122698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  122699. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122700. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  122701. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122702. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122703. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122704. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122705. var name = 'gpuRenderParticlesPixelShader';
  122706. 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";
  122707. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122708. /** @hidden */
  122709. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  122710. /***/ }),
  122711. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  122712. /*!**********************************************!*\
  122713. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  122714. \**********************************************/
  122715. /*! exports provided: gpuRenderParticlesVertexShader */
  122716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122717. "use strict";
  122718. __webpack_require__.r(__webpack_exports__);
  122719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  122720. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122721. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  122722. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122723. var name = 'gpuRenderParticlesVertexShader';
  122724. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  122725. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122726. /** @hidden */
  122727. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  122728. /***/ }),
  122729. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  122730. /*!************************************************!*\
  122731. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  122732. \************************************************/
  122733. /*! exports provided: gpuUpdateParticlesPixelShader */
  122734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122735. "use strict";
  122736. __webpack_require__.r(__webpack_exports__);
  122737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  122738. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122739. var name = 'gpuUpdateParticlesPixelShader';
  122740. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  122741. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122742. /** @hidden */
  122743. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  122744. /***/ }),
  122745. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  122746. /*!**********************************************!*\
  122747. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  122748. \**********************************************/
  122749. /*! exports provided: gpuUpdateParticlesVertexShader */
  122750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122751. "use strict";
  122752. __webpack_require__.r(__webpack_exports__);
  122753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  122754. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122755. var name = 'gpuUpdateParticlesVertexShader';
  122756. 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}";
  122757. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122758. /** @hidden */
  122759. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  122760. /***/ }),
  122761. /***/ "./Shaders/grain.fragment.ts":
  122762. /*!***********************************!*\
  122763. !*** ./Shaders/grain.fragment.ts ***!
  122764. \***********************************/
  122765. /*! exports provided: grainPixelShader */
  122766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122767. "use strict";
  122768. __webpack_require__.r(__webpack_exports__);
  122769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  122770. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122771. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122772. var name = 'grainPixelShader';
  122773. 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}";
  122774. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122775. /** @hidden */
  122776. var grainPixelShader = { name: name, shader: shader };
  122777. /***/ }),
  122778. /***/ "./Shaders/highlights.fragment.ts":
  122779. /*!****************************************!*\
  122780. !*** ./Shaders/highlights.fragment.ts ***!
  122781. \****************************************/
  122782. /*! exports provided: highlightsPixelShader */
  122783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122784. "use strict";
  122785. __webpack_require__.r(__webpack_exports__);
  122786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  122787. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122788. var name = 'highlightsPixelShader';
  122789. 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}";
  122790. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122791. /** @hidden */
  122792. var highlightsPixelShader = { name: name, shader: shader };
  122793. /***/ }),
  122794. /***/ "./Shaders/imageProcessing.fragment.ts":
  122795. /*!*********************************************!*\
  122796. !*** ./Shaders/imageProcessing.fragment.ts ***!
  122797. \*********************************************/
  122798. /*! exports provided: imageProcessingPixelShader */
  122799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122800. "use strict";
  122801. __webpack_require__.r(__webpack_exports__);
  122802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  122803. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122804. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122805. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122806. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122807. var name = 'imageProcessingPixelShader';
  122808. 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}";
  122809. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122810. /** @hidden */
  122811. var imageProcessingPixelShader = { name: name, shader: shader };
  122812. /***/ }),
  122813. /***/ "./Shaders/kernelBlur.fragment.ts":
  122814. /*!****************************************!*\
  122815. !*** ./Shaders/kernelBlur.fragment.ts ***!
  122816. \****************************************/
  122817. /*! exports provided: kernelBlurPixelShader */
  122818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122819. "use strict";
  122820. __webpack_require__.r(__webpack_exports__);
  122821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  122822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122823. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  122824. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  122825. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  122826. var name = 'kernelBlurPixelShader';
  122827. 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}";
  122828. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122829. /** @hidden */
  122830. var kernelBlurPixelShader = { name: name, shader: shader };
  122831. /***/ }),
  122832. /***/ "./Shaders/kernelBlur.vertex.ts":
  122833. /*!**************************************!*\
  122834. !*** ./Shaders/kernelBlur.vertex.ts ***!
  122835. \**************************************/
  122836. /*! exports provided: kernelBlurVertexShader */
  122837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122838. "use strict";
  122839. __webpack_require__.r(__webpack_exports__);
  122840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  122841. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122842. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  122843. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  122844. var name = 'kernelBlurVertexShader';
  122845. 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}";
  122846. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122847. /** @hidden */
  122848. var kernelBlurVertexShader = { name: name, shader: shader };
  122849. /***/ }),
  122850. /***/ "./Shaders/layer.fragment.ts":
  122851. /*!***********************************!*\
  122852. !*** ./Shaders/layer.fragment.ts ***!
  122853. \***********************************/
  122854. /*! exports provided: layerPixelShader */
  122855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122856. "use strict";
  122857. __webpack_require__.r(__webpack_exports__);
  122858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  122859. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122860. var name = 'layerPixelShader';
  122861. 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}";
  122862. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122863. /** @hidden */
  122864. var layerPixelShader = { name: name, shader: shader };
  122865. /***/ }),
  122866. /***/ "./Shaders/layer.vertex.ts":
  122867. /*!*********************************!*\
  122868. !*** ./Shaders/layer.vertex.ts ***!
  122869. \*********************************/
  122870. /*! exports provided: layerVertexShader */
  122871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122872. "use strict";
  122873. __webpack_require__.r(__webpack_exports__);
  122874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  122875. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122876. var name = 'layerVertexShader';
  122877. 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}";
  122878. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122879. /** @hidden */
  122880. var layerVertexShader = { name: name, shader: shader };
  122881. /***/ }),
  122882. /***/ "./Shaders/lensFlare.fragment.ts":
  122883. /*!***************************************!*\
  122884. !*** ./Shaders/lensFlare.fragment.ts ***!
  122885. \***************************************/
  122886. /*! exports provided: lensFlarePixelShader */
  122887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122888. "use strict";
  122889. __webpack_require__.r(__webpack_exports__);
  122890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  122891. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122892. var name = 'lensFlarePixelShader';
  122893. 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}";
  122894. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122895. /** @hidden */
  122896. var lensFlarePixelShader = { name: name, shader: shader };
  122897. /***/ }),
  122898. /***/ "./Shaders/lensFlare.vertex.ts":
  122899. /*!*************************************!*\
  122900. !*** ./Shaders/lensFlare.vertex.ts ***!
  122901. \*************************************/
  122902. /*! exports provided: lensFlareVertexShader */
  122903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122904. "use strict";
  122905. __webpack_require__.r(__webpack_exports__);
  122906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  122907. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122908. var name = 'lensFlareVertexShader';
  122909. 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}";
  122910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122911. /** @hidden */
  122912. var lensFlareVertexShader = { name: name, shader: shader };
  122913. /***/ }),
  122914. /***/ "./Shaders/lensHighlights.fragment.ts":
  122915. /*!********************************************!*\
  122916. !*** ./Shaders/lensHighlights.fragment.ts ***!
  122917. \********************************************/
  122918. /*! exports provided: lensHighlightsPixelShader */
  122919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122920. "use strict";
  122921. __webpack_require__.r(__webpack_exports__);
  122922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  122923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122924. var name = 'lensHighlightsPixelShader';
  122925. 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}";
  122926. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122927. /** @hidden */
  122928. var lensHighlightsPixelShader = { name: name, shader: shader };
  122929. /***/ }),
  122930. /***/ "./Shaders/line.fragment.ts":
  122931. /*!**********************************!*\
  122932. !*** ./Shaders/line.fragment.ts ***!
  122933. \**********************************/
  122934. /*! exports provided: linePixelShader */
  122935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122936. "use strict";
  122937. __webpack_require__.r(__webpack_exports__);
  122938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  122939. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122940. var name = 'linePixelShader';
  122941. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  122942. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122943. /** @hidden */
  122944. var linePixelShader = { name: name, shader: shader };
  122945. /***/ }),
  122946. /***/ "./Shaders/line.vertex.ts":
  122947. /*!********************************!*\
  122948. !*** ./Shaders/line.vertex.ts ***!
  122949. \********************************/
  122950. /*! exports provided: lineVertexShader */
  122951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122952. "use strict";
  122953. __webpack_require__.r(__webpack_exports__);
  122954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  122955. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122956. var name = 'lineVertexShader';
  122957. 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}";
  122958. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122959. /** @hidden */
  122960. var lineVertexShader = { name: name, shader: shader };
  122961. /***/ }),
  122962. /***/ "./Shaders/motionBlur.fragment.ts":
  122963. /*!****************************************!*\
  122964. !*** ./Shaders/motionBlur.fragment.ts ***!
  122965. \****************************************/
  122966. /*! exports provided: motionBlurPixelShader */
  122967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122968. "use strict";
  122969. __webpack_require__.r(__webpack_exports__);
  122970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  122971. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122972. var name = 'motionBlurPixelShader';
  122973. 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";
  122974. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122975. /** @hidden */
  122976. var motionBlurPixelShader = { name: name, shader: shader };
  122977. /***/ }),
  122978. /***/ "./Shaders/noise.fragment.ts":
  122979. /*!***********************************!*\
  122980. !*** ./Shaders/noise.fragment.ts ***!
  122981. \***********************************/
  122982. /*! exports provided: noisePixelShader */
  122983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122984. "use strict";
  122985. __webpack_require__.r(__webpack_exports__);
  122986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  122987. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122988. var name = 'noisePixelShader';
  122989. 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";
  122990. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122991. /** @hidden */
  122992. var noisePixelShader = { name: name, shader: shader };
  122993. /***/ }),
  122994. /***/ "./Shaders/outline.fragment.ts":
  122995. /*!*************************************!*\
  122996. !*** ./Shaders/outline.fragment.ts ***!
  122997. \*************************************/
  122998. /*! exports provided: outlinePixelShader */
  122999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123000. "use strict";
  123001. __webpack_require__.r(__webpack_exports__);
  123002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  123003. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123004. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123005. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123006. var name = 'outlinePixelShader';
  123007. 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}";
  123008. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123009. /** @hidden */
  123010. var outlinePixelShader = { name: name, shader: shader };
  123011. /***/ }),
  123012. /***/ "./Shaders/outline.vertex.ts":
  123013. /*!***********************************!*\
  123014. !*** ./Shaders/outline.vertex.ts ***!
  123015. \***********************************/
  123016. /*! exports provided: outlineVertexShader */
  123017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123018. "use strict";
  123019. __webpack_require__.r(__webpack_exports__);
  123020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  123021. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123022. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123023. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123024. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123025. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123026. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123027. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123028. var name = 'outlineVertexShader';
  123029. 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";
  123030. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123031. /** @hidden */
  123032. var outlineVertexShader = { name: name, shader: shader };
  123033. /***/ }),
  123034. /***/ "./Shaders/particles.fragment.ts":
  123035. /*!***************************************!*\
  123036. !*** ./Shaders/particles.fragment.ts ***!
  123037. \***************************************/
  123038. /*! exports provided: particlesPixelShader */
  123039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123040. "use strict";
  123041. __webpack_require__.r(__webpack_exports__);
  123042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  123043. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123044. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123045. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123046. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123047. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123048. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123049. var name = 'particlesPixelShader';
  123050. 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}";
  123051. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123052. /** @hidden */
  123053. var particlesPixelShader = { name: name, shader: shader };
  123054. /***/ }),
  123055. /***/ "./Shaders/particles.vertex.ts":
  123056. /*!*************************************!*\
  123057. !*** ./Shaders/particles.vertex.ts ***!
  123058. \*************************************/
  123059. /*! exports provided: particlesVertexShader */
  123060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123061. "use strict";
  123062. __webpack_require__.r(__webpack_exports__);
  123063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  123064. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123065. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123066. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123067. var name = 'particlesVertexShader';
  123068. 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}";
  123069. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123070. /** @hidden */
  123071. var particlesVertexShader = { name: name, shader: shader };
  123072. /***/ }),
  123073. /***/ "./Shaders/pass.fragment.ts":
  123074. /*!**********************************!*\
  123075. !*** ./Shaders/pass.fragment.ts ***!
  123076. \**********************************/
  123077. /*! exports provided: passPixelShader */
  123078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123079. "use strict";
  123080. __webpack_require__.r(__webpack_exports__);
  123081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  123082. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123083. var name = 'passPixelShader';
  123084. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  123085. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123086. /** @hidden */
  123087. var passPixelShader = { name: name, shader: shader };
  123088. /***/ }),
  123089. /***/ "./Shaders/passCube.fragment.ts":
  123090. /*!**************************************!*\
  123091. !*** ./Shaders/passCube.fragment.ts ***!
  123092. \**************************************/
  123093. /*! exports provided: passCubePixelShader */
  123094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123095. "use strict";
  123096. __webpack_require__.r(__webpack_exports__);
  123097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  123098. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123099. var name = 'passCubePixelShader';
  123100. 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}";
  123101. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123102. /** @hidden */
  123103. var passCubePixelShader = { name: name, shader: shader };
  123104. /***/ }),
  123105. /***/ "./Shaders/pbr.fragment.ts":
  123106. /*!*********************************!*\
  123107. !*** ./Shaders/pbr.fragment.ts ***!
  123108. \*********************************/
  123109. /*! exports provided: pbrPixelShader */
  123110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123111. "use strict";
  123112. __webpack_require__.r(__webpack_exports__);
  123113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  123114. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123115. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  123116. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123117. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123118. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123119. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123120. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123121. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123122. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123123. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123124. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  123125. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123126. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  123127. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123128. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123129. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123130. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123131. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123132. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123133. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123134. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123135. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123136. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123137. var name = 'pbrPixelShader';
  123138. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.;\nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";
  123139. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123140. /** @hidden */
  123141. var pbrPixelShader = { name: name, shader: shader };
  123142. /***/ }),
  123143. /***/ "./Shaders/pbr.vertex.ts":
  123144. /*!*******************************!*\
  123145. !*** ./Shaders/pbr.vertex.ts ***!
  123146. \*******************************/
  123147. /*! exports provided: pbrVertexShader */
  123148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123149. "use strict";
  123150. __webpack_require__.r(__webpack_exports__);
  123151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  123152. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123153. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  123154. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123155. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123156. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123157. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123158. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123159. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123160. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123161. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123162. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123163. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123164. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123165. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123166. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123167. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123168. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123169. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123170. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123171. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123172. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123173. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123174. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123175. var name = 'pbrVertexShader';
  123176. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}";
  123177. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123178. /** @hidden */
  123179. var pbrVertexShader = { name: name, shader: shader };
  123180. /***/ }),
  123181. /***/ "./Shaders/postprocess.vertex.ts":
  123182. /*!***************************************!*\
  123183. !*** ./Shaders/postprocess.vertex.ts ***!
  123184. \***************************************/
  123185. /*! exports provided: postprocessVertexShader */
  123186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123187. "use strict";
  123188. __webpack_require__.r(__webpack_exports__);
  123189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  123190. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123191. var name = 'postprocessVertexShader';
  123192. 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}";
  123193. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123194. /** @hidden */
  123195. var postprocessVertexShader = { name: name, shader: shader };
  123196. /***/ }),
  123197. /***/ "./Shaders/procedural.vertex.ts":
  123198. /*!**************************************!*\
  123199. !*** ./Shaders/procedural.vertex.ts ***!
  123200. \**************************************/
  123201. /*! exports provided: proceduralVertexShader */
  123202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123203. "use strict";
  123204. __webpack_require__.r(__webpack_exports__);
  123205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  123206. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123207. var name = 'proceduralVertexShader';
  123208. 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}";
  123209. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123210. /** @hidden */
  123211. var proceduralVertexShader = { name: name, shader: shader };
  123212. /***/ }),
  123213. /***/ "./Shaders/refraction.fragment.ts":
  123214. /*!****************************************!*\
  123215. !*** ./Shaders/refraction.fragment.ts ***!
  123216. \****************************************/
  123217. /*! exports provided: refractionPixelShader */
  123218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123219. "use strict";
  123220. __webpack_require__.r(__webpack_exports__);
  123221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  123222. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123223. var name = 'refractionPixelShader';
  123224. 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}";
  123225. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123226. /** @hidden */
  123227. var refractionPixelShader = { name: name, shader: shader };
  123228. /***/ }),
  123229. /***/ "./Shaders/rgbdDecode.fragment.ts":
  123230. /*!****************************************!*\
  123231. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  123232. \****************************************/
  123233. /*! exports provided: rgbdDecodePixelShader */
  123234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123235. "use strict";
  123236. __webpack_require__.r(__webpack_exports__);
  123237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  123238. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123239. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123240. var name = 'rgbdDecodePixelShader';
  123241. 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}";
  123242. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123243. /** @hidden */
  123244. var rgbdDecodePixelShader = { name: name, shader: shader };
  123245. /***/ }),
  123246. /***/ "./Shaders/rgbdEncode.fragment.ts":
  123247. /*!****************************************!*\
  123248. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  123249. \****************************************/
  123250. /*! exports provided: rgbdEncodePixelShader */
  123251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123252. "use strict";
  123253. __webpack_require__.r(__webpack_exports__);
  123254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  123255. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123256. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123257. var name = 'rgbdEncodePixelShader';
  123258. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  123259. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123260. /** @hidden */
  123261. var rgbdEncodePixelShader = { name: name, shader: shader };
  123262. /***/ }),
  123263. /***/ "./Shaders/shadowMap.fragment.ts":
  123264. /*!***************************************!*\
  123265. !*** ./Shaders/shadowMap.fragment.ts ***!
  123266. \***************************************/
  123267. /*! exports provided: shadowMapPixelShader */
  123268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123269. "use strict";
  123270. __webpack_require__.r(__webpack_exports__);
  123271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  123272. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123273. var name = 'shadowMapPixelShader';
  123274. 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}";
  123275. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123276. /** @hidden */
  123277. var shadowMapPixelShader = { name: name, shader: shader };
  123278. /***/ }),
  123279. /***/ "./Shaders/shadowMap.vertex.ts":
  123280. /*!*************************************!*\
  123281. !*** ./Shaders/shadowMap.vertex.ts ***!
  123282. \*************************************/
  123283. /*! exports provided: shadowMapVertexShader */
  123284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123285. "use strict";
  123286. __webpack_require__.r(__webpack_exports__);
  123287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  123288. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123289. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123290. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123291. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123292. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123293. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123294. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123295. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123296. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123297. var name = 'shadowMapVertexShader';
  123298. 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}";
  123299. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123300. /** @hidden */
  123301. var shadowMapVertexShader = { name: name, shader: shader };
  123302. /***/ }),
  123303. /***/ "./Shaders/sharpen.fragment.ts":
  123304. /*!*************************************!*\
  123305. !*** ./Shaders/sharpen.fragment.ts ***!
  123306. \*************************************/
  123307. /*! exports provided: sharpenPixelShader */
  123308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123309. "use strict";
  123310. __webpack_require__.r(__webpack_exports__);
  123311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  123312. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123313. var name = 'sharpenPixelShader';
  123314. 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}";
  123315. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123316. /** @hidden */
  123317. var sharpenPixelShader = { name: name, shader: shader };
  123318. /***/ }),
  123319. /***/ "./Shaders/sprites.fragment.ts":
  123320. /*!*************************************!*\
  123321. !*** ./Shaders/sprites.fragment.ts ***!
  123322. \*************************************/
  123323. /*! exports provided: spritesPixelShader */
  123324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123325. "use strict";
  123326. __webpack_require__.r(__webpack_exports__);
  123327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  123328. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123329. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123330. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123331. var name = 'spritesPixelShader';
  123332. 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}";
  123333. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123334. /** @hidden */
  123335. var spritesPixelShader = { name: name, shader: shader };
  123336. /***/ }),
  123337. /***/ "./Shaders/sprites.vertex.ts":
  123338. /*!***********************************!*\
  123339. !*** ./Shaders/sprites.vertex.ts ***!
  123340. \***********************************/
  123341. /*! exports provided: spritesVertexShader */
  123342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123343. "use strict";
  123344. __webpack_require__.r(__webpack_exports__);
  123345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  123346. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123347. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123348. var name = 'spritesVertexShader';
  123349. 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}";
  123350. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123351. /** @hidden */
  123352. var spritesVertexShader = { name: name, shader: shader };
  123353. /***/ }),
  123354. /***/ "./Shaders/ssao.fragment.ts":
  123355. /*!**********************************!*\
  123356. !*** ./Shaders/ssao.fragment.ts ***!
  123357. \**********************************/
  123358. /*! exports provided: ssaoPixelShader */
  123359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123360. "use strict";
  123361. __webpack_require__.r(__webpack_exports__);
  123362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  123363. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123364. var name = 'ssaoPixelShader';
  123365. 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";
  123366. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123367. /** @hidden */
  123368. var ssaoPixelShader = { name: name, shader: shader };
  123369. /***/ }),
  123370. /***/ "./Shaders/ssao2.fragment.ts":
  123371. /*!***********************************!*\
  123372. !*** ./Shaders/ssao2.fragment.ts ***!
  123373. \***********************************/
  123374. /*! exports provided: ssao2PixelShader */
  123375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123376. "use strict";
  123377. __webpack_require__.r(__webpack_exports__);
  123378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  123379. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123380. var name = 'ssao2PixelShader';
  123381. 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";
  123382. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123383. /** @hidden */
  123384. var ssao2PixelShader = { name: name, shader: shader };
  123385. /***/ }),
  123386. /***/ "./Shaders/ssaoCombine.fragment.ts":
  123387. /*!*****************************************!*\
  123388. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  123389. \*****************************************/
  123390. /*! exports provided: ssaoCombinePixelShader */
  123391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123392. "use strict";
  123393. __webpack_require__.r(__webpack_exports__);
  123394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  123395. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123396. var name = 'ssaoCombinePixelShader';
  123397. 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";
  123398. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123399. /** @hidden */
  123400. var ssaoCombinePixelShader = { name: name, shader: shader };
  123401. /***/ }),
  123402. /***/ "./Shaders/standard.fragment.ts":
  123403. /*!**************************************!*\
  123404. !*** ./Shaders/standard.fragment.ts ***!
  123405. \**************************************/
  123406. /*! exports provided: standardPixelShader */
  123407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123408. "use strict";
  123409. __webpack_require__.r(__webpack_exports__);
  123410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  123411. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123412. var name = 'standardPixelShader';
  123413. 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";
  123414. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123415. /** @hidden */
  123416. var standardPixelShader = { name: name, shader: shader };
  123417. /***/ }),
  123418. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  123419. /*!***************************************************!*\
  123420. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  123421. \***************************************************/
  123422. /*! exports provided: stereoscopicInterlacePixelShader */
  123423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123424. "use strict";
  123425. __webpack_require__.r(__webpack_exports__);
  123426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  123427. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123428. var name = 'stereoscopicInterlacePixelShader';
  123429. 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}";
  123430. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123431. /** @hidden */
  123432. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  123433. /***/ }),
  123434. /***/ "./Shaders/tonemap.fragment.ts":
  123435. /*!*************************************!*\
  123436. !*** ./Shaders/tonemap.fragment.ts ***!
  123437. \*************************************/
  123438. /*! exports provided: tonemapPixelShader */
  123439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123440. "use strict";
  123441. __webpack_require__.r(__webpack_exports__);
  123442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  123443. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123444. var name = 'tonemapPixelShader';
  123445. 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}";
  123446. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123447. /** @hidden */
  123448. var tonemapPixelShader = { name: name, shader: shader };
  123449. /***/ }),
  123450. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  123451. /*!*******************************************************!*\
  123452. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  123453. \*******************************************************/
  123454. /*! exports provided: volumetricLightScatteringPixelShader */
  123455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123456. "use strict";
  123457. __webpack_require__.r(__webpack_exports__);
  123458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  123459. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123460. var name = 'volumetricLightScatteringPixelShader';
  123461. 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";
  123462. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123463. /** @hidden */
  123464. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  123465. /***/ }),
  123466. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  123467. /*!***********************************************************!*\
  123468. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  123469. \***********************************************************/
  123470. /*! exports provided: volumetricLightScatteringPassPixelShader */
  123471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123472. "use strict";
  123473. __webpack_require__.r(__webpack_exports__);
  123474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  123475. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123476. var name = 'volumetricLightScatteringPassPixelShader';
  123477. 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";
  123478. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123479. /** @hidden */
  123480. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  123481. /***/ }),
  123482. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  123483. /*!****************************************************!*\
  123484. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  123485. \****************************************************/
  123486. /*! exports provided: vrDistortionCorrectionPixelShader */
  123487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123488. "use strict";
  123489. __webpack_require__.r(__webpack_exports__);
  123490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  123491. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123492. var name = 'vrDistortionCorrectionPixelShader';
  123493. 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}";
  123494. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123495. /** @hidden */
  123496. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  123497. /***/ }),
  123498. /***/ "./Sprites/index.ts":
  123499. /*!**************************!*\
  123500. !*** ./Sprites/index.ts ***!
  123501. \**************************/
  123502. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  123503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123504. "use strict";
  123505. __webpack_require__.r(__webpack_exports__);
  123506. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  123507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  123508. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  123509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  123510. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  123511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  123512. /***/ }),
  123513. /***/ "./Sprites/sprite.ts":
  123514. /*!***************************!*\
  123515. !*** ./Sprites/sprite.ts ***!
  123516. \***************************/
  123517. /*! exports provided: Sprite */
  123518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123519. "use strict";
  123520. __webpack_require__.r(__webpack_exports__);
  123521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  123522. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123523. /**
  123524. * Class used to represent a sprite
  123525. * @see http://doc.babylonjs.com/babylon101/sprites
  123526. */
  123527. var Sprite = /** @class */ (function () {
  123528. /**
  123529. * Creates a new Sprite
  123530. * @param name defines the name
  123531. * @param manager defines the manager
  123532. */
  123533. function Sprite(
  123534. /** defines the name */
  123535. name, manager) {
  123536. this.name = name;
  123537. /** Gets or sets the main color */
  123538. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  123539. /** Gets or sets the width */
  123540. this.width = 1.0;
  123541. /** Gets or sets the height */
  123542. this.height = 1.0;
  123543. /** Gets or sets rotation angle */
  123544. this.angle = 0;
  123545. /** Gets or sets the cell index in the sprite sheet */
  123546. this.cellIndex = 0;
  123547. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  123548. this.invertU = 0;
  123549. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  123550. this.invertV = 0;
  123551. /** Gets the list of attached animations */
  123552. this.animations = new Array();
  123553. /** Gets or sets a boolean indicating if the sprite can be picked */
  123554. this.isPickable = false;
  123555. this._animationStarted = false;
  123556. this._loopAnimation = false;
  123557. this._fromIndex = 0;
  123558. this._toIndex = 0;
  123559. this._delay = 0;
  123560. this._direction = 1;
  123561. this._time = 0;
  123562. /**
  123563. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  123564. */
  123565. this.isVisible = true;
  123566. this._manager = manager;
  123567. this._manager.sprites.push(this);
  123568. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  123569. }
  123570. Object.defineProperty(Sprite.prototype, "size", {
  123571. /**
  123572. * Gets or sets the sprite size
  123573. */
  123574. get: function () {
  123575. return this.width;
  123576. },
  123577. set: function (value) {
  123578. this.width = value;
  123579. this.height = value;
  123580. },
  123581. enumerable: true,
  123582. configurable: true
  123583. });
  123584. /**
  123585. * Starts an animation
  123586. * @param from defines the initial key
  123587. * @param to defines the end key
  123588. * @param loop defines if the animation must loop
  123589. * @param delay defines the start delay (in ms)
  123590. * @param onAnimationEnd defines a callback to call when animation ends
  123591. */
  123592. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  123593. this._fromIndex = from;
  123594. this._toIndex = to;
  123595. this._loopAnimation = loop;
  123596. this._delay = delay;
  123597. this._animationStarted = true;
  123598. this._direction = from < to ? 1 : -1;
  123599. this.cellIndex = from;
  123600. this._time = 0;
  123601. this._onAnimationEnd = onAnimationEnd;
  123602. };
  123603. /** Stops current animation (if any) */
  123604. Sprite.prototype.stopAnimation = function () {
  123605. this._animationStarted = false;
  123606. };
  123607. /** @hidden */
  123608. Sprite.prototype._animate = function (deltaTime) {
  123609. if (!this._animationStarted) {
  123610. return;
  123611. }
  123612. this._time += deltaTime;
  123613. if (this._time > this._delay) {
  123614. this._time = this._time % this._delay;
  123615. this.cellIndex += this._direction;
  123616. if (this.cellIndex > this._toIndex) {
  123617. if (this._loopAnimation) {
  123618. this.cellIndex = this._fromIndex;
  123619. }
  123620. else {
  123621. this.cellIndex = this._toIndex;
  123622. this._animationStarted = false;
  123623. if (this._onAnimationEnd) {
  123624. this._onAnimationEnd();
  123625. }
  123626. if (this.disposeWhenFinishedAnimating) {
  123627. this.dispose();
  123628. }
  123629. }
  123630. }
  123631. }
  123632. };
  123633. /** Release associated resources */
  123634. Sprite.prototype.dispose = function () {
  123635. for (var i = 0; i < this._manager.sprites.length; i++) {
  123636. if (this._manager.sprites[i] == this) {
  123637. this._manager.sprites.splice(i, 1);
  123638. }
  123639. }
  123640. };
  123641. return Sprite;
  123642. }());
  123643. /***/ }),
  123644. /***/ "./Sprites/spriteManager.ts":
  123645. /*!**********************************!*\
  123646. !*** ./Sprites/spriteManager.ts ***!
  123647. \**********************************/
  123648. /*! exports provided: SpriteManager */
  123649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123650. "use strict";
  123651. __webpack_require__.r(__webpack_exports__);
  123652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  123653. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123654. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123655. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123656. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123657. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  123658. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  123659. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123660. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123661. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123662. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123663. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  123664. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  123665. /**
  123666. * Class used to manage multiple sprites on the same spritesheet
  123667. * @see http://doc.babylonjs.com/babylon101/sprites
  123668. */
  123669. var SpriteManager = /** @class */ (function () {
  123670. /**
  123671. * Creates a new sprite manager
  123672. * @param name defines the manager's name
  123673. * @param imgUrl defines the sprite sheet url
  123674. * @param capacity defines the maximum allowed number of sprites
  123675. * @param cellSize defines the size of a sprite cell
  123676. * @param scene defines the hosting scene
  123677. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  123678. * @param samplingMode defines the smapling mode to use with spritesheet
  123679. */
  123680. function SpriteManager(
  123681. /** defines the manager's name */
  123682. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  123683. if (epsilon === void 0) { epsilon = 0.01; }
  123684. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  123685. this.name = name;
  123686. /** Gets the list of sprites */
  123687. this.sprites = new Array();
  123688. /** Gets or sets the rendering group id (0 by default) */
  123689. this.renderingGroupId = 0;
  123690. /** Gets or sets camera layer mask */
  123691. this.layerMask = 0x0FFFFFFF;
  123692. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  123693. this.fogEnabled = true;
  123694. /** Gets or sets a boolean indicating if the sprites are pickable */
  123695. this.isPickable = false;
  123696. /**
  123697. * An event triggered when the manager is disposed.
  123698. */
  123699. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  123700. this._vertexBuffers = {};
  123701. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  123702. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  123703. }
  123704. this._capacity = capacity;
  123705. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  123706. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  123707. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  123708. if (cellSize.width && cellSize.height) {
  123709. this.cellWidth = cellSize.width;
  123710. this.cellHeight = cellSize.height;
  123711. }
  123712. else if (cellSize !== undefined) {
  123713. this.cellWidth = cellSize;
  123714. this.cellHeight = cellSize;
  123715. }
  123716. else {
  123717. return;
  123718. }
  123719. this._epsilon = epsilon;
  123720. this._scene = scene;
  123721. this._scene.spriteManagers.push(this);
  123722. var indices = [];
  123723. var index = 0;
  123724. for (var count = 0; count < capacity; count++) {
  123725. indices.push(index);
  123726. indices.push(index + 1);
  123727. indices.push(index + 2);
  123728. indices.push(index);
  123729. indices.push(index + 2);
  123730. indices.push(index + 3);
  123731. index += 4;
  123732. }
  123733. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  123734. // VBO
  123735. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  123736. this._vertexData = new Float32Array(capacity * 16 * 4);
  123737. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  123738. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  123739. var options = this._buffer.createVertexBuffer("options", 4, 4);
  123740. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  123741. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  123742. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  123743. this._vertexBuffers["options"] = options;
  123744. this._vertexBuffers["cellInfo"] = cellInfo;
  123745. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  123746. // Effects
  123747. 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"], "");
  123748. 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");
  123749. }
  123750. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  123751. /**
  123752. * Callback called when the manager is disposed
  123753. */
  123754. set: function (callback) {
  123755. if (this._onDisposeObserver) {
  123756. this.onDisposeObservable.remove(this._onDisposeObserver);
  123757. }
  123758. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  123759. },
  123760. enumerable: true,
  123761. configurable: true
  123762. });
  123763. Object.defineProperty(SpriteManager.prototype, "texture", {
  123764. /**
  123765. * Gets or sets the spritesheet texture
  123766. */
  123767. get: function () {
  123768. return this._spriteTexture;
  123769. },
  123770. set: function (value) {
  123771. this._spriteTexture = value;
  123772. },
  123773. enumerable: true,
  123774. configurable: true
  123775. });
  123776. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  123777. var arrayOffset = index * 16;
  123778. if (offsetX === 0) {
  123779. offsetX = this._epsilon;
  123780. }
  123781. else if (offsetX === 1) {
  123782. offsetX = 1 - this._epsilon;
  123783. }
  123784. if (offsetY === 0) {
  123785. offsetY = this._epsilon;
  123786. }
  123787. else if (offsetY === 1) {
  123788. offsetY = 1 - this._epsilon;
  123789. }
  123790. this._vertexData[arrayOffset] = sprite.position.x;
  123791. this._vertexData[arrayOffset + 1] = sprite.position.y;
  123792. this._vertexData[arrayOffset + 2] = sprite.position.z;
  123793. this._vertexData[arrayOffset + 3] = sprite.angle;
  123794. this._vertexData[arrayOffset + 4] = sprite.width;
  123795. this._vertexData[arrayOffset + 5] = sprite.height;
  123796. this._vertexData[arrayOffset + 6] = offsetX;
  123797. this._vertexData[arrayOffset + 7] = offsetY;
  123798. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  123799. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  123800. var offset = (sprite.cellIndex / rowSize) >> 0;
  123801. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  123802. this._vertexData[arrayOffset + 11] = offset;
  123803. // Color
  123804. this._vertexData[arrayOffset + 12] = sprite.color.r;
  123805. this._vertexData[arrayOffset + 13] = sprite.color.g;
  123806. this._vertexData[arrayOffset + 14] = sprite.color.b;
  123807. this._vertexData[arrayOffset + 15] = sprite.color.a;
  123808. };
  123809. /**
  123810. * Intersects the sprites with a ray
  123811. * @param ray defines the ray to intersect with
  123812. * @param camera defines the current active camera
  123813. * @param predicate defines a predicate used to select candidate sprites
  123814. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  123815. * @returns null if no hit or a PickingInfo
  123816. */
  123817. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  123818. var count = Math.min(this._capacity, this.sprites.length);
  123819. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123820. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123821. var distance = Number.MAX_VALUE;
  123822. var currentSprite = null;
  123823. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123824. var cameraView = camera.getViewMatrix();
  123825. for (var index = 0; index < count; index++) {
  123826. var sprite = this.sprites[index];
  123827. if (!sprite) {
  123828. continue;
  123829. }
  123830. if (predicate) {
  123831. if (!predicate(sprite)) {
  123832. continue;
  123833. }
  123834. }
  123835. else if (!sprite.isPickable) {
  123836. continue;
  123837. }
  123838. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  123839. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  123840. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  123841. if (ray.intersectsBoxMinMax(min, max)) {
  123842. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  123843. if (distance > currentDistance) {
  123844. distance = currentDistance;
  123845. currentSprite = sprite;
  123846. if (fastCheck) {
  123847. break;
  123848. }
  123849. }
  123850. }
  123851. }
  123852. if (currentSprite) {
  123853. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  123854. result.hit = true;
  123855. result.pickedSprite = currentSprite;
  123856. result.distance = distance;
  123857. return result;
  123858. }
  123859. return null;
  123860. };
  123861. /**
  123862. * Render all child sprites
  123863. */
  123864. SpriteManager.prototype.render = function () {
  123865. // Check
  123866. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture || !this._spriteTexture.isReady()) {
  123867. return;
  123868. }
  123869. var engine = this._scene.getEngine();
  123870. var baseSize = this._spriteTexture.getBaseSize();
  123871. // Sprites
  123872. var deltaTime = engine.getDeltaTime();
  123873. var max = Math.min(this._capacity, this.sprites.length);
  123874. var rowSize = baseSize.width / this.cellWidth;
  123875. var offset = 0;
  123876. for (var index = 0; index < max; index++) {
  123877. var sprite = this.sprites[index];
  123878. if (!sprite || !sprite.isVisible) {
  123879. continue;
  123880. }
  123881. sprite._animate(deltaTime);
  123882. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  123883. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  123884. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  123885. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  123886. }
  123887. this._buffer.update(this._vertexData);
  123888. // Render
  123889. var effect = this._effectBase;
  123890. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  123891. effect = this._effectFog;
  123892. }
  123893. engine.enableEffect(effect);
  123894. var viewMatrix = this._scene.getViewMatrix();
  123895. effect.setTexture("diffuseSampler", this._spriteTexture);
  123896. effect.setMatrix("view", viewMatrix);
  123897. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  123898. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  123899. // Fog
  123900. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  123901. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  123902. effect.setColor3("vFogColor", this._scene.fogColor);
  123903. }
  123904. // VBOs
  123905. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  123906. // Draw order
  123907. engine.setDepthFunctionToLessOrEqual();
  123908. effect.setBool("alphaTest", true);
  123909. engine.setColorWrite(false);
  123910. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  123911. engine.setColorWrite(true);
  123912. effect.setBool("alphaTest", false);
  123913. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  123914. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  123915. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  123916. };
  123917. /**
  123918. * Release associated resources
  123919. */
  123920. SpriteManager.prototype.dispose = function () {
  123921. if (this._buffer) {
  123922. this._buffer.dispose();
  123923. this._buffer = null;
  123924. }
  123925. if (this._indexBuffer) {
  123926. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  123927. this._indexBuffer = null;
  123928. }
  123929. if (this._spriteTexture) {
  123930. this._spriteTexture.dispose();
  123931. this._spriteTexture = null;
  123932. }
  123933. // Remove from scene
  123934. var index = this._scene.spriteManagers.indexOf(this);
  123935. this._scene.spriteManagers.splice(index, 1);
  123936. // Callback
  123937. this.onDisposeObservable.notifyObservers(this);
  123938. this.onDisposeObservable.clear();
  123939. };
  123940. return SpriteManager;
  123941. }());
  123942. /***/ }),
  123943. /***/ "./Sprites/spriteSceneComponent.ts":
  123944. /*!*****************************************!*\
  123945. !*** ./Sprites/spriteSceneComponent.ts ***!
  123946. \*****************************************/
  123947. /*! exports provided: SpriteSceneComponent */
  123948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123949. "use strict";
  123950. __webpack_require__.r(__webpack_exports__);
  123951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  123952. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123953. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123954. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  123955. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  123956. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123957. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  123958. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123959. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  123960. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  123961. return null;
  123962. }
  123963. var pickingInfo = null;
  123964. if (!camera) {
  123965. if (!this.activeCamera) {
  123966. return null;
  123967. }
  123968. camera = this.activeCamera;
  123969. }
  123970. if (this.spriteManagers.length > 0) {
  123971. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  123972. var spriteManager = this.spriteManagers[spriteIndex];
  123973. if (!spriteManager.isPickable) {
  123974. continue;
  123975. }
  123976. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  123977. if (!result || !result.hit) {
  123978. continue;
  123979. }
  123980. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  123981. continue;
  123982. }
  123983. pickingInfo = result;
  123984. if (fastCheck) {
  123985. break;
  123986. }
  123987. }
  123988. }
  123989. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  123990. };
  123991. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  123992. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  123993. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  123994. };
  123995. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  123996. if (!this._tempSpritePickingRay) {
  123997. return null;
  123998. }
  123999. if (!camera) {
  124000. if (!this.activeCamera) {
  124001. return null;
  124002. }
  124003. camera = this.activeCamera;
  124004. }
  124005. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  124006. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124007. };
  124008. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  124009. if (this._pointerOverSprite === sprite) {
  124010. return;
  124011. }
  124012. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124013. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124014. }
  124015. this._pointerOverSprite = sprite;
  124016. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124017. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124018. }
  124019. };
  124020. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  124021. return this._pointerOverSprite;
  124022. };
  124023. /**
  124024. * Defines the sprite scene component responsible to manage sprites
  124025. * in a given scene.
  124026. */
  124027. var SpriteSceneComponent = /** @class */ (function () {
  124028. /**
  124029. * Creates a new instance of the component for the given scene
  124030. * @param scene Defines the scene to register the component in
  124031. */
  124032. function SpriteSceneComponent(scene) {
  124033. /**
  124034. * The component name helpfull to identify the component in the list of scene components.
  124035. */
  124036. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  124037. this.scene = scene;
  124038. this.scene.spriteManagers = new Array();
  124039. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  124040. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124041. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124042. this._spritePredicate = function (sprite) {
  124043. if (!sprite.actionManager) {
  124044. return false;
  124045. }
  124046. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  124047. };
  124048. }
  124049. /**
  124050. * Registers the component in a given scene
  124051. */
  124052. SpriteSceneComponent.prototype.register = function () {
  124053. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  124054. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  124055. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  124056. };
  124057. /**
  124058. * Rebuilds the elements related to this component in case of
  124059. * context lost for instance.
  124060. */
  124061. SpriteSceneComponent.prototype.rebuild = function () {
  124062. /** Nothing to do for sprites */
  124063. };
  124064. /**
  124065. * Disposes the component and the associated ressources.
  124066. */
  124067. SpriteSceneComponent.prototype.dispose = function () {
  124068. this.scene.onBeforeSpritesRenderingObservable.clear();
  124069. this.scene.onAfterSpritesRenderingObservable.clear();
  124070. var spriteManagers = this.scene.spriteManagers;
  124071. while (spriteManagers.length) {
  124072. spriteManagers[0].dispose();
  124073. }
  124074. };
  124075. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  124076. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  124077. if (result) {
  124078. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  124079. }
  124080. return result;
  124081. };
  124082. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  124083. var scene = this.scene;
  124084. if (isMeshPicked) {
  124085. scene.setPointerOverSprite(null);
  124086. }
  124087. else {
  124088. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  124089. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124090. scene.setPointerOverSprite(pickResult.pickedSprite);
  124091. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  124092. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  124093. }
  124094. else {
  124095. canvas.style.cursor = scene.hoverCursor;
  124096. }
  124097. }
  124098. else {
  124099. scene.setPointerOverSprite(null);
  124100. }
  124101. }
  124102. return pickResult;
  124103. };
  124104. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124105. var scene = this.scene;
  124106. scene._pickedDownSprite = null;
  124107. if (scene.spriteManagers.length > 0) {
  124108. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124109. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124110. if (pickResult.pickedSprite.actionManager) {
  124111. scene._pickedDownSprite = pickResult.pickedSprite;
  124112. switch (evt.button) {
  124113. case 0:
  124114. 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));
  124115. break;
  124116. case 1:
  124117. 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));
  124118. break;
  124119. case 2:
  124120. 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));
  124121. break;
  124122. }
  124123. if (pickResult.pickedSprite.actionManager) {
  124124. 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));
  124125. }
  124126. }
  124127. }
  124128. }
  124129. return pickResult;
  124130. };
  124131. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124132. var scene = this.scene;
  124133. if (scene.spriteManagers.length > 0) {
  124134. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124135. if (spritePickResult) {
  124136. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  124137. if (spritePickResult.pickedSprite.actionManager) {
  124138. 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));
  124139. if (spritePickResult.pickedSprite.actionManager) {
  124140. if (!this.scene._isPointerSwiping()) {
  124141. 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));
  124142. }
  124143. }
  124144. }
  124145. }
  124146. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  124147. 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));
  124148. }
  124149. }
  124150. }
  124151. return pickResult;
  124152. };
  124153. return SpriteSceneComponent;
  124154. }());
  124155. /***/ }),
  124156. /***/ "./States/alphaCullingState.ts":
  124157. /*!*************************************!*\
  124158. !*** ./States/alphaCullingState.ts ***!
  124159. \*************************************/
  124160. /*! exports provided: _AlphaState */
  124161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124162. "use strict";
  124163. __webpack_require__.r(__webpack_exports__);
  124164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  124165. /**
  124166. * @hidden
  124167. **/
  124168. var _AlphaState = /** @class */ (function () {
  124169. /**
  124170. * Initializes the state.
  124171. */
  124172. function _AlphaState() {
  124173. this._isAlphaBlendDirty = false;
  124174. this._isBlendFunctionParametersDirty = false;
  124175. this._isBlendEquationParametersDirty = false;
  124176. this._isBlendConstantsDirty = false;
  124177. this._alphaBlend = false;
  124178. this._blendFunctionParameters = new Array(4);
  124179. this._blendEquationParameters = new Array(2);
  124180. this._blendConstants = new Array(4);
  124181. this.reset();
  124182. }
  124183. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  124184. get: function () {
  124185. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  124186. },
  124187. enumerable: true,
  124188. configurable: true
  124189. });
  124190. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  124191. get: function () {
  124192. return this._alphaBlend;
  124193. },
  124194. set: function (value) {
  124195. if (this._alphaBlend === value) {
  124196. return;
  124197. }
  124198. this._alphaBlend = value;
  124199. this._isAlphaBlendDirty = true;
  124200. },
  124201. enumerable: true,
  124202. configurable: true
  124203. });
  124204. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  124205. if (this._blendConstants[0] === r &&
  124206. this._blendConstants[1] === g &&
  124207. this._blendConstants[2] === b &&
  124208. this._blendConstants[3] === a) {
  124209. return;
  124210. }
  124211. this._blendConstants[0] = r;
  124212. this._blendConstants[1] = g;
  124213. this._blendConstants[2] = b;
  124214. this._blendConstants[3] = a;
  124215. this._isBlendConstantsDirty = true;
  124216. };
  124217. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  124218. if (this._blendFunctionParameters[0] === value0 &&
  124219. this._blendFunctionParameters[1] === value1 &&
  124220. this._blendFunctionParameters[2] === value2 &&
  124221. this._blendFunctionParameters[3] === value3) {
  124222. return;
  124223. }
  124224. this._blendFunctionParameters[0] = value0;
  124225. this._blendFunctionParameters[1] = value1;
  124226. this._blendFunctionParameters[2] = value2;
  124227. this._blendFunctionParameters[3] = value3;
  124228. this._isBlendFunctionParametersDirty = true;
  124229. };
  124230. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  124231. if (this._blendEquationParameters[0] === rgb &&
  124232. this._blendEquationParameters[1] === alpha) {
  124233. return;
  124234. }
  124235. this._blendEquationParameters[0] = rgb;
  124236. this._blendEquationParameters[1] = alpha;
  124237. this._isBlendEquationParametersDirty = true;
  124238. };
  124239. _AlphaState.prototype.reset = function () {
  124240. this._alphaBlend = false;
  124241. this._blendFunctionParameters[0] = null;
  124242. this._blendFunctionParameters[1] = null;
  124243. this._blendFunctionParameters[2] = null;
  124244. this._blendFunctionParameters[3] = null;
  124245. this._blendEquationParameters[0] = null;
  124246. this._blendEquationParameters[1] = null;
  124247. this._blendConstants[0] = null;
  124248. this._blendConstants[1] = null;
  124249. this._blendConstants[2] = null;
  124250. this._blendConstants[3] = null;
  124251. this._isAlphaBlendDirty = true;
  124252. this._isBlendFunctionParametersDirty = false;
  124253. this._isBlendEquationParametersDirty = false;
  124254. this._isBlendConstantsDirty = false;
  124255. };
  124256. _AlphaState.prototype.apply = function (gl) {
  124257. if (!this.isDirty) {
  124258. return;
  124259. }
  124260. // Alpha blend
  124261. if (this._isAlphaBlendDirty) {
  124262. if (this._alphaBlend) {
  124263. gl.enable(gl.BLEND);
  124264. }
  124265. else {
  124266. gl.disable(gl.BLEND);
  124267. }
  124268. this._isAlphaBlendDirty = false;
  124269. }
  124270. // Alpha function
  124271. if (this._isBlendFunctionParametersDirty) {
  124272. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  124273. this._isBlendFunctionParametersDirty = false;
  124274. }
  124275. // Alpha equation
  124276. if (this._isBlendEquationParametersDirty) {
  124277. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  124278. this._isBlendEquationParametersDirty = false;
  124279. }
  124280. // Constants
  124281. if (this._isBlendConstantsDirty) {
  124282. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  124283. this._isBlendConstantsDirty = false;
  124284. }
  124285. };
  124286. return _AlphaState;
  124287. }());
  124288. /***/ }),
  124289. /***/ "./States/depthCullingState.ts":
  124290. /*!*************************************!*\
  124291. !*** ./States/depthCullingState.ts ***!
  124292. \*************************************/
  124293. /*! exports provided: _DepthCullingState */
  124294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124295. "use strict";
  124296. __webpack_require__.r(__webpack_exports__);
  124297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  124298. /**
  124299. * @hidden
  124300. **/
  124301. var _DepthCullingState = /** @class */ (function () {
  124302. /**
  124303. * Initializes the state.
  124304. */
  124305. function _DepthCullingState() {
  124306. this._isDepthTestDirty = false;
  124307. this._isDepthMaskDirty = false;
  124308. this._isDepthFuncDirty = false;
  124309. this._isCullFaceDirty = false;
  124310. this._isCullDirty = false;
  124311. this._isZOffsetDirty = false;
  124312. this._isFrontFaceDirty = false;
  124313. this.reset();
  124314. }
  124315. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  124316. get: function () {
  124317. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  124318. },
  124319. enumerable: true,
  124320. configurable: true
  124321. });
  124322. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  124323. get: function () {
  124324. return this._zOffset;
  124325. },
  124326. set: function (value) {
  124327. if (this._zOffset === value) {
  124328. return;
  124329. }
  124330. this._zOffset = value;
  124331. this._isZOffsetDirty = true;
  124332. },
  124333. enumerable: true,
  124334. configurable: true
  124335. });
  124336. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  124337. get: function () {
  124338. return this._cullFace;
  124339. },
  124340. set: function (value) {
  124341. if (this._cullFace === value) {
  124342. return;
  124343. }
  124344. this._cullFace = value;
  124345. this._isCullFaceDirty = true;
  124346. },
  124347. enumerable: true,
  124348. configurable: true
  124349. });
  124350. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  124351. get: function () {
  124352. return this._cull;
  124353. },
  124354. set: function (value) {
  124355. if (this._cull === value) {
  124356. return;
  124357. }
  124358. this._cull = value;
  124359. this._isCullDirty = true;
  124360. },
  124361. enumerable: true,
  124362. configurable: true
  124363. });
  124364. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  124365. get: function () {
  124366. return this._depthFunc;
  124367. },
  124368. set: function (value) {
  124369. if (this._depthFunc === value) {
  124370. return;
  124371. }
  124372. this._depthFunc = value;
  124373. this._isDepthFuncDirty = true;
  124374. },
  124375. enumerable: true,
  124376. configurable: true
  124377. });
  124378. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  124379. get: function () {
  124380. return this._depthMask;
  124381. },
  124382. set: function (value) {
  124383. if (this._depthMask === value) {
  124384. return;
  124385. }
  124386. this._depthMask = value;
  124387. this._isDepthMaskDirty = true;
  124388. },
  124389. enumerable: true,
  124390. configurable: true
  124391. });
  124392. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  124393. get: function () {
  124394. return this._depthTest;
  124395. },
  124396. set: function (value) {
  124397. if (this._depthTest === value) {
  124398. return;
  124399. }
  124400. this._depthTest = value;
  124401. this._isDepthTestDirty = true;
  124402. },
  124403. enumerable: true,
  124404. configurable: true
  124405. });
  124406. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  124407. get: function () {
  124408. return this._frontFace;
  124409. },
  124410. set: function (value) {
  124411. if (this._frontFace === value) {
  124412. return;
  124413. }
  124414. this._frontFace = value;
  124415. this._isFrontFaceDirty = true;
  124416. },
  124417. enumerable: true,
  124418. configurable: true
  124419. });
  124420. _DepthCullingState.prototype.reset = function () {
  124421. this._depthMask = true;
  124422. this._depthTest = true;
  124423. this._depthFunc = null;
  124424. this._cullFace = null;
  124425. this._cull = null;
  124426. this._zOffset = 0;
  124427. this._frontFace = null;
  124428. this._isDepthTestDirty = true;
  124429. this._isDepthMaskDirty = true;
  124430. this._isDepthFuncDirty = false;
  124431. this._isCullFaceDirty = false;
  124432. this._isCullDirty = false;
  124433. this._isZOffsetDirty = false;
  124434. this._isFrontFaceDirty = false;
  124435. };
  124436. _DepthCullingState.prototype.apply = function (gl) {
  124437. if (!this.isDirty) {
  124438. return;
  124439. }
  124440. // Cull
  124441. if (this._isCullDirty) {
  124442. if (this.cull) {
  124443. gl.enable(gl.CULL_FACE);
  124444. }
  124445. else {
  124446. gl.disable(gl.CULL_FACE);
  124447. }
  124448. this._isCullDirty = false;
  124449. }
  124450. // Cull face
  124451. if (this._isCullFaceDirty) {
  124452. gl.cullFace(this.cullFace);
  124453. this._isCullFaceDirty = false;
  124454. }
  124455. // Depth mask
  124456. if (this._isDepthMaskDirty) {
  124457. gl.depthMask(this.depthMask);
  124458. this._isDepthMaskDirty = false;
  124459. }
  124460. // Depth test
  124461. if (this._isDepthTestDirty) {
  124462. if (this.depthTest) {
  124463. gl.enable(gl.DEPTH_TEST);
  124464. }
  124465. else {
  124466. gl.disable(gl.DEPTH_TEST);
  124467. }
  124468. this._isDepthTestDirty = false;
  124469. }
  124470. // Depth func
  124471. if (this._isDepthFuncDirty) {
  124472. gl.depthFunc(this.depthFunc);
  124473. this._isDepthFuncDirty = false;
  124474. }
  124475. // zOffset
  124476. if (this._isZOffsetDirty) {
  124477. if (this.zOffset) {
  124478. gl.enable(gl.POLYGON_OFFSET_FILL);
  124479. gl.polygonOffset(this.zOffset, 0);
  124480. }
  124481. else {
  124482. gl.disable(gl.POLYGON_OFFSET_FILL);
  124483. }
  124484. this._isZOffsetDirty = false;
  124485. }
  124486. // Front face
  124487. if (this._isFrontFaceDirty) {
  124488. gl.frontFace(this.frontFace);
  124489. this._isFrontFaceDirty = false;
  124490. }
  124491. };
  124492. return _DepthCullingState;
  124493. }());
  124494. /***/ }),
  124495. /***/ "./States/index.ts":
  124496. /*!*************************!*\
  124497. !*** ./States/index.ts ***!
  124498. \*************************/
  124499. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  124500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124501. "use strict";
  124502. __webpack_require__.r(__webpack_exports__);
  124503. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  124504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  124505. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  124506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  124507. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  124508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  124509. /***/ }),
  124510. /***/ "./States/stencilState.ts":
  124511. /*!********************************!*\
  124512. !*** ./States/stencilState.ts ***!
  124513. \********************************/
  124514. /*! exports provided: _StencilState */
  124515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124516. "use strict";
  124517. __webpack_require__.r(__webpack_exports__);
  124518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  124519. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124520. /**
  124521. * @hidden
  124522. **/
  124523. var _StencilState = /** @class */ (function () {
  124524. function _StencilState() {
  124525. this._isStencilTestDirty = false;
  124526. this._isStencilMaskDirty = false;
  124527. this._isStencilFuncDirty = false;
  124528. this._isStencilOpDirty = false;
  124529. this.reset();
  124530. }
  124531. Object.defineProperty(_StencilState.prototype, "isDirty", {
  124532. get: function () {
  124533. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  124534. },
  124535. enumerable: true,
  124536. configurable: true
  124537. });
  124538. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  124539. get: function () {
  124540. return this._stencilFunc;
  124541. },
  124542. set: function (value) {
  124543. if (this._stencilFunc === value) {
  124544. return;
  124545. }
  124546. this._stencilFunc = value;
  124547. this._isStencilFuncDirty = true;
  124548. },
  124549. enumerable: true,
  124550. configurable: true
  124551. });
  124552. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  124553. get: function () {
  124554. return this._stencilFuncRef;
  124555. },
  124556. set: function (value) {
  124557. if (this._stencilFuncRef === value) {
  124558. return;
  124559. }
  124560. this._stencilFuncRef = value;
  124561. this._isStencilFuncDirty = true;
  124562. },
  124563. enumerable: true,
  124564. configurable: true
  124565. });
  124566. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  124567. get: function () {
  124568. return this._stencilFuncMask;
  124569. },
  124570. set: function (value) {
  124571. if (this._stencilFuncMask === value) {
  124572. return;
  124573. }
  124574. this._stencilFuncMask = value;
  124575. this._isStencilFuncDirty = true;
  124576. },
  124577. enumerable: true,
  124578. configurable: true
  124579. });
  124580. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  124581. get: function () {
  124582. return this._stencilOpStencilFail;
  124583. },
  124584. set: function (value) {
  124585. if (this._stencilOpStencilFail === value) {
  124586. return;
  124587. }
  124588. this._stencilOpStencilFail = value;
  124589. this._isStencilOpDirty = true;
  124590. },
  124591. enumerable: true,
  124592. configurable: true
  124593. });
  124594. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  124595. get: function () {
  124596. return this._stencilOpDepthFail;
  124597. },
  124598. set: function (value) {
  124599. if (this._stencilOpDepthFail === value) {
  124600. return;
  124601. }
  124602. this._stencilOpDepthFail = value;
  124603. this._isStencilOpDirty = true;
  124604. },
  124605. enumerable: true,
  124606. configurable: true
  124607. });
  124608. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  124609. get: function () {
  124610. return this._stencilOpStencilDepthPass;
  124611. },
  124612. set: function (value) {
  124613. if (this._stencilOpStencilDepthPass === value) {
  124614. return;
  124615. }
  124616. this._stencilOpStencilDepthPass = value;
  124617. this._isStencilOpDirty = true;
  124618. },
  124619. enumerable: true,
  124620. configurable: true
  124621. });
  124622. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  124623. get: function () {
  124624. return this._stencilMask;
  124625. },
  124626. set: function (value) {
  124627. if (this._stencilMask === value) {
  124628. return;
  124629. }
  124630. this._stencilMask = value;
  124631. this._isStencilMaskDirty = true;
  124632. },
  124633. enumerable: true,
  124634. configurable: true
  124635. });
  124636. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  124637. get: function () {
  124638. return this._stencilTest;
  124639. },
  124640. set: function (value) {
  124641. if (this._stencilTest === value) {
  124642. return;
  124643. }
  124644. this._stencilTest = value;
  124645. this._isStencilTestDirty = true;
  124646. },
  124647. enumerable: true,
  124648. configurable: true
  124649. });
  124650. _StencilState.prototype.reset = function () {
  124651. this._stencilTest = false;
  124652. this._stencilMask = 0xFF;
  124653. this._stencilFunc = _StencilState.ALWAYS;
  124654. this._stencilFuncRef = 1;
  124655. this._stencilFuncMask = 0xFF;
  124656. this._stencilOpStencilFail = _StencilState.KEEP;
  124657. this._stencilOpDepthFail = _StencilState.KEEP;
  124658. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  124659. this._isStencilTestDirty = true;
  124660. this._isStencilMaskDirty = true;
  124661. this._isStencilFuncDirty = true;
  124662. this._isStencilOpDirty = true;
  124663. };
  124664. _StencilState.prototype.apply = function (gl) {
  124665. if (!this.isDirty) {
  124666. return;
  124667. }
  124668. // Stencil test
  124669. if (this._isStencilTestDirty) {
  124670. if (this.stencilTest) {
  124671. gl.enable(gl.STENCIL_TEST);
  124672. }
  124673. else {
  124674. gl.disable(gl.STENCIL_TEST);
  124675. }
  124676. this._isStencilTestDirty = false;
  124677. }
  124678. // Stencil mask
  124679. if (this._isStencilMaskDirty) {
  124680. gl.stencilMask(this.stencilMask);
  124681. this._isStencilMaskDirty = false;
  124682. }
  124683. // Stencil func
  124684. if (this._isStencilFuncDirty) {
  124685. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  124686. this._isStencilFuncDirty = false;
  124687. }
  124688. // Stencil op
  124689. if (this._isStencilOpDirty) {
  124690. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  124691. this._isStencilOpDirty = false;
  124692. }
  124693. };
  124694. /** 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 */
  124695. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  124696. /** Passed to stencilOperation to specify that stencil value must be kept */
  124697. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  124698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  124699. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  124700. return _StencilState;
  124701. }());
  124702. /***/ }),
  124703. /***/ "./abstractScene.ts":
  124704. /*!**************************!*\
  124705. !*** ./abstractScene.ts ***!
  124706. \**************************/
  124707. /*! exports provided: AbstractScene */
  124708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124709. "use strict";
  124710. __webpack_require__.r(__webpack_exports__);
  124711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  124712. /**
  124713. * Base class of the scene acting as a container for the different elements composing a scene.
  124714. * This class is dynamically extended by the different components of the scene increasing
  124715. * flexibility and reducing coupling
  124716. */
  124717. var AbstractScene = /** @class */ (function () {
  124718. function AbstractScene() {
  124719. /**
  124720. * Gets the list of root nodes (ie. nodes with no parent)
  124721. */
  124722. this.rootNodes = new Array();
  124723. /** All of the cameras added to this scene
  124724. * @see http://doc.babylonjs.com/babylon101/cameras
  124725. */
  124726. this.cameras = new Array();
  124727. /**
  124728. * All of the lights added to this scene
  124729. * @see http://doc.babylonjs.com/babylon101/lights
  124730. */
  124731. this.lights = new Array();
  124732. /**
  124733. * All of the (abstract) meshes added to this scene
  124734. */
  124735. this.meshes = new Array();
  124736. /**
  124737. * The list of skeletons added to the scene
  124738. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  124739. */
  124740. this.skeletons = new Array();
  124741. /**
  124742. * All of the particle systems added to this scene
  124743. * @see http://doc.babylonjs.com/babylon101/particles
  124744. */
  124745. this.particleSystems = new Array();
  124746. /**
  124747. * Gets a list of Animations associated with the scene
  124748. */
  124749. this.animations = [];
  124750. /**
  124751. * All of the animation groups added to this scene
  124752. * @see http://doc.babylonjs.com/how_to/group
  124753. */
  124754. this.animationGroups = new Array();
  124755. /**
  124756. * All of the multi-materials added to this scene
  124757. * @see http://doc.babylonjs.com/how_to/multi_materials
  124758. */
  124759. this.multiMaterials = new Array();
  124760. /**
  124761. * All of the materials added to this scene
  124762. * In the context of a Scene, it is not supposed to be modified manually.
  124763. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  124764. * Note also that the order of the Material wihin the array is not significant and might change.
  124765. * @see http://doc.babylonjs.com/babylon101/materials
  124766. */
  124767. this.materials = new Array();
  124768. /**
  124769. * The list of morph target managers added to the scene
  124770. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  124771. */
  124772. this.morphTargetManagers = new Array();
  124773. /**
  124774. * The list of geometries used in the scene.
  124775. */
  124776. this.geometries = new Array();
  124777. /**
  124778. * All of the tranform nodes added to this scene
  124779. * In the context of a Scene, it is not supposed to be modified manually.
  124780. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  124781. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124782. * @see http://doc.babylonjs.com/how_to/transformnode
  124783. */
  124784. this.transformNodes = new Array();
  124785. /**
  124786. * ActionManagers available on the scene.
  124787. */
  124788. this.actionManagers = new Array();
  124789. /**
  124790. * Textures to keep.
  124791. */
  124792. this.textures = new Array();
  124793. }
  124794. /**
  124795. * Adds a parser in the list of available ones
  124796. * @param name Defines the name of the parser
  124797. * @param parser Defines the parser to add
  124798. */
  124799. AbstractScene.AddParser = function (name, parser) {
  124800. this._BabylonFileParsers[name] = parser;
  124801. };
  124802. /**
  124803. * Gets a general parser from the list of avaialble ones
  124804. * @param name Defines the name of the parser
  124805. * @returns the requested parser or null
  124806. */
  124807. AbstractScene.GetParser = function (name) {
  124808. if (this._BabylonFileParsers[name]) {
  124809. return this._BabylonFileParsers[name];
  124810. }
  124811. return null;
  124812. };
  124813. /**
  124814. * Adds n individual parser in the list of available ones
  124815. * @param name Defines the name of the parser
  124816. * @param parser Defines the parser to add
  124817. */
  124818. AbstractScene.AddIndividualParser = function (name, parser) {
  124819. this._IndividualBabylonFileParsers[name] = parser;
  124820. };
  124821. /**
  124822. * Gets an individual parser from the list of avaialble ones
  124823. * @param name Defines the name of the parser
  124824. * @returns the requested parser or null
  124825. */
  124826. AbstractScene.GetIndividualParser = function (name) {
  124827. if (this._IndividualBabylonFileParsers[name]) {
  124828. return this._IndividualBabylonFileParsers[name];
  124829. }
  124830. return null;
  124831. };
  124832. /**
  124833. * Parser json data and populate both a scene and its associated container object
  124834. * @param jsonData Defines the data to parse
  124835. * @param scene Defines the scene to parse the data for
  124836. * @param container Defines the container attached to the parsing sequence
  124837. * @param rootUrl Defines the root url of the data
  124838. */
  124839. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  124840. for (var parserName in this._BabylonFileParsers) {
  124841. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  124842. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  124843. }
  124844. }
  124845. };
  124846. /**
  124847. * Stores the list of available parsers in the application.
  124848. */
  124849. AbstractScene._BabylonFileParsers = {};
  124850. /**
  124851. * Stores the list of available individual parsers in the application.
  124852. */
  124853. AbstractScene._IndividualBabylonFileParsers = {};
  124854. return AbstractScene;
  124855. }());
  124856. /***/ }),
  124857. /***/ "./assetContainer.ts":
  124858. /*!***************************!*\
  124859. !*** ./assetContainer.ts ***!
  124860. \***************************/
  124861. /*! exports provided: KeepAssets, AssetContainer */
  124862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124863. "use strict";
  124864. __webpack_require__.r(__webpack_exports__);
  124865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  124866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  124867. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124868. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  124869. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  124870. /**
  124871. * Set of assets to keep when moving a scene into an asset container.
  124872. */
  124873. var KeepAssets = /** @class */ (function (_super) {
  124874. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  124875. function KeepAssets() {
  124876. return _super !== null && _super.apply(this, arguments) || this;
  124877. }
  124878. return KeepAssets;
  124879. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  124880. /**
  124881. * Container with a set of assets that can be added or removed from a scene.
  124882. */
  124883. var AssetContainer = /** @class */ (function (_super) {
  124884. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  124885. /**
  124886. * Instantiates an AssetContainer.
  124887. * @param scene The scene the AssetContainer belongs to.
  124888. */
  124889. function AssetContainer(scene) {
  124890. var _this = _super.call(this) || this;
  124891. _this.scene = scene;
  124892. _this["sounds"] = [];
  124893. _this["effectLayers"] = [];
  124894. _this["layers"] = [];
  124895. _this["lensFlareSystems"] = [];
  124896. _this["proceduralTextures"] = [];
  124897. _this["reflectionProbes"] = [];
  124898. return _this;
  124899. }
  124900. /**
  124901. * Adds all the assets from the container to the scene.
  124902. */
  124903. AssetContainer.prototype.addAllToScene = function () {
  124904. var _this = this;
  124905. this.cameras.forEach(function (o) {
  124906. _this.scene.addCamera(o);
  124907. });
  124908. this.lights.forEach(function (o) {
  124909. _this.scene.addLight(o);
  124910. });
  124911. this.meshes.forEach(function (o) {
  124912. _this.scene.addMesh(o);
  124913. });
  124914. this.skeletons.forEach(function (o) {
  124915. _this.scene.addSkeleton(o);
  124916. });
  124917. this.animations.forEach(function (o) {
  124918. _this.scene.addAnimation(o);
  124919. });
  124920. this.animationGroups.forEach(function (o) {
  124921. _this.scene.addAnimationGroup(o);
  124922. });
  124923. this.multiMaterials.forEach(function (o) {
  124924. _this.scene.addMultiMaterial(o);
  124925. });
  124926. this.materials.forEach(function (o) {
  124927. _this.scene.addMaterial(o);
  124928. });
  124929. this.morphTargetManagers.forEach(function (o) {
  124930. _this.scene.addMorphTargetManager(o);
  124931. });
  124932. this.geometries.forEach(function (o) {
  124933. _this.scene.addGeometry(o);
  124934. });
  124935. this.transformNodes.forEach(function (o) {
  124936. _this.scene.addTransformNode(o);
  124937. });
  124938. this.actionManagers.forEach(function (o) {
  124939. _this.scene.addActionManager(o);
  124940. });
  124941. this.textures.forEach(function (o) {
  124942. _this.scene.addTexture(o);
  124943. });
  124944. this.reflectionProbes.forEach(function (o) {
  124945. _this.scene.addReflectionProbe(o);
  124946. });
  124947. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  124948. var component = _a[_i];
  124949. component.addFromContainer(this);
  124950. }
  124951. };
  124952. /**
  124953. * Removes all the assets in the container from the scene
  124954. */
  124955. AssetContainer.prototype.removeAllFromScene = function () {
  124956. var _this = this;
  124957. this.cameras.forEach(function (o) {
  124958. _this.scene.removeCamera(o);
  124959. });
  124960. this.lights.forEach(function (o) {
  124961. _this.scene.removeLight(o);
  124962. });
  124963. this.meshes.forEach(function (o) {
  124964. _this.scene.removeMesh(o);
  124965. });
  124966. this.skeletons.forEach(function (o) {
  124967. _this.scene.removeSkeleton(o);
  124968. });
  124969. this.animations.forEach(function (o) {
  124970. _this.scene.removeAnimation(o);
  124971. });
  124972. this.animationGroups.forEach(function (o) {
  124973. _this.scene.removeAnimationGroup(o);
  124974. });
  124975. this.multiMaterials.forEach(function (o) {
  124976. _this.scene.removeMultiMaterial(o);
  124977. });
  124978. this.materials.forEach(function (o) {
  124979. _this.scene.removeMaterial(o);
  124980. });
  124981. this.morphTargetManagers.forEach(function (o) {
  124982. _this.scene.removeMorphTargetManager(o);
  124983. });
  124984. this.geometries.forEach(function (o) {
  124985. _this.scene.removeGeometry(o);
  124986. });
  124987. this.transformNodes.forEach(function (o) {
  124988. _this.scene.removeTransformNode(o);
  124989. });
  124990. this.actionManagers.forEach(function (o) {
  124991. _this.scene.removeActionManager(o);
  124992. });
  124993. this.textures.forEach(function (o) {
  124994. _this.scene.removeTexture(o);
  124995. });
  124996. this.reflectionProbes.forEach(function (o) {
  124997. _this.scene.removeReflectionProbe(o);
  124998. });
  124999. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125000. var component = _a[_i];
  125001. component.removeFromContainer(this);
  125002. }
  125003. };
  125004. /**
  125005. * Disposes all the assets in the container
  125006. */
  125007. AssetContainer.prototype.dispose = function () {
  125008. this.cameras.forEach(function (o) {
  125009. o.dispose();
  125010. });
  125011. this.lights.forEach(function (o) {
  125012. o.dispose();
  125013. });
  125014. this.meshes.forEach(function (o) {
  125015. o.dispose();
  125016. });
  125017. this.skeletons.forEach(function (o) {
  125018. o.dispose();
  125019. });
  125020. this.animationGroups.forEach(function (o) {
  125021. o.dispose();
  125022. });
  125023. this.multiMaterials.forEach(function (o) {
  125024. o.dispose();
  125025. });
  125026. this.materials.forEach(function (o) {
  125027. o.dispose();
  125028. });
  125029. this.geometries.forEach(function (o) {
  125030. o.dispose();
  125031. });
  125032. this.transformNodes.forEach(function (o) {
  125033. o.dispose();
  125034. });
  125035. this.actionManagers.forEach(function (o) {
  125036. o.dispose();
  125037. });
  125038. this.textures.forEach(function (o) {
  125039. o.dispose();
  125040. });
  125041. this.reflectionProbes.forEach(function (o) {
  125042. o.dispose();
  125043. });
  125044. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125045. var component = _a[_i];
  125046. component.dispose();
  125047. }
  125048. };
  125049. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  125050. if (!sourceAssets) {
  125051. return;
  125052. }
  125053. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  125054. var asset = sourceAssets_1[_i];
  125055. var move = true;
  125056. if (keepAssets) {
  125057. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  125058. var keepAsset = keepAssets_1[_a];
  125059. if (asset === keepAsset) {
  125060. move = false;
  125061. break;
  125062. }
  125063. }
  125064. }
  125065. if (move) {
  125066. targetAssets.push(asset);
  125067. }
  125068. }
  125069. };
  125070. /**
  125071. * Removes all the assets contained in the scene and adds them to the container.
  125072. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125073. */
  125074. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  125075. if (keepAssets === undefined) {
  125076. keepAssets = new KeepAssets();
  125077. }
  125078. for (var key in this) {
  125079. if (this.hasOwnProperty(key)) {
  125080. this[key] = this[key] || [];
  125081. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  125082. }
  125083. }
  125084. this.removeAllFromScene();
  125085. };
  125086. /**
  125087. * 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.
  125088. * @returns the root mesh
  125089. */
  125090. AssetContainer.prototype.createRootMesh = function () {
  125091. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  125092. this.meshes.forEach(function (m) {
  125093. if (!m.parent) {
  125094. rootMesh.addChild(m);
  125095. }
  125096. });
  125097. this.meshes.unshift(rootMesh);
  125098. return rootMesh;
  125099. };
  125100. return AssetContainer;
  125101. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125102. /***/ }),
  125103. /***/ "./index.ts":
  125104. /*!******************!*\
  125105. !*** ./index.ts ***!
  125106. \******************/
  125107. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, VRCameraMetrics, Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  125108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125109. "use strict";
  125110. __webpack_require__.r(__webpack_exports__);
  125111. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  125113. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  125114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  125115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  125116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  125117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  125118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  125119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  125120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  125121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  125122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  125123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  125124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  125125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  125126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  125127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  125128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  125129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  125130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  125131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  125132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  125133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  125134. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  125135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  125136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  125137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  125138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PathCursor"]; });
  125139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  125140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  125141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  125142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  125143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  125144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  125145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  125146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  125147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  125148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  125149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  125150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  125151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  125152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  125153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  125154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  125155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  125156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  125157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  125158. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  125159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  125160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  125161. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  125162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  125163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  125164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  125165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  125166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  125167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  125168. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  125169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  125170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  125171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  125172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  125173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  125174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  125175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  125176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  125177. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  125178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  125179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  125180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  125181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  125182. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  125183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  125184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  125185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  125186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  125187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  125188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  125189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  125190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  125191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  125192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  125193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  125194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  125195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  125196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  125197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  125198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  125199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  125200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  125201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  125202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  125203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  125204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  125205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  125206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  125207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  125208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  125209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  125210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  125211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  125212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  125213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  125214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  125215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  125216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  125217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  125218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  125219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  125220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  125221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  125222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  125223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  125224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  125225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  125226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  125227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  125228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  125229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  125230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  125231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  125232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  125233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  125234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  125235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  125236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  125237. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  125238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  125239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["CollisionCoordinatorLegacy"]; });
  125240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  125241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  125242. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  125243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  125244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  125245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  125246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  125247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  125248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  125249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  125250. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  125251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  125252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  125253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  125254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  125255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  125256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  125257. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  125258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  125259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  125260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  125261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  125262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  125263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  125264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  125265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  125266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  125267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  125268. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  125269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  125270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  125271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  125272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  125273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  125274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  125275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  125276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  125277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  125278. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  125279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  125280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  125281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  125282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  125283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  125284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  125285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  125286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  125287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  125288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  125289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  125290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  125291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  125292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  125293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  125294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  125295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  125296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  125297. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  125298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  125299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  125300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  125301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  125302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  125303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  125304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  125305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  125306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  125307. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  125308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  125309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  125310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  125311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  125312. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  125313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  125314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  125315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  125316. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  125317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  125318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  125319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  125320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  125321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  125322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  125323. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  125324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  125325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  125326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  125327. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  125328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  125329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  125330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  125331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  125332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  125333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  125334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  125335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  125336. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  125337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  125338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  125339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  125340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  125341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  125342. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  125343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  125344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  125345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  125346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  125347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  125348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  125349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  125350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  125351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  125352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  125353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  125354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  125355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  125356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  125357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  125358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  125359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  125360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  125361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  125362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  125363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  125364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  125365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  125366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  125367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  125368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  125369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  125370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  125371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  125372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  125373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  125374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  125375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  125376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  125377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  125378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  125379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  125380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  125381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  125382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  125383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  125384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  125385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  125386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  125387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  125388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  125389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  125390. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  125391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  125392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  125393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  125394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  125395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  125396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  125397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  125398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  125399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  125400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  125401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  125402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  125403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  125404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  125405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  125406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  125407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  125408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  125409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  125410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  125411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  125412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  125413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  125414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  125415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  125416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  125417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  125418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  125419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  125420. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  125421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  125422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  125423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  125424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  125425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  125426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_PrimitiveGeometry"]; });
  125427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonGeometry"]; });
  125428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxGeometry"]; });
  125429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereGeometry"]; });
  125430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscGeometry"]; });
  125431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderGeometry"]; });
  125432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusGeometry"]; });
  125433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundGeometry"]; });
  125434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TiledGroundGeometry"]; });
  125435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneGeometry"]; });
  125436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotGeometry"]; });
  125437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  125438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  125439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  125440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  125441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  125442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  125443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  125444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  125445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  125446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  125447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  125448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  125449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  125450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  125451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  125452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  125453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  125454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  125455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  125456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  125457. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  125458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  125459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  125460. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  125461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  125462. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  125463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  125464. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  125465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  125466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  125467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  125468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  125469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  125470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  125471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  125472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  125473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  125474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  125475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  125476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  125477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  125478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  125479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  125480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  125481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  125482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  125483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  125484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  125485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  125486. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  125487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  125488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  125489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  125490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  125491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  125492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  125493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  125494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  125495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  125496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  125497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  125498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  125499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  125500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  125501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  125502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  125503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  125504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  125505. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  125506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  125507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  125508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  125509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  125510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  125511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  125512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  125513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  125514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  125515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  125516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  125517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  125518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  125519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  125520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  125521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  125522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  125523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  125524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  125525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  125526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  125527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  125528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  125529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  125530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  125531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  125532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  125533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  125534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  125535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  125536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  125537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  125538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  125539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  125540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  125541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  125542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  125543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  125544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  125545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  125546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  125547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  125548. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  125549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  125550. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  125551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  125552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  125553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  125554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  125555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  125556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  125557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  125558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  125559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  125560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  125561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  125562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  125563. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  125564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  125565. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  125566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  125567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  125568. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  125569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  125570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  125571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  125572. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  125573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  125574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  125575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  125576. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  125577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  125578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  125579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  125580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  125581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  125582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  125583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  125584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  125585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  125586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  125587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  125588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  125589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  125590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  125591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  125592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  125593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  125594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  125595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  125596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  125597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  125598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  125599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  125600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  125601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  125602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  125603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  125604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  125605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  125606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  125607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  125608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  125609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  125610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  125611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  125612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  125613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  125614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  125615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  125616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  125617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  125618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  125619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  125620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  125621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  125622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  125623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  125624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  125625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  125626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  125627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  125628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  125629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  125630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  125631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  125632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  125633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  125634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  125635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  125636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  125637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  125638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  125639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  125640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  125641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  125642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  125643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  125644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  125645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  125646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  125647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  125648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  125649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  125650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  125651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  125652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  125653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  125654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  125655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  125656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  125657. /***/ }),
  125658. /***/ "./node.ts":
  125659. /*!*****************!*\
  125660. !*** ./node.ts ***!
  125661. \*****************/
  125662. /*! exports provided: Node */
  125663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125664. "use strict";
  125665. __webpack_require__.r(__webpack_exports__);
  125666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  125667. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125668. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  125669. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  125670. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  125671. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  125672. /**
  125673. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  125674. */
  125675. var Node = /** @class */ (function () {
  125676. /**
  125677. * Creates a new Node
  125678. * @param name the name and id to be given to this node
  125679. * @param scene the scene this node will be added to
  125680. * @param addToRootNodes the node will be added to scene.rootNodes
  125681. */
  125682. function Node(name, scene, addToRootNodes) {
  125683. if (scene === void 0) { scene = null; }
  125684. if (addToRootNodes === void 0) { addToRootNodes = true; }
  125685. /**
  125686. * Gets or sets a string used to store user defined state for the node
  125687. */
  125688. this.state = "";
  125689. /**
  125690. * Gets or sets an object used to store user defined information for the node
  125691. */
  125692. this.metadata = null;
  125693. /**
  125694. * For internal use only. Please do not use.
  125695. */
  125696. this.reservedDataStore = null;
  125697. /**
  125698. * Gets or sets a boolean used to define if the node must be serialized
  125699. */
  125700. this.doNotSerialize = false;
  125701. /** @hidden */
  125702. this._isDisposed = false;
  125703. /**
  125704. * Gets a list of Animations associated with the node
  125705. */
  125706. this.animations = new Array();
  125707. this._ranges = {};
  125708. this._isEnabled = true;
  125709. this._isParentEnabled = true;
  125710. this._isReady = true;
  125711. /** @hidden */
  125712. this._currentRenderId = -1;
  125713. this._parentRenderId = -1;
  125714. this._childRenderId = -1;
  125715. /** @hidden */
  125716. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  125717. /** @hidden */
  125718. this._worldMatrixDeterminant = 0;
  125719. /** @hidden */
  125720. this._sceneRootNodesIndex = -1;
  125721. this._animationPropertiesOverride = null;
  125722. /** @hidden */
  125723. this._isNode = true;
  125724. /**
  125725. * An event triggered when the mesh is disposed
  125726. */
  125727. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  125728. // Behaviors
  125729. this._behaviors = new Array();
  125730. this.name = name;
  125731. this.id = name;
  125732. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  125733. this.uniqueId = this._scene.getUniqueId();
  125734. this._initCache();
  125735. if (addToRootNodes) {
  125736. this.addToSceneRootNodes();
  125737. }
  125738. }
  125739. /**
  125740. * Add a new node constructor
  125741. * @param type defines the type name of the node to construct
  125742. * @param constructorFunc defines the constructor function
  125743. */
  125744. Node.AddNodeConstructor = function (type, constructorFunc) {
  125745. this._NodeConstructors[type] = constructorFunc;
  125746. };
  125747. /**
  125748. * Returns a node constructor based on type name
  125749. * @param type defines the type name
  125750. * @param name defines the new node name
  125751. * @param scene defines the hosting scene
  125752. * @param options defines optional options to transmit to constructors
  125753. * @returns the new constructor or null
  125754. */
  125755. Node.Construct = function (type, name, scene, options) {
  125756. var constructorFunc = this._NodeConstructors[type];
  125757. if (!constructorFunc) {
  125758. return null;
  125759. }
  125760. return constructorFunc(name, scene, options);
  125761. };
  125762. /**
  125763. * Gets a boolean indicating if the node has been disposed
  125764. * @returns true if the node was disposed
  125765. */
  125766. Node.prototype.isDisposed = function () {
  125767. return this._isDisposed;
  125768. };
  125769. Object.defineProperty(Node.prototype, "parent", {
  125770. get: function () {
  125771. return this._parentNode;
  125772. },
  125773. /**
  125774. * Gets or sets the parent of the node
  125775. */
  125776. set: function (parent) {
  125777. if (this._parentNode === parent) {
  125778. return;
  125779. }
  125780. var previousParentNode = this._parentNode;
  125781. // Remove self from list of children of parent
  125782. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  125783. var index = this._parentNode._children.indexOf(this);
  125784. if (index !== -1) {
  125785. this._parentNode._children.splice(index, 1);
  125786. }
  125787. if (!parent && !this._isDisposed) {
  125788. this.addToSceneRootNodes();
  125789. }
  125790. }
  125791. // Store new parent
  125792. this._parentNode = parent;
  125793. // Add as child to new parent
  125794. if (this._parentNode) {
  125795. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  125796. this._parentNode._children = new Array();
  125797. }
  125798. this._parentNode._children.push(this);
  125799. if (!previousParentNode) {
  125800. this.removeFromSceneRootNodes();
  125801. }
  125802. }
  125803. // Enabled state
  125804. this._syncParentEnabledState();
  125805. },
  125806. enumerable: true,
  125807. configurable: true
  125808. });
  125809. Node.prototype.addToSceneRootNodes = function () {
  125810. if (this._sceneRootNodesIndex === -1) {
  125811. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  125812. this._scene.rootNodes.push(this);
  125813. }
  125814. };
  125815. Node.prototype.removeFromSceneRootNodes = function () {
  125816. if (this._sceneRootNodesIndex !== -1) {
  125817. var rootNodes = this._scene.rootNodes;
  125818. var lastIdx = rootNodes.length - 1;
  125819. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  125820. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  125821. this._scene.rootNodes.pop();
  125822. this._sceneRootNodesIndex = -1;
  125823. }
  125824. };
  125825. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  125826. /**
  125827. * Gets or sets the animation properties override
  125828. */
  125829. get: function () {
  125830. if (!this._animationPropertiesOverride) {
  125831. return this._scene.animationPropertiesOverride;
  125832. }
  125833. return this._animationPropertiesOverride;
  125834. },
  125835. set: function (value) {
  125836. this._animationPropertiesOverride = value;
  125837. },
  125838. enumerable: true,
  125839. configurable: true
  125840. });
  125841. /**
  125842. * Gets a string idenfifying the name of the class
  125843. * @returns "Node" string
  125844. */
  125845. Node.prototype.getClassName = function () {
  125846. return "Node";
  125847. };
  125848. Object.defineProperty(Node.prototype, "onDispose", {
  125849. /**
  125850. * Sets a callback that will be raised when the node will be disposed
  125851. */
  125852. set: function (callback) {
  125853. if (this._onDisposeObserver) {
  125854. this.onDisposeObservable.remove(this._onDisposeObserver);
  125855. }
  125856. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  125857. },
  125858. enumerable: true,
  125859. configurable: true
  125860. });
  125861. /**
  125862. * Gets the scene of the node
  125863. * @returns a scene
  125864. */
  125865. Node.prototype.getScene = function () {
  125866. return this._scene;
  125867. };
  125868. /**
  125869. * Gets the engine of the node
  125870. * @returns a Engine
  125871. */
  125872. Node.prototype.getEngine = function () {
  125873. return this._scene.getEngine();
  125874. };
  125875. /**
  125876. * Attach a behavior to the node
  125877. * @see http://doc.babylonjs.com/features/behaviour
  125878. * @param behavior defines the behavior to attach
  125879. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  125880. * @returns the current Node
  125881. */
  125882. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  125883. var _this = this;
  125884. if (attachImmediately === void 0) { attachImmediately = false; }
  125885. var index = this._behaviors.indexOf(behavior);
  125886. if (index !== -1) {
  125887. return this;
  125888. }
  125889. behavior.init();
  125890. if (this._scene.isLoading && !attachImmediately) {
  125891. // We defer the attach when the scene will be loaded
  125892. this._scene.onDataLoadedObservable.addOnce(function () {
  125893. behavior.attach(_this);
  125894. });
  125895. }
  125896. else {
  125897. behavior.attach(this);
  125898. }
  125899. this._behaviors.push(behavior);
  125900. return this;
  125901. };
  125902. /**
  125903. * Remove an attached behavior
  125904. * @see http://doc.babylonjs.com/features/behaviour
  125905. * @param behavior defines the behavior to attach
  125906. * @returns the current Node
  125907. */
  125908. Node.prototype.removeBehavior = function (behavior) {
  125909. var index = this._behaviors.indexOf(behavior);
  125910. if (index === -1) {
  125911. return this;
  125912. }
  125913. this._behaviors[index].detach();
  125914. this._behaviors.splice(index, 1);
  125915. return this;
  125916. };
  125917. Object.defineProperty(Node.prototype, "behaviors", {
  125918. /**
  125919. * Gets the list of attached behaviors
  125920. * @see http://doc.babylonjs.com/features/behaviour
  125921. */
  125922. get: function () {
  125923. return this._behaviors;
  125924. },
  125925. enumerable: true,
  125926. configurable: true
  125927. });
  125928. /**
  125929. * Gets an attached behavior by name
  125930. * @param name defines the name of the behavior to look for
  125931. * @see http://doc.babylonjs.com/features/behaviour
  125932. * @returns null if behavior was not found else the requested behavior
  125933. */
  125934. Node.prototype.getBehaviorByName = function (name) {
  125935. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  125936. var behavior = _a[_i];
  125937. if (behavior.name === name) {
  125938. return behavior;
  125939. }
  125940. }
  125941. return null;
  125942. };
  125943. /**
  125944. * Returns the latest update of the World matrix
  125945. * @returns a Matrix
  125946. */
  125947. Node.prototype.getWorldMatrix = function () {
  125948. if (this._currentRenderId !== this._scene.getRenderId()) {
  125949. this.computeWorldMatrix();
  125950. }
  125951. return this._worldMatrix;
  125952. };
  125953. /** @hidden */
  125954. Node.prototype._getWorldMatrixDeterminant = function () {
  125955. return this._worldMatrixDeterminant;
  125956. };
  125957. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  125958. /**
  125959. * Returns directly the latest state of the mesh World matrix.
  125960. * A Matrix is returned.
  125961. */
  125962. get: function () {
  125963. return this._worldMatrix;
  125964. },
  125965. enumerable: true,
  125966. configurable: true
  125967. });
  125968. // override it in derived class if you add new variables to the cache
  125969. // and call the parent class method
  125970. /** @hidden */
  125971. Node.prototype._initCache = function () {
  125972. this._cache = {};
  125973. this._cache.parent = undefined;
  125974. };
  125975. /** @hidden */
  125976. Node.prototype.updateCache = function (force) {
  125977. if (!force && this.isSynchronized()) {
  125978. return;
  125979. }
  125980. this._cache.parent = this.parent;
  125981. this._updateCache();
  125982. };
  125983. // override it in derived class if you add new variables to the cache
  125984. // and call the parent class method if !ignoreParentClass
  125985. /** @hidden */
  125986. Node.prototype._updateCache = function (ignoreParentClass) {
  125987. };
  125988. // override it in derived class if you add new variables to the cache
  125989. /** @hidden */
  125990. Node.prototype._isSynchronized = function () {
  125991. return true;
  125992. };
  125993. /** @hidden */
  125994. Node.prototype._markSyncedWithParent = function () {
  125995. if (this._parentNode) {
  125996. this._parentRenderId = this._parentNode._childRenderId;
  125997. }
  125998. };
  125999. /** @hidden */
  126000. Node.prototype.isSynchronizedWithParent = function () {
  126001. if (!this._parentNode) {
  126002. return true;
  126003. }
  126004. if (this._parentRenderId !== this._parentNode._childRenderId) {
  126005. return false;
  126006. }
  126007. return this._parentNode.isSynchronized();
  126008. };
  126009. /** @hidden */
  126010. Node.prototype.isSynchronized = function () {
  126011. if (this._cache.parent != this._parentNode) {
  126012. this._cache.parent = this._parentNode;
  126013. return false;
  126014. }
  126015. if (this._parentNode && !this.isSynchronizedWithParent()) {
  126016. return false;
  126017. }
  126018. return this._isSynchronized();
  126019. };
  126020. /**
  126021. * Is this node ready to be used/rendered
  126022. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  126023. * @return true if the node is ready
  126024. */
  126025. Node.prototype.isReady = function (completeCheck) {
  126026. if (completeCheck === void 0) { completeCheck = false; }
  126027. return this._isReady;
  126028. };
  126029. /**
  126030. * Is this node enabled?
  126031. * 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
  126032. * @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
  126033. * @return whether this node (and its parent) is enabled
  126034. */
  126035. Node.prototype.isEnabled = function (checkAncestors) {
  126036. if (checkAncestors === void 0) { checkAncestors = true; }
  126037. if (checkAncestors === false) {
  126038. return this._isEnabled;
  126039. }
  126040. if (!this._isEnabled) {
  126041. return false;
  126042. }
  126043. return this._isParentEnabled;
  126044. };
  126045. /** @hidden */
  126046. Node.prototype._syncParentEnabledState = function () {
  126047. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  126048. if (this._children) {
  126049. this._children.forEach(function (c) {
  126050. c._syncParentEnabledState(); // Force children to update accordingly
  126051. });
  126052. }
  126053. };
  126054. /**
  126055. * Set the enabled state of this node
  126056. * @param value defines the new enabled state
  126057. */
  126058. Node.prototype.setEnabled = function (value) {
  126059. this._isEnabled = value;
  126060. this._syncParentEnabledState();
  126061. };
  126062. /**
  126063. * Is this node a descendant of the given node?
  126064. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  126065. * @param ancestor defines the parent node to inspect
  126066. * @returns a boolean indicating if this node is a descendant of the given node
  126067. */
  126068. Node.prototype.isDescendantOf = function (ancestor) {
  126069. if (this.parent) {
  126070. if (this.parent === ancestor) {
  126071. return true;
  126072. }
  126073. return this.parent.isDescendantOf(ancestor);
  126074. }
  126075. return false;
  126076. };
  126077. /** @hidden */
  126078. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  126079. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  126080. if (!this._children) {
  126081. return;
  126082. }
  126083. for (var index = 0; index < this._children.length; index++) {
  126084. var item = this._children[index];
  126085. if (!predicate || predicate(item)) {
  126086. results.push(item);
  126087. }
  126088. if (!directDescendantsOnly) {
  126089. item._getDescendants(results, false, predicate);
  126090. }
  126091. }
  126092. };
  126093. /**
  126094. * Will return all nodes that have this node as ascendant
  126095. * @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
  126096. * @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
  126097. * @return all children nodes of all types
  126098. */
  126099. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  126100. var results = new Array();
  126101. this._getDescendants(results, directDescendantsOnly, predicate);
  126102. return results;
  126103. };
  126104. /**
  126105. * Get all child-meshes of this node
  126106. * @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
  126107. * @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
  126108. * @returns an array of AbstractMesh
  126109. */
  126110. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  126111. var results = [];
  126112. this._getDescendants(results, directDescendantsOnly, function (node) {
  126113. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  126114. });
  126115. return results;
  126116. };
  126117. /**
  126118. * Get all direct children of this node
  126119. * @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
  126120. * @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)
  126121. * @returns an array of Node
  126122. */
  126123. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  126124. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  126125. return this.getDescendants(directDescendantsOnly, predicate);
  126126. };
  126127. /** @hidden */
  126128. Node.prototype._setReady = function (state) {
  126129. if (state === this._isReady) {
  126130. return;
  126131. }
  126132. if (!state) {
  126133. this._isReady = false;
  126134. return;
  126135. }
  126136. if (this.onReady) {
  126137. this.onReady(this);
  126138. }
  126139. this._isReady = true;
  126140. };
  126141. /**
  126142. * Get an animation by name
  126143. * @param name defines the name of the animation to look for
  126144. * @returns null if not found else the requested animation
  126145. */
  126146. Node.prototype.getAnimationByName = function (name) {
  126147. for (var i = 0; i < this.animations.length; i++) {
  126148. var animation = this.animations[i];
  126149. if (animation.name === name) {
  126150. return animation;
  126151. }
  126152. }
  126153. return null;
  126154. };
  126155. /**
  126156. * Creates an animation range for this node
  126157. * @param name defines the name of the range
  126158. * @param from defines the starting key
  126159. * @param to defines the end key
  126160. */
  126161. Node.prototype.createAnimationRange = function (name, from, to) {
  126162. // check name not already in use
  126163. if (!this._ranges[name]) {
  126164. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  126165. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126166. if (this.animations[i]) {
  126167. this.animations[i].createRange(name, from, to);
  126168. }
  126169. }
  126170. }
  126171. };
  126172. /**
  126173. * Delete a specific animation range
  126174. * @param name defines the name of the range to delete
  126175. * @param deleteFrames defines if animation frames from the range must be deleted as well
  126176. */
  126177. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  126178. if (deleteFrames === void 0) { deleteFrames = true; }
  126179. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126180. if (this.animations[i]) {
  126181. this.animations[i].deleteRange(name, deleteFrames);
  126182. }
  126183. }
  126184. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  126185. };
  126186. /**
  126187. * Get an animation range by name
  126188. * @param name defines the name of the animation range to look for
  126189. * @returns null if not found else the requested animation range
  126190. */
  126191. Node.prototype.getAnimationRange = function (name) {
  126192. return this._ranges[name];
  126193. };
  126194. /**
  126195. * Will start the animation sequence
  126196. * @param name defines the range frames for animation sequence
  126197. * @param loop defines if the animation should loop (false by default)
  126198. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  126199. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  126200. * @returns the object created for this animation. If range does not exist, it will return null
  126201. */
  126202. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  126203. var range = this.getAnimationRange(name);
  126204. if (!range) {
  126205. return null;
  126206. }
  126207. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  126208. };
  126209. /**
  126210. * Serialize animation ranges into a JSON compatible object
  126211. * @returns serialization object
  126212. */
  126213. Node.prototype.serializeAnimationRanges = function () {
  126214. var serializationRanges = [];
  126215. for (var name in this._ranges) {
  126216. var localRange = this._ranges[name];
  126217. if (!localRange) {
  126218. continue;
  126219. }
  126220. var range = {};
  126221. range.name = name;
  126222. range.from = localRange.from;
  126223. range.to = localRange.to;
  126224. serializationRanges.push(range);
  126225. }
  126226. return serializationRanges;
  126227. };
  126228. /**
  126229. * Computes the world matrix of the node
  126230. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  126231. * @returns the world matrix
  126232. */
  126233. Node.prototype.computeWorldMatrix = function (force) {
  126234. if (!this._worldMatrix) {
  126235. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126236. }
  126237. return this._worldMatrix;
  126238. };
  126239. /**
  126240. * Releases resources associated with this node.
  126241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126243. */
  126244. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  126245. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  126246. this._isDisposed = true;
  126247. if (!doNotRecurse) {
  126248. var nodes = this.getDescendants(true);
  126249. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  126250. var node = nodes_1[_i];
  126251. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  126252. }
  126253. }
  126254. if (!this.parent) {
  126255. this.removeFromSceneRootNodes();
  126256. }
  126257. else {
  126258. this.parent = null;
  126259. }
  126260. // Callback
  126261. this.onDisposeObservable.notifyObservers(this);
  126262. this.onDisposeObservable.clear();
  126263. // Behaviors
  126264. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  126265. var behavior = _b[_a];
  126266. behavior.detach();
  126267. }
  126268. this._behaviors = [];
  126269. };
  126270. /**
  126271. * Parse animation range data from a serialization object and store them into a given node
  126272. * @param node defines where to store the animation ranges
  126273. * @param parsedNode defines the serialization object to read data from
  126274. * @param scene defines the hosting scene
  126275. */
  126276. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  126277. if (parsedNode.ranges) {
  126278. for (var index = 0; index < parsedNode.ranges.length; index++) {
  126279. var data = parsedNode.ranges[index];
  126280. node.createAnimationRange(data.name, data.from, data.to);
  126281. }
  126282. }
  126283. };
  126284. /** @hidden */
  126285. Node._AnimationRangeFactory = function (name, from, to) {
  126286. throw "AnimationRange needs to be imported from animation before being created.";
  126287. };
  126288. Node._NodeConstructors = {};
  126289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126291. ], Node.prototype, "name", void 0);
  126292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126294. ], Node.prototype, "id", void 0);
  126295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126297. ], Node.prototype, "uniqueId", void 0);
  126298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126300. ], Node.prototype, "state", void 0);
  126301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126303. ], Node.prototype, "metadata", void 0);
  126304. return Node;
  126305. }());
  126306. /***/ }),
  126307. /***/ "./scene.ts":
  126308. /*!******************!*\
  126309. !*** ./scene.ts ***!
  126310. \******************/
  126311. /*! exports provided: Scene */
  126312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126313. "use strict";
  126314. __webpack_require__.r(__webpack_exports__);
  126315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  126316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126317. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  126318. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  126319. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126320. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  126321. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  126322. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  126323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126324. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126325. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  126326. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126327. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  126328. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  126329. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Animations/animation */ "./Animations/animation.ts");
  126330. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Animations/animatable */ "./Animations/animatable.ts");
  126331. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  126332. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  126333. /* harmony import */ var _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Collisions/collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  126334. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  126335. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  126336. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  126337. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Actions/actionManager */ "./Actions/actionManager.ts");
  126338. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  126339. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  126340. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126341. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Culling/ray */ "./Culling/ray.ts");
  126342. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  126343. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  126344. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  126345. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126346. /** @hidden */
  126347. var ClickInfo = /** @class */ (function () {
  126348. function ClickInfo() {
  126349. this._singleClick = false;
  126350. this._doubleClick = false;
  126351. this._hasSwiped = false;
  126352. this._ignore = false;
  126353. }
  126354. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  126355. get: function () {
  126356. return this._singleClick;
  126357. },
  126358. set: function (b) {
  126359. this._singleClick = b;
  126360. },
  126361. enumerable: true,
  126362. configurable: true
  126363. });
  126364. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  126365. get: function () {
  126366. return this._doubleClick;
  126367. },
  126368. set: function (b) {
  126369. this._doubleClick = b;
  126370. },
  126371. enumerable: true,
  126372. configurable: true
  126373. });
  126374. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  126375. get: function () {
  126376. return this._hasSwiped;
  126377. },
  126378. set: function (b) {
  126379. this._hasSwiped = b;
  126380. },
  126381. enumerable: true,
  126382. configurable: true
  126383. });
  126384. Object.defineProperty(ClickInfo.prototype, "ignore", {
  126385. get: function () {
  126386. return this._ignore;
  126387. },
  126388. set: function (b) {
  126389. this._ignore = b;
  126390. },
  126391. enumerable: true,
  126392. configurable: true
  126393. });
  126394. return ClickInfo;
  126395. }());
  126396. /**
  126397. * Represents a scene to be rendered by the engine.
  126398. * @see http://doc.babylonjs.com/features/scene
  126399. */
  126400. var Scene = /** @class */ (function (_super) {
  126401. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  126402. /**
  126403. * Creates a new Scene
  126404. * @param engine defines the engine to use to render this scene
  126405. */
  126406. function Scene(engine, options) {
  126407. var _this = _super.call(this) || this;
  126408. // Members
  126409. /** @hidden */
  126410. _this._isScene = true;
  126411. /**
  126412. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  126413. */
  126414. _this.autoClear = true;
  126415. /**
  126416. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  126417. */
  126418. _this.autoClearDepthAndStencil = true;
  126419. /**
  126420. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  126421. */
  126422. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  126423. /**
  126424. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  126425. */
  126426. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  126427. _this._forceWireframe = false;
  126428. _this._forcePointsCloud = false;
  126429. /**
  126430. * Gets or sets a boolean indicating if animations are enabled
  126431. */
  126432. _this.animationsEnabled = true;
  126433. _this._animationPropertiesOverride = null;
  126434. /**
  126435. * Gets or sets a boolean indicating if a constant deltatime has to be used
  126436. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  126437. */
  126438. _this.useConstantAnimationDeltaTime = false;
  126439. /**
  126440. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  126441. * Please note that it requires to run a ray cast through the scene on every frame
  126442. */
  126443. _this.constantlyUpdateMeshUnderPointer = false;
  126444. /**
  126445. * Defines the HTML cursor to use when hovering over interactive elements
  126446. */
  126447. _this.hoverCursor = "pointer";
  126448. /**
  126449. * Defines the HTML default cursor to use (empty by default)
  126450. */
  126451. _this.defaultCursor = "";
  126452. /**
  126453. * This is used to call preventDefault() on pointer down
  126454. * in order to block unwanted artifacts like system double clicks
  126455. */
  126456. _this.preventDefaultOnPointerDown = true;
  126457. /**
  126458. * This is used to call preventDefault() on pointer up
  126459. * in order to block unwanted artifacts like system double clicks
  126460. */
  126461. _this.preventDefaultOnPointerUp = true;
  126462. // Metadata
  126463. /**
  126464. * Gets or sets user defined metadata
  126465. */
  126466. _this.metadata = null;
  126467. /**
  126468. * For internal use only. Please do not use.
  126469. */
  126470. _this.reservedDataStore = null;
  126471. /**
  126472. * Use this array to add regular expressions used to disable offline support for specific urls
  126473. */
  126474. _this.disableOfflineSupportExceptionRules = new Array();
  126475. /**
  126476. * An event triggered when the scene is disposed.
  126477. */
  126478. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126479. _this._onDisposeObserver = null;
  126480. /**
  126481. * An event triggered before rendering the scene (right after animations and physics)
  126482. */
  126483. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126484. _this._onBeforeRenderObserver = null;
  126485. /**
  126486. * An event triggered after rendering the scene
  126487. */
  126488. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126489. _this._onAfterRenderObserver = null;
  126490. /**
  126491. * An event triggered before animating the scene
  126492. */
  126493. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126494. /**
  126495. * An event triggered after animations processing
  126496. */
  126497. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126498. /**
  126499. * An event triggered before draw calls are ready to be sent
  126500. */
  126501. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126502. /**
  126503. * An event triggered after draw calls have been sent
  126504. */
  126505. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126506. /**
  126507. * An event triggered when the scene is ready
  126508. */
  126509. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126510. /**
  126511. * An event triggered before rendering a camera
  126512. */
  126513. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126514. _this._onBeforeCameraRenderObserver = null;
  126515. /**
  126516. * An event triggered after rendering a camera
  126517. */
  126518. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126519. _this._onAfterCameraRenderObserver = null;
  126520. /**
  126521. * An event triggered when active meshes evaluation is about to start
  126522. */
  126523. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126524. /**
  126525. * An event triggered when active meshes evaluation is done
  126526. */
  126527. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126528. /**
  126529. * An event triggered when particles rendering is about to start
  126530. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126531. */
  126532. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126533. /**
  126534. * An event triggered when particles rendering is done
  126535. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126536. */
  126537. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126538. /**
  126539. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  126540. */
  126541. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126542. /**
  126543. * An event triggered when a camera is created
  126544. */
  126545. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126546. /**
  126547. * An event triggered when a camera is removed
  126548. */
  126549. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126550. /**
  126551. * An event triggered when a light is created
  126552. */
  126553. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126554. /**
  126555. * An event triggered when a light is removed
  126556. */
  126557. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126558. /**
  126559. * An event triggered when a geometry is created
  126560. */
  126561. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126562. /**
  126563. * An event triggered when a geometry is removed
  126564. */
  126565. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126566. /**
  126567. * An event triggered when a transform node is created
  126568. */
  126569. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126570. /**
  126571. * An event triggered when a transform node is removed
  126572. */
  126573. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126574. /**
  126575. * An event triggered when a mesh is created
  126576. */
  126577. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126578. /**
  126579. * An event triggered when a mesh is removed
  126580. */
  126581. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126582. /**
  126583. * An event triggered when a material is created
  126584. */
  126585. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126586. /**
  126587. * An event triggered when a material is removed
  126588. */
  126589. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126590. /**
  126591. * An event triggered when a texture is created
  126592. */
  126593. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126594. /**
  126595. * An event triggered when a texture is removed
  126596. */
  126597. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126598. /**
  126599. * An event triggered when render targets are about to be rendered
  126600. * Can happen multiple times per frame.
  126601. */
  126602. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126603. /**
  126604. * An event triggered when render targets were rendered.
  126605. * Can happen multiple times per frame.
  126606. */
  126607. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126608. /**
  126609. * An event triggered before calculating deterministic simulation step
  126610. */
  126611. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126612. /**
  126613. * An event triggered after calculating deterministic simulation step
  126614. */
  126615. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126616. /**
  126617. * An event triggered when the activeCamera property is updated
  126618. */
  126619. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126620. /**
  126621. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  126622. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126623. * 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)
  126624. */
  126625. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126626. /**
  126627. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  126628. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126629. * 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)
  126630. */
  126631. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126632. /**
  126633. * This Observable will when a mesh has been imported into the scene.
  126634. */
  126635. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126636. // Animations
  126637. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126638. /**
  126639. * 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).
  126640. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  126641. */
  126642. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126643. /**
  126644. * Observable event triggered each time an input event is received from the rendering canvas
  126645. */
  126646. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126647. _this._meshPickProceed = false;
  126648. _this._currentPickResult = null;
  126649. _this._previousPickResult = null;
  126650. _this._totalPointersPressed = 0;
  126651. _this._doubleClickOccured = false;
  126652. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  126653. _this.cameraToUseForPointers = null;
  126654. _this._pointerX = 0;
  126655. _this._pointerY = 0;
  126656. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  126657. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  126658. _this._startingPointerTime = 0;
  126659. _this._previousStartingPointerTime = 0;
  126660. _this._pointerCaptures = {};
  126661. // Deterministic lockstep
  126662. _this._timeAccumulator = 0;
  126663. _this._currentStepId = 0;
  126664. _this._currentInternalStep = 0;
  126665. // Keyboard
  126666. /**
  126667. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  126668. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  126669. */
  126670. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126671. /**
  126672. * Observable event triggered each time an keyboard event is received from the hosting window
  126673. */
  126674. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126675. // Coordinates system
  126676. _this._useRightHandedSystem = false;
  126677. // Fog
  126678. _this._fogEnabled = true;
  126679. _this._fogMode = Scene.FOGMODE_NONE;
  126680. /**
  126681. * Gets or sets the fog color to use
  126682. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126683. * (Default is Color3(0.2, 0.2, 0.3))
  126684. */
  126685. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  126686. /**
  126687. * Gets or sets the fog density to use
  126688. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126689. * (Default is 0.1)
  126690. */
  126691. _this.fogDensity = 0.1;
  126692. /**
  126693. * Gets or sets the fog start distance to use
  126694. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126695. * (Default is 0)
  126696. */
  126697. _this.fogStart = 0;
  126698. /**
  126699. * Gets or sets the fog end distance to use
  126700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126701. * (Default is 1000)
  126702. */
  126703. _this.fogEnd = 1000.0;
  126704. // Lights
  126705. _this._shadowsEnabled = true;
  126706. _this._lightsEnabled = true;
  126707. /** All of the active cameras added to this scene. */
  126708. _this.activeCameras = new Array();
  126709. // Textures
  126710. _this._texturesEnabled = true;
  126711. // Particles
  126712. /**
  126713. * Gets or sets a boolean indicating if particles are enabled on this scene
  126714. */
  126715. _this.particlesEnabled = true;
  126716. // Sprites
  126717. /**
  126718. * Gets or sets a boolean indicating if sprites are enabled on this scene
  126719. */
  126720. _this.spritesEnabled = true;
  126721. // Skeletons
  126722. _this._skeletonsEnabled = true;
  126723. // Lens flares
  126724. /**
  126725. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  126726. */
  126727. _this.lensFlaresEnabled = true;
  126728. // Collisions
  126729. /**
  126730. * Gets or sets a boolean indicating if collisions are enabled on this scene
  126731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  126732. */
  126733. _this.collisionsEnabled = true;
  126734. /**
  126735. * Defines the gravity applied to this scene (used only for collisions)
  126736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  126737. */
  126738. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  126739. // Postprocesses
  126740. /**
  126741. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  126742. */
  126743. _this.postProcessesEnabled = true;
  126744. /**
  126745. * The list of postprocesses added to the scene
  126746. */
  126747. _this.postProcesses = new Array();
  126748. // Customs render targets
  126749. /**
  126750. * Gets or sets a boolean indicating if render targets are enabled on this scene
  126751. */
  126752. _this.renderTargetsEnabled = true;
  126753. /**
  126754. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  126755. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  126756. */
  126757. _this.dumpNextRenderTargets = false;
  126758. /**
  126759. * The list of user defined render targets added to the scene
  126760. */
  126761. _this.customRenderTargets = new Array();
  126762. /**
  126763. * Gets the list of meshes imported to the scene through SceneLoader
  126764. */
  126765. _this.importedMeshesFiles = new Array();
  126766. // Probes
  126767. /**
  126768. * Gets or sets a boolean indicating if probes are enabled on this scene
  126769. */
  126770. _this.probesEnabled = true;
  126771. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126772. // Procedural textures
  126773. /**
  126774. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  126775. */
  126776. _this.proceduralTexturesEnabled = true;
  126777. // Performance counters
  126778. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126779. /** @hidden */
  126780. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126781. /** @hidden */
  126782. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126783. /** @hidden */
  126784. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126785. _this._animationTime = 0;
  126786. /**
  126787. * Gets or sets a general scale for animation speed
  126788. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  126789. */
  126790. _this.animationTimeScale = 1;
  126791. _this._renderId = 0;
  126792. _this._frameId = 0;
  126793. _this._executeWhenReadyTimeoutId = -1;
  126794. _this._intermediateRendering = false;
  126795. _this._viewUpdateFlag = -1;
  126796. _this._projectionUpdateFlag = -1;
  126797. _this._alternateViewUpdateFlag = -1;
  126798. _this._alternateProjectionUpdateFlag = -1;
  126799. /** @hidden */
  126800. _this._toBeDisposed = new Array(256);
  126801. _this._activeRequests = new Array();
  126802. _this._pendingData = new Array();
  126803. _this._isDisposed = false;
  126804. /**
  126805. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  126806. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  126807. */
  126808. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  126809. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126810. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126811. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126812. /** @hidden */
  126813. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126814. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  126815. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  126816. /** @hidden */
  126817. _this._activeAnimatables = new Array();
  126818. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  126819. _this._useAlternateCameraConfiguration = false;
  126820. _this._alternateRendering = false;
  126821. _this._wheelEventName = "";
  126822. /**
  126823. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  126824. * This is useful if there are more lights that the maximum simulteanous authorized
  126825. */
  126826. _this.requireLightSorting = false;
  126827. /**
  126828. * @hidden
  126829. * Backing store of defined scene components.
  126830. */
  126831. _this._components = [];
  126832. /**
  126833. * @hidden
  126834. * Backing store of defined scene components.
  126835. */
  126836. _this._serializableComponents = [];
  126837. /**
  126838. * List of components to register on the next registration step.
  126839. */
  126840. _this._transientComponents = [];
  126841. /**
  126842. * @hidden
  126843. * Defines the actions happening before camera updates.
  126844. */
  126845. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126846. /**
  126847. * @hidden
  126848. * Defines the actions happening before clear the canvas.
  126849. */
  126850. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126851. /**
  126852. * @hidden
  126853. * Defines the actions when collecting render targets for the frame.
  126854. */
  126855. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126856. /**
  126857. * @hidden
  126858. * Defines the actions happening for one camera in the frame.
  126859. */
  126860. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126861. /**
  126862. * @hidden
  126863. * Defines the actions happening during the per mesh ready checks.
  126864. */
  126865. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126866. /**
  126867. * @hidden
  126868. * Defines the actions happening before evaluate active mesh checks.
  126869. */
  126870. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126871. /**
  126872. * @hidden
  126873. * Defines the actions happening during the evaluate sub mesh checks.
  126874. */
  126875. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126876. /**
  126877. * @hidden
  126878. * Defines the actions happening during the active mesh stage.
  126879. */
  126880. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126881. /**
  126882. * @hidden
  126883. * Defines the actions happening during the per camera render target step.
  126884. */
  126885. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126886. /**
  126887. * @hidden
  126888. * Defines the actions happening just before the active camera is drawing.
  126889. */
  126890. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126891. /**
  126892. * @hidden
  126893. * Defines the actions happening just before a render target is drawing.
  126894. */
  126895. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126896. /**
  126897. * @hidden
  126898. * Defines the actions happening just before a rendering group is drawing.
  126899. */
  126900. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126901. /**
  126902. * @hidden
  126903. * Defines the actions happening just before a mesh is drawing.
  126904. */
  126905. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126906. /**
  126907. * @hidden
  126908. * Defines the actions happening just after a mesh has been drawn.
  126909. */
  126910. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126911. /**
  126912. * @hidden
  126913. * Defines the actions happening just after a rendering group has been drawn.
  126914. */
  126915. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126916. /**
  126917. * @hidden
  126918. * Defines the actions happening just after the active camera has been drawn.
  126919. */
  126920. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126921. /**
  126922. * @hidden
  126923. * Defines the actions happening just after a render target has been drawn.
  126924. */
  126925. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126926. /**
  126927. * @hidden
  126928. * Defines the actions happening just after rendering all cameras and computing intersections.
  126929. */
  126930. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126931. /**
  126932. * @hidden
  126933. * Defines the actions happening when a pointer move event happens.
  126934. */
  126935. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126936. /**
  126937. * @hidden
  126938. * Defines the actions happening when a pointer down event happens.
  126939. */
  126940. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126941. /**
  126942. * @hidden
  126943. * Defines the actions happening when a pointer up event happens.
  126944. */
  126945. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  126946. /**
  126947. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  126948. */
  126949. _this.geometriesByUniqueId = null;
  126950. _this._defaultMeshCandidates = {
  126951. data: [],
  126952. length: 0
  126953. };
  126954. _this._defaultSubMeshCandidates = {
  126955. data: [],
  126956. length: 0
  126957. };
  126958. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  126959. _this._activeMeshesFrozen = false;
  126960. /** @hidden */
  126961. _this._allowPostProcessClearColor = true;
  126962. /**
  126963. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  126964. */
  126965. _this.getDeterministicFrameTime = function () {
  126966. return 1000.0 / 60.0; // frame time in ms
  126967. };
  126968. _this._tempPickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero() : null;
  126969. _this._blockMaterialDirtyMechanism = false;
  126970. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__["EngineStore"].LastCreatedEngine;
  126971. _this._engine.scenes.push(_this);
  126972. _this._uid = null;
  126973. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__["RenderingManager"](_this);
  126974. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]) {
  126975. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"](_this);
  126976. }
  126977. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__["DomManagement"].IsWindowObjectExist()) {
  126978. _this.attachControl();
  126979. }
  126980. //collision coordinator initialization. For now legacy per default.
  126981. _this.workerCollisions = false; //(!!Worker && (!!CollisionWorker || WorkerIncluded));
  126982. // Uniform Buffer
  126983. _this._createUbo();
  126984. // Default Image processing definition
  126985. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  126986. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  126987. }
  126988. _this.setDefaultCandidateProviders();
  126989. if (options && options.useGeometryUniqueIdsMap === true) {
  126990. _this.geometriesByUniqueId = {};
  126991. }
  126992. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  126993. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  126994. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  126995. return _this;
  126996. }
  126997. /**
  126998. * Factory used to create the default material.
  126999. * @param name The name of the material to create
  127000. * @param scene The scene to create the material for
  127001. * @returns The default material
  127002. */
  127003. Scene.DefaultMaterialFactory = function (scene) {
  127004. throw "Import StandardMaterial or Fill DefaultMaterialFactory static property on scene before relying on default material creation.";
  127005. };
  127006. Object.defineProperty(Scene.prototype, "environmentTexture", {
  127007. /**
  127008. * Texture used in all pbr material as the reflection texture.
  127009. * As in the majority of the scene they are the same (exception for multi room and so on),
  127010. * this is easier to reference from here than from all the materials.
  127011. */
  127012. get: function () {
  127013. return this._environmentTexture;
  127014. },
  127015. /**
  127016. * Texture used in all pbr material as the reflection texture.
  127017. * As in the majority of the scene they are the same (exception for multi room and so on),
  127018. * this is easier to set here than in all the materials.
  127019. */
  127020. set: function (value) {
  127021. if (this._environmentTexture === value) {
  127022. return;
  127023. }
  127024. this._environmentTexture = value;
  127025. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127026. },
  127027. enumerable: true,
  127028. configurable: true
  127029. });
  127030. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  127031. /**
  127032. * Default image processing configuration used either in the rendering
  127033. * Forward main pass or through the imageProcessingPostProcess if present.
  127034. * As in the majority of the scene they are the same (exception for multi camera),
  127035. * this is easier to reference from here than from all the materials and post process.
  127036. *
  127037. * No setter as we it is a shared configuration, you can set the values instead.
  127038. */
  127039. get: function () {
  127040. return this._imageProcessingConfiguration;
  127041. },
  127042. enumerable: true,
  127043. configurable: true
  127044. });
  127045. Object.defineProperty(Scene.prototype, "forceWireframe", {
  127046. get: function () {
  127047. return this._forceWireframe;
  127048. },
  127049. /**
  127050. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  127051. */
  127052. set: function (value) {
  127053. if (this._forceWireframe === value) {
  127054. return;
  127055. }
  127056. this._forceWireframe = value;
  127057. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127058. },
  127059. enumerable: true,
  127060. configurable: true
  127061. });
  127062. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  127063. get: function () {
  127064. return this._forcePointsCloud;
  127065. },
  127066. /**
  127067. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  127068. */
  127069. set: function (value) {
  127070. if (this._forcePointsCloud === value) {
  127071. return;
  127072. }
  127073. this._forcePointsCloud = value;
  127074. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127075. },
  127076. enumerable: true,
  127077. configurable: true
  127078. });
  127079. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  127080. /**
  127081. * Gets or sets the animation properties override
  127082. */
  127083. get: function () {
  127084. return this._animationPropertiesOverride;
  127085. },
  127086. set: function (value) {
  127087. this._animationPropertiesOverride = value;
  127088. },
  127089. enumerable: true,
  127090. configurable: true
  127091. });
  127092. Object.defineProperty(Scene.prototype, "onDispose", {
  127093. /** Sets a function to be executed when this scene is disposed. */
  127094. set: function (callback) {
  127095. if (this._onDisposeObserver) {
  127096. this.onDisposeObservable.remove(this._onDisposeObserver);
  127097. }
  127098. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127099. },
  127100. enumerable: true,
  127101. configurable: true
  127102. });
  127103. Object.defineProperty(Scene.prototype, "beforeRender", {
  127104. /** Sets a function to be executed before rendering this scene */
  127105. set: function (callback) {
  127106. if (this._onBeforeRenderObserver) {
  127107. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  127108. }
  127109. if (callback) {
  127110. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  127111. }
  127112. },
  127113. enumerable: true,
  127114. configurable: true
  127115. });
  127116. Object.defineProperty(Scene.prototype, "afterRender", {
  127117. /** Sets a function to be executed after rendering this scene */
  127118. set: function (callback) {
  127119. if (this._onAfterRenderObserver) {
  127120. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  127121. }
  127122. if (callback) {
  127123. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  127124. }
  127125. },
  127126. enumerable: true,
  127127. configurable: true
  127128. });
  127129. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  127130. /** Sets a function to be executed before rendering a camera*/
  127131. set: function (callback) {
  127132. if (this._onBeforeCameraRenderObserver) {
  127133. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  127134. }
  127135. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  127136. },
  127137. enumerable: true,
  127138. configurable: true
  127139. });
  127140. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  127141. /** Sets a function to be executed after rendering a camera*/
  127142. set: function (callback) {
  127143. if (this._onAfterCameraRenderObserver) {
  127144. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  127145. }
  127146. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  127147. },
  127148. enumerable: true,
  127149. configurable: true
  127150. });
  127151. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  127152. /**
  127153. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  127154. */
  127155. get: function () {
  127156. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  127157. },
  127158. enumerable: true,
  127159. configurable: true
  127160. });
  127161. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  127162. get: function () {
  127163. return this._useRightHandedSystem;
  127164. },
  127165. /**
  127166. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  127167. */
  127168. set: function (value) {
  127169. if (this._useRightHandedSystem === value) {
  127170. return;
  127171. }
  127172. this._useRightHandedSystem = value;
  127173. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127174. },
  127175. enumerable: true,
  127176. configurable: true
  127177. });
  127178. /**
  127179. * Sets the step Id used by deterministic lock step
  127180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127181. * @param newStepId defines the step Id
  127182. */
  127183. Scene.prototype.setStepId = function (newStepId) {
  127184. this._currentStepId = newStepId;
  127185. };
  127186. /**
  127187. * Gets the step Id used by deterministic lock step
  127188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127189. * @returns the step Id
  127190. */
  127191. Scene.prototype.getStepId = function () {
  127192. return this._currentStepId;
  127193. };
  127194. /**
  127195. * Gets the internal step used by deterministic lock step
  127196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127197. * @returns the internal step
  127198. */
  127199. Scene.prototype.getInternalStep = function () {
  127200. return this._currentInternalStep;
  127201. };
  127202. Object.defineProperty(Scene.prototype, "fogEnabled", {
  127203. get: function () {
  127204. return this._fogEnabled;
  127205. },
  127206. /**
  127207. * Gets or sets a boolean indicating if fog is enabled on this scene
  127208. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127209. * (Default is true)
  127210. */
  127211. set: function (value) {
  127212. if (this._fogEnabled === value) {
  127213. return;
  127214. }
  127215. this._fogEnabled = value;
  127216. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127217. },
  127218. enumerable: true,
  127219. configurable: true
  127220. });
  127221. Object.defineProperty(Scene.prototype, "fogMode", {
  127222. get: function () {
  127223. return this._fogMode;
  127224. },
  127225. /**
  127226. * Gets or sets the fog mode to use
  127227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127228. * | mode | value |
  127229. * | --- | --- |
  127230. * | FOGMODE_NONE | 0 |
  127231. * | FOGMODE_EXP | 1 |
  127232. * | FOGMODE_EXP2 | 2 |
  127233. * | FOGMODE_LINEAR | 3 |
  127234. */
  127235. set: function (value) {
  127236. if (this._fogMode === value) {
  127237. return;
  127238. }
  127239. this._fogMode = value;
  127240. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127241. },
  127242. enumerable: true,
  127243. configurable: true
  127244. });
  127245. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  127246. get: function () {
  127247. return this._shadowsEnabled;
  127248. },
  127249. /**
  127250. * Gets or sets a boolean indicating if shadows are enabled on this scene
  127251. */
  127252. set: function (value) {
  127253. if (this._shadowsEnabled === value) {
  127254. return;
  127255. }
  127256. this._shadowsEnabled = value;
  127257. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127258. },
  127259. enumerable: true,
  127260. configurable: true
  127261. });
  127262. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  127263. get: function () {
  127264. return this._lightsEnabled;
  127265. },
  127266. /**
  127267. * Gets or sets a boolean indicating if lights are enabled on this scene
  127268. */
  127269. set: function (value) {
  127270. if (this._lightsEnabled === value) {
  127271. return;
  127272. }
  127273. this._lightsEnabled = value;
  127274. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127275. },
  127276. enumerable: true,
  127277. configurable: true
  127278. });
  127279. Object.defineProperty(Scene.prototype, "activeCamera", {
  127280. /** Gets or sets the current active camera */
  127281. get: function () {
  127282. return this._activeCamera;
  127283. },
  127284. set: function (value) {
  127285. if (value === this._activeCamera) {
  127286. return;
  127287. }
  127288. this._activeCamera = value;
  127289. this.onActiveCameraChanged.notifyObservers(this);
  127290. },
  127291. enumerable: true,
  127292. configurable: true
  127293. });
  127294. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  127295. /** The default material used on meshes when no material is affected */
  127296. get: function () {
  127297. if (!this._defaultMaterial) {
  127298. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  127299. }
  127300. return this._defaultMaterial;
  127301. },
  127302. /** The default material used on meshes when no material is affected */
  127303. set: function (value) {
  127304. this._defaultMaterial = value;
  127305. },
  127306. enumerable: true,
  127307. configurable: true
  127308. });
  127309. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  127310. get: function () {
  127311. return this._texturesEnabled;
  127312. },
  127313. /**
  127314. * Gets or sets a boolean indicating if textures are enabled on this scene
  127315. */
  127316. set: function (value) {
  127317. if (this._texturesEnabled === value) {
  127318. return;
  127319. }
  127320. this._texturesEnabled = value;
  127321. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127322. },
  127323. enumerable: true,
  127324. configurable: true
  127325. });
  127326. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  127327. get: function () {
  127328. return this._skeletonsEnabled;
  127329. },
  127330. /**
  127331. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  127332. */
  127333. set: function (value) {
  127334. if (this._skeletonsEnabled === value) {
  127335. return;
  127336. }
  127337. this._skeletonsEnabled = value;
  127338. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AttributesDirtyFlag);
  127339. },
  127340. enumerable: true,
  127341. configurable: true
  127342. });
  127343. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  127344. /** @hidden */
  127345. get: function () {
  127346. return this._alternateRendering;
  127347. },
  127348. enumerable: true,
  127349. configurable: true
  127350. });
  127351. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  127352. /**
  127353. * Gets the list of frustum planes (built from the active camera)
  127354. */
  127355. get: function () {
  127356. return this._frustumPlanes;
  127357. },
  127358. enumerable: true,
  127359. configurable: true
  127360. });
  127361. /**
  127362. * Registers the transient components if needed.
  127363. */
  127364. Scene.prototype._registerTransientComponents = function () {
  127365. // Register components that have been associated lately to the scene.
  127366. if (this._transientComponents.length > 0) {
  127367. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  127368. var component = _a[_i];
  127369. component.register();
  127370. }
  127371. this._transientComponents = [];
  127372. }
  127373. };
  127374. /**
  127375. * @hidden
  127376. * Add a component to the scene.
  127377. * Note that the ccomponent could be registered on th next frame if this is called after
  127378. * the register component stage.
  127379. * @param component Defines the component to add to the scene
  127380. */
  127381. Scene.prototype._addComponent = function (component) {
  127382. this._components.push(component);
  127383. this._transientComponents.push(component);
  127384. var serializableComponent = component;
  127385. if (serializableComponent.addFromContainer) {
  127386. this._serializableComponents.push(serializableComponent);
  127387. }
  127388. };
  127389. /**
  127390. * @hidden
  127391. * Gets a component from the scene.
  127392. * @param name defines the name of the component to retrieve
  127393. * @returns the component or null if not present
  127394. */
  127395. Scene.prototype._getComponent = function (name) {
  127396. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  127397. var component = _a[_i];
  127398. if (component.name === name) {
  127399. return component;
  127400. }
  127401. }
  127402. return null;
  127403. };
  127404. /**
  127405. * @hidden
  127406. */
  127407. Scene.prototype._getDefaultMeshCandidates = function () {
  127408. this._defaultMeshCandidates.data = this.meshes;
  127409. this._defaultMeshCandidates.length = this.meshes.length;
  127410. return this._defaultMeshCandidates;
  127411. };
  127412. /**
  127413. * @hidden
  127414. */
  127415. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  127416. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  127417. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  127418. return this._defaultSubMeshCandidates;
  127419. };
  127420. /**
  127421. * Sets the default candidate providers for the scene.
  127422. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  127423. * and getCollidingSubMeshCandidates to their default function
  127424. */
  127425. Scene.prototype.setDefaultCandidateProviders = function () {
  127426. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  127427. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127428. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127429. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127430. };
  127431. Object.defineProperty(Scene.prototype, "workerCollisions", {
  127432. /**
  127433. * Gets a boolean indicating if collisions are processed on a web worker
  127434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  127435. */
  127436. get: function () {
  127437. // Worker has been deprecated.
  127438. // Keep for back compat.
  127439. return false;
  127440. },
  127441. set: function (enabled) {
  127442. if (!_Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]) {
  127443. return;
  127444. }
  127445. if (this.collisionCoordinator) {
  127446. this.collisionCoordinator.destroy();
  127447. }
  127448. this.collisionCoordinator = new _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]();
  127449. this.collisionCoordinator.init(this);
  127450. },
  127451. enumerable: true,
  127452. configurable: true
  127453. });
  127454. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  127455. /**
  127456. * Gets the mesh that is currently under the pointer
  127457. */
  127458. get: function () {
  127459. return this._pointerOverMesh;
  127460. },
  127461. enumerable: true,
  127462. configurable: true
  127463. });
  127464. Object.defineProperty(Scene.prototype, "pointerX", {
  127465. /**
  127466. * Gets or sets the current on-screen X position of the pointer
  127467. */
  127468. get: function () {
  127469. return this._pointerX;
  127470. },
  127471. set: function (value) {
  127472. this._pointerX = value;
  127473. },
  127474. enumerable: true,
  127475. configurable: true
  127476. });
  127477. Object.defineProperty(Scene.prototype, "pointerY", {
  127478. /**
  127479. * Gets or sets the current on-screen Y position of the pointer
  127480. */
  127481. get: function () {
  127482. return this._pointerY;
  127483. },
  127484. set: function (value) {
  127485. this._pointerY = value;
  127486. },
  127487. enumerable: true,
  127488. configurable: true
  127489. });
  127490. /**
  127491. * Gets the cached material (ie. the latest rendered one)
  127492. * @returns the cached material
  127493. */
  127494. Scene.prototype.getCachedMaterial = function () {
  127495. return this._cachedMaterial;
  127496. };
  127497. /**
  127498. * Gets the cached effect (ie. the latest rendered one)
  127499. * @returns the cached effect
  127500. */
  127501. Scene.prototype.getCachedEffect = function () {
  127502. return this._cachedEffect;
  127503. };
  127504. /**
  127505. * Gets the cached visibility state (ie. the latest rendered one)
  127506. * @returns the cached visibility state
  127507. */
  127508. Scene.prototype.getCachedVisibility = function () {
  127509. return this._cachedVisibility;
  127510. };
  127511. /**
  127512. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  127513. * @param material defines the current material
  127514. * @param effect defines the current effect
  127515. * @param visibility defines the current visibility state
  127516. * @returns true if one parameter is not cached
  127517. */
  127518. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  127519. if (visibility === void 0) { visibility = 1; }
  127520. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  127521. };
  127522. /**
  127523. * Gets the engine associated with the scene
  127524. * @returns an Engine
  127525. */
  127526. Scene.prototype.getEngine = function () {
  127527. return this._engine;
  127528. };
  127529. /**
  127530. * Gets the total number of vertices rendered per frame
  127531. * @returns the total number of vertices rendered per frame
  127532. */
  127533. Scene.prototype.getTotalVertices = function () {
  127534. return this._totalVertices.current;
  127535. };
  127536. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  127537. /**
  127538. * Gets the performance counter for total vertices
  127539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127540. */
  127541. get: function () {
  127542. return this._totalVertices;
  127543. },
  127544. enumerable: true,
  127545. configurable: true
  127546. });
  127547. /**
  127548. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  127549. * @returns the total number of active indices rendered per frame
  127550. */
  127551. Scene.prototype.getActiveIndices = function () {
  127552. return this._activeIndices.current;
  127553. };
  127554. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  127555. /**
  127556. * Gets the performance counter for active indices
  127557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127558. */
  127559. get: function () {
  127560. return this._activeIndices;
  127561. },
  127562. enumerable: true,
  127563. configurable: true
  127564. });
  127565. /**
  127566. * Gets the total number of active particles rendered per frame
  127567. * @returns the total number of active particles rendered per frame
  127568. */
  127569. Scene.prototype.getActiveParticles = function () {
  127570. return this._activeParticles.current;
  127571. };
  127572. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  127573. /**
  127574. * Gets the performance counter for active particles
  127575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127576. */
  127577. get: function () {
  127578. return this._activeParticles;
  127579. },
  127580. enumerable: true,
  127581. configurable: true
  127582. });
  127583. /**
  127584. * Gets the total number of active bones rendered per frame
  127585. * @returns the total number of active bones rendered per frame
  127586. */
  127587. Scene.prototype.getActiveBones = function () {
  127588. return this._activeBones.current;
  127589. };
  127590. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  127591. /**
  127592. * Gets the performance counter for active bones
  127593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127594. */
  127595. get: function () {
  127596. return this._activeBones;
  127597. },
  127598. enumerable: true,
  127599. configurable: true
  127600. });
  127601. /**
  127602. * Gets the array of active meshes
  127603. * @returns an array of AbstractMesh
  127604. */
  127605. Scene.prototype.getActiveMeshes = function () {
  127606. return this._activeMeshes;
  127607. };
  127608. /**
  127609. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  127610. * @returns a number
  127611. */
  127612. Scene.prototype.getAnimationRatio = function () {
  127613. return this._animationRatio !== undefined ? this._animationRatio : 1;
  127614. };
  127615. /**
  127616. * Gets an unique Id for the current render phase
  127617. * @returns a number
  127618. */
  127619. Scene.prototype.getRenderId = function () {
  127620. return this._renderId;
  127621. };
  127622. /**
  127623. * Gets an unique Id for the current frame
  127624. * @returns a number
  127625. */
  127626. Scene.prototype.getFrameId = function () {
  127627. return this._frameId;
  127628. };
  127629. /** Call this function if you want to manually increment the render Id*/
  127630. Scene.prototype.incrementRenderId = function () {
  127631. this._renderId++;
  127632. };
  127633. Scene.prototype._updatePointerPosition = function (evt) {
  127634. var canvasRect = this._engine.getRenderingCanvasClientRect();
  127635. if (!canvasRect) {
  127636. return;
  127637. }
  127638. this._pointerX = evt.clientX - canvasRect.left;
  127639. this._pointerY = evt.clientY - canvasRect.top;
  127640. this._unTranslatedPointerX = this._pointerX;
  127641. this._unTranslatedPointerY = this._pointerY;
  127642. };
  127643. Scene.prototype._createUbo = function () {
  127644. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127645. this._sceneUbo.addUniform("viewProjection", 16);
  127646. this._sceneUbo.addUniform("view", 16);
  127647. };
  127648. Scene.prototype._createAlternateUbo = function () {
  127649. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127650. this._alternateSceneUbo.addUniform("viewProjection", 16);
  127651. this._alternateSceneUbo.addUniform("view", 16);
  127652. };
  127653. // Pointers handling
  127654. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  127655. if (pointerInfo.pickInfo) {
  127656. if (!pointerInfo.pickInfo.ray) {
  127657. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  127658. }
  127659. }
  127660. };
  127661. /**
  127662. * Use this method to simulate a pointer move on a mesh
  127663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127666. * @returns the current scene
  127667. */
  127668. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  127669. var evt = new PointerEvent("pointermove", pointerEventInit);
  127670. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE)) {
  127671. return this;
  127672. }
  127673. return this._processPointerMove(pickResult, evt);
  127674. };
  127675. Scene.prototype._processPointerMove = function (pickResult, evt) {
  127676. var canvas = this._engine.getRenderingCanvas();
  127677. if (!canvas) {
  127678. return this;
  127679. }
  127680. // Restore pointer
  127681. canvas.style.cursor = this.defaultCursor;
  127682. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  127683. if (isMeshPicked) {
  127684. this.setPointerOverMesh(pickResult.pickedMesh);
  127685. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  127686. if (this._pointerOverMesh.actionManager.hoverCursor) {
  127687. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  127688. }
  127689. else {
  127690. canvas.style.cursor = this.hoverCursor;
  127691. }
  127692. }
  127693. }
  127694. else {
  127695. this.setPointerOverMesh(null);
  127696. }
  127697. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  127698. var step = _a[_i];
  127699. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  127700. }
  127701. if (pickResult) {
  127702. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE;
  127703. if (this.onPointerMove) {
  127704. this.onPointerMove(evt, pickResult, type);
  127705. }
  127706. if (this.onPointerObservable.hasObservers()) {
  127707. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127708. this._setRayOnPointerInfo(pi);
  127709. this.onPointerObservable.notifyObservers(pi, type);
  127710. }
  127711. }
  127712. return this;
  127713. };
  127714. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  127715. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  127716. if (pickResult) {
  127717. pi.ray = pickResult.ray;
  127718. }
  127719. this.onPrePointerObservable.notifyObservers(pi, type);
  127720. if (pi.skipOnPointerObservable) {
  127721. return true;
  127722. }
  127723. else {
  127724. return false;
  127725. }
  127726. };
  127727. /**
  127728. * Use this method to simulate a pointer down on a mesh
  127729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127732. * @returns the current scene
  127733. */
  127734. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  127735. var evt = new PointerEvent("pointerdown", pointerEventInit);
  127736. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  127737. return this;
  127738. }
  127739. return this._processPointerDown(pickResult, evt);
  127740. };
  127741. Scene.prototype._processPointerDown = function (pickResult, evt) {
  127742. var _this = this;
  127743. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  127744. this._pickedDownMesh = pickResult.pickedMesh;
  127745. var actionManager = pickResult.pickedMesh.actionManager;
  127746. if (actionManager) {
  127747. if (actionManager.hasPickTriggers) {
  127748. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127749. switch (evt.button) {
  127750. case 0:
  127751. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127752. break;
  127753. case 1:
  127754. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127755. break;
  127756. case 2:
  127757. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127758. break;
  127759. }
  127760. }
  127761. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger)) {
  127762. window.setTimeout(function () {
  127763. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  127764. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  127765. if (_this._totalPointersPressed !== 0 &&
  127766. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  127767. !_this._isPointerSwiping()) {
  127768. _this._startingPointerTime = 0;
  127769. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127770. }
  127771. }
  127772. }, Scene.LongPressDelay);
  127773. }
  127774. }
  127775. }
  127776. else {
  127777. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  127778. var step = _a[_i];
  127779. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  127780. }
  127781. }
  127782. if (pickResult) {
  127783. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN;
  127784. if (this.onPointerDown) {
  127785. this.onPointerDown(evt, pickResult, type);
  127786. }
  127787. if (this.onPointerObservable.hasObservers()) {
  127788. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127789. this._setRayOnPointerInfo(pi);
  127790. this.onPointerObservable.notifyObservers(pi, type);
  127791. }
  127792. }
  127793. return this;
  127794. };
  127795. /**
  127796. * Use this method to simulate a pointer up on a mesh
  127797. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127798. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127799. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127800. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  127801. * @returns the current scene
  127802. */
  127803. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  127804. var evt = new PointerEvent("pointerup", pointerEventInit);
  127805. var clickInfo = new ClickInfo();
  127806. if (doubleTap) {
  127807. clickInfo.doubleClick = true;
  127808. }
  127809. else {
  127810. clickInfo.singleClick = true;
  127811. }
  127812. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  127813. return this;
  127814. }
  127815. return this._processPointerUp(pickResult, evt, clickInfo);
  127816. };
  127817. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  127818. if (pickResult && pickResult && pickResult.pickedMesh) {
  127819. this._pickedUpMesh = pickResult.pickedMesh;
  127820. if (this._pickedDownMesh === this._pickedUpMesh) {
  127821. if (this.onPointerPick) {
  127822. this.onPointerPick(evt, pickResult);
  127823. }
  127824. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  127825. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK;
  127826. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type_1, evt, pickResult);
  127827. this._setRayOnPointerInfo(pi);
  127828. this.onPointerObservable.notifyObservers(pi, type_1);
  127829. }
  127830. }
  127831. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  127832. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127833. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  127834. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127835. }
  127836. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  127837. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127838. }
  127839. }
  127840. }
  127841. else {
  127842. if (!clickInfo.ignore) {
  127843. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  127844. var step = _a[_i];
  127845. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  127846. }
  127847. }
  127848. }
  127849. if (this._pickedDownMesh &&
  127850. this._pickedDownMesh.actionManager &&
  127851. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger) &&
  127852. this._pickedDownMesh !== this._pickedUpMesh) {
  127853. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  127854. }
  127855. var type = 0;
  127856. if (this.onPointerObservable.hasObservers()) {
  127857. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  127858. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  127859. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP;
  127860. }
  127861. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  127862. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP;
  127863. }
  127864. if (type) {
  127865. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127866. this._setRayOnPointerInfo(pi);
  127867. this.onPointerObservable.notifyObservers(pi, type);
  127868. }
  127869. }
  127870. if (!clickInfo.ignore) {
  127871. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP;
  127872. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127873. this._setRayOnPointerInfo(pi);
  127874. this.onPointerObservable.notifyObservers(pi, type);
  127875. }
  127876. }
  127877. if (this.onPointerUp && !clickInfo.ignore) {
  127878. this.onPointerUp(evt, pickResult, type);
  127879. }
  127880. return this;
  127881. };
  127882. /**
  127883. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  127884. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  127885. * @returns true if the pointer was captured
  127886. */
  127887. Scene.prototype.isPointerCaptured = function (pointerId) {
  127888. if (pointerId === void 0) { pointerId = 0; }
  127889. return this._pointerCaptures[pointerId];
  127890. };
  127891. /** @hidden */
  127892. Scene.prototype._isPointerSwiping = function () {
  127893. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  127894. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  127895. };
  127896. /**
  127897. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  127898. * @param attachUp defines if you want to attach events to pointerup
  127899. * @param attachDown defines if you want to attach events to pointerdown
  127900. * @param attachMove defines if you want to attach events to pointermove
  127901. */
  127902. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  127903. var _this = this;
  127904. if (attachUp === void 0) { attachUp = true; }
  127905. if (attachDown === void 0) { attachDown = true; }
  127906. if (attachMove === void 0) { attachMove = true; }
  127907. this._initActionManager = function (act, clickInfo) {
  127908. if (!_this._meshPickProceed) {
  127909. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  127910. _this._currentPickResult = pickResult;
  127911. if (pickResult) {
  127912. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  127913. }
  127914. _this._meshPickProceed = true;
  127915. }
  127916. return act;
  127917. };
  127918. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  127919. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  127920. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  127921. btn !== _this._previousButtonPressed) {
  127922. _this._doubleClickOccured = false;
  127923. clickInfo.singleClick = true;
  127924. clickInfo.ignore = false;
  127925. cb(clickInfo, _this._currentPickResult);
  127926. }
  127927. };
  127928. this._initClickEvent = function (obs1, obs2, evt, cb) {
  127929. var clickInfo = new ClickInfo();
  127930. _this._currentPickResult = null;
  127931. var act = null;
  127932. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK)
  127933. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)
  127934. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  127935. if (!checkPicking && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"]) {
  127936. act = _this._initActionManager(act, clickInfo);
  127937. if (act) {
  127938. checkPicking = act.hasPickTriggers;
  127939. }
  127940. }
  127941. var needToIgnoreNext = false;
  127942. if (checkPicking) {
  127943. var btn = evt.button;
  127944. clickInfo.hasSwiped = _this._isPointerSwiping();
  127945. if (!clickInfo.hasSwiped) {
  127946. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  127947. if (!checkSingleClickImmediately) {
  127948. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) &&
  127949. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  127950. if (checkSingleClickImmediately && !_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  127951. act = _this._initActionManager(act, clickInfo);
  127952. if (act) {
  127953. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  127954. }
  127955. }
  127956. }
  127957. if (checkSingleClickImmediately) {
  127958. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  127959. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  127960. btn !== _this._previousButtonPressed) {
  127961. clickInfo.singleClick = true;
  127962. cb(clickInfo, _this._currentPickResult);
  127963. needToIgnoreNext = true;
  127964. }
  127965. }
  127966. // at least one double click is required to be check and exclusive double click is enabled
  127967. else {
  127968. // wait that no double click has been raised during the double click delay
  127969. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  127970. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  127971. }
  127972. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) ||
  127973. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  127974. if (!checkDoubleClick && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  127975. act = _this._initActionManager(act, clickInfo);
  127976. if (act) {
  127977. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  127978. }
  127979. }
  127980. if (checkDoubleClick) {
  127981. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  127982. if (btn === _this._previousButtonPressed &&
  127983. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  127984. !_this._doubleClickOccured) {
  127985. // pointer has not moved for 2 clicks, it's a double click
  127986. if (!clickInfo.hasSwiped &&
  127987. !_this._isPointerSwiping()) {
  127988. _this._previousStartingPointerTime = 0;
  127989. _this._doubleClickOccured = true;
  127990. clickInfo.doubleClick = true;
  127991. clickInfo.ignore = false;
  127992. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  127993. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  127994. }
  127995. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  127996. cb(clickInfo, _this._currentPickResult);
  127997. }
  127998. // if the two successive clicks are too far, it's just two simple clicks
  127999. else {
  128000. _this._doubleClickOccured = false;
  128001. _this._previousStartingPointerTime = _this._startingPointerTime;
  128002. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128003. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128004. _this._previousButtonPressed = btn;
  128005. if (Scene.ExclusiveDoubleClickMode) {
  128006. if (_this._previousDelayedSimpleClickTimeout) {
  128007. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128008. }
  128009. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128010. cb(clickInfo, _this._previousPickResult);
  128011. }
  128012. else {
  128013. cb(clickInfo, _this._currentPickResult);
  128014. }
  128015. }
  128016. needToIgnoreNext = true;
  128017. }
  128018. // just the first click of the double has been raised
  128019. else {
  128020. _this._doubleClickOccured = false;
  128021. _this._previousStartingPointerTime = _this._startingPointerTime;
  128022. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128023. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128024. _this._previousButtonPressed = btn;
  128025. }
  128026. }
  128027. }
  128028. }
  128029. if (!needToIgnoreNext) {
  128030. cb(clickInfo, _this._currentPickResult);
  128031. }
  128032. };
  128033. this._onPointerMove = function (evt) {
  128034. _this._updatePointerPosition(evt);
  128035. // PreObservable support
  128036. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE)) {
  128037. return;
  128038. }
  128039. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128040. return;
  128041. }
  128042. if (!_this.pointerMovePredicate) {
  128043. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  128044. }
  128045. // Meshes
  128046. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  128047. _this._processPointerMove(pickResult, evt);
  128048. };
  128049. this._onPointerDown = function (evt) {
  128050. _this._totalPointersPressed++;
  128051. _this._pickedDownMesh = null;
  128052. _this._meshPickProceed = false;
  128053. _this._updatePointerPosition(evt);
  128054. if (_this.preventDefaultOnPointerDown && canvas) {
  128055. evt.preventDefault();
  128056. canvas.focus();
  128057. }
  128058. _this._startingPointerPosition.x = _this._pointerX;
  128059. _this._startingPointerPosition.y = _this._pointerY;
  128060. _this._startingPointerTime = Date.now();
  128061. // PreObservable support
  128062. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  128063. return;
  128064. }
  128065. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128066. return;
  128067. }
  128068. _this._pointerCaptures[evt.pointerId] = true;
  128069. if (!_this.pointerDownPredicate) {
  128070. _this.pointerDownPredicate = function (mesh) {
  128071. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128072. };
  128073. }
  128074. // Meshes
  128075. _this._pickedDownMesh = null;
  128076. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128077. _this._processPointerDown(pickResult, evt);
  128078. };
  128079. this._onPointerUp = function (evt) {
  128080. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  128081. return; // So we need to test it the pointer down was pressed before.
  128082. }
  128083. _this._totalPointersPressed--;
  128084. _this._pickedUpMesh = null;
  128085. _this._meshPickProceed = false;
  128086. _this._updatePointerPosition(evt);
  128087. if (_this.preventDefaultOnPointerUp && canvas) {
  128088. evt.preventDefault();
  128089. canvas.focus();
  128090. }
  128091. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  128092. _this._pointerCaptures[evt.pointerId] = false;
  128093. // PreObservable support
  128094. if (_this.onPrePointerObservable.hasObservers()) {
  128095. if (!clickInfo.ignore) {
  128096. if (!clickInfo.hasSwiped) {
  128097. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128098. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128099. return;
  128100. }
  128101. }
  128102. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128103. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128104. return;
  128105. }
  128106. }
  128107. }
  128108. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  128109. return;
  128110. }
  128111. }
  128112. }
  128113. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128114. return;
  128115. }
  128116. if (!_this.pointerUpPredicate) {
  128117. _this.pointerUpPredicate = function (mesh) {
  128118. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128119. };
  128120. }
  128121. // Meshes
  128122. if (!_this._meshPickProceed && (_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"] && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  128123. _this._initActionManager(null, clickInfo);
  128124. }
  128125. if (!pickResult) {
  128126. pickResult = _this._currentPickResult;
  128127. }
  128128. _this._processPointerUp(pickResult, evt, clickInfo);
  128129. _this._previousPickResult = _this._currentPickResult;
  128130. });
  128131. };
  128132. this._onKeyDown = function (evt) {
  128133. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYDOWN;
  128134. if (_this.onPreKeyboardObservable.hasObservers()) {
  128135. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128136. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128137. if (pi.skipOnPointerObservable) {
  128138. return;
  128139. }
  128140. }
  128141. if (_this.onKeyboardObservable.hasObservers()) {
  128142. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128143. _this.onKeyboardObservable.notifyObservers(pi, type);
  128144. }
  128145. if (_this.actionManager) {
  128146. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128147. }
  128148. };
  128149. this._onKeyUp = function (evt) {
  128150. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYUP;
  128151. if (_this.onPreKeyboardObservable.hasObservers()) {
  128152. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128153. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128154. if (pi.skipOnPointerObservable) {
  128155. return;
  128156. }
  128157. }
  128158. if (_this.onKeyboardObservable.hasObservers()) {
  128159. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128160. _this.onKeyboardObservable.notifyObservers(pi, type);
  128161. }
  128162. if (_this.actionManager) {
  128163. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128164. }
  128165. };
  128166. var engine = this.getEngine();
  128167. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  128168. if (!canvas) {
  128169. return;
  128170. }
  128171. canvas.addEventListener("keydown", _this._onKeyDown, false);
  128172. canvas.addEventListener("keyup", _this._onKeyUp, false);
  128173. });
  128174. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  128175. if (!canvas) {
  128176. return;
  128177. }
  128178. canvas.removeEventListener("keydown", _this._onKeyDown);
  128179. canvas.removeEventListener("keyup", _this._onKeyUp);
  128180. });
  128181. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128182. var canvas = this._engine.getRenderingCanvas();
  128183. if (!canvas) {
  128184. return;
  128185. }
  128186. if (attachMove) {
  128187. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  128188. // Wheel
  128189. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  128190. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  128191. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  128192. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  128193. }
  128194. if (attachDown) {
  128195. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  128196. }
  128197. if (attachUp) {
  128198. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  128199. }
  128200. canvas.tabIndex = 1;
  128201. };
  128202. /** Detaches all event handlers*/
  128203. Scene.prototype.detachControl = function () {
  128204. var engine = this.getEngine();
  128205. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128206. var canvas = engine.getRenderingCanvas();
  128207. if (!canvas) {
  128208. return;
  128209. }
  128210. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  128211. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  128212. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  128213. if (this._onCanvasBlurObserver) {
  128214. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  128215. }
  128216. if (this._onCanvasFocusObserver) {
  128217. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  128218. }
  128219. // Wheel
  128220. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  128221. // Keyboard
  128222. canvas.removeEventListener("keydown", this._onKeyDown);
  128223. canvas.removeEventListener("keyup", this._onKeyUp);
  128224. // Observables
  128225. this.onKeyboardObservable.clear();
  128226. this.onPreKeyboardObservable.clear();
  128227. this.onPointerObservable.clear();
  128228. this.onPrePointerObservable.clear();
  128229. };
  128230. /**
  128231. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  128232. * Delay loaded resources are not taking in account
  128233. * @return true if all required resources are ready
  128234. */
  128235. Scene.prototype.isReady = function () {
  128236. if (this._isDisposed) {
  128237. return false;
  128238. }
  128239. var index;
  128240. var engine = this.getEngine();
  128241. // Effects
  128242. if (!engine.areAllEffectsReady()) {
  128243. return false;
  128244. }
  128245. // Pending data
  128246. if (this._pendingData.length > 0) {
  128247. return false;
  128248. }
  128249. // Meshes
  128250. for (index = 0; index < this.meshes.length; index++) {
  128251. var mesh = this.meshes[index];
  128252. if (!mesh.isEnabled()) {
  128253. continue;
  128254. }
  128255. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  128256. continue;
  128257. }
  128258. if (!mesh.isReady(true)) {
  128259. return false;
  128260. }
  128261. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  128262. // Is Ready For Mesh
  128263. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  128264. var step = _a[_i];
  128265. if (!step.action(mesh, hardwareInstancedRendering)) {
  128266. return false;
  128267. }
  128268. }
  128269. }
  128270. // Geometries
  128271. for (index = 0; index < this.geometries.length; index++) {
  128272. var geometry = this.geometries[index];
  128273. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].DELAYLOADSTATE_LOADING) {
  128274. return false;
  128275. }
  128276. }
  128277. // Post-processes
  128278. if (this.activeCameras && this.activeCameras.length > 0) {
  128279. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  128280. var camera = _c[_b];
  128281. if (!camera.isReady(true)) {
  128282. return false;
  128283. }
  128284. }
  128285. }
  128286. else if (this.activeCamera) {
  128287. if (!this.activeCamera.isReady(true)) {
  128288. return false;
  128289. }
  128290. }
  128291. // Particles
  128292. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  128293. var particleSystem = _e[_d];
  128294. if (!particleSystem.isReady()) {
  128295. return false;
  128296. }
  128297. }
  128298. return true;
  128299. };
  128300. /** Resets all cached information relative to material (including effect and visibility) */
  128301. Scene.prototype.resetCachedMaterial = function () {
  128302. this._cachedMaterial = null;
  128303. this._cachedEffect = null;
  128304. this._cachedVisibility = null;
  128305. };
  128306. /**
  128307. * Registers a function to be called before every frame render
  128308. * @param func defines the function to register
  128309. */
  128310. Scene.prototype.registerBeforeRender = function (func) {
  128311. this.onBeforeRenderObservable.add(func);
  128312. };
  128313. /**
  128314. * Unregisters a function called before every frame render
  128315. * @param func defines the function to unregister
  128316. */
  128317. Scene.prototype.unregisterBeforeRender = function (func) {
  128318. this.onBeforeRenderObservable.removeCallback(func);
  128319. };
  128320. /**
  128321. * Registers a function to be called after every frame render
  128322. * @param func defines the function to register
  128323. */
  128324. Scene.prototype.registerAfterRender = function (func) {
  128325. this.onAfterRenderObservable.add(func);
  128326. };
  128327. /**
  128328. * Unregisters a function called after every frame render
  128329. * @param func defines the function to unregister
  128330. */
  128331. Scene.prototype.unregisterAfterRender = function (func) {
  128332. this.onAfterRenderObservable.removeCallback(func);
  128333. };
  128334. Scene.prototype._executeOnceBeforeRender = function (func) {
  128335. var _this = this;
  128336. var execFunc = function () {
  128337. func();
  128338. setTimeout(function () {
  128339. _this.unregisterBeforeRender(execFunc);
  128340. });
  128341. };
  128342. this.registerBeforeRender(execFunc);
  128343. };
  128344. /**
  128345. * The provided function will run before render once and will be disposed afterwards.
  128346. * A timeout delay can be provided so that the function will be executed in N ms.
  128347. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  128348. * @param func The function to be executed.
  128349. * @param timeout optional delay in ms
  128350. */
  128351. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  128352. var _this = this;
  128353. if (timeout !== undefined) {
  128354. setTimeout(function () {
  128355. _this._executeOnceBeforeRender(func);
  128356. }, timeout);
  128357. }
  128358. else {
  128359. this._executeOnceBeforeRender(func);
  128360. }
  128361. };
  128362. /** @hidden */
  128363. Scene.prototype._addPendingData = function (data) {
  128364. this._pendingData.push(data);
  128365. };
  128366. /** @hidden */
  128367. Scene.prototype._removePendingData = function (data) {
  128368. var wasLoading = this.isLoading;
  128369. var index = this._pendingData.indexOf(data);
  128370. if (index !== -1) {
  128371. this._pendingData.splice(index, 1);
  128372. }
  128373. if (wasLoading && !this.isLoading) {
  128374. this.onDataLoadedObservable.notifyObservers(this);
  128375. }
  128376. };
  128377. /**
  128378. * Returns the number of items waiting to be loaded
  128379. * @returns the number of items waiting to be loaded
  128380. */
  128381. Scene.prototype.getWaitingItemsCount = function () {
  128382. return this._pendingData.length;
  128383. };
  128384. Object.defineProperty(Scene.prototype, "isLoading", {
  128385. /**
  128386. * Returns a boolean indicating if the scene is still loading data
  128387. */
  128388. get: function () {
  128389. return this._pendingData.length > 0;
  128390. },
  128391. enumerable: true,
  128392. configurable: true
  128393. });
  128394. /**
  128395. * Registers a function to be executed when the scene is ready
  128396. * @param {Function} func - the function to be executed
  128397. */
  128398. Scene.prototype.executeWhenReady = function (func) {
  128399. var _this = this;
  128400. this.onReadyObservable.add(func);
  128401. if (this._executeWhenReadyTimeoutId !== -1) {
  128402. return;
  128403. }
  128404. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128405. _this._checkIsReady();
  128406. }, 150);
  128407. };
  128408. /**
  128409. * Returns a promise that resolves when the scene is ready
  128410. * @returns A promise that resolves when the scene is ready
  128411. */
  128412. Scene.prototype.whenReadyAsync = function () {
  128413. var _this = this;
  128414. return new Promise(function (resolve) {
  128415. _this.executeWhenReady(function () {
  128416. resolve();
  128417. });
  128418. });
  128419. };
  128420. /** @hidden */
  128421. Scene.prototype._checkIsReady = function () {
  128422. var _this = this;
  128423. this._registerTransientComponents();
  128424. if (this.isReady()) {
  128425. this.onReadyObservable.notifyObservers(this);
  128426. this.onReadyObservable.clear();
  128427. this._executeWhenReadyTimeoutId = -1;
  128428. return;
  128429. }
  128430. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128431. _this._checkIsReady();
  128432. }, 150);
  128433. };
  128434. // Animations
  128435. /**
  128436. * Will start the animation sequence of a given target
  128437. * @param target defines the target
  128438. * @param from defines from which frame should animation start
  128439. * @param to defines until which frame should animation run.
  128440. * @param weight defines the weight to apply to the animation (1.0 by default)
  128441. * @param loop defines if the animation loops
  128442. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128443. * @param onAnimationEnd defines the function to be executed when the animation ends
  128444. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128445. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128446. * @param onAnimationLoop defines the callback to call when an animation loops
  128447. * @returns the animatable object created for this animation
  128448. */
  128449. Scene.prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  128450. if (weight === void 0) { weight = 1.0; }
  128451. if (speedRatio === void 0) { speedRatio = 1.0; }
  128452. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  128453. returnedAnimatable.weight = weight;
  128454. return returnedAnimatable;
  128455. };
  128456. /**
  128457. * Will start the animation sequence of a given target
  128458. * @param target defines the target
  128459. * @param from defines from which frame should animation start
  128460. * @param to defines until which frame should animation run.
  128461. * @param loop defines if the animation loops
  128462. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128463. * @param onAnimationEnd defines the function to be executed when the animation ends
  128464. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128465. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128466. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  128467. * @param onAnimationLoop defines the callback to call when an animation loops
  128468. * @returns the animatable object created for this animation
  128469. */
  128470. Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128471. if (speedRatio === void 0) { speedRatio = 1.0; }
  128472. if (stopCurrent === void 0) { stopCurrent = true; }
  128473. if (from > to && speedRatio > 0) {
  128474. speedRatio *= -1;
  128475. }
  128476. if (stopCurrent) {
  128477. this.stopAnimation(target, undefined, targetMask);
  128478. }
  128479. if (!animatable) {
  128480. animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  128481. }
  128482. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  128483. // Local animations
  128484. if (target.animations && shouldRunTargetAnimations) {
  128485. animatable.appendAnimations(target, target.animations);
  128486. }
  128487. // Children animations
  128488. if (target.getAnimatables) {
  128489. var animatables = target.getAnimatables();
  128490. for (var index = 0; index < animatables.length; index++) {
  128491. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  128492. }
  128493. }
  128494. animatable.reset();
  128495. return animatable;
  128496. };
  128497. /**
  128498. * Will start the animation sequence of a given target and its hierarchy
  128499. * @param target defines the target
  128500. * @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.
  128501. * @param from defines from which frame should animation start
  128502. * @param to defines until which frame should animation run.
  128503. * @param loop defines if the animation loops
  128504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128505. * @param onAnimationEnd defines the function to be executed when the animation ends
  128506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128509. * @param onAnimationLoop defines the callback to call when an animation loops
  128510. * @returns the list of created animatables
  128511. */
  128512. Scene.prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128513. if (speedRatio === void 0) { speedRatio = 1.0; }
  128514. if (stopCurrent === void 0) { stopCurrent = true; }
  128515. var children = target.getDescendants(directDescendantsOnly);
  128516. var result = [];
  128517. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128518. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  128519. var child = children_1[_i];
  128520. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128521. }
  128522. return result;
  128523. };
  128524. /**
  128525. * Begin a new animation on a given node
  128526. * @param target defines the target where the animation will take place
  128527. * @param animations defines the list of animations to start
  128528. * @param from defines the initial value
  128529. * @param to defines the final value
  128530. * @param loop defines if you want animation to loop (off by default)
  128531. * @param speedRatio defines the speed ratio to apply to all animations
  128532. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128533. * @param onAnimationLoop defines the callback to call when an animation loops
  128534. * @returns the list of created animatables
  128535. */
  128536. Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128537. if (speedRatio === undefined) {
  128538. speedRatio = 1.0;
  128539. }
  128540. var animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  128541. return animatable;
  128542. };
  128543. /**
  128544. * Begin a new animation on a given node and its hierarchy
  128545. * @param target defines the root node where the animation will take place
  128546. * @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.
  128547. * @param animations defines the list of animations to start
  128548. * @param from defines the initial value
  128549. * @param to defines the final value
  128550. * @param loop defines if you want animation to loop (off by default)
  128551. * @param speedRatio defines the speed ratio to apply to all animations
  128552. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128553. * @param onAnimationLoop defines the callback to call when an animation loops
  128554. * @returns the list of animatables created for all nodes
  128555. */
  128556. Scene.prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128557. var children = target.getDescendants(directDescendantsOnly);
  128558. var result = [];
  128559. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128560. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  128561. var child = children_2[_i];
  128562. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128563. }
  128564. return result;
  128565. };
  128566. /**
  128567. * Gets the animatable associated with a specific target
  128568. * @param target defines the target of the animatable
  128569. * @returns the required animatable if found
  128570. */
  128571. Scene.prototype.getAnimatableByTarget = function (target) {
  128572. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128573. if (this._activeAnimatables[index].target === target) {
  128574. return this._activeAnimatables[index];
  128575. }
  128576. }
  128577. return null;
  128578. };
  128579. /**
  128580. * Gets all animatables associated with a given target
  128581. * @param target defines the target to look animatables for
  128582. * @returns an array of Animatables
  128583. */
  128584. Scene.prototype.getAllAnimatablesByTarget = function (target) {
  128585. var result = [];
  128586. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128587. if (this._activeAnimatables[index].target === target) {
  128588. result.push(this._activeAnimatables[index]);
  128589. }
  128590. }
  128591. return result;
  128592. };
  128593. Object.defineProperty(Scene.prototype, "animatables", {
  128594. /**
  128595. * Gets all animatable attached to the scene
  128596. */
  128597. get: function () {
  128598. return this._activeAnimatables;
  128599. },
  128600. enumerable: true,
  128601. configurable: true
  128602. });
  128603. /**
  128604. * Will stop the animation of the given target
  128605. * @param target - the target
  128606. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  128607. * @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)
  128608. */
  128609. Scene.prototype.stopAnimation = function (target, animationName, targetMask) {
  128610. var animatables = this.getAllAnimatablesByTarget(target);
  128611. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  128612. var animatable = animatables_1[_i];
  128613. animatable.stop(animationName, targetMask);
  128614. }
  128615. };
  128616. /**
  128617. * Stops and removes all animations that have been applied to the scene
  128618. */
  128619. Scene.prototype.stopAllAnimations = function () {
  128620. if (this._activeAnimatables) {
  128621. for (var i = 0; i < this._activeAnimatables.length; i++) {
  128622. this._activeAnimatables[i].stop();
  128623. }
  128624. this._activeAnimatables = [];
  128625. }
  128626. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  128627. var group = _a[_i];
  128628. group.stop();
  128629. }
  128630. };
  128631. /**
  128632. * Resets the last animation time frame.
  128633. * Useful to override when animations start running when loading a scene for the first time.
  128634. */
  128635. Scene.prototype.resetLastAnimationTimeFrame = function () {
  128636. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128637. };
  128638. Scene.prototype._animate = function () {
  128639. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  128640. return;
  128641. }
  128642. // Getting time
  128643. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128644. if (!this._animationTimeLast) {
  128645. if (this._pendingData.length > 0) {
  128646. return;
  128647. }
  128648. this._animationTimeLast = now;
  128649. }
  128650. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  128651. this._animationTime += deltaTime;
  128652. this._animationTimeLast = now;
  128653. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128654. this._activeAnimatables[index]._animate(this._animationTime);
  128655. }
  128656. // Late animation bindings
  128657. this._processLateAnimationBindings();
  128658. };
  128659. /** @hidden */
  128660. Scene.prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  128661. var target = runtimeAnimation.target;
  128662. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  128663. if (!target._lateAnimationHolders) {
  128664. target._lateAnimationHolders = {};
  128665. }
  128666. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  128667. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  128668. totalWeight: 0,
  128669. animations: [],
  128670. originalValue: originalValue
  128671. };
  128672. }
  128673. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  128674. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  128675. };
  128676. Scene.prototype._processLateAnimationBindingsForMatrices = function (holder) {
  128677. var normalizer = 1.0;
  128678. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[0];
  128679. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[1];
  128680. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[0];
  128681. var startIndex = 0;
  128682. var originalAnimation = holder.animations[0];
  128683. var originalValue = holder.originalValue;
  128684. var scale = 1;
  128685. if (holder.totalWeight < 1.0) {
  128686. // We need to mix the original value in
  128687. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  128688. scale = 1.0 - holder.totalWeight;
  128689. }
  128690. else {
  128691. startIndex = 1;
  128692. // We need to normalize the weights
  128693. normalizer = holder.totalWeight;
  128694. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  128695. scale = originalAnimation.weight / normalizer;
  128696. if (scale == 1) {
  128697. return originalAnimation.currentValue;
  128698. }
  128699. }
  128700. finalScaling.scaleInPlace(scale);
  128701. finalPosition.scaleInPlace(scale);
  128702. finalQuaternion.scaleInPlace(scale);
  128703. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  128704. var runtimeAnimation = holder.animations[animIndex];
  128705. var scale = runtimeAnimation.weight / normalizer;
  128706. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[2];
  128707. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[3];
  128708. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[1];
  128709. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  128710. currentScaling.scaleAndAddToRef(scale, finalScaling);
  128711. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  128712. currentPosition.scaleAndAddToRef(scale, finalPosition);
  128713. }
  128714. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  128715. return originalAnimation._workValue;
  128716. };
  128717. Scene.prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  128718. var originalAnimation = holder.animations[0];
  128719. var originalValue = holder.originalValue;
  128720. if (holder.animations.length === 1) {
  128721. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  128722. return refQuaternion;
  128723. }
  128724. var normalizer = 1.0;
  128725. var quaternions;
  128726. var weights;
  128727. if (holder.totalWeight < 1.0) {
  128728. var scale = 1.0 - holder.totalWeight;
  128729. quaternions = [];
  128730. weights = [];
  128731. quaternions.push(originalValue);
  128732. weights.push(scale);
  128733. }
  128734. else {
  128735. if (holder.animations.length === 2) { // Slerp as soon as we can
  128736. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  128737. return refQuaternion;
  128738. }
  128739. quaternions = [];
  128740. weights = [];
  128741. normalizer = holder.totalWeight;
  128742. }
  128743. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  128744. var runtimeAnimation = holder.animations[animIndex];
  128745. quaternions.push(runtimeAnimation.currentValue);
  128746. weights.push(runtimeAnimation.weight / normalizer);
  128747. }
  128748. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  128749. var cumulativeAmount = 0;
  128750. var cumulativeQuaternion = null;
  128751. for (var index = 0; index < quaternions.length;) {
  128752. if (!cumulativeQuaternion) {
  128753. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  128754. cumulativeQuaternion = refQuaternion;
  128755. cumulativeAmount = weights[index] + weights[index + 1];
  128756. index += 2;
  128757. continue;
  128758. }
  128759. cumulativeAmount += weights[index];
  128760. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  128761. index++;
  128762. }
  128763. return cumulativeQuaternion;
  128764. };
  128765. Scene.prototype._processLateAnimationBindings = function () {
  128766. if (!this._registeredForLateAnimationBindings.length) {
  128767. return;
  128768. }
  128769. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  128770. var target = this._registeredForLateAnimationBindings.data[index];
  128771. for (var path in target._lateAnimationHolders) {
  128772. var holder = target._lateAnimationHolders[path];
  128773. var originalAnimation = holder.animations[0];
  128774. var originalValue = holder.originalValue;
  128775. var matrixDecomposeMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_13__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  128776. var finalValue = target[path];
  128777. if (matrixDecomposeMode) {
  128778. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  128779. }
  128780. else {
  128781. var quaternionMode = originalValue.w !== undefined;
  128782. if (quaternionMode) {
  128783. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].Identity());
  128784. }
  128785. else {
  128786. var startIndex = 0;
  128787. var normalizer = 1.0;
  128788. if (holder.totalWeight < 1.0) {
  128789. // We need to mix the original value in
  128790. if (originalValue.scale) {
  128791. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  128792. }
  128793. else {
  128794. finalValue = originalValue * (1.0 - holder.totalWeight);
  128795. }
  128796. }
  128797. else {
  128798. // We need to normalize the weights
  128799. normalizer = holder.totalWeight;
  128800. var scale_1 = originalAnimation.weight / normalizer;
  128801. if (scale_1 !== 1) {
  128802. if (originalAnimation.currentValue.scale) {
  128803. finalValue = originalAnimation.currentValue.scale(scale_1);
  128804. }
  128805. else {
  128806. finalValue = originalAnimation.currentValue * scale_1;
  128807. }
  128808. }
  128809. else {
  128810. finalValue = originalAnimation.currentValue;
  128811. }
  128812. startIndex = 1;
  128813. }
  128814. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  128815. var runtimeAnimation = holder.animations[animIndex];
  128816. var scale = runtimeAnimation.weight / normalizer;
  128817. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  128818. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  128819. }
  128820. else {
  128821. finalValue += runtimeAnimation.currentValue * scale;
  128822. }
  128823. }
  128824. }
  128825. }
  128826. target[path] = finalValue;
  128827. }
  128828. target._lateAnimationHolders = {};
  128829. }
  128830. this._registeredForLateAnimationBindings.reset();
  128831. };
  128832. // Matrix
  128833. /** @hidden */
  128834. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  128835. this._useAlternateCameraConfiguration = active;
  128836. };
  128837. /**
  128838. * Gets the current view matrix
  128839. * @returns a Matrix
  128840. */
  128841. Scene.prototype.getViewMatrix = function () {
  128842. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  128843. };
  128844. /**
  128845. * Gets the current projection matrix
  128846. * @returns a Matrix
  128847. */
  128848. Scene.prototype.getProjectionMatrix = function () {
  128849. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  128850. };
  128851. /**
  128852. * Gets the current transform matrix
  128853. * @returns a Matrix made of View * Projection
  128854. */
  128855. Scene.prototype.getTransformMatrix = function () {
  128856. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  128857. };
  128858. /**
  128859. * Sets the current transform matrix
  128860. * @param view defines the View matrix to use
  128861. * @param projection defines the Projection matrix to use
  128862. */
  128863. Scene.prototype.setTransformMatrix = function (view, projection) {
  128864. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  128865. return;
  128866. }
  128867. this._viewUpdateFlag = view.updateFlag;
  128868. this._projectionUpdateFlag = projection.updateFlag;
  128869. this._viewMatrix = view;
  128870. this._projectionMatrix = projection;
  128871. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  128872. // Update frustum
  128873. if (!this._frustumPlanes) {
  128874. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  128875. }
  128876. else {
  128877. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  128878. }
  128879. if (this.activeCamera && this.activeCamera._alternateCamera) {
  128880. var otherCamera = this.activeCamera._alternateCamera;
  128881. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  128882. _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
  128883. }
  128884. if (this._sceneUbo.useUbo) {
  128885. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  128886. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  128887. this._sceneUbo.update();
  128888. }
  128889. };
  128890. /** @hidden */
  128891. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  128892. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  128893. return;
  128894. }
  128895. this._alternateViewUpdateFlag = view.updateFlag;
  128896. this._alternateProjectionUpdateFlag = projection.updateFlag;
  128897. this._alternateViewMatrix = view;
  128898. this._alternateProjectionMatrix = projection;
  128899. if (!this._alternateTransformMatrix) {
  128900. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128901. }
  128902. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  128903. if (!this._alternateSceneUbo) {
  128904. this._createAlternateUbo();
  128905. }
  128906. if (this._alternateSceneUbo.useUbo) {
  128907. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  128908. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  128909. this._alternateSceneUbo.update();
  128910. }
  128911. };
  128912. /**
  128913. * Gets the uniform buffer used to store scene data
  128914. * @returns a UniformBuffer
  128915. */
  128916. Scene.prototype.getSceneUniformBuffer = function () {
  128917. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  128918. };
  128919. /**
  128920. * Gets an unique (relatively to the current scene) Id
  128921. * @returns an unique number for the scene
  128922. */
  128923. Scene.prototype.getUniqueId = function () {
  128924. var result = Scene._uniqueIdCounter;
  128925. Scene._uniqueIdCounter++;
  128926. return result;
  128927. };
  128928. /**
  128929. * Add a mesh to the list of scene's meshes
  128930. * @param newMesh defines the mesh to add
  128931. * @param recursive if all child meshes should also be added to the scene
  128932. */
  128933. Scene.prototype.addMesh = function (newMesh, recursive) {
  128934. var _this = this;
  128935. if (recursive === void 0) { recursive = false; }
  128936. this.meshes.push(newMesh);
  128937. //notify the collision coordinator
  128938. if (this.collisionCoordinator) {
  128939. this.collisionCoordinator.onMeshAdded(newMesh);
  128940. }
  128941. newMesh._resyncLightSources();
  128942. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  128943. if (recursive) {
  128944. newMesh.getChildMeshes().forEach(function (m) {
  128945. _this.addMesh(m);
  128946. });
  128947. }
  128948. };
  128949. /**
  128950. * Remove a mesh for the list of scene's meshes
  128951. * @param toRemove defines the mesh to remove
  128952. * @param recursive if all child meshes should also be removed from the scene
  128953. * @returns the index where the mesh was in the mesh list
  128954. */
  128955. Scene.prototype.removeMesh = function (toRemove, recursive) {
  128956. var _this = this;
  128957. if (recursive === void 0) { recursive = false; }
  128958. var index = this.meshes.indexOf(toRemove);
  128959. if (index !== -1) {
  128960. // Remove from the scene if mesh found
  128961. this.meshes[index] = this.meshes[this.meshes.length - 1];
  128962. this.meshes.pop();
  128963. }
  128964. this.onMeshRemovedObservable.notifyObservers(toRemove);
  128965. if (recursive) {
  128966. toRemove.getChildMeshes().forEach(function (m) {
  128967. _this.removeMesh(m);
  128968. });
  128969. }
  128970. return index;
  128971. };
  128972. /**
  128973. * Add a transform node to the list of scene's transform nodes
  128974. * @param newTransformNode defines the transform node to add
  128975. */
  128976. Scene.prototype.addTransformNode = function (newTransformNode) {
  128977. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  128978. this.transformNodes.push(newTransformNode);
  128979. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  128980. };
  128981. /**
  128982. * Remove a transform node for the list of scene's transform nodes
  128983. * @param toRemove defines the transform node to remove
  128984. * @returns the index where the transform node was in the transform node list
  128985. */
  128986. Scene.prototype.removeTransformNode = function (toRemove) {
  128987. var index = toRemove._indexInSceneTransformNodesArray;
  128988. if (index !== -1) {
  128989. if (index !== this.transformNodes.length - 1) {
  128990. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  128991. this.transformNodes[index] = lastNode;
  128992. lastNode._indexInSceneTransformNodesArray = index;
  128993. }
  128994. toRemove._indexInSceneTransformNodesArray = -1;
  128995. this.transformNodes.pop();
  128996. }
  128997. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  128998. return index;
  128999. };
  129000. /**
  129001. * Remove a skeleton for the list of scene's skeletons
  129002. * @param toRemove defines the skeleton to remove
  129003. * @returns the index where the skeleton was in the skeleton list
  129004. */
  129005. Scene.prototype.removeSkeleton = function (toRemove) {
  129006. var index = this.skeletons.indexOf(toRemove);
  129007. if (index !== -1) {
  129008. // Remove from the scene if found
  129009. this.skeletons.splice(index, 1);
  129010. }
  129011. return index;
  129012. };
  129013. /**
  129014. * Remove a morph target for the list of scene's morph targets
  129015. * @param toRemove defines the morph target to remove
  129016. * @returns the index where the morph target was in the morph target list
  129017. */
  129018. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129019. var index = this.morphTargetManagers.indexOf(toRemove);
  129020. if (index !== -1) {
  129021. // Remove from the scene if found
  129022. this.morphTargetManagers.splice(index, 1);
  129023. }
  129024. return index;
  129025. };
  129026. /**
  129027. * Remove a light for the list of scene's lights
  129028. * @param toRemove defines the light to remove
  129029. * @returns the index where the light was in the light list
  129030. */
  129031. Scene.prototype.removeLight = function (toRemove) {
  129032. var index = this.lights.indexOf(toRemove);
  129033. if (index !== -1) {
  129034. // Remove from meshes
  129035. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129036. var mesh = _a[_i];
  129037. mesh._removeLightSource(toRemove);
  129038. }
  129039. // Remove from the scene if mesh found
  129040. this.lights.splice(index, 1);
  129041. this.sortLightsByPriority();
  129042. }
  129043. this.onLightRemovedObservable.notifyObservers(toRemove);
  129044. return index;
  129045. };
  129046. /**
  129047. * Remove a camera for the list of scene's cameras
  129048. * @param toRemove defines the camera to remove
  129049. * @returns the index where the camera was in the camera list
  129050. */
  129051. Scene.prototype.removeCamera = function (toRemove) {
  129052. var index = this.cameras.indexOf(toRemove);
  129053. if (index !== -1) {
  129054. // Remove from the scene if mesh found
  129055. this.cameras.splice(index, 1);
  129056. }
  129057. // Remove from activeCameras
  129058. var index2 = this.activeCameras.indexOf(toRemove);
  129059. if (index2 !== -1) {
  129060. // Remove from the scene if mesh found
  129061. this.activeCameras.splice(index2, 1);
  129062. }
  129063. // Reset the activeCamera
  129064. if (this.activeCamera === toRemove) {
  129065. if (this.cameras.length > 0) {
  129066. this.activeCamera = this.cameras[0];
  129067. }
  129068. else {
  129069. this.activeCamera = null;
  129070. }
  129071. }
  129072. this.onCameraRemovedObservable.notifyObservers(toRemove);
  129073. return index;
  129074. };
  129075. /**
  129076. * Remove a particle system for the list of scene's particle systems
  129077. * @param toRemove defines the particle system to remove
  129078. * @returns the index where the particle system was in the particle system list
  129079. */
  129080. Scene.prototype.removeParticleSystem = function (toRemove) {
  129081. var index = this.particleSystems.indexOf(toRemove);
  129082. if (index !== -1) {
  129083. this.particleSystems.splice(index, 1);
  129084. }
  129085. return index;
  129086. };
  129087. /**
  129088. * Remove a animation for the list of scene's animations
  129089. * @param toRemove defines the animation to remove
  129090. * @returns the index where the animation was in the animation list
  129091. */
  129092. Scene.prototype.removeAnimation = function (toRemove) {
  129093. var index = this.animations.indexOf(toRemove);
  129094. if (index !== -1) {
  129095. this.animations.splice(index, 1);
  129096. }
  129097. return index;
  129098. };
  129099. /**
  129100. * Removes the given animation group from this scene.
  129101. * @param toRemove The animation group to remove
  129102. * @returns The index of the removed animation group
  129103. */
  129104. Scene.prototype.removeAnimationGroup = function (toRemove) {
  129105. var index = this.animationGroups.indexOf(toRemove);
  129106. if (index !== -1) {
  129107. this.animationGroups.splice(index, 1);
  129108. }
  129109. return index;
  129110. };
  129111. /**
  129112. * Removes the given multi-material from this scene.
  129113. * @param toRemove The multi-material to remove
  129114. * @returns The index of the removed multi-material
  129115. */
  129116. Scene.prototype.removeMultiMaterial = function (toRemove) {
  129117. var index = this.multiMaterials.indexOf(toRemove);
  129118. if (index !== -1) {
  129119. this.multiMaterials.splice(index, 1);
  129120. }
  129121. return index;
  129122. };
  129123. /**
  129124. * Removes the given material from this scene.
  129125. * @param toRemove The material to remove
  129126. * @returns The index of the removed material
  129127. */
  129128. Scene.prototype.removeMaterial = function (toRemove) {
  129129. var index = toRemove._indexInSceneMaterialArray;
  129130. if (index !== -1 && index < this.materials.length) {
  129131. if (index !== this.materials.length - 1) {
  129132. var lastMaterial = this.materials[this.materials.length - 1];
  129133. this.materials[index] = lastMaterial;
  129134. lastMaterial._indexInSceneMaterialArray = index;
  129135. }
  129136. toRemove._indexInSceneMaterialArray = -1;
  129137. this.materials.pop();
  129138. }
  129139. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  129140. return index;
  129141. };
  129142. /**
  129143. * Removes the given action manager from this scene.
  129144. * @param toRemove The action manager to remove
  129145. * @returns The index of the removed action manager
  129146. */
  129147. Scene.prototype.removeActionManager = function (toRemove) {
  129148. var index = this.actionManagers.indexOf(toRemove);
  129149. if (index !== -1) {
  129150. this.actionManagers.splice(index, 1);
  129151. }
  129152. return index;
  129153. };
  129154. /**
  129155. * Removes the given texture from this scene.
  129156. * @param toRemove The texture to remove
  129157. * @returns The index of the removed texture
  129158. */
  129159. Scene.prototype.removeTexture = function (toRemove) {
  129160. var index = this.textures.indexOf(toRemove);
  129161. if (index !== -1) {
  129162. this.textures.splice(index, 1);
  129163. }
  129164. this.onTextureRemovedObservable.notifyObservers(toRemove);
  129165. return index;
  129166. };
  129167. /**
  129168. * Adds the given light to this scene
  129169. * @param newLight The light to add
  129170. */
  129171. Scene.prototype.addLight = function (newLight) {
  129172. this.lights.push(newLight);
  129173. this.sortLightsByPriority();
  129174. // Add light to all meshes (To support if the light is removed and then readded)
  129175. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129176. var mesh = _a[_i];
  129177. if (mesh._lightSources.indexOf(newLight) === -1) {
  129178. mesh._lightSources.push(newLight);
  129179. mesh._resyncLightSources();
  129180. }
  129181. }
  129182. this.onNewLightAddedObservable.notifyObservers(newLight);
  129183. };
  129184. /**
  129185. * Sorts the list list based on light priorities
  129186. */
  129187. Scene.prototype.sortLightsByPriority = function () {
  129188. if (this.requireLightSorting) {
  129189. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_15__["Light"].CompareLightsPriority);
  129190. }
  129191. };
  129192. /**
  129193. * Adds the given camera to this scene
  129194. * @param newCamera The camera to add
  129195. */
  129196. Scene.prototype.addCamera = function (newCamera) {
  129197. this.cameras.push(newCamera);
  129198. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  129199. };
  129200. /**
  129201. * Adds the given skeleton to this scene
  129202. * @param newSkeleton The skeleton to add
  129203. */
  129204. Scene.prototype.addSkeleton = function (newSkeleton) {
  129205. this.skeletons.push(newSkeleton);
  129206. };
  129207. /**
  129208. * Adds the given particle system to this scene
  129209. * @param newParticleSystem The particle system to add
  129210. */
  129211. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  129212. this.particleSystems.push(newParticleSystem);
  129213. };
  129214. /**
  129215. * Adds the given animation to this scene
  129216. * @param newAnimation The animation to add
  129217. */
  129218. Scene.prototype.addAnimation = function (newAnimation) {
  129219. this.animations.push(newAnimation);
  129220. };
  129221. /**
  129222. * Adds the given animation group to this scene.
  129223. * @param newAnimationGroup The animation group to add
  129224. */
  129225. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  129226. this.animationGroups.push(newAnimationGroup);
  129227. };
  129228. /**
  129229. * Adds the given multi-material to this scene
  129230. * @param newMultiMaterial The multi-material to add
  129231. */
  129232. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  129233. this.multiMaterials.push(newMultiMaterial);
  129234. };
  129235. /**
  129236. * Adds the given material to this scene
  129237. * @param newMaterial The material to add
  129238. */
  129239. Scene.prototype.addMaterial = function (newMaterial) {
  129240. newMaterial._indexInSceneMaterialArray = this.materials.length;
  129241. this.materials.push(newMaterial);
  129242. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  129243. };
  129244. /**
  129245. * Adds the given morph target to this scene
  129246. * @param newMorphTargetManager The morph target to add
  129247. */
  129248. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  129249. this.morphTargetManagers.push(newMorphTargetManager);
  129250. };
  129251. /**
  129252. * Adds the given geometry to this scene
  129253. * @param newGeometry The geometry to add
  129254. */
  129255. Scene.prototype.addGeometry = function (newGeometry) {
  129256. if (this.geometriesByUniqueId) {
  129257. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  129258. }
  129259. this.geometries.push(newGeometry);
  129260. };
  129261. /**
  129262. * Adds the given action manager to this scene
  129263. * @param newActionManager The action manager to add
  129264. */
  129265. Scene.prototype.addActionManager = function (newActionManager) {
  129266. this.actionManagers.push(newActionManager);
  129267. };
  129268. /**
  129269. * Adds the given texture to this scene.
  129270. * @param newTexture The texture to add
  129271. */
  129272. Scene.prototype.addTexture = function (newTexture) {
  129273. this.textures.push(newTexture);
  129274. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  129275. };
  129276. /**
  129277. * Switch active camera
  129278. * @param newCamera defines the new active camera
  129279. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  129280. */
  129281. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  129282. if (attachControl === void 0) { attachControl = true; }
  129283. var canvas = this._engine.getRenderingCanvas();
  129284. if (!canvas) {
  129285. return;
  129286. }
  129287. if (this.activeCamera) {
  129288. this.activeCamera.detachControl(canvas);
  129289. }
  129290. this.activeCamera = newCamera;
  129291. if (attachControl) {
  129292. newCamera.attachControl(canvas);
  129293. }
  129294. };
  129295. /**
  129296. * sets the active camera of the scene using its ID
  129297. * @param id defines the camera's ID
  129298. * @return the new active camera or null if none found.
  129299. */
  129300. Scene.prototype.setActiveCameraByID = function (id) {
  129301. var camera = this.getCameraByID(id);
  129302. if (camera) {
  129303. this.activeCamera = camera;
  129304. return camera;
  129305. }
  129306. return null;
  129307. };
  129308. /**
  129309. * sets the active camera of the scene using its name
  129310. * @param name defines the camera's name
  129311. * @returns the new active camera or null if none found.
  129312. */
  129313. Scene.prototype.setActiveCameraByName = function (name) {
  129314. var camera = this.getCameraByName(name);
  129315. if (camera) {
  129316. this.activeCamera = camera;
  129317. return camera;
  129318. }
  129319. return null;
  129320. };
  129321. /**
  129322. * get an animation group using its name
  129323. * @param name defines the material's name
  129324. * @return the animation group or null if none found.
  129325. */
  129326. Scene.prototype.getAnimationGroupByName = function (name) {
  129327. for (var index = 0; index < this.animationGroups.length; index++) {
  129328. if (this.animationGroups[index].name === name) {
  129329. return this.animationGroups[index];
  129330. }
  129331. }
  129332. return null;
  129333. };
  129334. /**
  129335. * get a material using its id
  129336. * @param id defines the material's ID
  129337. * @return the material or null if none found.
  129338. */
  129339. Scene.prototype.getMaterialByID = function (id) {
  129340. for (var index = 0; index < this.materials.length; index++) {
  129341. if (this.materials[index].id === id) {
  129342. return this.materials[index];
  129343. }
  129344. }
  129345. return null;
  129346. };
  129347. /**
  129348. * Gets a material using its name
  129349. * @param name defines the material's name
  129350. * @return the material or null if none found.
  129351. */
  129352. Scene.prototype.getMaterialByName = function (name) {
  129353. for (var index = 0; index < this.materials.length; index++) {
  129354. if (this.materials[index].name === name) {
  129355. return this.materials[index];
  129356. }
  129357. }
  129358. return null;
  129359. };
  129360. /**
  129361. * Gets a camera using its id
  129362. * @param id defines the id to look for
  129363. * @returns the camera or null if not found
  129364. */
  129365. Scene.prototype.getCameraByID = function (id) {
  129366. for (var index = 0; index < this.cameras.length; index++) {
  129367. if (this.cameras[index].id === id) {
  129368. return this.cameras[index];
  129369. }
  129370. }
  129371. return null;
  129372. };
  129373. /**
  129374. * Gets a camera using its unique id
  129375. * @param uniqueId defines the unique id to look for
  129376. * @returns the camera or null if not found
  129377. */
  129378. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  129379. for (var index = 0; index < this.cameras.length; index++) {
  129380. if (this.cameras[index].uniqueId === uniqueId) {
  129381. return this.cameras[index];
  129382. }
  129383. }
  129384. return null;
  129385. };
  129386. /**
  129387. * Gets a camera using its name
  129388. * @param name defines the camera's name
  129389. * @return the camera or null if none found.
  129390. */
  129391. Scene.prototype.getCameraByName = function (name) {
  129392. for (var index = 0; index < this.cameras.length; index++) {
  129393. if (this.cameras[index].name === name) {
  129394. return this.cameras[index];
  129395. }
  129396. }
  129397. return null;
  129398. };
  129399. /**
  129400. * Gets a bone using its id
  129401. * @param id defines the bone's id
  129402. * @return the bone or null if not found
  129403. */
  129404. Scene.prototype.getBoneByID = function (id) {
  129405. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129406. var skeleton = this.skeletons[skeletonIndex];
  129407. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129408. if (skeleton.bones[boneIndex].id === id) {
  129409. return skeleton.bones[boneIndex];
  129410. }
  129411. }
  129412. }
  129413. return null;
  129414. };
  129415. /**
  129416. * Gets a bone using its id
  129417. * @param name defines the bone's name
  129418. * @return the bone or null if not found
  129419. */
  129420. Scene.prototype.getBoneByName = function (name) {
  129421. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129422. var skeleton = this.skeletons[skeletonIndex];
  129423. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129424. if (skeleton.bones[boneIndex].name === name) {
  129425. return skeleton.bones[boneIndex];
  129426. }
  129427. }
  129428. }
  129429. return null;
  129430. };
  129431. /**
  129432. * Gets a light node using its name
  129433. * @param name defines the the light's name
  129434. * @return the light or null if none found.
  129435. */
  129436. Scene.prototype.getLightByName = function (name) {
  129437. for (var index = 0; index < this.lights.length; index++) {
  129438. if (this.lights[index].name === name) {
  129439. return this.lights[index];
  129440. }
  129441. }
  129442. return null;
  129443. };
  129444. /**
  129445. * Gets a light node using its id
  129446. * @param id defines the light's id
  129447. * @return the light or null if none found.
  129448. */
  129449. Scene.prototype.getLightByID = function (id) {
  129450. for (var index = 0; index < this.lights.length; index++) {
  129451. if (this.lights[index].id === id) {
  129452. return this.lights[index];
  129453. }
  129454. }
  129455. return null;
  129456. };
  129457. /**
  129458. * Gets a light node using its scene-generated unique ID
  129459. * @param uniqueId defines the light's unique id
  129460. * @return the light or null if none found.
  129461. */
  129462. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  129463. for (var index = 0; index < this.lights.length; index++) {
  129464. if (this.lights[index].uniqueId === uniqueId) {
  129465. return this.lights[index];
  129466. }
  129467. }
  129468. return null;
  129469. };
  129470. /**
  129471. * Gets a particle system by id
  129472. * @param id defines the particle system id
  129473. * @return the corresponding system or null if none found
  129474. */
  129475. Scene.prototype.getParticleSystemByID = function (id) {
  129476. for (var index = 0; index < this.particleSystems.length; index++) {
  129477. if (this.particleSystems[index].id === id) {
  129478. return this.particleSystems[index];
  129479. }
  129480. }
  129481. return null;
  129482. };
  129483. /**
  129484. * Gets a geometry using its ID
  129485. * @param id defines the geometry's id
  129486. * @return the geometry or null if none found.
  129487. */
  129488. Scene.prototype.getGeometryByID = function (id) {
  129489. for (var index = 0; index < this.geometries.length; index++) {
  129490. if (this.geometries[index].id === id) {
  129491. return this.geometries[index];
  129492. }
  129493. }
  129494. return null;
  129495. };
  129496. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  129497. if (this.geometriesByUniqueId) {
  129498. var index_1 = this.geometriesByUniqueId[uniqueId];
  129499. if (index_1 !== undefined) {
  129500. return this.geometries[index_1];
  129501. }
  129502. }
  129503. else {
  129504. for (var index = 0; index < this.geometries.length; index++) {
  129505. if (this.geometries[index].uniqueId === uniqueId) {
  129506. return this.geometries[index];
  129507. }
  129508. }
  129509. }
  129510. return null;
  129511. };
  129512. /**
  129513. * Add a new geometry to this scene
  129514. * @param geometry defines the geometry to be added to the scene.
  129515. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  129516. * @return a boolean defining if the geometry was added or not
  129517. */
  129518. Scene.prototype.pushGeometry = function (geometry, force) {
  129519. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  129520. return false;
  129521. }
  129522. this.addGeometry(geometry);
  129523. //notify the collision coordinator
  129524. if (this.collisionCoordinator) {
  129525. this.collisionCoordinator.onGeometryAdded(geometry);
  129526. }
  129527. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  129528. return true;
  129529. };
  129530. /**
  129531. * Removes an existing geometry
  129532. * @param geometry defines the geometry to be removed from the scene
  129533. * @return a boolean defining if the geometry was removed or not
  129534. */
  129535. Scene.prototype.removeGeometry = function (geometry) {
  129536. var index;
  129537. if (this.geometriesByUniqueId) {
  129538. index = this.geometriesByUniqueId[geometry.uniqueId];
  129539. if (index === undefined) {
  129540. return false;
  129541. }
  129542. }
  129543. else {
  129544. index = this.geometries.indexOf(geometry);
  129545. if (index < 0) {
  129546. return false;
  129547. }
  129548. }
  129549. if (index !== this.geometries.length - 1) {
  129550. var lastGeometry = this.geometries[this.geometries.length - 1];
  129551. this.geometries[index] = lastGeometry;
  129552. if (this.geometriesByUniqueId) {
  129553. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  129554. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  129555. }
  129556. }
  129557. this.geometries.pop();
  129558. //notify the collision coordinator
  129559. if (this.collisionCoordinator) {
  129560. this.collisionCoordinator.onGeometryDeleted(geometry);
  129561. }
  129562. this.onGeometryRemovedObservable.notifyObservers(geometry);
  129563. return true;
  129564. };
  129565. /**
  129566. * Gets the list of geometries attached to the scene
  129567. * @returns an array of Geometry
  129568. */
  129569. Scene.prototype.getGeometries = function () {
  129570. return this.geometries;
  129571. };
  129572. /**
  129573. * Gets the first added mesh found of a given ID
  129574. * @param id defines the id to search for
  129575. * @return the mesh found or null if not found at all
  129576. */
  129577. Scene.prototype.getMeshByID = function (id) {
  129578. for (var index = 0; index < this.meshes.length; index++) {
  129579. if (this.meshes[index].id === id) {
  129580. return this.meshes[index];
  129581. }
  129582. }
  129583. return null;
  129584. };
  129585. /**
  129586. * Gets a list of meshes using their id
  129587. * @param id defines the id to search for
  129588. * @returns a list of meshes
  129589. */
  129590. Scene.prototype.getMeshesByID = function (id) {
  129591. return this.meshes.filter(function (m) {
  129592. return m.id === id;
  129593. });
  129594. };
  129595. /**
  129596. * Gets the first added transform node found of a given ID
  129597. * @param id defines the id to search for
  129598. * @return the found transform node or null if not found at all.
  129599. */
  129600. Scene.prototype.getTransformNodeByID = function (id) {
  129601. for (var index = 0; index < this.transformNodes.length; index++) {
  129602. if (this.transformNodes[index].id === id) {
  129603. return this.transformNodes[index];
  129604. }
  129605. }
  129606. return null;
  129607. };
  129608. /**
  129609. * Gets a list of transform nodes using their id
  129610. * @param id defines the id to search for
  129611. * @returns a list of transform nodes
  129612. */
  129613. Scene.prototype.getTransformNodesByID = function (id) {
  129614. return this.transformNodes.filter(function (m) {
  129615. return m.id === id;
  129616. });
  129617. };
  129618. /**
  129619. * Gets a mesh with its auto-generated unique id
  129620. * @param uniqueId defines the unique id to search for
  129621. * @return the found mesh or null if not found at all.
  129622. */
  129623. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  129624. for (var index = 0; index < this.meshes.length; index++) {
  129625. if (this.meshes[index].uniqueId === uniqueId) {
  129626. return this.meshes[index];
  129627. }
  129628. }
  129629. return null;
  129630. };
  129631. /**
  129632. * Gets a the last added mesh using a given id
  129633. * @param id defines the id to search for
  129634. * @return the found mesh or null if not found at all.
  129635. */
  129636. Scene.prototype.getLastMeshByID = function (id) {
  129637. for (var index = this.meshes.length - 1; index >= 0; index--) {
  129638. if (this.meshes[index].id === id) {
  129639. return this.meshes[index];
  129640. }
  129641. }
  129642. return null;
  129643. };
  129644. /**
  129645. * Gets a the last added node (Mesh, Camera, Light) using a given id
  129646. * @param id defines the id to search for
  129647. * @return the found node or null if not found at all
  129648. */
  129649. Scene.prototype.getLastEntryByID = function (id) {
  129650. var index;
  129651. for (index = this.meshes.length - 1; index >= 0; index--) {
  129652. if (this.meshes[index].id === id) {
  129653. return this.meshes[index];
  129654. }
  129655. }
  129656. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  129657. if (this.transformNodes[index].id === id) {
  129658. return this.transformNodes[index];
  129659. }
  129660. }
  129661. for (index = this.cameras.length - 1; index >= 0; index--) {
  129662. if (this.cameras[index].id === id) {
  129663. return this.cameras[index];
  129664. }
  129665. }
  129666. for (index = this.lights.length - 1; index >= 0; index--) {
  129667. if (this.lights[index].id === id) {
  129668. return this.lights[index];
  129669. }
  129670. }
  129671. return null;
  129672. };
  129673. /**
  129674. * Gets a node (Mesh, Camera, Light) using a given id
  129675. * @param id defines the id to search for
  129676. * @return the found node or null if not found at all
  129677. */
  129678. Scene.prototype.getNodeByID = function (id) {
  129679. var mesh = this.getMeshByID(id);
  129680. if (mesh) {
  129681. return mesh;
  129682. }
  129683. var transformNode = this.getTransformNodeByID(id);
  129684. if (transformNode) {
  129685. return transformNode;
  129686. }
  129687. var light = this.getLightByID(id);
  129688. if (light) {
  129689. return light;
  129690. }
  129691. var camera = this.getCameraByID(id);
  129692. if (camera) {
  129693. return camera;
  129694. }
  129695. var bone = this.getBoneByID(id);
  129696. if (bone) {
  129697. return bone;
  129698. }
  129699. return null;
  129700. };
  129701. /**
  129702. * Gets a node (Mesh, Camera, Light) using a given name
  129703. * @param name defines the name to search for
  129704. * @return the found node or null if not found at all.
  129705. */
  129706. Scene.prototype.getNodeByName = function (name) {
  129707. var mesh = this.getMeshByName(name);
  129708. if (mesh) {
  129709. return mesh;
  129710. }
  129711. var transformNode = this.getTransformNodeByName(name);
  129712. if (transformNode) {
  129713. return transformNode;
  129714. }
  129715. var light = this.getLightByName(name);
  129716. if (light) {
  129717. return light;
  129718. }
  129719. var camera = this.getCameraByName(name);
  129720. if (camera) {
  129721. return camera;
  129722. }
  129723. var bone = this.getBoneByName(name);
  129724. if (bone) {
  129725. return bone;
  129726. }
  129727. return null;
  129728. };
  129729. /**
  129730. * Gets a mesh using a given name
  129731. * @param name defines the name to search for
  129732. * @return the found mesh or null if not found at all.
  129733. */
  129734. Scene.prototype.getMeshByName = function (name) {
  129735. for (var index = 0; index < this.meshes.length; index++) {
  129736. if (this.meshes[index].name === name) {
  129737. return this.meshes[index];
  129738. }
  129739. }
  129740. return null;
  129741. };
  129742. /**
  129743. * Gets a transform node using a given name
  129744. * @param name defines the name to search for
  129745. * @return the found transform node or null if not found at all.
  129746. */
  129747. Scene.prototype.getTransformNodeByName = function (name) {
  129748. for (var index = 0; index < this.transformNodes.length; index++) {
  129749. if (this.transformNodes[index].name === name) {
  129750. return this.transformNodes[index];
  129751. }
  129752. }
  129753. return null;
  129754. };
  129755. /**
  129756. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  129757. * @param id defines the id to search for
  129758. * @return the found skeleton or null if not found at all.
  129759. */
  129760. Scene.prototype.getLastSkeletonByID = function (id) {
  129761. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  129762. if (this.skeletons[index].id === id) {
  129763. return this.skeletons[index];
  129764. }
  129765. }
  129766. return null;
  129767. };
  129768. /**
  129769. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  129770. * @param id defines the id to search for
  129771. * @return the found skeleton or null if not found at all.
  129772. */
  129773. Scene.prototype.getSkeletonById = function (id) {
  129774. for (var index = 0; index < this.skeletons.length; index++) {
  129775. if (this.skeletons[index].id === id) {
  129776. return this.skeletons[index];
  129777. }
  129778. }
  129779. return null;
  129780. };
  129781. /**
  129782. * Gets a skeleton using a given name
  129783. * @param name defines the name to search for
  129784. * @return the found skeleton or null if not found at all.
  129785. */
  129786. Scene.prototype.getSkeletonByName = function (name) {
  129787. for (var index = 0; index < this.skeletons.length; index++) {
  129788. if (this.skeletons[index].name === name) {
  129789. return this.skeletons[index];
  129790. }
  129791. }
  129792. return null;
  129793. };
  129794. /**
  129795. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  129796. * @param id defines the id to search for
  129797. * @return the found morph target manager or null if not found at all.
  129798. */
  129799. Scene.prototype.getMorphTargetManagerById = function (id) {
  129800. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  129801. if (this.morphTargetManagers[index].uniqueId === id) {
  129802. return this.morphTargetManagers[index];
  129803. }
  129804. }
  129805. return null;
  129806. };
  129807. /**
  129808. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  129809. * @param id defines the id to search for
  129810. * @return the found morph target or null if not found at all.
  129811. */
  129812. Scene.prototype.getMorphTargetById = function (id) {
  129813. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  129814. var morphTargetManager = this.morphTargetManagers[managerIndex];
  129815. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  129816. var target = morphTargetManager.getTarget(index);
  129817. if (target.id === id) {
  129818. return target;
  129819. }
  129820. }
  129821. }
  129822. return null;
  129823. };
  129824. /**
  129825. * Gets a boolean indicating if the given mesh is active
  129826. * @param mesh defines the mesh to look for
  129827. * @returns true if the mesh is in the active list
  129828. */
  129829. Scene.prototype.isActiveMesh = function (mesh) {
  129830. return (this._activeMeshes.indexOf(mesh) !== -1);
  129831. };
  129832. Object.defineProperty(Scene.prototype, "uid", {
  129833. /**
  129834. * Return a unique id as a string which can serve as an identifier for the scene
  129835. */
  129836. get: function () {
  129837. if (!this._uid) {
  129838. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  129839. }
  129840. return this._uid;
  129841. },
  129842. enumerable: true,
  129843. configurable: true
  129844. });
  129845. /**
  129846. * Add an externaly attached data from its key.
  129847. * This method call will fail and return false, if such key already exists.
  129848. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  129849. * @param key the unique key that identifies the data
  129850. * @param data the data object to associate to the key for this Engine instance
  129851. * @return true if no such key were already present and the data was added successfully, false otherwise
  129852. */
  129853. Scene.prototype.addExternalData = function (key, data) {
  129854. if (!this._externalData) {
  129855. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  129856. }
  129857. return this._externalData.add(key, data);
  129858. };
  129859. /**
  129860. * Get an externaly attached data from its key
  129861. * @param key the unique key that identifies the data
  129862. * @return the associated data, if present (can be null), or undefined if not present
  129863. */
  129864. Scene.prototype.getExternalData = function (key) {
  129865. if (!this._externalData) {
  129866. return null;
  129867. }
  129868. return this._externalData.get(key);
  129869. };
  129870. /**
  129871. * Get an externaly attached data from its key, create it using a factory if it's not already present
  129872. * @param key the unique key that identifies the data
  129873. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  129874. * @return the associated data, can be null if the factory returned null.
  129875. */
  129876. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  129877. if (!this._externalData) {
  129878. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  129879. }
  129880. return this._externalData.getOrAddWithFactory(key, factory);
  129881. };
  129882. /**
  129883. * Remove an externaly attached data from the Engine instance
  129884. * @param key the unique key that identifies the data
  129885. * @return true if the data was successfully removed, false if it doesn't exist
  129886. */
  129887. Scene.prototype.removeExternalData = function (key) {
  129888. return this._externalData.remove(key);
  129889. };
  129890. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  129891. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  129892. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  129893. var step = _a[_i];
  129894. step.action(mesh, subMesh);
  129895. }
  129896. var material = subMesh.getMaterial();
  129897. if (material !== null && material !== undefined) {
  129898. // Render targets
  129899. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  129900. if (this._processedMaterials.indexOf(material) === -1) {
  129901. this._processedMaterials.push(material);
  129902. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  129903. }
  129904. }
  129905. // Dispatch
  129906. this._activeIndices.addCount(subMesh.indexCount, false);
  129907. this._renderingManager.dispatch(subMesh, mesh, material);
  129908. }
  129909. }
  129910. };
  129911. /**
  129912. * Clear the processed materials smart array preventing retention point in material dispose.
  129913. */
  129914. Scene.prototype.freeProcessedMaterials = function () {
  129915. this._processedMaterials.dispose();
  129916. };
  129917. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  129918. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  129919. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  129920. * when disposing several meshes in a row or a hierarchy of meshes.
  129921. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  129922. */
  129923. get: function () {
  129924. return this._preventFreeActiveMeshesAndRenderingGroups;
  129925. },
  129926. set: function (value) {
  129927. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  129928. return;
  129929. }
  129930. if (value) {
  129931. this.freeActiveMeshes();
  129932. this.freeRenderingGroups();
  129933. }
  129934. this._preventFreeActiveMeshesAndRenderingGroups = value;
  129935. },
  129936. enumerable: true,
  129937. configurable: true
  129938. });
  129939. /**
  129940. * Clear the active meshes smart array preventing retention point in mesh dispose.
  129941. */
  129942. Scene.prototype.freeActiveMeshes = function () {
  129943. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  129944. return;
  129945. }
  129946. this._activeMeshes.dispose();
  129947. if (this.activeCamera && this.activeCamera._activeMeshes) {
  129948. this.activeCamera._activeMeshes.dispose();
  129949. }
  129950. if (this.activeCameras) {
  129951. for (var i = 0; i < this.activeCameras.length; i++) {
  129952. var activeCamera = this.activeCameras[i];
  129953. if (activeCamera && activeCamera._activeMeshes) {
  129954. activeCamera._activeMeshes.dispose();
  129955. }
  129956. }
  129957. }
  129958. };
  129959. /**
  129960. * Clear the info related to rendering groups preventing retention points during dispose.
  129961. */
  129962. Scene.prototype.freeRenderingGroups = function () {
  129963. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  129964. return;
  129965. }
  129966. if (this._renderingManager) {
  129967. this._renderingManager.freeRenderingGroups();
  129968. }
  129969. if (this.textures) {
  129970. for (var i = 0; i < this.textures.length; i++) {
  129971. var texture = this.textures[i];
  129972. if (texture && texture.renderList) {
  129973. texture.freeRenderingGroups();
  129974. }
  129975. }
  129976. }
  129977. };
  129978. /** @hidden */
  129979. Scene.prototype._isInIntermediateRendering = function () {
  129980. return this._intermediateRendering;
  129981. };
  129982. /**
  129983. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  129984. * @returns the current scene
  129985. */
  129986. Scene.prototype.freezeActiveMeshes = function () {
  129987. if (!this.activeCamera) {
  129988. return this;
  129989. }
  129990. if (!this._frustumPlanes) {
  129991. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  129992. }
  129993. this._evaluateActiveMeshes();
  129994. this._activeMeshesFrozen = true;
  129995. return this;
  129996. };
  129997. /**
  129998. * Use this function to restart evaluating active meshes on every frame
  129999. * @returns the current scene
  130000. */
  130001. Scene.prototype.unfreezeActiveMeshes = function () {
  130002. this._activeMeshesFrozen = false;
  130003. return this;
  130004. };
  130005. Scene.prototype._evaluateActiveMeshes = function () {
  130006. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130007. return;
  130008. }
  130009. if (!this.activeCamera) {
  130010. return;
  130011. }
  130012. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130013. this.activeCamera._activeMeshes.reset();
  130014. this._activeMeshes.reset();
  130015. this._renderingManager.reset();
  130016. this._processedMaterials.reset();
  130017. this._activeParticleSystems.reset();
  130018. this._activeSkeletons.reset();
  130019. this._softwareSkinnedMeshes.reset();
  130020. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130021. var step = _a[_i];
  130022. step.action();
  130023. }
  130024. // Determine mesh candidates
  130025. var meshes = this.getActiveMeshCandidates();
  130026. // Check each mesh
  130027. var len = meshes.length;
  130028. for (var i = 0; i < len; i++) {
  130029. var mesh = meshes.data[i];
  130030. if (mesh.isBlocked) {
  130031. continue;
  130032. }
  130033. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130034. if (!mesh.isReady() || !mesh.isEnabled()) {
  130035. continue;
  130036. }
  130037. mesh.computeWorldMatrix();
  130038. // Intersections
  130039. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130040. this._meshesForIntersections.pushNoDuplicate(mesh);
  130041. }
  130042. // Switch to current LOD
  130043. var meshLOD = mesh.getLOD(this.activeCamera);
  130044. if (meshLOD === undefined || meshLOD === null) {
  130045. continue;
  130046. }
  130047. mesh._preActivate();
  130048. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  130049. this._activeMeshes.push(mesh);
  130050. this.activeCamera._activeMeshes.push(mesh);
  130051. mesh._activate(this._renderId);
  130052. if (meshLOD !== mesh) {
  130053. meshLOD._activate(this._renderId);
  130054. }
  130055. this._activeMesh(mesh, meshLOD);
  130056. }
  130057. }
  130058. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  130059. // Particle systems
  130060. if (this.particlesEnabled) {
  130061. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  130062. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  130063. var particleSystem = this.particleSystems[particleIndex];
  130064. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  130065. continue;
  130066. }
  130067. var emitter = particleSystem.emitter;
  130068. if (!emitter.position || emitter.isEnabled()) {
  130069. this._activeParticleSystems.push(particleSystem);
  130070. particleSystem.animate();
  130071. this._renderingManager.dispatchParticles(particleSystem);
  130072. }
  130073. }
  130074. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  130075. }
  130076. };
  130077. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  130078. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  130079. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  130080. mesh.skeleton.prepare();
  130081. }
  130082. if (!mesh.computeBonesUsingShaders) {
  130083. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  130084. }
  130085. }
  130086. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  130087. var step = _a[_i];
  130088. step.action(sourceMesh, mesh);
  130089. }
  130090. if (mesh !== undefined && mesh !== null
  130091. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  130092. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  130093. var len = subMeshes.length;
  130094. for (var i = 0; i < len; i++) {
  130095. var subMesh = subMeshes.data[i];
  130096. this._evaluateSubMesh(subMesh, mesh);
  130097. }
  130098. }
  130099. };
  130100. /**
  130101. * Update the transform matrix to update from the current active camera
  130102. * @param force defines a boolean used to force the update even if cache is up to date
  130103. */
  130104. Scene.prototype.updateTransformMatrix = function (force) {
  130105. if (!this.activeCamera) {
  130106. return;
  130107. }
  130108. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  130109. };
  130110. /**
  130111. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  130112. * @param alternateCamera defines the camera to use
  130113. */
  130114. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  130115. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  130116. };
  130117. Scene.prototype._renderForCamera = function (camera, rigParent) {
  130118. if (camera && camera._skipRendering) {
  130119. return;
  130120. }
  130121. var engine = this._engine;
  130122. this.activeCamera = camera;
  130123. if (!this.activeCamera) {
  130124. throw new Error("Active camera not set");
  130125. }
  130126. // Viewport
  130127. engine.setViewport(this.activeCamera.viewport);
  130128. // Camera
  130129. this.resetCachedMaterial();
  130130. this._renderId++;
  130131. this.updateTransformMatrix();
  130132. if (camera._alternateCamera) {
  130133. this.updateAlternateTransformMatrix(camera._alternateCamera);
  130134. this._alternateRendering = true;
  130135. }
  130136. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  130137. // Meshes
  130138. this._evaluateActiveMeshes();
  130139. // Software skinning
  130140. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  130141. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  130142. mesh.applySkeleton(mesh.skeleton);
  130143. }
  130144. // Render targets
  130145. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130146. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  130147. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  130148. }
  130149. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  130150. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  130151. }
  130152. // Collects render targets from external components.
  130153. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  130154. var step = _a[_i];
  130155. step.action(this._renderTargets);
  130156. }
  130157. if (this.renderTargetsEnabled) {
  130158. this._intermediateRendering = true;
  130159. if (this._renderTargets.length > 0) {
  130160. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130161. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  130162. var renderTarget = this._renderTargets.data[renderIndex];
  130163. if (renderTarget._shouldRender()) {
  130164. this._renderId++;
  130165. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  130166. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  130167. }
  130168. }
  130169. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130170. this._renderId++;
  130171. }
  130172. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  130173. var step = _c[_b];
  130174. step.action(this.activeCamera);
  130175. }
  130176. this._intermediateRendering = false;
  130177. if (this.activeCamera.outputRenderTarget) {
  130178. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  130179. if (internalTexture) {
  130180. engine.bindFramebuffer(internalTexture);
  130181. }
  130182. else {
  130183. _Misc_logger__WEBPACK_IMPORTED_MODULE_28__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  130184. }
  130185. }
  130186. else {
  130187. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  130188. }
  130189. }
  130190. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130191. // Prepare Frame
  130192. if (this.postProcessManager) {
  130193. this.postProcessManager._prepareFrame();
  130194. }
  130195. // Before Camera Draw
  130196. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  130197. var step = _e[_d];
  130198. step.action(this.activeCamera);
  130199. }
  130200. // Render
  130201. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  130202. this._renderingManager.render(null, null, true, true);
  130203. this.onAfterDrawPhaseObservable.notifyObservers(this);
  130204. // After Camera Draw
  130205. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  130206. var step = _g[_f];
  130207. step.action(this.activeCamera);
  130208. }
  130209. // Finalize frame
  130210. if (this.postProcessManager) {
  130211. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  130212. }
  130213. // Reset some special arrays
  130214. this._renderTargets.reset();
  130215. this._alternateRendering = false;
  130216. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  130217. };
  130218. Scene.prototype._processSubCameras = function (camera) {
  130219. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130220. this._renderForCamera(camera);
  130221. return;
  130222. }
  130223. // rig cameras
  130224. for (var index = 0; index < camera._rigCameras.length; index++) {
  130225. this._renderForCamera(camera._rigCameras[index], camera);
  130226. }
  130227. this.activeCamera = camera;
  130228. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130229. };
  130230. Scene.prototype._checkIntersections = function () {
  130231. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  130232. var sourceMesh = this._meshesForIntersections.data[index];
  130233. if (!sourceMesh.actionManager) {
  130234. continue;
  130235. }
  130236. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  130237. var action = sourceMesh.actionManager.actions[actionIndex];
  130238. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130239. var parameters = action.getTriggerParameter();
  130240. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  130241. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  130242. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  130243. if (areIntersecting && currentIntersectionInProgress === -1) {
  130244. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  130245. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130246. sourceMesh._intersectionsInProgress.push(otherMesh);
  130247. }
  130248. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130249. sourceMesh._intersectionsInProgress.push(otherMesh);
  130250. }
  130251. }
  130252. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  130253. //They intersected, and now they don't.
  130254. //is this trigger an exit trigger? execute an event.
  130255. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130256. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130257. }
  130258. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  130259. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  130260. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  130261. return otherMesh === parameterMesh;
  130262. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130263. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  130264. }
  130265. }
  130266. }
  130267. }
  130268. }
  130269. };
  130270. /** @hidden */
  130271. Scene.prototype._advancePhysicsEngineStep = function (step) {
  130272. // Do nothing. Code will be replaced if physics engine component is referenced
  130273. };
  130274. /**
  130275. * Render the scene
  130276. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  130277. */
  130278. Scene.prototype.render = function (updateCameras) {
  130279. if (updateCameras === void 0) { updateCameras = true; }
  130280. if (this.isDisposed) {
  130281. return;
  130282. }
  130283. this._frameId++;
  130284. // Register components that have been associated lately to the scene.
  130285. this._registerTransientComponents();
  130286. this._activeParticles.fetchNewFrame();
  130287. this._totalVertices.fetchNewFrame();
  130288. this._activeIndices.fetchNewFrame();
  130289. this._activeBones.fetchNewFrame();
  130290. this._meshesForIntersections.reset();
  130291. this.resetCachedMaterial();
  130292. this.onBeforeAnimationsObservable.notifyObservers(this);
  130293. // Actions
  130294. if (this.actionManager) {
  130295. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnEveryFrameTrigger);
  130296. }
  130297. if (this._engine.isDeterministicLockStep()) {
  130298. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  130299. var defaultFPS = (60.0 / 1000.0);
  130300. var defaultFrameTime = this.getDeterministicFrameTime();
  130301. var stepsTaken = 0;
  130302. var maxSubSteps = this._engine.getLockstepMaxSteps();
  130303. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  130304. internalSteps = Math.min(internalSteps, maxSubSteps);
  130305. do {
  130306. this.onBeforeStepObservable.notifyObservers(this);
  130307. // Animations
  130308. this._animationRatio = defaultFrameTime * defaultFPS;
  130309. this._animate();
  130310. this.onAfterAnimationsObservable.notifyObservers(this);
  130311. // Physics
  130312. this._advancePhysicsEngineStep(defaultFrameTime);
  130313. this.onAfterStepObservable.notifyObservers(this);
  130314. this._currentStepId++;
  130315. stepsTaken++;
  130316. deltaTime -= defaultFrameTime;
  130317. } while (deltaTime > 0 && stepsTaken < internalSteps);
  130318. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  130319. }
  130320. else {
  130321. // Animations
  130322. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  130323. this._animationRatio = deltaTime * (60.0 / 1000.0);
  130324. this._animate();
  130325. this.onAfterAnimationsObservable.notifyObservers(this);
  130326. // Physics
  130327. this._advancePhysicsEngineStep(deltaTime);
  130328. }
  130329. // Before camera update steps
  130330. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  130331. var step = _a[_i];
  130332. step.action();
  130333. }
  130334. // Update Cameras
  130335. if (updateCameras) {
  130336. if (this.activeCameras.length > 0) {
  130337. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130338. var camera = this.activeCameras[cameraIndex];
  130339. camera.update();
  130340. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130341. // rig cameras
  130342. for (var index = 0; index < camera._rigCameras.length; index++) {
  130343. camera._rigCameras[index].update();
  130344. }
  130345. }
  130346. }
  130347. }
  130348. else if (this.activeCamera) {
  130349. this.activeCamera.update();
  130350. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130351. // rig cameras
  130352. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  130353. this.activeCamera._rigCameras[index].update();
  130354. }
  130355. }
  130356. }
  130357. }
  130358. // Before render
  130359. this.onBeforeRenderObservable.notifyObservers(this);
  130360. // Customs render targets
  130361. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130362. var engine = this.getEngine();
  130363. var currentActiveCamera = this.activeCamera;
  130364. if (this.renderTargetsEnabled) {
  130365. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130366. this._intermediateRendering = true;
  130367. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  130368. var renderTarget = this.customRenderTargets[customIndex];
  130369. if (renderTarget._shouldRender()) {
  130370. this._renderId++;
  130371. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  130372. if (!this.activeCamera) {
  130373. throw new Error("Active camera not set");
  130374. }
  130375. // Viewport
  130376. engine.setViewport(this.activeCamera.viewport);
  130377. // Camera
  130378. this.updateTransformMatrix();
  130379. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  130380. }
  130381. }
  130382. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130383. this._intermediateRendering = false;
  130384. this._renderId++;
  130385. }
  130386. // Restore back buffer
  130387. if (this.customRenderTargets.length > 0) {
  130388. engine.restoreDefaultFramebuffer();
  130389. }
  130390. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130391. this.activeCamera = currentActiveCamera;
  130392. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  130393. var step = _c[_b];
  130394. step.action();
  130395. }
  130396. // Clear
  130397. if (this.autoClearDepthAndStencil || this.autoClear) {
  130398. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  130399. }
  130400. // Collects render targets from external components.
  130401. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  130402. var step = _e[_d];
  130403. step.action(this._renderTargets);
  130404. }
  130405. // Multi-cameras?
  130406. if (this.activeCameras.length > 0) {
  130407. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130408. if (cameraIndex > 0) {
  130409. this._engine.clear(null, false, true, true);
  130410. }
  130411. this._processSubCameras(this.activeCameras[cameraIndex]);
  130412. }
  130413. }
  130414. else {
  130415. if (!this.activeCamera) {
  130416. throw new Error("No camera defined");
  130417. }
  130418. this._processSubCameras(this.activeCamera);
  130419. }
  130420. // Intersection checks
  130421. this._checkIntersections();
  130422. // Executes the after render stage actions.
  130423. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  130424. var step = _g[_f];
  130425. step.action();
  130426. }
  130427. // After render
  130428. if (this.afterRender) {
  130429. this.afterRender();
  130430. }
  130431. this.onAfterRenderObservable.notifyObservers(this);
  130432. // Cleaning
  130433. if (this._toBeDisposed.length) {
  130434. for (var index = 0; index < this._toBeDisposed.length; index++) {
  130435. var data = this._toBeDisposed[index];
  130436. if (data) {
  130437. data.dispose();
  130438. }
  130439. }
  130440. this._toBeDisposed = [];
  130441. }
  130442. if (this.dumpNextRenderTargets) {
  130443. this.dumpNextRenderTargets = false;
  130444. }
  130445. this._activeBones.addCount(0, true);
  130446. this._activeIndices.addCount(0, true);
  130447. this._activeParticles.addCount(0, true);
  130448. };
  130449. /**
  130450. * Freeze all materials
  130451. * A frozen material will not be updatable but should be faster to render
  130452. */
  130453. Scene.prototype.freezeMaterials = function () {
  130454. for (var i = 0; i < this.materials.length; i++) {
  130455. this.materials[i].freeze();
  130456. }
  130457. };
  130458. /**
  130459. * Unfreeze all materials
  130460. * A frozen material will not be updatable but should be faster to render
  130461. */
  130462. Scene.prototype.unfreezeMaterials = function () {
  130463. for (var i = 0; i < this.materials.length; i++) {
  130464. this.materials[i].unfreeze();
  130465. }
  130466. };
  130467. /**
  130468. * Releases all held ressources
  130469. */
  130470. Scene.prototype.dispose = function () {
  130471. this.beforeRender = null;
  130472. this.afterRender = null;
  130473. this.skeletons = [];
  130474. this.morphTargetManagers = [];
  130475. this._transientComponents = [];
  130476. this._isReadyForMeshStage.clear();
  130477. this._beforeEvaluateActiveMeshStage.clear();
  130478. this._evaluateSubMeshStage.clear();
  130479. this._activeMeshStage.clear();
  130480. this._cameraDrawRenderTargetStage.clear();
  130481. this._beforeCameraDrawStage.clear();
  130482. this._beforeRenderTargetDrawStage.clear();
  130483. this._beforeRenderingGroupDrawStage.clear();
  130484. this._beforeRenderingMeshStage.clear();
  130485. this._afterRenderingMeshStage.clear();
  130486. this._afterRenderingGroupDrawStage.clear();
  130487. this._afterCameraDrawStage.clear();
  130488. this._afterRenderTargetDrawStage.clear();
  130489. this._afterRenderStage.clear();
  130490. this._beforeCameraUpdateStage.clear();
  130491. this._beforeClearStage.clear();
  130492. this._gatherRenderTargetsStage.clear();
  130493. this._gatherActiveCameraRenderTargetsStage.clear();
  130494. this._pointerMoveStage.clear();
  130495. this._pointerDownStage.clear();
  130496. this._pointerUpStage.clear();
  130497. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  130498. var component = _a[_i];
  130499. component.dispose();
  130500. }
  130501. this.importedMeshesFiles = new Array();
  130502. this.stopAllAnimations();
  130503. this.resetCachedMaterial();
  130504. // Smart arrays
  130505. if (this.activeCamera) {
  130506. this.activeCamera._activeMeshes.dispose();
  130507. this.activeCamera = null;
  130508. }
  130509. this._activeMeshes.dispose();
  130510. this._renderingManager.dispose();
  130511. this._processedMaterials.dispose();
  130512. this._activeParticleSystems.dispose();
  130513. this._activeSkeletons.dispose();
  130514. this._softwareSkinnedMeshes.dispose();
  130515. this._renderTargets.dispose();
  130516. this._registeredForLateAnimationBindings.dispose();
  130517. this._meshesForIntersections.dispose();
  130518. this._toBeDisposed = [];
  130519. // Abort active requests
  130520. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  130521. var request = _c[_b];
  130522. request.abort();
  130523. }
  130524. // Events
  130525. this.onDisposeObservable.notifyObservers(this);
  130526. this.onDisposeObservable.clear();
  130527. this.onBeforeRenderObservable.clear();
  130528. this.onAfterRenderObservable.clear();
  130529. this.onBeforeRenderTargetsRenderObservable.clear();
  130530. this.onAfterRenderTargetsRenderObservable.clear();
  130531. this.onAfterStepObservable.clear();
  130532. this.onBeforeStepObservable.clear();
  130533. this.onBeforeActiveMeshesEvaluationObservable.clear();
  130534. this.onAfterActiveMeshesEvaluationObservable.clear();
  130535. this.onBeforeParticlesRenderingObservable.clear();
  130536. this.onAfterParticlesRenderingObservable.clear();
  130537. this.onBeforeDrawPhaseObservable.clear();
  130538. this.onAfterDrawPhaseObservable.clear();
  130539. this.onBeforeAnimationsObservable.clear();
  130540. this.onAfterAnimationsObservable.clear();
  130541. this.onDataLoadedObservable.clear();
  130542. this.onBeforeRenderingGroupObservable.clear();
  130543. this.onAfterRenderingGroupObservable.clear();
  130544. this.onMeshImportedObservable.clear();
  130545. this.onBeforeCameraRenderObservable.clear();
  130546. this.onAfterCameraRenderObservable.clear();
  130547. this.onReadyObservable.clear();
  130548. this.onNewCameraAddedObservable.clear();
  130549. this.onCameraRemovedObservable.clear();
  130550. this.onNewLightAddedObservable.clear();
  130551. this.onLightRemovedObservable.clear();
  130552. this.onNewGeometryAddedObservable.clear();
  130553. this.onGeometryRemovedObservable.clear();
  130554. this.onNewTransformNodeAddedObservable.clear();
  130555. this.onTransformNodeRemovedObservable.clear();
  130556. this.onNewMeshAddedObservable.clear();
  130557. this.onMeshRemovedObservable.clear();
  130558. this.onNewMaterialAddedObservable.clear();
  130559. this.onMaterialRemovedObservable.clear();
  130560. this.onNewTextureAddedObservable.clear();
  130561. this.onTextureRemovedObservable.clear();
  130562. this.onPrePointerObservable.clear();
  130563. this.onPointerObservable.clear();
  130564. this.onPreKeyboardObservable.clear();
  130565. this.onKeyboardObservable.clear();
  130566. this.onActiveCameraChanged.clear();
  130567. this.detachControl();
  130568. // Detach cameras
  130569. var canvas = this._engine.getRenderingCanvas();
  130570. if (canvas) {
  130571. var index;
  130572. for (index = 0; index < this.cameras.length; index++) {
  130573. this.cameras[index].detachControl(canvas);
  130574. }
  130575. }
  130576. // Release animation groups
  130577. while (this.animationGroups.length) {
  130578. this.animationGroups[0].dispose();
  130579. }
  130580. // Release lights
  130581. while (this.lights.length) {
  130582. this.lights[0].dispose();
  130583. }
  130584. // Release meshes
  130585. while (this.meshes.length) {
  130586. this.meshes[0].dispose(true);
  130587. }
  130588. while (this.transformNodes.length) {
  130589. this.removeTransformNode(this.transformNodes[0]);
  130590. }
  130591. // Release cameras
  130592. while (this.cameras.length) {
  130593. this.cameras[0].dispose();
  130594. }
  130595. // Release materials
  130596. if (this.defaultMaterial) {
  130597. this.defaultMaterial.dispose();
  130598. }
  130599. while (this.multiMaterials.length) {
  130600. this.multiMaterials[0].dispose();
  130601. }
  130602. while (this.materials.length) {
  130603. this.materials[0].dispose();
  130604. }
  130605. // Release particles
  130606. while (this.particleSystems.length) {
  130607. this.particleSystems[0].dispose();
  130608. }
  130609. // Release postProcesses
  130610. while (this.postProcesses.length) {
  130611. this.postProcesses[0].dispose();
  130612. }
  130613. // Release textures
  130614. while (this.textures.length) {
  130615. this.textures[0].dispose();
  130616. }
  130617. // Release UBO
  130618. this._sceneUbo.dispose();
  130619. if (this._alternateSceneUbo) {
  130620. this._alternateSceneUbo.dispose();
  130621. }
  130622. // Post-processes
  130623. this.postProcessManager.dispose();
  130624. // Remove from engine
  130625. index = this._engine.scenes.indexOf(this);
  130626. if (index > -1) {
  130627. this._engine.scenes.splice(index, 1);
  130628. }
  130629. this._engine.wipeCaches(true);
  130630. this._isDisposed = true;
  130631. };
  130632. Object.defineProperty(Scene.prototype, "isDisposed", {
  130633. /**
  130634. * Gets if the scene is already disposed
  130635. */
  130636. get: function () {
  130637. return this._isDisposed;
  130638. },
  130639. enumerable: true,
  130640. configurable: true
  130641. });
  130642. /**
  130643. * Call this function to reduce memory footprint of the scene.
  130644. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  130645. */
  130646. Scene.prototype.clearCachedVertexData = function () {
  130647. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130648. var mesh = this.meshes[meshIndex];
  130649. var geometry = mesh.geometry;
  130650. if (geometry) {
  130651. geometry._indices = [];
  130652. for (var vbName in geometry._vertexBuffers) {
  130653. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  130654. continue;
  130655. }
  130656. geometry._vertexBuffers[vbName]._buffer._data = null;
  130657. }
  130658. }
  130659. }
  130660. };
  130661. /**
  130662. * This function will remove the local cached buffer data from texture.
  130663. * It will save memory but will prevent the texture from being rebuilt
  130664. */
  130665. Scene.prototype.cleanCachedTextureBuffer = function () {
  130666. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  130667. var baseTexture = _a[_i];
  130668. var buffer = baseTexture._buffer;
  130669. if (buffer) {
  130670. baseTexture._buffer = null;
  130671. }
  130672. }
  130673. };
  130674. /**
  130675. * Get the world extend vectors with an optional filter
  130676. *
  130677. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  130678. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  130679. */
  130680. Scene.prototype.getWorldExtends = function (filterPredicate) {
  130681. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  130682. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  130683. filterPredicate = filterPredicate || (function () { return true; });
  130684. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  130685. mesh.computeWorldMatrix(true);
  130686. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  130687. return;
  130688. }
  130689. var boundingInfo = mesh.getBoundingInfo();
  130690. var minBox = boundingInfo.boundingBox.minimumWorld;
  130691. var maxBox = boundingInfo.boundingBox.maximumWorld;
  130692. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  130693. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  130694. });
  130695. return {
  130696. min: min,
  130697. max: max
  130698. };
  130699. };
  130700. // Picking
  130701. /**
  130702. * Creates a ray that can be used to pick in the scene
  130703. * @param x defines the x coordinate of the origin (on-screen)
  130704. * @param y defines the y coordinate of the origin (on-screen)
  130705. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  130706. * @param camera defines the camera to use for the picking
  130707. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  130708. * @returns a Ray
  130709. */
  130710. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  130711. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  130712. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130713. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  130714. return result;
  130715. };
  130716. /**
  130717. * Creates a ray that can be used to pick in the scene
  130718. * @param x defines the x coordinate of the origin (on-screen)
  130719. * @param y defines the y coordinate of the origin (on-screen)
  130720. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  130721. * @param result defines the ray where to store the picking ray
  130722. * @param camera defines the camera to use for the picking
  130723. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  130724. * @returns the current scene
  130725. */
  130726. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  130727. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  130728. var engine = this._engine;
  130729. if (!camera) {
  130730. if (!this.activeCamera) {
  130731. throw new Error("Active camera not set");
  130732. }
  130733. camera = this.activeCamera;
  130734. }
  130735. var cameraViewport = camera.viewport;
  130736. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  130737. // Moving coordinates to local viewport world
  130738. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  130739. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  130740. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  130741. return this;
  130742. };
  130743. /**
  130744. * Creates a ray that can be used to pick in the scene
  130745. * @param x defines the x coordinate of the origin (on-screen)
  130746. * @param y defines the y coordinate of the origin (on-screen)
  130747. * @param camera defines the camera to use for the picking
  130748. * @returns a Ray
  130749. */
  130750. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  130751. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130752. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  130753. return result;
  130754. };
  130755. /**
  130756. * Creates a ray that can be used to pick in the scene
  130757. * @param x defines the x coordinate of the origin (on-screen)
  130758. * @param y defines the y coordinate of the origin (on-screen)
  130759. * @param result defines the ray where to store the picking ray
  130760. * @param camera defines the camera to use for the picking
  130761. * @returns the current scene
  130762. */
  130763. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  130764. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130765. return this;
  130766. }
  130767. var engine = this._engine;
  130768. if (!camera) {
  130769. if (!this.activeCamera) {
  130770. throw new Error("Active camera not set");
  130771. }
  130772. camera = this.activeCamera;
  130773. }
  130774. var cameraViewport = camera.viewport;
  130775. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  130776. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  130777. // Moving coordinates to local viewport world
  130778. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  130779. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  130780. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  130781. return this;
  130782. };
  130783. Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  130784. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130785. return null;
  130786. }
  130787. var pickingInfo = null;
  130788. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130789. var mesh = this.meshes[meshIndex];
  130790. if (predicate) {
  130791. if (!predicate(mesh)) {
  130792. continue;
  130793. }
  130794. }
  130795. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  130796. continue;
  130797. }
  130798. var world = mesh.getWorldMatrix();
  130799. var ray = rayFunction(world);
  130800. var result = mesh.intersects(ray, fastCheck);
  130801. if (!result || !result.hit) {
  130802. continue;
  130803. }
  130804. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  130805. continue;
  130806. }
  130807. pickingInfo = result;
  130808. if (fastCheck) {
  130809. break;
  130810. }
  130811. }
  130812. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]();
  130813. };
  130814. Scene.prototype._internalMultiPick = function (rayFunction, predicate) {
  130815. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130816. return null;
  130817. }
  130818. var pickingInfos = new Array();
  130819. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130820. var mesh = this.meshes[meshIndex];
  130821. if (predicate) {
  130822. if (!predicate(mesh)) {
  130823. continue;
  130824. }
  130825. }
  130826. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  130827. continue;
  130828. }
  130829. var world = mesh.getWorldMatrix();
  130830. var ray = rayFunction(world);
  130831. var result = mesh.intersects(ray, false);
  130832. if (!result || !result.hit) {
  130833. continue;
  130834. }
  130835. pickingInfos.push(result);
  130836. }
  130837. return pickingInfos;
  130838. };
  130839. /** Launch a ray to try to pick a mesh in the scene
  130840. * @param x position on screen
  130841. * @param y position on screen
  130842. * @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
  130843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  130844. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  130845. * @returns a PickingInfo
  130846. */
  130847. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  130848. var _this = this;
  130849. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130850. return null;
  130851. }
  130852. var result = this._internalPick(function (world) {
  130853. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  130854. return _this._tempPickingRay;
  130855. }, predicate, fastCheck);
  130856. if (result) {
  130857. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), camera || null);
  130858. }
  130859. return result;
  130860. };
  130861. /** Use the given ray to pick a mesh in the scene
  130862. * @param ray The ray to use to pick meshes
  130863. * @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
  130864. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  130865. * @returns a PickingInfo
  130866. */
  130867. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  130868. var _this = this;
  130869. var result = this._internalPick(function (world) {
  130870. if (!_this._pickWithRayInverseMatrix) {
  130871. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  130872. }
  130873. world.invertToRef(_this._pickWithRayInverseMatrix);
  130874. if (!_this._cachedRayForTransform) {
  130875. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130876. }
  130877. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  130878. return _this._cachedRayForTransform;
  130879. }, predicate, fastCheck);
  130880. if (result) {
  130881. result.ray = ray;
  130882. }
  130883. return result;
  130884. };
  130885. /**
  130886. * Launch a ray to try to pick a mesh in the scene
  130887. * @param x X position on screen
  130888. * @param y Y position on screen
  130889. * @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
  130890. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  130891. * @returns an array of PickingInfo
  130892. */
  130893. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  130894. var _this = this;
  130895. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  130896. };
  130897. /**
  130898. * Launch a ray to try to pick a mesh in the scene
  130899. * @param ray Ray to use
  130900. * @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
  130901. * @returns an array of PickingInfo
  130902. */
  130903. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  130904. var _this = this;
  130905. return this._internalMultiPick(function (world) {
  130906. if (!_this._pickWithRayInverseMatrix) {
  130907. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  130908. }
  130909. world.invertToRef(_this._pickWithRayInverseMatrix);
  130910. if (!_this._cachedRayForTransform) {
  130911. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130912. }
  130913. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  130914. return _this._cachedRayForTransform;
  130915. }, predicate);
  130916. };
  130917. /**
  130918. * Force the value of meshUnderPointer
  130919. * @param mesh defines the mesh to use
  130920. */
  130921. Scene.prototype.setPointerOverMesh = function (mesh) {
  130922. if (this._pointerOverMesh === mesh) {
  130923. return;
  130924. }
  130925. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  130926. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  130927. }
  130928. this._pointerOverMesh = mesh;
  130929. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  130930. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  130931. }
  130932. };
  130933. /**
  130934. * Gets the mesh under the pointer
  130935. * @returns a Mesh or null if no mesh is under the pointer
  130936. */
  130937. Scene.prototype.getPointerOverMesh = function () {
  130938. return this._pointerOverMesh;
  130939. };
  130940. // Misc.
  130941. /** @hidden */
  130942. Scene.prototype._rebuildGeometries = function () {
  130943. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  130944. var geometry = _a[_i];
  130945. geometry._rebuild();
  130946. }
  130947. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  130948. var mesh = _c[_b];
  130949. mesh._rebuild();
  130950. }
  130951. if (this.postProcessManager) {
  130952. this.postProcessManager._rebuild();
  130953. }
  130954. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  130955. var component = _e[_d];
  130956. component.rebuild();
  130957. }
  130958. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  130959. var system = _g[_f];
  130960. system.rebuild();
  130961. }
  130962. };
  130963. /** @hidden */
  130964. Scene.prototype._rebuildTextures = function () {
  130965. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  130966. var texture = _a[_i];
  130967. texture._rebuild();
  130968. }
  130969. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  130970. };
  130971. // Tags
  130972. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  130973. if (tagsQuery === undefined) {
  130974. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  130975. return list;
  130976. }
  130977. var listByTags = [];
  130978. forEach = forEach || (function (item) { return; });
  130979. for (var i in list) {
  130980. var item = list[i];
  130981. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  130982. listByTags.push(item);
  130983. forEach(item);
  130984. }
  130985. }
  130986. return listByTags;
  130987. };
  130988. /**
  130989. * Get a list of meshes by tags
  130990. * @param tagsQuery defines the tags query to use
  130991. * @param forEach defines a predicate used to filter results
  130992. * @returns an array of Mesh
  130993. */
  130994. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  130995. return this._getByTags(this.meshes, tagsQuery, forEach);
  130996. };
  130997. /**
  130998. * Get a list of cameras by tags
  130999. * @param tagsQuery defines the tags query to use
  131000. * @param forEach defines a predicate used to filter results
  131001. * @returns an array of Camera
  131002. */
  131003. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131004. return this._getByTags(this.cameras, tagsQuery, forEach);
  131005. };
  131006. /**
  131007. * Get a list of lights by tags
  131008. * @param tagsQuery defines the tags query to use
  131009. * @param forEach defines a predicate used to filter results
  131010. * @returns an array of Light
  131011. */
  131012. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131013. return this._getByTags(this.lights, tagsQuery, forEach);
  131014. };
  131015. /**
  131016. * Get a list of materials by tags
  131017. * @param tagsQuery defines the tags query to use
  131018. * @param forEach defines a predicate used to filter results
  131019. * @returns an array of Material
  131020. */
  131021. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131022. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131023. };
  131024. /**
  131025. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131026. * This allowed control for front to back rendering or reversly depending of the special needs.
  131027. *
  131028. * @param renderingGroupId The rendering group id corresponding to its index
  131029. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131030. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131031. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131032. */
  131033. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131034. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131035. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131036. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131037. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131038. };
  131039. /**
  131040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131041. *
  131042. * @param renderingGroupId The rendering group id corresponding to its index
  131043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131044. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131045. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131046. */
  131047. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131048. if (depth === void 0) { depth = true; }
  131049. if (stencil === void 0) { stencil = true; }
  131050. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131051. };
  131052. /**
  131053. * Gets the current auto clear configuration for one rendering group of the rendering
  131054. * manager.
  131055. * @param index the rendering group index to get the information for
  131056. * @returns The auto clear setup for the requested rendering group
  131057. */
  131058. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131059. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131060. };
  131061. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131062. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131063. get: function () {
  131064. return this._blockMaterialDirtyMechanism;
  131065. },
  131066. set: function (value) {
  131067. if (this._blockMaterialDirtyMechanism === value) {
  131068. return;
  131069. }
  131070. this._blockMaterialDirtyMechanism = value;
  131071. if (!value) { // Do a complete update
  131072. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AllDirtyFlag);
  131073. }
  131074. },
  131075. enumerable: true,
  131076. configurable: true
  131077. });
  131078. /**
  131079. * Will flag all materials as dirty to trigger new shader compilation
  131080. * @param flag defines the flag used to specify which material part must be marked as dirty
  131081. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131082. */
  131083. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131084. if (this._blockMaterialDirtyMechanism) {
  131085. return;
  131086. }
  131087. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131088. var material = _a[_i];
  131089. if (predicate && !predicate(material)) {
  131090. continue;
  131091. }
  131092. material.markAsDirty(flag);
  131093. }
  131094. };
  131095. /** @hidden */
  131096. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131097. var _this = this;
  131098. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131099. this._activeRequests.push(request);
  131100. request.onCompleteObservable.add(function (request) {
  131101. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131102. });
  131103. return request;
  131104. };
  131105. /** @hidden */
  131106. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131107. var _this = this;
  131108. return new Promise(function (resolve, reject) {
  131109. _this._loadFile(url, function (data) {
  131110. resolve(data);
  131111. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131112. reject(exception);
  131113. });
  131114. });
  131115. };
  131116. // Statics
  131117. Scene._uniqueIdCounter = 0;
  131118. /** The fog is deactivated */
  131119. Scene.FOGMODE_NONE = 0;
  131120. /** The fog density is following an exponential function */
  131121. Scene.FOGMODE_EXP = 1;
  131122. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131123. Scene.FOGMODE_EXP2 = 2;
  131124. /** The fog density is following a linear function. */
  131125. Scene.FOGMODE_LINEAR = 3;
  131126. /**
  131127. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131128. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131129. */
  131130. Scene.MinDeltaTime = 1.0;
  131131. /**
  131132. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131134. */
  131135. Scene.MaxDeltaTime = 1000.0;
  131136. /** The distance in pixel that you have to move to prevent some events */
  131137. Scene.DragMovementThreshold = 10; // in pixels
  131138. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131139. Scene.LongPressDelay = 500; // in milliseconds
  131140. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131141. Scene.DoubleClickDelay = 300; // in milliseconds
  131142. /** If you need to check double click without raising a single click at first click, enable this flag */
  131143. Scene.ExclusiveDoubleClickMode = false;
  131144. return Scene;
  131145. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131146. /***/ }),
  131147. /***/ "./sceneComponent.ts":
  131148. /*!***************************!*\
  131149. !*** ./sceneComponent.ts ***!
  131150. \***************************/
  131151. /*! exports provided: SceneComponentConstants, Stage */
  131152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131153. "use strict";
  131154. __webpack_require__.r(__webpack_exports__);
  131155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131158. /**
  131159. * Groups all the scene component constants in one place to ease maintenance.
  131160. * @hidden
  131161. */
  131162. var SceneComponentConstants = /** @class */ (function () {
  131163. function SceneComponentConstants() {
  131164. }
  131165. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  131166. SceneComponentConstants.NAME_LAYER = "Layer";
  131167. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  131168. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  131169. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  131170. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  131171. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  131172. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  131173. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  131174. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  131175. SceneComponentConstants.NAME_SPRITE = "Sprite";
  131176. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  131177. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  131178. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  131179. SceneComponentConstants.NAME_OCTREE = "Octree";
  131180. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  131181. SceneComponentConstants.NAME_AUDIO = "Audio";
  131182. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  131183. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131184. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  131185. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131186. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  131187. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  131188. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  131189. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  131190. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  131191. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  131192. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  131193. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  131194. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  131195. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  131196. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  131197. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  131198. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  131199. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  131200. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  131201. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  131202. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  131203. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  131204. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  131205. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  131206. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  131207. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  131208. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  131209. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  131210. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  131211. return SceneComponentConstants;
  131212. }());
  131213. /**
  131214. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  131215. * @hidden
  131216. */
  131217. var Stage = /** @class */ (function (_super) {
  131218. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  131219. /**
  131220. * Hide ctor from the rest of the world.
  131221. * @param items The items to add.
  131222. */
  131223. function Stage(items) {
  131224. return _super.apply(this, items) || this;
  131225. }
  131226. /**
  131227. * Creates a new Stage.
  131228. * @returns A new instance of a Stage
  131229. */
  131230. Stage.Create = function () {
  131231. return Object.create(Stage.prototype);
  131232. };
  131233. /**
  131234. * Registers a step in an ordered way in the targeted stage.
  131235. * @param index Defines the position to register the step in
  131236. * @param component Defines the component attached to the step
  131237. * @param action Defines the action to launch during the step
  131238. */
  131239. Stage.prototype.registerStep = function (index, component, action) {
  131240. var i = 0;
  131241. var maxIndex = Number.MAX_VALUE;
  131242. for (; i < this.length; i++) {
  131243. var step = this[i];
  131244. maxIndex = step.index;
  131245. if (index < maxIndex) {
  131246. break;
  131247. }
  131248. }
  131249. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  131250. };
  131251. /**
  131252. * Clears all the steps from the stage.
  131253. */
  131254. Stage.prototype.clear = function () {
  131255. this.length = 0;
  131256. };
  131257. return Stage;
  131258. }(Array));
  131259. /***/ })
  131260. /******/ });
  131261. });
  131262. //# sourceMappingURL=babylon.max.js.map